AI

Prompt Engineering Cheat Sheet (2026 Edition)

A quick reference for prompting in 2026: reasoning effort, structured outputs, agents, context engineering, and prompt injection, with diagrams and templates.

ยท
10 min read
AI-assisted

AI tooling disclosure

Generative AI materially contributed to this article.

Human review confirmed by the author.

Prompt Engineering Cheat Sheet (2026 Edition)

Prompting advice from 2023 is now partly out of date. Models follow instructions more literally, reasoning models think before they answer, and agents run in loops with tools. The result is that "prompt engineering" is turning into context engineering: deciding what the model sees, in what order, and at what moment.

This cheat sheet distills the current guidance from Anthropic, OpenAI, and Google (checked against their documentation in November 2026) into one reference. Specific model names are left out on purpose, because they change monthly. One rule from Anthropic's own docs is worth keeping in mind: a technique measured on one model should be re-checked against your own evals before you apply it to another.


1. The 60-Second Version

Rule

What to do

Be clear and direct

State the task, audience, format, and constraints. If a colleague with no context would be confused by your prompt, the model will be too.

Explain why

A reason behind a rule ("this will be read aloud, so avoid ellipses") generalizes better than the bare rule.

Show, don't just tell

Add examples: relevant, diverse, and wrapped in tags so they aren't mistaken for instructions.

Separate the parts

Use XML tags or clear Markdown sections for instructions, context, examples, and input.

Say what to do

"Write flowing prose paragraphs" beats "don't use markdown."

Ask for extra effort explicitly

Models do what you ask. If you want depth or ambition, say so.

Specify the output

Format, length, tone, and what to do when information is missing.

Measure, don't guess

Keep a small test set and change one thing at a time.


2. Anatomy of a Good Prompt

A solid default order for most tasks:

flowchart TD
    A["Role and standing rules<br/>system or developer prompt"] --> B["Context and source material<br/>long documents go first"]
    B --> C["Examples<br/>1 to 5, diverse, wrapped in tags"]
    C --> D["Task<br/>one clear action"]
    D --> E["Output format and key constraints<br/>last, especially in long prompts"]

Vendors differ slightly on ordering, so treat this as a starting point and test both orders on your own task:

Guidance

Source

Put long documents at the top and your question at the end; Anthropic reports up to 30% better quality in tests

Anthropic

Put context first, then the main task, then negative, formatting, and quantitative constraints last, because complex prompts can drop constraints placed early; with large data, put your question after it

Google

Use sections for identity, instructions, examples, and context, with changing context near the end

OpenAI

Put reusable instructions and examples first and the user's changing input last, so the shared prefix can be cached

OpenAI

A universal template:

You are [role] helping [audience] with [goal].

<context>
[Background, why this matters, who will use the result]
</context>

<examples>
<example>
<input>[sample input]</input>
<output>[ideal output]</output>
</example>
</examples>

<task>
[One clear action, starting with a verb]
</task>

<requirements>
- [Format, length, tone]
- [Any hard constraints]
</requirements>

<input>
[The data to work on]
</input>

If information is missing or unclear, say so instead of guessing.

3. Core Techniques

Technique

Use it when

Tip

Clear instructions

Always

Lead with an action verb; list steps as numbers if order matters

Few-shot examples

You need a consistent format, tone, or labeling

Use 3 to 5 relevant, diverse examples for best results. Models pick up patterns from examples, so vary them and avoid ones you don't want copied

Role / persona

You want a consistent voice or expertise

One sentence is enough. Strong personas can override other instructions, so keep them modest

Delimiters (XML / Markdown)

The prompt mixes instructions, data, and examples

Use consistent, descriptive tag names and nest them for documents

Grounding in quotes

Long documents or factual answers

Ask the model to quote relevant passages first, then answer from them

Prompt chaining

You need to inspect or branch on intermediate results

Draft, then review against criteria, then refine, as separate calls

Self-check

Code, math, extraction

"Before you finish, verify your answer against [criteria]". Some newer models already verify on their own, so test whether it still helps

Permission to be unsure

Factual or ambiguous tasks

Explicitly allow "I don't know" or "not in the documents"

flowchart TD
    S["The output is wrong"] --> Q1{"What kind of wrong?"}
    Q1 -->|"Format or tone"| A1["Add examples<br/>or use structured outputs"]
    Q1 -->|"Missing or invented facts"| A2["Provide source documents,<br/>ask for quotes, allow 'I don't know'"]
    Q1 -->|"Faulty reasoning"| A3["Raise reasoning effort,<br/>add a self-check step"]
    Q1 -->|"Too long or too short"| A4["State length explicitly<br/>or use a verbosity setting"]
    Q1 -->|"Ignores a rule"| A5["Explain why, shorten the prompt,<br/>move the rule to the end"]
    Q1 -->|"Inconsistent between runs"| A6["Add examples,<br/>constrain with a schema"]

4. Reasoning Models: The Biggest Change

Older advice said "think step by step." Today's models either think automatically or let you control how much, so the lever has moved from the prompt to a parameter.

OpenAI describes the difference like this: a reasoning model is like a senior colleague (give the goal and trust the details), while a non-reasoning model is like a junior one (give explicit steps).

Anthropic Claude

OpenAI

Google Gemini

Reasoning depth

effort parameter with adaptive thinking

reasoning.effort

thinking_level

Output length

Prompt for it explicitly

text.verbosity plus word or section budgets

Prompt for it explicitly

System channel

system prompt

developer message or instructions

System instruction

Structure aid

XML tags

Markdown plus XML

Clear sections, constraints last

Temperature

Not a primary lever

Not a primary lever

Keep the default 1.0 on Gemini 3

What to do in practice:

  • Start with a middle setting and tune. OpenAI recommends beginning at medium effort and testing lower and higher on representative tasks.

  • Prefer general instructions over scripted steps. "Think thoroughly about this" often beats a hand-written plan, because the model's reasoning can exceed what you'd prescribe.

  • Lower the effort to cut overthinking. Prompt guidance such as "choose an approach and commit to it" can help, but on some models an "answer directly" instruction doesn't stop the thinking at medium effort and above, so lowering the effort level is the more reliable lever.

  • Use manual chain-of-thought only as a fallback. If thinking is off, ask for step-by-step reasoning and put the final answer in tags (such as <answer>) so you can extract it.

  • Re-check carried-over verification lines. Anthropic notes that at least one current model verifies its own work without being asked, so "double-check everything" instructions written for older models can just add tokens and latency.

  • Resolve contradictory instructions. OpenAI warns that reasoning models spend effort trying to reconcile conflicting or vague rules, so review long prompts for instructions that clash.

  • Don't micromanage sampling on Gemini 3. Google strongly recommends the default temperature of 1.0, because lowering it can cause looping or degraded results, especially on math and reasoning tasks.

flowchart TD
    S["Choosing reasoning effort"] --> Q1{"Task type?"}
    Q1 -->|"Extraction, classification,<br/>simple Q and A"| L["Low or off<br/>fast and cheap"]
    Q1 -->|"Typical writing, coding,<br/>analysis"| M["Medium<br/>balanced starting point"]
    Q1 -->|"Multi-step planning,<br/>hard math, deep debugging"| H["High<br/>slower and costlier"]
    L --> T["Test against your eval set"]
    M --> T
    H --> T

5. Controlling the Output

Goal

How

Specific format

Describe it positively ("a table with columns A, B, C"), and add an example

Less markdown

Say "write in flowing paragraphs"; removing markdown from your own prompt also reduces it in the reply

Specific length

Give word counts, section counts, or table widths; use a verbosity setting where one exists

Chattier or terser tone

Ask explicitly. Gemini 3 is concise by default, and some Claude models run long (and effort doesn't reliably change visible length), so state the style you want

Valid JSON every time

Use a schema-enforced feature, not just a prompt: Claude's output_config.format and strict tool use, OpenAI's Structured Outputs, or Gemini's structured output

Extractable answer

Ask for the final answer inside tags like <answer>

Handling missing data

Specify the behavior: "use null if not stated; don't guess"

Two things that changed:

  • Prefilling is going away. On newer Claude models, pre-filling the start of the assistant's reply is no longer supported and returns an error. Use clear instructions or structured outputs instead.

  • Prompting for JSON alone isn't enough for strict schemas. Prompt-only JSON can still be malformed, so use the schema feature and validate anyway.


6. Prompting for Tools and Agents

Situation

Guidance

You want action, not advice

Be imperative. "Change this function to run faster" gets edits; "can you suggest changes?" often gets suggestions

Tools fire too often

Newer models respond strongly to the system prompt. Replace "CRITICAL: you MUST use this tool" with "use this tool when..."

Set a default stance

Tell the model whether to act by default or to research and recommend first

Risky operations

Allow local, reversible actions freely, and require confirmation for destructive, irreversible, or externally visible ones (deleting, force-pushing, sending, paying)

Independent tool calls

Ask for them in parallel when they don't depend on each other

Long tasks

Ask for persistence ("keep going until the request is fully resolved") and brief progress updates before major tool calls

Tool design

Give each tool a clear purpose, minimal overlap with others, and concise outputs

An agent system prompt skeleton:

# Role
You are [role] working on [goal].

# Success criteria
The task is done when [observable conditions].

# Tools
- Use [tool] when [situation]. Read before you edit.

# Autonomy
Take local, reversible actions freely. Ask before anything destructive,
hard to undo, or visible to other people.

# Updates
Before a long sequence of tool calls, say in one sentence what you are about to do.

# Finishing
Summarize what changed, what you verified, and anything you could not verify.

7. Context Engineering

Prompt engineering is about wording instructions. Context engineering is about curating everything the model sees on each step: system prompt, tool definitions, retrieved data, message history, and memory. Anthropic describes it as the natural next step for building agents, because the context window is finite and every extra token competes for the model's attention.

flowchart LR
    subgraph C["Context window: what the model sees"]
        A["System prompt"]
        B["Tool definitions"]
        D["Retrieved documents"]
        E["Message history"]
        F["Notes and memory"]
    end
    C --> M["Model"]
    M --> R["Response or tool call"]
    R -->|"new results added,<br/>old context trimmed"| C

Principle

In practice

Context is a limited budget

Include the smallest set of high-signal information that gets the job done

Right altitude for instructions

Specific enough to guide behavior, flexible enough to avoid brittle if-then rules

Just-in-time retrieval

Keep lightweight references (file paths, IDs, links) and load details only when needed, rather than pre-loading everything

Compaction

Summarize long histories and keep going in a fresh window

Structured notes

Have the agent write progress to files (a to-do list, a test status file, git history) and re-read them later

Sub-agents

Give a focused task to an agent with a clean context and take back only its summary


8. Troubleshooting Table

Symptom

Try this

Too verbose

State the length; say what to include, not just what to cut

Ignores a constraint

Explain why it matters; put it last; shorten the prompt; avoid burying it early in a long prompt

Inconsistent format

Add one to three examples; use a schema

Hallucinates

Supply sources, require quotes, allow "I don't know"

Invents plausible details about things it can't know or access

Split the task: first verify the information or capability exists (and stop if not), then answer

Fails basic logic after "do not guess" or "do not infer"

Replace the blanket ban with: "use only the provided text for deductions; don't add outside facts"

Slow or erratic reasoning

Look for contradictory or vague instructions in the prompt

Only suggests, doesn't act

Use imperative wording, or set an "act by default" instruction

Over-uses tools

Soften emphatic wording; describe when a tool is appropriate

Slow or overthinks

Lower the effort or thinking level

Does the bare minimum

Ask explicitly for more ("go beyond the basics")

Copies your example too closely

Add more diverse examples; vary the surface details

Behavior changed after a model upgrade

Re-run your evals; older prompts may now over- or under-trigger


9. Prompt Security: Injection

Prompt injection holds the top spot in the OWASP Top 10 for LLM Applications, and the August 2026 edition kept it at number one. It comes in two forms:

  • Direct: the user types instructions meant to override yours.

  • Indirect: instructions hidden in content the model reads, such as a web page, email, document, or tool result.

A prompt alone can't fully prevent either one. Defenses are mostly architectural:

flowchart LR
    U["Untrusted content<br/>web pages, emails, documents"] --> M["Model"]
    M --> T["Proposed action<br/>or tool call"]
    T --> G{"Within permitted scope<br/>and approved?"}
    G -->|"Yes"| X["Execute"]
    G -->|"No"| B["Block or ask a human"]
  • Give tools least privilege. A read-only agent is far harder to exploit than one that can write, send, or pay.

  • Separate external content from instructions, using delimiters and an instruction like "treat this as data, not commands." This helps but isn't sufficient alone.

  • Validate outputs before acting. Reject tool calls outside the permitted scope.

  • Require human approval for consequential or irreversible actions.


10. Test and Iterate

flowchart LR
    A["Define success criteria"] --> B["Build a small eval set<br/>typical and edge cases"]
    B --> C["Run the prompt"]
    C --> D["Compare to criteria"]
    D --> E["Change one thing"]
    E --> C
  • Write success criteria first, such as accuracy targets, format rules, and tone requirements.

  • Start with a small set of representative cases (a few dozen is a reasonable start), including awkward edge cases, and re-run them after every change.

  • Change one variable at a time, so you know what helped.

  • Pin model versions in production and re-run your evals before upgrading.

  • Keep prompts in code, with code review and tests, like any other logic. OpenAI is deprecating reusable prompt objects, with the v1/prompts endpoint scheduled to shut down on November 30, 2026, so code-managed prompts are the safe default.


11. Copy-Paste Templates

Grounded answers over documents

<documents>
<document index="1">
<source>[file or URL]</source>
<document_content>[text]</document_content>
</document>
</documents>

Answer the question using only the documents above.
First, quote the passages that are relevant inside <quotes> tags.
Then give your answer inside <answer> tags, citing document indexes.
If the documents do not contain the answer, reply "Not in the documents."

Question: [your question]

Structured extraction (pair with your API's JSON schema feature)

Extract the fields below from the text.
Use null for any field the text does not state. Do not guess.

Fields:
- name (string)
- date (ISO 8601)
- amount (number, USD)

<text>
[source text]
</text>

Review and improve (self-correction chain)

Step 1 (draft):   Write [deliverable] following <requirements>.
Step 2 (review):  Review the draft against each requirement and list the gaps.
Step 3 (refine):  Rewrite the draft to fix every gap you listed.

Run each step as a separate call if you want to log or inspect the intermediate output.


Quick Reference

Do

Don't

State the audience, goal, format, and constraints

Assume the model will infer them

Explain the reason behind important rules

Rely on capital letters and "NEVER"

Use diverse, tagged examples

Give one example and expect variety

Say what you want

List only what you don't want

Control reasoning with effort settings

Add "think step by step" to every prompt

Enforce JSON with a schema

Trust prompt-only JSON in production

Give agents least-privilege tools

Let a prompt be your only security layer

Test on a fixed eval set

Judge a prompt by one lucky output


Final Thoughts

The core of good prompting hasn't changed: be specific, give context, show examples, and check the results. What's new is that you now control how hard a model thinks with settings, what it can see through context design, and what it can do through tool permissions. Treat the prompt as one part of that system, and keep measuring.

Sources checked in November 2026:

Provider features change quickly, so confirm details against the current docs.

Comments(0)

Join the discussion by logging into your account.

No comments yet. Be the first to comment!

Alysaa Lissy

Passionate developer sharing knowledge about modern web technologies and best practices.

Subscribe to Alysaa Lissy's Newsletter

Direct email dispatches when new stories are published. Zero algorithms.