chapter four

4 Patterns

 

This chapter covers

  • Eight foundational prompt patterns for common language model interaction problems
  • Structural patterns that establish consistent behavior and output quality
  • Contextual patterns that surface overlooked risks, gaps, and blind spots
  • Transformational patterns that improve content quality
  • Combining patterns to handle complex prompting problems

In chapters 2 and 3, you mastered the building blocks of effective prompts: structural elements that organize information and linguistic elements that influence communication precision. These foundations enable you to construct well-formed prompts, but they don’t address how to interact with language models strategically across different types of problems.

This chapter introduces prompt patterns, repeatable strategies for solving common prompting problems. Jules White, Quchen Fu, and their coauthors were the first to formally introduce the term prompt pattern and publish a formal catalog of prompt patterns for conversational large language models in A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT (2023).

4.1 Understanding prompt patterns

4.2 Role assignment pattern

4.2.1 Practical example: Pull request description generation

4.3 Delimiter pattern

4.3.1 Practical example: Multisource bug analysis

4.4 Template pattern

4.4.1 Practical example: Incident postmortem summaries

4.5 Repetition pattern

4.5.1 When to use the repetition pattern

4.5.2 Practical example: Selecting a logging approach

4.6 Self-reflection pattern

4.6.1 Practical example: Technical onboarding plan

4.7 Inversion pattern

4.7.1 Practical example: Architecture proposal review

4.8 Refinement pattern

4.8.1 Practical example: API documentation improvement

4.9 Comment-driven generation

4.9.1 Practical example: Technical Request for Comments review

4.9.2 Hands-on practice