Multi-Stage Prompts (Composition)
In this step, you’ll learn how to turn a complex prompt into a clear sequence of smaller stages. Instead of relying on a single, sprawling instruction, you’ll guide the AI through a chain of focused sub-prompts, each one producing something specific that the next step can build on. By the end, you’ll know how to design multi-stage prompts that are modular, easier to debug, and much more reliable.
Problem
When your prompt tries to do everything at once, things can get messy. The responses might be inconsistent, or parts of the task might get skipped entirely.
Your task is to break your prompt into smaller, focused stages so it’s easier to test, reuse, and build on over time.
What you need to know
Multi-stage prompts turn a big, fuzzy task into a pipeline of small, reliable steps. Each stage has a clear purpose, a defined input/output, and a compact artifact (plan, outline, analysis, draft, review).
This makes the overall process easier to reason about, test, and fix. If something goes wrong, you know which stage failed; if you want to improve quality, you can swap or refine a single stage without rewriting everything. Composition also scales: long-running or ambiguous work (like instructions generation) becomes repeatable and automatable—you can run stages in order, cache outputs, re-run just one stage after edits, and track decisions as files in version control.
Benefits in practice
Modularity & reuse: upgrade one stage (e.g., “architecture analysis”) without touching “drafting.”
Quality & debuggability: intermediate artifacts (plan/outline/analyses/review notes) make issues visible and fixable.
Traceability: decisions are tied to files and steps, great for reviews and audits.
Scalability: long tasks become a dependable pipeline you can script, parallelize where safe, and CI-ify.
Example
At Bitovi we’ve developed a custom multi-stage prompt for generating instruction files, which is stored in a public repo: Instruction Generation Prompt.
✏️ Look through Bitovi’s prompt above and study the structure to get an idea of how a large prompt can be broken up into stages.
Do’s and Don’ts for Multi-Stage Prompts
Do
Define contracts per stage. Specify exact inputs/outputs (schemas, headings) so handoffs are clean.
Name and persist artifacts. Save
ANALYSIS_ARCH.json,OUTLINE_DECISION.json, etc., so you can inspect and reuse.Restate key parameters each stage. Re-assert output format, tone, limits, and audience to prevent drift.
Gate with understanding. Add a “confirm understanding of the sequence” step before execution; it reduces wrong turns.
Bound each stage. Word caps/timeboxes keep options/plans short and drafting focused.
Don’t
Don’t mash stages together. One mega paragraph with mixed goals invites contradictions and loss of state.
Don’t rely on implicit structure. If you don’t give schemas/skeletons, stages will invent shapes that don’t align.
Don’t let decisions vanish. Require a visible “Decision” (or hybrid) and carry it forward throughout the process
Don’t ignore failures. Add simple validation (required sections/keys, length, JSON validity) and a “fix once” rule.
Don’t over-engineer. Start with 3–5 stages; only add more if it improves clarity or reusability.
These practices keep composition practical: small, well-bounded steps with explicit handoffs that you can version, rerun, and improve over time.
Technical Requirements
✏️ Complete the following steps to break your prompt into multiple stages.
Identify the natural steps
Read your prompt and break it into logical chunks (e.g., understand, plan, generate, review). Each chunk should do one job and produce something useful.
Split and rewrite as standalone stages
Turn each chunk into its own prompt. Add a clear goal, expected output, and any needed parameters (e.g., tone, format, word limit).
Think through how information will be passed through the stages of the prompt.
Test each stage on its own
Run the parts separately to make sure they work. Tweak wording, clarify outputs, and make sure the next step can use the results cleanly.
Chain them together
Combine the steps into one file with clear dividers—or keep them in separate files and run them in order. Optional: add a "confirm understanding" step upfront if the flow is long.
Solution
When designing multi-stage prompts, you can place all the stages into a single monolith prompt file and separate everything using delimiters. However, in a lot of cases, it makes sense to split everything into multiple files stored in a folder together.
At Bitovi we’ve developed a custom multi-stage prompt for generating instruction files, which is stored in a public repo: Instruction Generation Prompt. Below is the kickoff prompt for the chain, which composes everything together:
{output_folder} = .results
{final_output_file} = /.github/copilot-instructions.mdYou are assisting with generating a {final_output_file} file using a multi-step prompt chain.
Open this repository on GitHub: https://github.com/bitovi/ai-enablement-prompts.
Navigate to the
/understanding-code/instruction-generationfolder within the repo.Review all the prompt files in this folder WITHOUT executing them.
This will help you understand the full scope of the prompt chain.
Confirm you have a full understanding of the prompt chain sequence.
Once you're familiar with the flow, begin executing the prompts in numerical order:
1-determine-techstack.md
2-categorize-files.md
3-identify-architecture.md
4-domain-deep-dive.md
5-styleguide-generation.md
6-build-instructions.md
For each step, output results into a corresponding
{output_folder}/folder.
Mirror the step’s filename e.g.,
1-determine-techstack.md>{output_folder}/1-determine-techstack.md.Stop ONLY when:
All
instruction-generationsteps are completeA full
{final_output_file}can be generated.
Full prompt usage instructions: https://bitovi.atlassian.net/wiki/spaces/AIEnabledDevelopment/pages/1644920875/Copilot+Instructions#Advanced---The-Instruction-Generation-Prompt-Chain
This initial prompt kicks off the larger prompt chain by asking the AI to first analyze all the prompt files in the repo and then execute them one by one. Because coding agents generally have access to the public internet, all of these prompts can be checked into version control on http://GitHub.com and developed using a normal git workflow.
In this multi-stage prompt, we have several prompt files which define different steps in the larger instructions generation pipeline. These are then composed using a kickoff prompt which directs the AI how to run the larger workflow.
Having the AI confirm it’s understanding - Notice in step 4 from the prompt above we ask the AI to confirm it has a full understanding of the prompt chain sequence. This is a useful addition to a multi-stage prompt like this as it helps the AI slow down and think through the overall structure of the prompt before it goes off and starts working (this is essentially a version of Chain-of-Thought).
Next Steps
Your prompt is now more modular and maintainable!
Continue to: https://bitovi.atlassian.net/wiki/spaces/AIEnabledDevelopment/pages/1608122389/Prompt+Engineering+Workshop#Conclusion
Or check out some completed example prompts: https://bitovi.atlassian.net/wiki/spaces/AIEnabledDevelopment/pages/1625587759/Prompt+Examples?atlOrigin=eyJpIjoiZTY4ZDdkYjdmY2FmNGI3YThiZjQ3ZWZjZjAxNTVlMjIiLCJwIjoiYyJ9