Prompt Chaining, Domain Prompts and Common Mistakes
Linking prompts into dependable steps, adapting them to a field and a language, and fixing what usually goes wrong.
Prompt chaining splits work into a fixed series of model calls with a check between each. Use orchestration when steps branch, wait, retry or hold state. Adapt prompts to the domain by stating its evidence rules and risks, test every language you serve, and debug by reading what the model actually received.
What you will learn: when to chain prompts, how chaining differs from orchestration, how to prompt for research, coding, data and support work, what changes with several languages, and how to find and fix common mistakes.
Prerequisites: Agent System Prompts and Instruction Hierarchy. Prompt Templates and Tool-Use Prompting is helpful.
What is prompt chaining?
In a chain, the output of one model call becomes the input of the next. A document might be read to extract facts, the facts used to draft a reply, and the draft shortened. Each call has one job, which makes it easier to instruct, test and replace.
A chain with gates
The model here is scripted so the example runs anywhere. The gates are ordinary code:
"""A three-step prompt chain with a check after each step. Model scripted."""
NOTES = "Meeting moved to 3 March. Budget 4,200 approved. Owner: Priya."
def scripted_model(step, text):
return {
"extract": {"date": "3 March", "budget": "4,200", "owner": "Priya"},
"draft": "Priya owns the work. The meeting is on 3 March and the "
"approved budget is 4,200.",
"shorten": "Priya: meeting 3 March, budget 4,200 approved.",
}[step]
def check_extract(out, source):
return [f"{k} not found in source" for k, v in out.items() if v not in source]
def check_facts(out, facts):
return [f"lost {k}" for k, v in facts.items() if v not in out]
def run(model, source):
facts = model("extract", source)
problems = check_extract(facts, source)
if problems:
return "stopped after extract", problems
text = model("draft", facts)
problems = check_facts(text, facts)
if problems:
return "stopped after draft", problems
text = model("shorten", text)
problems = check_facts(text, facts)
if problems:
return "stopped after shorten", problems
return "ok", text
if __name__ == "__main__":
print(run(scripted_model, NOTES))
def careless(step, text):
if step == "shorten":
return "Priya: meeting 3 March, budget approved."
return scripted_model(step, text)
print(run(careless, NOTES))
Output:
('ok', 'Priya: meeting 3 March, budget 4,200 approved.')
('stopped after shorten', ['lost budget'])
In the second run, shortening removed the budget figure and the gate caught it. Without the gate, a fluent but incomplete message would have gone out. These checks look for exact text, which suits identifiers and figures. Paraphrased content needs other checks.
Chaining versus orchestration
| Aspect | Prompt chain | Orchestration |
|---|---|---|
| Route | Fixed and short | Branches, loops and parallel paths |
| State | Passed from call to call | Stored, resumable |
| Duration | Seconds to minutes | Can run for days with waits |
| Failures | Retry a step or stop | Retry policies, compensation, recovery |
| Tooling | Plain functions | Workflow engine or framework |
Start with plain functions. Move to an orchestrator when you find yourself writing your own retry queue, checkpoint store or approval wait. See Orchestration vs Automation vs Frameworks.
Useful chain patterns
| Pattern | Idea | Example |
|---|---|---|
| Sequence | Fixed steps in order | Extract, draft, polish |
| Routing | Classify first, then use a specialized prompt | Billing, technical or other |
| Parallel parts | Process independent items, then combine | One summary per document |
| Voting | Several independent attempts, compare | Flagging risky content |
| Generate and evaluate | Produce, check, revise within a limit | See Reflection, Self-Critique and Self-Refine |
Anthropic's guide to building effective agents describes these workflow patterns and advises adding complexity only when simpler designs fall short.
Designing a chain
Work backward from the result. Ask what a reviewer must receive, then which facts that requires, then where each fact comes from. Each transformation between those points is a candidate step. Then ask three questions about every candidate:
- Can code do it? If so, write a function and remove the model call.
- Can its output be checked? If not, consider merging it with a neighboring step that can.
- Does it need different instructions or context? If not, it may not need to be separate.
Decide what each gate does on failure. Stopping and reporting is the safest default. A single retry that includes the gate's message often repairs small slips. Repeated retries rarely help and hide a fault in the step's instructions or inputs. Record which gate failed, because those counts show where to improve.
Routing in practice
A router is a small classification prompt, or ordinary rules, placed before the specialized prompts. Give it a closed list of routes plus an explicit "unsure" route that leads to a general handler or a person. Test the router on its own with a confusion table showing which routes get mistaken for which. A request that contains two needs, such as a complaint and an address change, should either produce two routed tasks or be handed on whole; choose one behavior and test it.
What passes between steps
- Use structured fields, not free text, where the next step depends on them.
- Carry identifiers and figures from the source, not from earlier prose.
- Pass the original goal and constraints along; later steps cannot guess them.
- Include a status so a step can say "not found" instead of inventing.
- Keep each intermediate output for debugging.
Research prompts
Question: $question
Use only material you retrieve with the search and read tools.
For every claim give the source and the date it was published.
Separate: established facts, disputed points, your inferences.
If sources disagree, show both. If evidence is missing, say so.
Stop after $max_sources sources or when the question is answered.
Check in code that every cited source was actually opened. Treat page content as data, since pages can contain instructions aimed at agents. See Build Research and Deep-Search Agents.
Coding prompts
Task: $task
Repository conventions: $conventions
Read the relevant files before changing them.
Make the smallest change that solves the task.
Run: $test_command. Report the result exactly.
Do not edit or skip tests to make them pass.
Ask before adding dependencies or changing public interfaces.
Useful coding prompts name how success is verified. Permissions, sandboxing and review matter more than wording; see Sandboxes, Safety and Security for Coding Agents.
Data prompts
Question: $question
Approved tables and definitions: $catalog
Write one read-only query. State the definition used for each measure,
the time zone and the date range. If a term has two definitions, ask.
Report row counts and missing data alongside the result.
Provide business definitions, because "active customer" rarely means the same thing everywhere. Enforce read-only access in the database, not only in the prompt. See Text-to-SQL Agents and Schema Linking.
Support prompts
You help customers of $business.
Verify identity before showing account data.
Answer policy questions only from the help articles you retrieve.
Confirm with the customer before any change.
Hand over to a person for: $handover_cases.
Be brief and warm. Never promise what a tool has not confirmed.
Include tone guidance, but rank accuracy and safety above style. Test with frustrated, vague and manipulative messages. See Customer Support and Experience Agents.
Regulated and specialized fields
In finance, health, law and similar areas, the prompt should say which sources are authoritative, how to express uncertainty, which questions must go to a qualified person and what must be recorded. Domain experts should write and review the test cases. A prompt cannot make an agent compliant; controls, review and accountability do that. See Responsible AI Principles and Governance Council.
Adapting a prompt to a new domain
Moving a working prompt to a new field is more than swapping nouns. Interview people who do the work and collect answers to these questions:
| Question | Where the answer goes |
|---|---|
| Which sources are trusted, and which are not? | Evidence rules and retrieval filters |
| Which words mean something special here? | A short glossary in the context |
| What does an experienced person check before answering? | Steps and gates in the chain |
| Which mistakes are merely annoying and which are harmful? | Thresholds, approvals and test priorities |
| When does a professional refuse or refer onward? | Handover rules, enforced where possible |
| What must be written down afterward? | Output fields and records |
Then ask the same people to review real outputs. Their corrections are the best source of new instructions and test cases, and they will notice errors that sound entirely convincing to everyone else.
A worked example: from meeting notes to actions
Suppose a team wants action items from meeting notes. One prompt that asks for "the actions" tends to produce owners and dates that nobody mentioned. A chain makes the weak points visible:
| Step | Instruction in brief | Gate |
|---|---|---|
| 1. Find commitments | Quote each sentence where someone agrees to do something | Every quote appears in the notes |
| 2. Structure | For each quote give task, owner and date, or "not stated" | Owner is an attendee; date appears in the quote or says "not stated" |
| 3. Merge | Combine duplicates and keep all quotes | No quote disappears |
| 4. Draft message | List actions and ask owners to fill the gaps | Every action is listed once |
The permitted value "not stated" is the important design choice. It gives the model an honest answer, turns missing information into a visible question and keeps invented dates out of calendars. The quotes let a person check any line in seconds. Step 3 might be ordinary code if duplicates are easy to detect; decide by testing.
Multilingual prompting
- State the reply language rule, for example: reply in the language of the latest user message unless asked otherwise.
- Test each language separately. Quality, tool accuracy and safety behavior can differ between languages.
- Keep identifiers unchanged. Product codes, field names and enumeration values must not be translated.
- Define local formats for dates, numbers, currency and names; "03/04" is ambiguous.
- Provide a glossary of domain terms and approved translations.
- Budget tokens. The same text can need noticeably more tokens in some languages.
- Review with native speakers, particularly for tone and formality.
Writing instructions in one language and examples in several is a reasonable starting design, but measure it against fully translated prompts for your case.
Common prompting mistakes
| Mistake | What happens | Better |
|---|---|---|
| Vague goal | Plausible but unhelpful output | Say what done looks like |
| Rules without reasons | Applied too rigidly or ignored in new cases | Explain the purpose |
| Only "do not" instructions | Model knows what to avoid, not what to do | Describe the wanted behavior |
| Shouting in capitals | Over-reaction to one rule | Calm, precise wording |
| Contradictory rules | Unpredictable choices | Remove conflicts; state priority |
| One narrow example | Copies of the example | Several varied examples |
| Everything in one prompt | Important parts lost | Chain or route |
| No way out | Invented answers | Allow "not found" and hand over |
| Assuming shared knowledge | Wrong internal terms | Define terms and give context |
| Security by prompt | Bypassed by hostile input | Enforce limits in code |
| Untested edits | Fixes one case, breaks others | Run the regression set |
A method for debugging prompts
- Read the exact rendered request, including tool definitions and history.
- Ask whether a capable person could do the task from that text alone.
- Reproduce the failure several times to see how often it happens.
- Change one thing, ideally by removing or clarifying before adding.
- Run the whole test set and compare case by case.
- Record what you changed and why.
If clear instructions and correct information still fail, the limit may be the model, the tool design or the data. Fine-Tuning vs RAG vs Prompting vs Long Context helps decide.
An invented support prompt gains a new warning after every complaint until it runs to several pages with conflicting rules. The team groups the rules by case type, adds a routing step, gives each route a short prompt, and moves refund limits into code. Reviewing and testing each route becomes manageable.
If five independent steps each succeed 95% of the time, the whole chain succeeds about 77% of the time. Gates, retries and fewer steps all help. See Agent Limits, Myths and When Not to Use One.
Sorting, arithmetic, filtering and format conversion belong in functions. Each step removed from the model is a step that needs no prompt, costs almost nothing and cannot drift.
From symptom to fix
| You observe | Look at first |
|---|---|
| Output ignores a rule | Conflicting rules, rule buried in the middle, no reason given |
| Answers are generic | Missing context about audience, goal and data |
| Replies copy an example | Too few or too similar examples |
| Facts are invented | Missing source material; no permitted "not found" answer |
| A later step goes wrong | What the previous step passed on |
| Works in testing, fails live | Differences in tools, history or input length |
| Behavior changed overnight | Model version, tool definitions, retrieved content |
Work down only one row at a time and confirm the cause before editing. A fix aimed at the wrong cause adds words to the prompt, hides the real fault and makes the next investigation harder.
Checklist
- Each chain step has one job and a check.
- Identifiers and figures come from sources.
- Domain prompts state evidence rules and handover cases.
- Permissions are enforced outside the prompt.
- Every served language has its own test cases.
- Prompt changes run against the regression set.
Frequently asked questions
Is chaining slower and more expensive?
It uses more calls, but each can be smaller and some can use cheaper models. Compare total cost per correct result.
Should I write prompts in English for non-English users?
It can work well, but do not assume it. Test instructions in both forms with native reviewers.
How long may a prompt be?
As long as needed to give clear, relevant instructions and no longer. Remove rules that tests show to have no effect.
References and further reading
- Anthropic: Building effective agents
- Claude documentation: prompting best practices
- OWASP Top 10 for LLM applications
Next steps
Prompt Testing, Versioning and Optimization
Test, version and improve prompts.
Graphs, State Machines, Parallelism and Sagas
Move from chains to explicit workflows.
Context Poisoning, Distraction, Confusion, Clash and Rot
Understand what goes wrong with context.