GPT-Talk

Prompt Engineering Core Patterns: 8 Templates That 2× GPT Output

A systematic walkthrough of 8 high-frequency prompt patterns — role prompting, few-shot, chain-of-thought, ReAct, self-consistency — each with a reusable template.

TL;DR
This article walks through 8 high-frequency prompt patterns — role prompting, few-shot, chain-of-thought, ReAct, self-consistency and more. Each pattern ships with a directly reusable template and a 'when to use it' list.
Prompt Engineering is the practice of guiding a large language model to high-quality output through structured instructions — the core skill for working with LLMs.

How to

  1. Start with role + task + output format skeleton

    Pin three blocks first: "You are [role]", "Task: [what to do]", "Output format: [Markdown / JSON / table]".

  2. Add 2-3 few-shot examples

    Examples beat descriptions. Drop 2-3 input/output pairs and behaviour stabilises. Diversify the examples to cover edge cases.

  3. Use Chain-of-Thought for complex reasoning

    Add "let's think step by step" or an explicit "list the steps, then give the conclusion" instruction. Noticeable accuracy gains on math, code, planning.

  4. Embed tool calls with ReAct

    Format: "Thought: ...; Action: [tool_name]; Input: ...; Observation: ..." in a loop. The model decides when to call tools; close with "Final Answer".

  5. Use Self-Consistency for majority voting

    Sample N answers for the same question (temperature 0.5-0.7). Take the majority. Expensive but stable — use for high-stakes decisions.

  6. Register templates in your team's prompt registry

    Templates carry owner, version, last updated, best model (model + reasoning.effort), cost estimate. Bump the version on every major change.

Prompt Engineering Core Patterns: 8 Templates That 2× GPT Output

Prompt engineering is the "programming language" for working with LLMs. Master these patterns and your output quality jumps.

1. Role Prompting

Give the model a persona — output style and depth shift immediately.

You are a senior front-end architect with 10 years of experience, focused on React performance.
Review the code below and point out at least 3 potential performance issues:

[code]

The more specific the role, the more focused the output. Stack roles: senior + domain + style.

2. Few-shot Learning

Give 2-5 examples and the model will imitate the pattern.

Convert spoken-style to written-style:

Spoken: yeah that thing just doesn't work
Written: The component fails to mount.

Spoken: I think maybe he won't come
Written: He is unlikely to attend.

Spoken: hurry up we're gonna be late
Written:

Few-shot beats zero-shot on classification, extraction, and transformation tasks.

3. Chain-of-Thought (CoT)

Ask the model to "think step by step" — huge boost on reasoning tasks.

Q: A shop sold 12 apples in the morning and 8 in the afternoon, starting with 20. How many are left?

A: Let me reason step by step:
1. Starting count: 20 apples
2. Morning sales: 20 - 12 = 8 remaining
3. Afternoon sales: 8 - 8 = 0 remaining
Answer: 0.

Trick: append "Let's think step by step" or its Chinese equivalent.

4. ReAct

Alternate thinking and action steps; pairs naturally with tool calling — the foundation of agents.

Q: What's the weather in Beijing today?

Thought 1: I need the current Beijing weather.
Action 1: Search["Beijing weather"]
Observation 1: Sunny today, high 25°C.
Thought 2: I have what I need, ready to answer.
Action 2: Finish["Sunny, high 25°C."]

5. Self-Consistency

Sample multiple completions and take the majority answer. Costs more, but accuracy bumps noticeably.

Best for classification / extraction / multiple-choice decisions.

6. Reflexion

Have the model critique and revise its own output.

Step 1: generate answer
Step 2: review (find errors)
Step 3: regenerate based on review
Step 4: stop when satisfied (max 3 rounds)

7. Skeleton-of-Thought

Emit the skeleton (outline) first, then expand each branch in parallel. 2-3× faster than traditional generation.

8. Structured Output (JSON Schema)

Constrain output to a JSON Schema that downstream code can parse.

Output must match this JSON Schema:

{
  "type": "object",
  "properties": {
    "summary":  { "type": "string" },
    "keywords": { "type": "array", "items": { "type": "string" } },
    "sentiment": { "enum": ["positive", "neutral", "negative"] }
  },
  "required": ["summary", "keywords", "sentiment"]
}

response_format=json_schema is currently the most reliable option on OpenAI.

In Practice: Combine Them

Real production prompts often stack:

# Role + Few-shot + CoT + Structured Output
You are a senior code reviewer (role).

# Examples (Few-shot):
code: [...] → feedback: ...
code: [...] → feedback: ...

# Task:
Review step by step (CoT):
[code]

# Format (Structured):
{ "issues": [...], "suggestions": [...], "score": 1-10 }

Cheat Sheet

  • Translation / summarisation → role + few-shot
  • Math / reasoning → CoT
  • Agent / tool calling → ReAct
  • Classification / decision → Self-Consistency
  • Code generation → Reflexion
  • Long-form generation → Skeleton-of-Thought
  • API output → Structured Output

Key points

  • Role prompting — give the model an explicit persona and its output style shifts immediately.
  • Few-shot — supply 2-5 examples and the model will imitate the pattern.
  • Chain-of-Thought (CoT) — ask the model to 'think step by step' for a big boost on reasoning tasks.
  • ReAct — alternate thinking and action steps, the foundation of tool-using agents.
  • Self-consistency — sample multiple times and take the majority answer.
  • Reflexion — let the model critique its own output and revise.
  • Skeleton-of-Thought — emit the skeleton first, then expand each branch in parallel.
  • Structured Output — constrain outputs to a JSON Schema so downstream code can parse them safely.

Frequently asked questions

Yes. Even as models get stronger, structured prompts make outputs more stable and controllable — especially in production.

Official references

Subscribe to GPTMap Weekly

One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.

GPTMap EditorialPublished 2026-07-12 3 min read
Test environment (EEAT)
Last tested: 2026-07-12
Model used: gpt-5.6