@ckelsoe/prompt-architect 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +20 -0
- package/.claude-plugin/plugin.json +18 -0
- package/CHANGELOG.md +264 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +66 -0
- package/README.md +1184 -0
- package/adapters/README.md +267 -0
- package/adapters/for-cursor.mdc +138 -0
- package/adapters/for-gemini-cli.md +70 -0
- package/adapters/for-github-copilot.md +141 -0
- package/adapters/for-openai-codex-cli.md +158 -0
- package/adapters/for-windsurf.md +136 -0
- package/adapters/system-prompt.md +243 -0
- package/package.json +135 -0
- package/scripts/install.js +490 -0
- package/scripts/test.js +213 -0
- package/scripts/validate-skill.js +350 -0
- package/skills/prompt-architect/SKILL.md +331 -0
- package/skills/prompt-architect/assets/templates/ape_template.txt +5 -0
- package/skills/prompt-architect/assets/templates/bab_template.txt +15 -0
- package/skills/prompt-architect/assets/templates/broke_template.txt +15 -0
- package/skills/prompt-architect/assets/templates/cai-critique-revise_template.txt +18 -0
- package/skills/prompt-architect/assets/templates/care_template.txt +16 -0
- package/skills/prompt-architect/assets/templates/chain-of-density_template.txt +46 -0
- package/skills/prompt-architect/assets/templates/chain-of-thought_template.txt +49 -0
- package/skills/prompt-architect/assets/templates/co-star_template.txt +17 -0
- package/skills/prompt-architect/assets/templates/crispe_template.txt +14 -0
- package/skills/prompt-architect/assets/templates/ctf_template.txt +15 -0
- package/skills/prompt-architect/assets/templates/devils-advocate_template.txt +25 -0
- package/skills/prompt-architect/assets/templates/hybrid_template.txt +101 -0
- package/skills/prompt-architect/assets/templates/least-to-most_template.txt +16 -0
- package/skills/prompt-architect/assets/templates/plan-and-solve_template.txt +7 -0
- package/skills/prompt-architect/assets/templates/pre-mortem_template.txt +27 -0
- package/skills/prompt-architect/assets/templates/race_template.txt +19 -0
- package/skills/prompt-architect/assets/templates/rcot_template.txt +31 -0
- package/skills/prompt-architect/assets/templates/react_template.txt +27 -0
- package/skills/prompt-architect/assets/templates/reverse-role_template.txt +11 -0
- package/skills/prompt-architect/assets/templates/rise-ie_template.txt +23 -0
- package/skills/prompt-architect/assets/templates/rise-ix_template.txt +28 -0
- package/skills/prompt-architect/assets/templates/risen_template.txt +21 -0
- package/skills/prompt-architect/assets/templates/rpef_template.txt +26 -0
- package/skills/prompt-architect/assets/templates/rtf_template.txt +13 -0
- package/skills/prompt-architect/assets/templates/self-refine_template.txt +16 -0
- package/skills/prompt-architect/assets/templates/skeleton-of-thought_template.txt +15 -0
- package/skills/prompt-architect/assets/templates/step-back_template.txt +10 -0
- package/skills/prompt-architect/assets/templates/tidd-ec_template.txt +45 -0
- package/skills/prompt-architect/assets/templates/tree-of-thought_template.txt +30 -0
- package/skills/prompt-architect/references/frameworks/ape.md +200 -0
- package/skills/prompt-architect/references/frameworks/bab.md +242 -0
- package/skills/prompt-architect/references/frameworks/broke.md +242 -0
- package/skills/prompt-architect/references/frameworks/cai-critique-revise.md +230 -0
- package/skills/prompt-architect/references/frameworks/care.md +235 -0
- package/skills/prompt-architect/references/frameworks/chain-of-density.md +479 -0
- package/skills/prompt-architect/references/frameworks/chain-of-thought.md +424 -0
- package/skills/prompt-architect/references/frameworks/co-star.md +256 -0
- package/skills/prompt-architect/references/frameworks/crispe.md +253 -0
- package/skills/prompt-architect/references/frameworks/ctf.md +207 -0
- package/skills/prompt-architect/references/frameworks/devils-advocate.md +206 -0
- package/skills/prompt-architect/references/frameworks/least-to-most.md +226 -0
- package/skills/prompt-architect/references/frameworks/plan-and-solve.md +210 -0
- package/skills/prompt-architect/references/frameworks/pre-mortem.md +197 -0
- package/skills/prompt-architect/references/frameworks/race.md +243 -0
- package/skills/prompt-architect/references/frameworks/rcot.md +203 -0
- package/skills/prompt-architect/references/frameworks/react.md +304 -0
- package/skills/prompt-architect/references/frameworks/reverse-role.md +189 -0
- package/skills/prompt-architect/references/frameworks/rise.md +555 -0
- package/skills/prompt-architect/references/frameworks/risen.md +297 -0
- package/skills/prompt-architect/references/frameworks/rpef.md +195 -0
- package/skills/prompt-architect/references/frameworks/rtf.md +358 -0
- package/skills/prompt-architect/references/frameworks/self-refine.md +205 -0
- package/skills/prompt-architect/references/frameworks/skeleton-of-thought.md +186 -0
- package/skills/prompt-architect/references/frameworks/step-back.md +206 -0
- package/skills/prompt-architect/references/frameworks/tidd-ec.md +470 -0
- package/skills/prompt-architect/references/frameworks/tree-of-thought.md +260 -0
- package/skills/prompt-architect/scripts/framework_analyzer.py +807 -0
- package/skills/prompt-architect/scripts/prompt_evaluator.py +336 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Least-to-Most (LtM) Prompting
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Least-to-Most (LtM) prompting is a decomposition-first framework that breaks a complex problem into an ordered sequence of simpler subproblems, then solves them sequentially — using each prior answer as context for the next. Unlike Chain of Thought (which reasons through a problem in one pass), LtM explicitly separates decomposition from execution, and the subproblems are sequenced from simplest to most complex.
|
|
6
|
+
|
|
7
|
+
**Research basis:** "Least-to-Most Prompting Enables Complex Reasoning in Large Language Models" (Zhou et al., Google Brain, arXiv:2205.10625, ICLR 2023). On SCAN compositional generalization: LtM achieves 99.7% vs. CoT's 16%. On GSM8K math: matches or exceeds CoT with fewer errors.
|
|
8
|
+
|
|
9
|
+
## Why LtM Differs from Chain of Thought
|
|
10
|
+
|
|
11
|
+
| | Chain of Thought | Least-to-Most |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Structure | Single-pass linear reasoning | Explicit decompose → solve sequence |
|
|
14
|
+
| Decomposition | Implicit (within the chain) | Explicit first step |
|
|
15
|
+
| Subproblem order | Not explicitly structured | Simplest → most complex |
|
|
16
|
+
| Answer reuse | May or may not reference prior steps | Each answer feeds explicitly into the next |
|
|
17
|
+
| Best for | Known procedure, moderate complexity | Compositional tasks, building-block problems |
|
|
18
|
+
|
|
19
|
+
## Components
|
|
20
|
+
|
|
21
|
+
### Phase 1: Decomposition
|
|
22
|
+
**Purpose:** Break the original problem into an ordered list of subproblems, from simplest to most complex. The key: later subproblems should build on earlier ones.
|
|
23
|
+
|
|
24
|
+
**Trigger:** "To solve [problem], we need to first solve: [list subproblems in order]"
|
|
25
|
+
|
|
26
|
+
**Questions to Ask:**
|
|
27
|
+
- What is the simplest thing that must be true before we can answer the full question?
|
|
28
|
+
- What building blocks does the final answer depend on?
|
|
29
|
+
- What is the correct ordering — which must come first?
|
|
30
|
+
|
|
31
|
+
### Phase 2: Sequential Solving
|
|
32
|
+
**Purpose:** Solve each subproblem in order, explicitly using prior answers as context.
|
|
33
|
+
|
|
34
|
+
**Pattern:** Answer subproblem 1 → use that answer when solving subproblem 2 → use both when solving subproblem 3 → ... → solve original problem.
|
|
35
|
+
|
|
36
|
+
## Template Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
PROBLEM:
|
|
40
|
+
[The full, complex problem to solve]
|
|
41
|
+
|
|
42
|
+
DECOMPOSE:
|
|
43
|
+
Break this problem into ordered subproblems, from simplest to most complex.
|
|
44
|
+
Each later subproblem should build on the answer to the previous.
|
|
45
|
+
|
|
46
|
+
Subproblem 1: [Simplest prerequisite]
|
|
47
|
+
Subproblem 2: [Next level, may depend on #1]
|
|
48
|
+
Subproblem 3: [More complex, depends on #1-2]
|
|
49
|
+
...
|
|
50
|
+
Final: [The original problem, now solvable using all prior answers]
|
|
51
|
+
|
|
52
|
+
SOLVE SEQUENTIALLY:
|
|
53
|
+
Solve each subproblem in order. Use prior answers as context for each
|
|
54
|
+
subsequent subproblem. Show each solution before moving to the next.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Single-Pass Trigger (model decomposes and solves itself):
|
|
58
|
+
```
|
|
59
|
+
To solve the following problem, first identify the simpler subproblems
|
|
60
|
+
that must be solved first (from least to most complex). Then solve each
|
|
61
|
+
in sequence, using prior answers as context. Show decomposition, then
|
|
62
|
+
sequential solutions.
|
|
63
|
+
|
|
64
|
+
Problem: [your problem]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Complete Examples
|
|
68
|
+
|
|
69
|
+
### Example 1: Multi-Hop Reasoning
|
|
70
|
+
|
|
71
|
+
**Before LtM:**
|
|
72
|
+
"What would the tax implications be for a US remote employee working from Portugal for 3 months?"
|
|
73
|
+
|
|
74
|
+
**After LtM:**
|
|
75
|
+
```
|
|
76
|
+
PROBLEM:
|
|
77
|
+
What are the tax implications for a US citizen employed by a US company who
|
|
78
|
+
works remotely from Portugal for 3 months in one calendar year?
|
|
79
|
+
|
|
80
|
+
DECOMPOSE:
|
|
81
|
+
Subproblem 1: What are the US tax rules for citizens earning income abroad
|
|
82
|
+
(general principles, FEIE, FTC)?
|
|
83
|
+
|
|
84
|
+
Subproblem 2: What is Portugal's tax rule for foreigners working there —
|
|
85
|
+
specifically the threshold for establishing tax residency?
|
|
86
|
+
|
|
87
|
+
Subproblem 3: Does 3 months in Portugal trigger Portuguese tax residency?
|
|
88
|
+
(Use answers from 1 and 2)
|
|
89
|
+
|
|
90
|
+
Subproblem 4: If both US and Portuguese tax obligations potentially apply,
|
|
91
|
+
what does the US-Portugal tax treaty say about double taxation?
|
|
92
|
+
|
|
93
|
+
Final: Given the above, what are the practical tax implications and what
|
|
94
|
+
should the employee do?
|
|
95
|
+
|
|
96
|
+
SOLVE SEQUENTIALLY:
|
|
97
|
+
[Solve in order, each answer informing the next]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Example 2: Code Architecture
|
|
101
|
+
|
|
102
|
+
**Before LtM:**
|
|
103
|
+
"How do I add real-time notifications to my Django app?"
|
|
104
|
+
|
|
105
|
+
**After LtM:**
|
|
106
|
+
```
|
|
107
|
+
PROBLEM:
|
|
108
|
+
I need to add real-time push notifications to a Django app with PostgreSQL.
|
|
109
|
+
Users should receive browser notifications when certain database records change.
|
|
110
|
+
|
|
111
|
+
DECOMPOSE:
|
|
112
|
+
Subproblem 1: What are the available mechanisms for real-time browser
|
|
113
|
+
communication in Django? (WebSockets, SSE, polling — trade-offs)
|
|
114
|
+
|
|
115
|
+
Subproblem 2: For the chosen mechanism, what Django-specific libraries
|
|
116
|
+
and setup are required?
|
|
117
|
+
|
|
118
|
+
Subproblem 3: How do we detect database record changes and trigger
|
|
119
|
+
notifications? (Django signals, PostgreSQL LISTEN/NOTIFY, or polling)
|
|
120
|
+
|
|
121
|
+
Subproblem 4: How do we route a database event → notification trigger →
|
|
122
|
+
connected browser client?
|
|
123
|
+
|
|
124
|
+
Final: What is the complete implementation plan and any gotchas?
|
|
125
|
+
|
|
126
|
+
SOLVE SEQUENTIALLY:
|
|
127
|
+
[Solve in order]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Example 3: Business Analysis
|
|
131
|
+
|
|
132
|
+
**Before LtM:**
|
|
133
|
+
"Should we expand to the European market?"
|
|
134
|
+
|
|
135
|
+
**After LtM:**
|
|
136
|
+
```
|
|
137
|
+
PROBLEM:
|
|
138
|
+
Our B2B SaaS has strong US traction. Should we expand to the European market
|
|
139
|
+
now, given our current 20-person team and 18 months of runway?
|
|
140
|
+
|
|
141
|
+
DECOMPOSE:
|
|
142
|
+
Subproblem 1: What are the key differences between US and European B2B SaaS
|
|
143
|
+
markets that affect a US-native product? (GDPR, sales cycles, localization needs)
|
|
144
|
+
|
|
145
|
+
Subproblem 2: What resources are typically required for a credible EU market entry?
|
|
146
|
+
(team, timeline, cost estimates)
|
|
147
|
+
|
|
148
|
+
Subproblem 3: What are the signals that a company is or isn't ready for
|
|
149
|
+
international expansion?
|
|
150
|
+
|
|
151
|
+
Subproblem 4: Given our specific constraints (20 people, 18 months runway),
|
|
152
|
+
how do our resources map to those requirements?
|
|
153
|
+
|
|
154
|
+
Final: Should we expand to Europe now, wait, or explore a different
|
|
155
|
+
expansion approach? With clear reasoning from the above.
|
|
156
|
+
|
|
157
|
+
SOLVE SEQUENTIALLY:
|
|
158
|
+
[Solve each in order, carry answers forward]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Best Use Cases
|
|
162
|
+
|
|
163
|
+
1. **Compositional Reasoning**
|
|
164
|
+
- Multi-hop questions requiring chained facts
|
|
165
|
+
- Problems where the answer depends on several intermediate results
|
|
166
|
+
- Any question with "it depends on X, which depends on Y"
|
|
167
|
+
|
|
168
|
+
2. **Complex Technical Problems**
|
|
169
|
+
- Architecture decisions with prerequisites
|
|
170
|
+
- Debugging with unknown root cause
|
|
171
|
+
- Implementation planning with dependencies
|
|
172
|
+
|
|
173
|
+
3. **Multi-Domain Questions**
|
|
174
|
+
- Questions spanning legal + technical, financial + operational, etc.
|
|
175
|
+
- Any question where different areas of knowledge must be combined
|
|
176
|
+
|
|
177
|
+
4. **Long Math / Calculation Chains**
|
|
178
|
+
- Financial projections with multiple steps
|
|
179
|
+
- Physics problems with multiple formulas
|
|
180
|
+
- Anything where intermediate errors cascade
|
|
181
|
+
|
|
182
|
+
5. **When Chain of Thought Keeps Failing**
|
|
183
|
+
- LtM's explicit decomposition reduces error propagation
|
|
184
|
+
- If CoT gives wrong answers, decomposing first often helps
|
|
185
|
+
|
|
186
|
+
## Selection Criteria
|
|
187
|
+
|
|
188
|
+
**Choose LtM when:**
|
|
189
|
+
- ✅ Problem has multiple prerequisite subproblems
|
|
190
|
+
- ✅ Subproblems have a natural ordering (simplest first)
|
|
191
|
+
- ✅ Each answer genuinely builds on the previous
|
|
192
|
+
- ✅ CoT gives shallow or wrong answers on this type of question
|
|
193
|
+
- ✅ Decomposition is non-trivial (question is compositional)
|
|
194
|
+
|
|
195
|
+
**Avoid LtM when:**
|
|
196
|
+
- ❌ Problem is simple and self-contained → use CoT or APE
|
|
197
|
+
- ❌ No natural decomposition exists → use Tree of Thought instead
|
|
198
|
+
- ❌ Subproblems are independent (no ordering needed) → use SoT or ToT
|
|
199
|
+
- ❌ Content creation task → use CO-STAR or BAB
|
|
200
|
+
|
|
201
|
+
## Common Mistakes
|
|
202
|
+
|
|
203
|
+
1. **Subproblems That Don't Build**
|
|
204
|
+
- Each subproblem should be a prerequisite for the next
|
|
205
|
+
- If they're independent, that's SoT or Tree of Thought, not LtM
|
|
206
|
+
|
|
207
|
+
2. **Wrong Ordering**
|
|
208
|
+
- More complex ≠ later; it's about dependency, not complexity per se
|
|
209
|
+
- "What is X?" must come before "Given X, what is Y?"
|
|
210
|
+
|
|
211
|
+
3. **Not Carrying Answers Forward**
|
|
212
|
+
- The key to LtM is that each answer is explicitly used in the next step
|
|
213
|
+
- Don't solve subproblems in isolation
|
|
214
|
+
|
|
215
|
+
4. **Using LtM When CoT Is Sufficient**
|
|
216
|
+
- If the problem has one reasoning path, CoT is simpler
|
|
217
|
+
- LtM overhead is only worth it for genuinely compositional problems
|
|
218
|
+
|
|
219
|
+
## Quick Reference
|
|
220
|
+
|
|
221
|
+
| Phase | Purpose | Key Question |
|
|
222
|
+
|-------|---------|--------------|
|
|
223
|
+
| Decompose | Order the subproblems | "What must I know first?" |
|
|
224
|
+
| Solve (simplest) | Build the foundation | "What's the answer to this piece?" |
|
|
225
|
+
| Solve (sequentially) | Build on prior answers | "Given what we know, what's next?" |
|
|
226
|
+
| Final solve | Assemble the answer | "Now that I have all pieces, what's the answer?" |
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Plan-and-Solve (PS+) Prompting
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Plan-and-Solve (PS+) is a zero-shot prompting technique that improves upon standard Chain of Thought by instructing the model to explicitly plan the solution approach before executing it — and to be careful about extracting variables and calculating intermediate results. It requires no examples or demonstrations and consistently outperforms Zero-Shot CoT ("Let's think step by step") on reasoning tasks.
|
|
6
|
+
|
|
7
|
+
**Research basis:** "Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Models" (Wang et al., ACL 2023, arXiv:2305.04091). Tested across 10 reasoning datasets — consistently outperforms Zero-Shot-CoT and is competitive with few-shot CoT.
|
|
8
|
+
|
|
9
|
+
## The Core Trigger Phrases
|
|
10
|
+
|
|
11
|
+
### PS (Basic):
|
|
12
|
+
```
|
|
13
|
+
Let's first understand the problem and devise a plan to solve it.
|
|
14
|
+
Then, let's carry out the plan and solve the problem step by step.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### PS+ (Enhanced — recommended):
|
|
18
|
+
```
|
|
19
|
+
Let's first understand the problem, extract relevant variables and their
|
|
20
|
+
corresponding numerals, and devise a complete plan. Then, let's carry out
|
|
21
|
+
the plan, calculate intermediate values, pay attention to computation,
|
|
22
|
+
and solve the problem step by step.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The PS+ additions over PS:
|
|
26
|
+
1. **"Extract relevant variables"** — forces the model to identify all given information before starting
|
|
27
|
+
2. **"Calculate intermediate values"** — prevents skipping computational steps
|
|
28
|
+
3. **"Pay attention to computation"** — explicit reminder to be accurate with numbers
|
|
29
|
+
|
|
30
|
+
## Template Structure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
PROBLEM:
|
|
34
|
+
[Your problem or question]
|
|
35
|
+
|
|
36
|
+
INSTRUCTION:
|
|
37
|
+
Let's first understand the problem, extract relevant variables and their
|
|
38
|
+
corresponding numerals, and devise a complete plan. Then, let's carry out
|
|
39
|
+
the plan, calculate intermediate values, pay attention to computation,
|
|
40
|
+
and solve the problem step by step.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Inline Version (append to any question):
|
|
44
|
+
```
|
|
45
|
+
[Your question]. Let's first understand the problem, extract relevant
|
|
46
|
+
variables and their corresponding numerals, and devise a complete plan.
|
|
47
|
+
Then let's carry out the plan, calculate intermediate values, and solve
|
|
48
|
+
step by step.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Complete Examples
|
|
52
|
+
|
|
53
|
+
### Example 1: Math / Calculation
|
|
54
|
+
|
|
55
|
+
**Before PS+:**
|
|
56
|
+
"If a SaaS company has 500 customers at $200/month each, 5% monthly churn, and adds 30 new customers per month, what is the MRR in 6 months?"
|
|
57
|
+
|
|
58
|
+
**After PS+:**
|
|
59
|
+
```
|
|
60
|
+
PROBLEM:
|
|
61
|
+
A SaaS company has 500 customers paying $200/month each. Monthly churn
|
|
62
|
+
is 5%. The company acquires 30 new customers per month. What is the MRR
|
|
63
|
+
in 6 months?
|
|
64
|
+
|
|
65
|
+
Let's first understand the problem, extract relevant variables and their
|
|
66
|
+
corresponding numerals, and devise a complete plan. Then, let's carry out
|
|
67
|
+
the plan, calculate intermediate values, pay attention to computation,
|
|
68
|
+
and solve the problem step by step.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Expected model behavior:**
|
|
72
|
+
```
|
|
73
|
+
Variables:
|
|
74
|
+
- Starting customers: 500
|
|
75
|
+
- Monthly price: $200/month
|
|
76
|
+
- Monthly churn rate: 5% = 0.05
|
|
77
|
+
- Monthly new customers: 30
|
|
78
|
+
- Target period: 6 months
|
|
79
|
+
|
|
80
|
+
Plan:
|
|
81
|
+
1. Calculate customers lost per month (churn)
|
|
82
|
+
2. Calculate net new customers per month (acquired - churned)
|
|
83
|
+
3. Calculate customer count at end of each month (months 1-6)
|
|
84
|
+
4. Calculate MRR for month 6
|
|
85
|
+
|
|
86
|
+
Execution:
|
|
87
|
+
Month 0: 500 customers, MRR = $100,000
|
|
88
|
+
Month 1: 500 × (1 - 0.05) + 30 = 475 + 30 = 505 customers, MRR = $101,000
|
|
89
|
+
Month 2: 505 × 0.95 + 30 = 479.75 + 30 = 509.75 ≈ 510 customers, MRR = $102,000
|
|
90
|
+
...
|
|
91
|
+
[continues through month 6]
|
|
92
|
+
|
|
93
|
+
Final answer: Month 6 MRR = $X
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Example 2: Multi-Step Technical Problem
|
|
97
|
+
|
|
98
|
+
**Before PS+:**
|
|
99
|
+
"Our API is returning responses in 800ms average. We want to get it under 200ms. What should we do?"
|
|
100
|
+
|
|
101
|
+
**After PS+:**
|
|
102
|
+
```
|
|
103
|
+
PROBLEM:
|
|
104
|
+
Our REST API averages 800ms response time. Target is under 200ms.
|
|
105
|
+
The API serves product catalog queries (read-heavy), is Node.js with
|
|
106
|
+
PostgreSQL, and currently has no caching layer. Database queries are
|
|
107
|
+
the main bottleneck (600ms average per request).
|
|
108
|
+
|
|
109
|
+
Let's first understand the problem, extract relevant variables and their
|
|
110
|
+
corresponding numerals, and devise a complete plan. Then, let's carry out
|
|
111
|
+
the plan and solve step by step.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Example 3: Business Calculation
|
|
115
|
+
|
|
116
|
+
**Before PS+:**
|
|
117
|
+
"What's our payback period if CAC is $1,200 and average MRR per customer is $150 with 70% gross margin?"
|
|
118
|
+
|
|
119
|
+
**After PS+:**
|
|
120
|
+
```
|
|
121
|
+
PROBLEM:
|
|
122
|
+
Customer Acquisition Cost (CAC): $1,200
|
|
123
|
+
Average MRR per customer: $150
|
|
124
|
+
Gross margin: 70%
|
|
125
|
+
|
|
126
|
+
What is our payback period?
|
|
127
|
+
|
|
128
|
+
Let's first understand the problem, extract relevant variables and their
|
|
129
|
+
corresponding numerals, and devise a complete plan. Then, let's carry out
|
|
130
|
+
the plan, calculate intermediate values, pay attention to computation,
|
|
131
|
+
and solve the problem step by step.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Example 4: Logic / Reasoning
|
|
135
|
+
|
|
136
|
+
**Before PS+:**
|
|
137
|
+
"Given these constraints [complex scheduling problem], is there a valid schedule?"
|
|
138
|
+
|
|
139
|
+
**After PS+:**
|
|
140
|
+
```
|
|
141
|
+
PROBLEM:
|
|
142
|
+
[Complex scheduling problem with constraints]
|
|
143
|
+
|
|
144
|
+
Let's first understand the problem, extract all constraints and their
|
|
145
|
+
relationships, and devise a complete plan for finding a valid schedule
|
|
146
|
+
or proving none exists. Then, let's carry out the plan step by step.
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Best Use Cases
|
|
150
|
+
|
|
151
|
+
1. **Numerical Reasoning**
|
|
152
|
+
- Financial calculations (MRR, CAC, payback, LTV)
|
|
153
|
+
- Math word problems
|
|
154
|
+
- Rate/proportion problems
|
|
155
|
+
- Statistical computations
|
|
156
|
+
|
|
157
|
+
2. **Multi-Step Technical Problems**
|
|
158
|
+
- Performance optimization (where numbers matter)
|
|
159
|
+
- Resource estimation
|
|
160
|
+
- Capacity planning
|
|
161
|
+
|
|
162
|
+
3. **Logic Problems**
|
|
163
|
+
- Constraint satisfaction
|
|
164
|
+
- Scheduling
|
|
165
|
+
- Eligibility determination
|
|
166
|
+
|
|
167
|
+
4. **Zero-Shot Reasoning Improvement**
|
|
168
|
+
- When you don't have few-shot examples
|
|
169
|
+
- When vanilla CoT ("think step by step") isn't accurate enough
|
|
170
|
+
- Drop-in improvement for any reasoning prompt
|
|
171
|
+
|
|
172
|
+
5. **Any Prompt Where Prior CoT Answers Were Wrong**
|
|
173
|
+
- PS+ reduces calculation errors
|
|
174
|
+
- Forces variable extraction before calculation
|
|
175
|
+
- Reduces "skipped step" errors
|
|
176
|
+
|
|
177
|
+
## Selection Criteria
|
|
178
|
+
|
|
179
|
+
**Choose PS+ when:**
|
|
180
|
+
- ✅ Numerical calculation involved
|
|
181
|
+
- ✅ Multi-step reasoning with intermediate values
|
|
182
|
+
- ✅ No few-shot examples available (zero-shot context)
|
|
183
|
+
- ✅ Prior CoT attempts gave calculation errors
|
|
184
|
+
- ✅ Variables need explicit extraction before solving
|
|
185
|
+
|
|
186
|
+
**Avoid PS+ when:**
|
|
187
|
+
- ❌ Task is not a reasoning/calculation problem → use other frameworks
|
|
188
|
+
- ❌ Few-shot examples are available → consider manual CoT instead
|
|
189
|
+
- ❌ Problem requires branching (multiple approaches) → use Tree of Thought
|
|
190
|
+
- ❌ Compositional multi-hop → use Least-to-Most
|
|
191
|
+
|
|
192
|
+
## PS+ vs. Chain of Thought vs. Least-to-Most
|
|
193
|
+
|
|
194
|
+
| | Zero-Shot CoT | PS+ | Least-to-Most |
|
|
195
|
+
|---|---|---|---|
|
|
196
|
+
| Trigger | "Think step by step" | "Plan first, then execute" | Decompose → solve sequentially |
|
|
197
|
+
| Variable extraction | No | Yes (explicit) | Partial |
|
|
198
|
+
| Planning step | No | Yes (explicit) | Decomposition step |
|
|
199
|
+
| Best for | General reasoning | Numerical/variable problems | Compositional multi-hop |
|
|
200
|
+
| Few-shot needed | No | No | Optional |
|
|
201
|
+
|
|
202
|
+
## Quick Reference
|
|
203
|
+
|
|
204
|
+
| Component | Purpose |
|
|
205
|
+
|-----------|---------|
|
|
206
|
+
| Understand problem | Ensure full comprehension before starting |
|
|
207
|
+
| Extract variables | Identify all given values explicitly |
|
|
208
|
+
| Devise plan | State the approach before executing |
|
|
209
|
+
| Calculate intermediates | Show all calculation steps |
|
|
210
|
+
| Solve step by step | Execute the plan with attention to detail |
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Pre-Mortem Prompting
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Pre-Mortem Prompting adapts Gary Klein's prospective hindsight technique to AI prompting. Instead of asking "what could go wrong?" (which triggers optimism bias and produces vague risks), it instructs the AI to *assume* the project or decision has already failed catastrophically — then work backwards to identify the specific reasons why. This committed-failure frame consistently produces more specific, actionable failure identification than forward risk analysis.
|
|
6
|
+
|
|
7
|
+
**Research basis:** Gary Klein's prospective hindsight research (Cognitive Systems Engineering; Brookings Institution). Studies show ~30% improvement in correct identification of failure causes compared to standard forward risk analysis. Application to LLM prompting is practitioner-level (no dedicated AI paper), but the cognitive mechanism is well-established.
|
|
8
|
+
|
|
9
|
+
## Why Assumed Failure Outperforms Forward Risk Analysis
|
|
10
|
+
|
|
11
|
+
Forward risk: *"What could go wrong?"* → Produces vague, hedged answers ("there might be delays", "adoption could be low")
|
|
12
|
+
|
|
13
|
+
Pre-mortem: *"This has already failed — why did it fail?"* → Produces specific, committed answers ("the integration with Salesforce took 3x longer than estimated because we didn't account for their API rate limits")
|
|
14
|
+
|
|
15
|
+
The difference: by committing to the failure frame, the model bypasses optimism bias and generates specific causal narratives rather than probabilistic hedges.
|
|
16
|
+
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
### Project/Decision Description
|
|
20
|
+
**Purpose:** What is being analyzed. Include enough context for the model to generate specific (not generic) failure causes.
|
|
21
|
+
|
|
22
|
+
### Future Date
|
|
23
|
+
**Purpose:** Set the time horizon. "12 months from now" produces different analysis than "3 months from now." Match to the natural completion window of the project.
|
|
24
|
+
|
|
25
|
+
### Failure Framing
|
|
26
|
+
**Purpose:** The core assumption: this has failed. Not "might fail" — has failed. The framing is everything.
|
|
27
|
+
|
|
28
|
+
**Standard framing:** *"It is [future date] and [project/decision] has completely and catastrophically failed."*
|
|
29
|
+
|
|
30
|
+
### Domain Analysis
|
|
31
|
+
**Purpose:** The specific dimensions to analyze for failure causes. More dimensions = more comprehensive coverage.
|
|
32
|
+
|
|
33
|
+
**Standard domains:**
|
|
34
|
+
- Technical / product
|
|
35
|
+
- People / team / organizational
|
|
36
|
+
- Market / customers / adoption
|
|
37
|
+
- Financial / resource
|
|
38
|
+
- External / dependencies
|
|
39
|
+
- Timeline / scope
|
|
40
|
+
|
|
41
|
+
### Warning Signs
|
|
42
|
+
**Purpose:** For each failure cause, identify the earliest observable warning sign. This is what makes pre-mortem actionable — not just "this could fail" but "this is what we'd see 30 days before it fails."
|
|
43
|
+
|
|
44
|
+
### Mitigation Pass (optional)
|
|
45
|
+
**Purpose:** A second pass ranking the failure causes by likelihood × preventability and suggesting pre-emptive actions.
|
|
46
|
+
|
|
47
|
+
## Template Structure
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
PRE-MORTEM ANALYSIS
|
|
51
|
+
|
|
52
|
+
PROJECT/DECISION:
|
|
53
|
+
[Describe the project, plan, or decision being analyzed]
|
|
54
|
+
|
|
55
|
+
FAILURE ASSUMPTION:
|
|
56
|
+
It is [DATE — e.g., 12 months from now] and [project/decision] has
|
|
57
|
+
completely and catastrophically failed. It did not achieve [primary goal].
|
|
58
|
+
|
|
59
|
+
FAILURE ANALYSIS:
|
|
60
|
+
Describe the failure in 2-3 sentences from the perspective of someone
|
|
61
|
+
looking back on it.
|
|
62
|
+
|
|
63
|
+
Then identify [8-12] specific reasons this failed. For each reason:
|
|
64
|
+
- CAUSE: [What specifically went wrong — be specific, not generic]
|
|
65
|
+
- DOMAIN: [Technical / People / Market / Financial / External / Timeline]
|
|
66
|
+
- WARNING SIGN: [What was the earliest observable indicator this was happening?]
|
|
67
|
+
|
|
68
|
+
PRIORITY:
|
|
69
|
+
After listing all causes, identify:
|
|
70
|
+
1. The 3 most likely failure causes (given our specific situation)
|
|
71
|
+
2. The 3 most preventable failure causes (where action now would help most)
|
|
72
|
+
3. Any single point of failure that could kill the project alone
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Complete Examples
|
|
76
|
+
|
|
77
|
+
### Example 1: Product Launch
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
PROJECT:
|
|
81
|
+
We are launching a new B2B project management tool for engineering teams
|
|
82
|
+
in Q3. Our team is 4 engineers, 1 designer, and 1 PM. We have 3 design
|
|
83
|
+
partners signed up for beta. Target: 50 paying customers by end of Q4.
|
|
84
|
+
|
|
85
|
+
FAILURE ASSUMPTION:
|
|
86
|
+
It is December 31st and we have failed to reach 50 paying customers.
|
|
87
|
+
The product launched in October with 8 beta customers but growth stalled.
|
|
88
|
+
|
|
89
|
+
FAILURE ANALYSIS:
|
|
90
|
+
Describe how this played out. Then identify 10 specific failure causes
|
|
91
|
+
with domain, and earliest warning sign for each.
|
|
92
|
+
|
|
93
|
+
PRIORITY:
|
|
94
|
+
Rank by likelihood. Flag any single points of failure.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Example 2: Organizational Change
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
PROJECT:
|
|
101
|
+
We are implementing a company-wide shift to OKRs across a 200-person
|
|
102
|
+
organization. Executive sponsorship is in place. We're starting with
|
|
103
|
+
a 2-day offsite to train team leads, then cascading to individual
|
|
104
|
+
contributors over the following 6 weeks.
|
|
105
|
+
|
|
106
|
+
FAILURE ASSUMPTION:
|
|
107
|
+
It is 6 months from now and the OKR implementation has failed.
|
|
108
|
+
Most teams have abandoned OKRs and reverted to old goal-setting methods.
|
|
109
|
+
|
|
110
|
+
FAILURE ANALYSIS:
|
|
111
|
+
10 specific reasons the rollout failed. Include: leadership domain,
|
|
112
|
+
middle management domain, cultural domain, process domain, and tooling.
|
|
113
|
+
For each: earliest warning sign.
|
|
114
|
+
|
|
115
|
+
PRIORITY:
|
|
116
|
+
The 3 most likely. The most preventable. Any single point of failure.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Example 3: Technical Decision
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
PROJECT:
|
|
123
|
+
We are migrating our primary database from MySQL to PostgreSQL. Timeline:
|
|
124
|
+
3 months. Team: 2 senior engineers part-time. We're running 2M daily
|
|
125
|
+
active users with a 99.9% uptime SLA.
|
|
126
|
+
|
|
127
|
+
FAILURE ASSUMPTION:
|
|
128
|
+
It is 4 months from now and the migration has failed. We experienced
|
|
129
|
+
significant downtime, data integrity issues, or were forced to roll back.
|
|
130
|
+
|
|
131
|
+
FAILURE ANALYSIS:
|
|
132
|
+
10 specific technical and organizational failure causes.
|
|
133
|
+
Cover: migration strategy, testing gaps, rollback planning,
|
|
134
|
+
team knowledge gaps, operational issues, and unforeseen dependencies.
|
|
135
|
+
For each: earliest warning sign.
|
|
136
|
+
|
|
137
|
+
PRIORITY:
|
|
138
|
+
The 3 most likely. The most preventable. Any single point of failure
|
|
139
|
+
that could cause a full rollback or data loss.
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Best Use Cases
|
|
143
|
+
|
|
144
|
+
1. **Pre-Launch Risk Assessment**
|
|
145
|
+
- Product launches
|
|
146
|
+
- Marketing campaigns
|
|
147
|
+
- Feature releases
|
|
148
|
+
|
|
149
|
+
2. **Organizational Initiatives**
|
|
150
|
+
- Process changes, reorgs, new methodologies
|
|
151
|
+
- Cultural initiatives
|
|
152
|
+
|
|
153
|
+
3. **Technical Decisions**
|
|
154
|
+
- Migrations, rewrites, architecture changes
|
|
155
|
+
- High-risk deployments
|
|
156
|
+
|
|
157
|
+
4. **Investment and Strategic Decisions**
|
|
158
|
+
- New market entry
|
|
159
|
+
- Major hires or partnerships
|
|
160
|
+
- Significant capital allocation
|
|
161
|
+
|
|
162
|
+
5. **Any High-Stakes, Hard-to-Reverse Decision**
|
|
163
|
+
|
|
164
|
+
## Selection Criteria
|
|
165
|
+
|
|
166
|
+
**Choose Pre-Mortem when:**
|
|
167
|
+
- ✅ You're about to commit to something with significant stakes
|
|
168
|
+
- ✅ You want specific failure causes, not generic risks
|
|
169
|
+
- ✅ Optimism bias is a risk (you're attached to this plan)
|
|
170
|
+
- ✅ You want to surface the "what were we thinking?" failure modes
|
|
171
|
+
|
|
172
|
+
**Avoid when:**
|
|
173
|
+
- ❌ You want to attack the reasoning of a current position → use Devil's Advocate
|
|
174
|
+
- ❌ You want iterative output improvement → use Self-Refine
|
|
175
|
+
- ❌ The decision is already made and irreversible (too late for pre-mortem)
|
|
176
|
+
|
|
177
|
+
## Pre-Mortem vs. Devil's Advocate
|
|
178
|
+
|
|
179
|
+
| | Pre-Mortem | Devil's Advocate |
|
|
180
|
+
|---|---|---|
|
|
181
|
+
| Frame | "This has already failed" (committed) | "Here's why this is wrong" (oppositional) |
|
|
182
|
+
| Output | Specific failure causes + warning signs | Strongest opposing argument |
|
|
183
|
+
| Best for | Risk identification + mitigation | Testing reasoning + debiasing |
|
|
184
|
+
| Bias bypass | Optimism bias | Confirmation bias / groupthink |
|
|
185
|
+
|
|
186
|
+
**Combined use:** Run Devil's Advocate first (attack the reasoning), then Pre-Mortem (assume failure and find causes). They complement each other for high-stakes decisions.
|
|
187
|
+
|
|
188
|
+
## Quick Reference
|
|
189
|
+
|
|
190
|
+
| Component | Purpose |
|
|
191
|
+
|-----------|---------|
|
|
192
|
+
| Project Description | What's being analyzed |
|
|
193
|
+
| Future Date | Time horizon |
|
|
194
|
+
| Failure Framing | "Has already failed" (committed, not probabilistic) |
|
|
195
|
+
| Domain Analysis | Dimensions to cover |
|
|
196
|
+
| Warning Signs | Earliest observable indicators |
|
|
197
|
+
| Priority Pass | Most likely + most preventable + single points of failure |
|