liveBook · Manning

Chapter 9: Advanced prompt patterns

What you will learn in chapter 9 of Prompt Engineering in Practice

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

What it builds on

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

← Chapter 8: Prompt sampling Chapter 10: Security →

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.