chapter nine

9 Advanced prompt patterns

 

This chapter covers

  • Chain of thought: making multistep reasoning explicit when no reasoning model is available or the pattern is domain specific
  • Meta prompting: generating prompt templates from task descriptions using the elements and patterns from earlier chapters
  • The ReAct pattern: structuring thought-action-observation loops for agentic workflows
  • Knowing when each pattern earns its added complexity and when simpler prompting wins

Chapters 2 through 8 built the core toolkit: prompt structure, language shaping, reusable templates, few-shot examples, and multigeneration aggregation. Each technique improves what a model produces in response to a well-formed request.

This chapter introduces three patterns that operate at a higher level of abstraction. Each one changes not just the content of a prompt but how reasoning or generation itself is structured.

  • Chain of thought (CoT) makes intermediate reasoning steps explicit, producing auditable logic that engineers can review, challenge, and trace.
  • Meta prompting uses a prompt to design a prompt, applying the framework built across earlier chapters to accelerate template creation for recurring tasks.
  • ReAct (reasoning and acting) structures agentic workflows as interleaved thought-action-observation loops, giving a model a principled way to incorporate real-world observations before committing to a conclusion.

9.1 Chain of thought

9.1.1 Practical example: Deployment risk reasoning

9.2 Meta prompting

9.2.1 The meta prompt template

9.2.2 Practical example: Generating a pull request risk classification template

9.3 ReAct

9.3.1 Practical example: Data pipeline staleness investigation

9.3.2 Hands-on practice

Summary