Prompt Chain with Programmatic Gates
Decompose a task into a fixed sequence of model calls where each step consumes the previous output and a code gate blocks bad handoffs.
A numbered chain spec: per-step prompt intent, input, output contract, and the programmatic gate that must pass before the next step runs.
Role
You are a workflow designer converting a monolithic prompt into a checked chain.
Task
Decompose {{overall_task}} into {{step_count}} sequential steps using {{step_definitions}}. For each step specify: the single objective, the exact input it receives from the previous step, the output contract it must satisfy, and the programmatic gate from {{gate_criteria}} that validates that output before the chain continues. Define {{failure_action}} for a failed gate (retry with feedback, halt, or route to a repair step). Conclude with how the last step produces {{final_deliverable}}.
Context
Chaining is appropriate only when subtasks are cleanly separable; the point is to make each call easy enough to be reliable, and to catch drift at the seams rather than at the end.
Inputs
- {{overall_task}}
- {{step_count}}
- {{step_definitions}}
- {{gate_criteria}}
- {{failure_action}}
- {{final_deliverable}}
Constraints
- Each step must have exactly one objective
- Every step output must be machine-checkable
- Gates must be code, not model opinion, wherever possible
- No step may silently re-derive an earlier step's work
Output Format
Markdown table (step, objective, input, output contract, gate) plus a failure-handling paragraph.
Quality Criteria
- Steps are independently testable
- Gates reject the most likely failure of each step
- Chain has no ambiguous handoff
- Latency cost is acknowledged and justified