Prompt Chaining with Subagents in Codex and Claude Code

Learn how sequential subagents can prototype prompt chaining in Codex and Claude Code without dedicated orchestration code.

Published

You can prototype a prompt chain without writing dedicated orchestration code.

Prompt chaining connects separate model stages: the output of one stage becomes the input to the next. Putting Step 1, Step 2, and Step 3 inside one prompt is still one model call, not automatically a chain.

Where subagents are available, you can ask Codex or Claude Code to coordinate dependent stages. The exact mechanics differ between tools, but the pattern is the same: make every handoff explicit.

A practical prompt-chaining example

Suppose you want to analyse customer feedback.

Subagent 1 extracts the strongest themes and the evidence supporting them.

Subagent 2 receives that result and identifies the most consequential problem supported by the evidence.

Subagent 3 receives the diagnosis and evidence, then recommends an action.

You can describe the workflow in natural language:

"Use three subagents sequentially, not in parallel. Label the result of each stage. Pass a compact handoff containing its findings and supporting evidence to the next stage, and show me every intermediate result."

The handoff is what creates the chain. For example, Stage 1 can return three recurring themes with supporting feedback excerpts. Stage 2 uses that artifact to produce an evidence-based diagnosis. Stage 3 receives both the diagnosis and its evidence before recommending an action.

Delegation is not automatically prompt chaining

Three subagents working on separate tasks is delegation.

When one subagent's result becomes the next subagent's input, that is prompt chaining. The stages are ordered: the second cannot begin until the first has produced its handoff.

This distinction matters because independent tasks can often run in parallel, while dependent stages cannot.

When sequential subagents are useful

Use a chain when intermediate results need separate inspection, testing, or improvement. Showing each result can help you identify whether extraction, analysis, or recommendation caused a weak final answer.

If you need to approve or revise a result before it affects the next stage, ask the coordinator to pause after each handoff. Exact pause-and-resume behavior depends on the tool and configuration.

For a small task that does not need those checkpoints, one agent or one model call may be simpler.

The trade-offs

Sequential subagents can take longer and use more tokens than a comparable single-agent task. A weak result can propagate through the chain, and a summarized handoff can omit evidence that later stages cannot recover.

Use prompt chaining when visible stage boundaries improve verification or failure diagnosis enough to justify that overhead. Otherwise, prefer one agent.