Chapter 9: Advanced prompt patterns
The introduction distinguishes three advanced prompt patterns by how each structures reasoning or prompt generation, and connects them to techniques from earlier chapters.
After this chapter you will be able to
- Advanced pattern purposes. Distinguish what chain of thought, meta prompting, and ReAct each do at the level described in this introduction.
- Explicit reasoning steps. Explain that chain-of-thought prompting asks a model to show intermediate reasoning before its conclusion, and why that can help with multistep tasks.
- Reasoning mode versus explicit prompting. Distinguish using a reasoning model’s built-in mode from adding explicit chain-of-thought instructions, and describe when explicit prompting remains useful.
- Canary signal weighting. Explain why the example recommends NO-GO by comparing the error rate with its threshold and duration requirement, while treating the other signals as secondary or nonblocking.
- Visible zero-shot reasoning. Distinguish the direct prompt's answer from the zero-shot CoT response in terms of what the on-call engineer can inspect.
- Few-shot reasoning pattern. Explain how the worked reference example guides the target rollout assessment when domain-specific decision criteria matter.
- Prompt-generated templates. Explain that meta prompting asks a model to generate a structured prompt template from a plain-English task description, rather than requiring the engineer to write the template by hand.
- Template description precision. Explain why a precise description of a well-formed template improves the generated result, while a vague description yields generic instructions without enforced output structure.
- Meta prompt input and output. Explain that the meta prompt takes a task description and produces a complete, reusable prompt template with a design rationale.
- Three patterns in the template. Describe what role assignment, delimiters, and the template pattern do in this meta prompt.
- Reusable risk assessment template. Explain how the task description becomes a reusable prompt template for classifying pull requests before merge. Describe the template’s three assessment factors, evidence constraint, and required output.
- Sample high-risk verdict. Trace how the sample pull request’s change scope, effects on two services, and test coverage support its high-risk verdict. Identify the specific untested interaction named in the justification.
- ReAct reasoning and action loop. Trace how a ReAct workflow moves from a thought about current evidence and an information gap, to an action, to an observation that informs the next thought. Distinguish this changing context from chain-of-thought reasoning over fixed context.
- ReAct investigation loop. Describe how the triage prompt alternates a Thought that identifies the current evidence and next gap with one specific Action, then switches to a Conclusion when the diagnosis has sufficient support.
- Pipeline diagnosis from observations. Trace why the agent first requests job history, then transformation logs, and how those observations lead to the example’s diagnosis and immediate action.
- ReAct versus fixed context. Distinguish when this section recommends ReAct instead of chain of thought or a direct prompt.
- CoT reasoning checks. Apply zero-shot CoT to a deployment GO/NO-GO decision and few-shot CoT to a domain-specific threshold assessment. Describe how to check that the resulting reasoning identifies the deciding signal or follows the worked example.
- Meta prompt template review. Describe how to practice meta prompting for a recurring team task and what to check in the resulting template.
- ReAct observation uptake. Trace the two-turn ReAct simulation and state what the second thought must show.
- Task based pattern selection. Justify choosing CoT, meta prompting, or ReAct for the listed tasks based on auditability, reuse, sequential information, and uncertain weighting rules.
What it builds on
- Few-shot prompting (chapter 7) · Few-shot reference examples that CoT extends.
- Understanding prompt patterns (chapter 4) · Prompt patterns applied by meta prompting.
- What you design: System and user prompts (chapter 6) · System and user prompt separation on which ReAct builds.
- Prompt templates as reusable frameworks (chapter 5) · The idea of a prompt template as a reusable framework.
- Role assignment pattern (chapter 4) · The role assignment pattern
- Delimiter pattern (chapter 4) · The delimiter pattern
- Template pattern (chapter 4) · The template pattern
Section by section
Introduction
The introduction distinguishes three advanced prompt patterns by how each structures reasoning or prompt generation, and connects them to techniques from earlier chapters.
- Advanced pattern purposes: Distinguish what chain of thought, meta prompting, and ReAct each do at the level described in this introduction.
Why it matters: Their different purposes help you recognize which kind of problem each pattern addresses. - Earlier toolkit connections: Explain how these patterns differ in scope from earlier prompt techniques and state the earlier techniques each builds on.
Why it matters: The connections show how the advanced patterns build on prompt-design techniques you have already encountered.
Key terms: chain of thought (CoT), meta prompting, ReAct, thought-action-observation loops, few-shot reference-examples, structural elements, prompt patterns, system prompt, user prompt
9.1 Chain of thought
This section explains how chain-of-thought prompting makes multistep reasoning explicit and when to use it instead of a model’s built-in reasoning mode.
- Explicit reasoning steps: Explain that chain-of-thought prompting asks a model to show intermediate reasoning before its conclusion, and why that can help with multistep tasks.
Why it matters: The visible steps give you something to inspect besides the final answer. - Reasoning mode versus explicit prompting: Distinguish using a reasoning model’s built-in mode from adding explicit chain-of-thought instructions, and describe when explicit prompting remains useful.
Why it matters: Choosing the right approach avoids unnecessary prompt cost while retaining explicit guidance where it helps. - Domain-specific reasoning examples: Describe what a few-shot chain-of-thought example supplies when the required reasoning pattern is domain-specific.
Why it matters: An example can convey not just the desired answer style but how to reason in that domain.
Key terms: CoT prompting, intermediate reasoning steps, auditable, reasoning mode, reasoning or thinking model, nonreasoning model, explicit CoT prompting, few-shot chain-of-thought example, domain logic, reasoning structure
9.1.1 Practical example: Deployment risk reasoning
A canary-rollout example shows how chain-of-thought prompts make a risk recommendation auditable, how a worked example reinforces domain-specific reasoning, and when to choose another approach.
- Canary signal weighting: Explain why the example recommends NO-GO by comparing the error rate with its threshold and duration requirement, while treating the other signals as secondary or nonblocking.
Why it matters: The decision depends on identifying the deciding signal without ignoring the others. - Visible zero-shot reasoning: Distinguish the direct prompt's answer from the zero-shot CoT response in terms of what the on-call engineer can inspect.
Why it matters: A visible reasoning path lets the on-call team review or override a recommendation with confidence. - Few-shot reasoning pattern: Explain how the worked reference example guides the target rollout assessment when domain-specific decision criteria matter.
Why it matters: A worked case can make the team's decision criteria more consistent across different rollout signals. - Prompt approach selection: Describe when this section favors explicit CoT, a direct prompt or reasoning model, or ReAct.
Why it matters: Choosing the approach by auditability and information needs avoids adding explicit reasoning steps where they are not needed.
Key terms: rollback threshold, alert threshold, noncritical path, deciding signal, NO-GO, direct prompt, zero-shot CoT, reasoning trace, auditable, few-shot CoT
9.2 Meta prompting
Meta prompting uses a model to turn a plain-English task description into a prompt template, with the result depending on how precisely the desired template is described.
- Prompt-generated templates: Explain that meta prompting asks a model to generate a structured prompt template from a plain-English task description, rather than requiring the engineer to write the template by hand.
Why it matters: It gives you a starting template without having to draft its structure yourself. - Template description precision: Explain why a precise description of a well-formed template improves the generated result, while a vague description yields generic instructions without enforced output structure.
Why it matters: A precise description makes the generated template more useful on the first pass.
Key terms: meta prompting, prompt template, well-formed template, output structure
9.2.1 The meta prompt template
This section presents a reusable meta prompt that turns a task description into a prompt template and explains the design choices built into it.
- Meta prompt input and output: Explain that the meta prompt takes a task description and produces a complete, reusable prompt template with a design rationale.
Why it matters: This distinguishes a prompt that designs prompts from a prompt that performs the described task. - Three patterns in the template: Describe what role assignment, delimiters, and the template pattern do in this meta prompt.
Why it matters: Each pattern has a distinct job in keeping the prompt-design request organized. - Template construction rules: State the template’s rules for handling variable content, conditional sections, and input parameters.
Why it matters: These rules make the generated template reusable without adding sections a task does not need.
Key terms: meta prompt template, task description, design rationale, role assignment pattern, delimiter pattern, template pattern, triple-backtick fences, Constraints subsection, Jinja2 double-brace syntax, input parameters
9.2.2 Practical example: Generating a pull request risk classification template
This section shows how a precise task description produces a reusable pull request risk-classification prompt, applies it to a sample pull request, and identifies when meta prompting is worth using.
- Reusable risk assessment template: Explain how the task description becomes a reusable prompt template for classifying pull requests before merge. Describe the template’s three assessment factors, evidence constraint, and required output.
Why it matters: The example shows what a task description must make explicit to produce a template the team can reuse. - Sample high-risk verdict: Trace how the sample pull request’s change scope, effects on two services, and test coverage support its high-risk verdict. Identify the specific untested interaction named in the justification.
Why it matters: The verdict is useful because it ties the risk level to the supplied PR details and a specific coverage gap. - Meta prompting fit: Distinguish when the section recommends generating a template through meta prompting from when it recommends writing the prompt template directly.
Why it matters: Choosing the approach to match the task avoids template-design overhead when reuse or stable requirements are absent.
Key terms: meta prompt template, task description, change scope, service impact, test coverage, risk level, Assessment, Justification, integration tests, cross-service interaction
9.3 ReAct
This section explains the ReAct thought–action–observation loop and how its actions and observations are handled with or without tool calling.
- ReAct reasoning and action loop: Trace how a ReAct workflow moves from a thought about current evidence and an information gap, to an action, to an observation that informs the next thought. Distinguish this changing context from chain-of-thought reasoning over fixed context.
Why it matters: The loop explains how an agent can update its reasoning when it obtains new evidence. - Action execution and observation delivery: Describe how a proposed action becomes an observation in a production agentic system, and how the conversational approach supplies that observation without tool calling.
Why it matters: It clarifies who carries out an action and how its result reaches the model in each setting.
Key terms: ReAct, Thought, Action, Observation, CoT, structured action request, runtime layer, tool call, conversational approach
9.3.1 Practical example: Data pipeline staleness investigation
A data-pipeline investigation illustrates how ReAct uses successive observations to reach an evidence-grounded diagnosis, and when to choose it over fixed-context reasoning.
- ReAct investigation loop: Describe how the triage prompt alternates a Thought that identifies the current evidence and next gap with one specific Action, then switches to a Conclusion when the diagnosis has sufficient support.
Why it matters: This structure keeps the agent from jumping from an alert to an unsupported root cause. - Pipeline diagnosis from observations: Trace why the agent first requests job history, then transformation logs, and how those observations lead to the example’s diagnosis and immediate action.
Why it matters: Following the evidence explains both where the pipeline stopped and why the dashboard remained stale. - ReAct versus fixed context: Distinguish when this section recommends ReAct instead of chain of thought or a direct prompt.
Why it matters: Choosing by information availability avoids adding an investigation loop when the prompt already has everything it needs.
Key terms: Thought, Action, Conclusion, observations, stopping condition, ingestion, transformation, export, job execution history, transformation error logs
9.3.2 Hands-on practice
This hands-on section asks readers to practice CoT, meta prompting, and ReAct in software-engineering tasks and justify which pattern fits different task constraints.
- CoT reasoning checks: Apply zero-shot CoT to a deployment GO/NO-GO decision and few-shot CoT to a domain-specific threshold assessment. Describe how to check that the resulting reasoning identifies the deciding signal or follows the worked example.
Why it matters: These checks help distinguish a traceable decision from an answer that merely states a result. - Meta prompt template review: Describe how to practice meta prompting for a recurring team task and what to check in the resulting template.
Why it matters: A generated reusable template still needs review against the task it is meant to serve. - ReAct observation uptake: Trace the two-turn ReAct simulation and state what the second thought must show.
Why it matters: The second thought shows whether the simulated investigation responds to information received after its first action. - Task based pattern selection: Justify choosing CoT, meta prompting, or ReAct for the listed tasks based on auditability, reuse, sequential information, and uncertain weighting rules.
Why it matters: The useful pattern depends on what the task needs, not merely on its subject matter.
Key terms: zero-shot CoT, few-shot CoT, reasoning trace, worked reference example, meta prompting, meta prompt template, design rationale, structural elements, linguistic elements, prompt patterns
9.4 Summary
The section summarizes what CoT, meta prompting, and ReAct do and when to choose each pattern.
Concepts explained in this chapter
- chain-of-thought promptingA reasoning or prompting technique in which a model generates intermediate steps toward an answer.
- few-shot chain of thoughtA prompting technique that provides worked examples demonstrating intermediate reasoning steps.
- ReActReACT is a prompting pattern for agentic workflows in which a model alternates between reasoning, actions, and observations.
- meta-promptMeta Prompting is a prompting technique in which a model is instructed to design, refine, or apply prompts for another task.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
