Pattern: Prompt Chaining

Pattern: Prompt Chaining

Category: Orchestration Source: Internal usage (Role Factory workflow), FOR-0012 Status: Active

When to Use

When a complex task can be broken into sequential steps where each step's output feeds the next. Ideal when intermediate validation is needed, or when the full task is too large for a single prompt.

How It Works

  • Break a large task into discrete, ordered steps
  • Each step receives the output of the previous step as input
  • Each step validates its input before processing (gate check)
  • If validation fails, the step retries or returns to the previous step
  • The chain continues until all steps complete or a failure halts the pipeline

Example

The Role Factory workflow is a prompt chain: INTAKE -> DESIGN -> BUILD -> TEST -> AUTO-IMPROVE -> DEPLOY. Each stage has a clear gate. The output of INTAKE (role requirements) feeds DESIGN, which produces role.md + agent.md, which feeds BUILD, and so on. No stage is skipped.

Tradeoffs

Pro Con
Each step can be validated independently Latency grows linearly with chain length
Failures are caught early before downstream work Tight coupling between steps — changing one may ripple
Easier to debug than monolithic prompts Diminishing returns beyond ~10 steps
Can mix AI and non-AI steps in the same chain Total cost scales with number of steps

Factory Usage

  • Role Factory workflow (workflows/role-factory/workflow.md): The 6-stage pipeline is a textbook prompt chain.
  • Production Line stages (production-lines/): Every production line follows a staged chain (intake, configure, assemble, test, package).