prompt-chaining
Prompt Chaining
Anthropic canonical agent pattern. Linear flow. One step feeds next step.
What It Is
Split one task into ordered stages. Each stage has one job. Pass output forward. Check output before next step.
When to Use
- Task has clear sequence
- Later step needs cleaned output from earlier step
- Need traceable intermediate state
- Need step-specific prompt, tool set, or model
- Need cheap guardrails between stages
When Not to Use
- One prompt solves task well
- Order does not matter
- Work can run in parallel
- Steps depend on dynamic branching more than fixed flow
- Handoff cost bigger than quality gain
Core Flow
input
→ step 1: extract / classify / plan
→ validate
→ step 2: transform / expand
→ validate
→ step 3: format / finalize
→ output
Simple Implementation Outline
- Define end output.
- Split into small steps.
- Give each step one job.
- Lock schema for each handoff.
- Validate after each step.
- Retry or stop on bad output.
- Log step input, output, cost, latency.
Good Step Boundaries
- Extract facts
- Summarize facts
- Draft answer
- Check answer against facts
- Format for target system
Failure Modes
- Too many steps. Slow. Fragile.
- Vague handoff format. Drift.
- Later step redoes earlier step.
- Bad early output poisons rest.
- No validation. Errors compound.
- Full context copied every step. Cost spike.
Practical Checklist
- Steps fixed and ordered
- One responsibility per step
- Input/output schema per step
- Validation between steps
- Retry rule per step
- Stop rule on hard fail
- Logs for each handoff
- Baseline against single prompt
Decision Rule
Use prompt chaining when decomposition lowers error more than handoff adds cost. If not, use one prompt.
More from flpbalada/fb-skills
progressive-disclosure
Reduce complexity by revealing information progressively. Use when designing
7discuss-task
Clarify ambiguous tasks before action. Use when goal, scope, success criteria, constraints, or risks are unclear.
4cognitive-fluency-psychology
Apply cognitive fluency principles to improve clarity, trust, and conversion.
4react-useeffect-avoid
Guides when NOT to use useEffect and suggests better alternatives. Use when reviewing React code, troubleshooting performance, or considering useEffect for derived state or form resets.
4discuss-code
Critically discuss code issues with compact findings. Use when code needs review for logic, simplicity, structure, naming, or maintainability.
4learn
Extract reusable patterns from the current session. Use when errors, debugging techniques, workarounds, or project conventions should become skills.
3