Prompt Engineering Cheat Sheet
The prompt patterns that actually change LLM output — anatomy, few-shot, chain-of-thought, and structured formatting — with real examples, pitfalls, and a searchable quick reference.
Core Principles
Everything below is a variation on one idea: a model fills in whatever you leave ambiguous with its own best guess, not yours.
Be specific about the task, format, and constraints — not just the topic.A vague prompt gets a vague, average answer. Every gap you leave gets filled with the model's guess about what you probably meant — and that guess is rarely the specific thing you had in mind.
State the goal before you state the constraints.Put the actual task first, then list the rules for how to do it. The model locks onto what you're asking for before it has to start filtering how to phrase the answer.
Show, don't just describe.One concrete example of the input/output shape you want teaches the model far more precisely than a paragraph describing that shape in the abstract.
Iterate — treat the first draft of a prompt as a hypothesis.Your first attempt rarely nails a task completely. Read the output, find the specific way it went wrong, and edit the prompt to close that exact gap — don't rewrite from scratch every time.
Prompt Anatomy
The parts that go into a well-formed prompt regardless of what the task is — leave one out and the model has to guess it.
Role: You are a senior {role}, and your job is to {responsibility}.Framing who the model is speaking as changes its vocabulary and what it treats as obvious versus worth explaining — a senior security engineer and a friendly tutor answer the same question very differently.
Task: Your task is to {single, specific action}.The one sentence that states exactly what output you want produced — phrased as an instruction, not a question.
Context: Here is the relevant background — {context}.Information the model needs but shouldn't have to guess at: prior conversation, source documents, real-world constraints that shape what a good answer even looks like.
Format: Respond using {format}, for example: {mini example}.Specify the output shape explicitly. Don't assume the model will default to whatever shape you were picturing — it hasn't seen your picture, only your words.
Constraints: Do not {thing to avoid}. Keep the response under {limit}.The boundary conditions: what's off-limits, how long, what tone. Boundaries left unstated get whatever the model's default happens to be, which varies task to task.
Zero, One & Few-Shot
How many examples to include, and why more isn't automatically better.
Zero-shot — just ask directly, no examples.For tasks the model has clearly seen many times (summarizing, translating, basic classification), zero-shot is often enough. Every example you add costs context budget and can bias output toward that example's specific style.
One-shot — give exactly one example of the input/output shape.Use when the format is unusual or ambiguous enough that a single example removes the guesswork, but the task itself is simple enough that a second example wouldn't teach anything new.
Few-shot — give 3-5 diverse examples covering the edge cases, not just the typical case.The highest-leverage technique for consistent formatting and tone. The examples teach whatever pattern is common to all of them — including patterns you didn't intend, like always using the same sentence length.
Chain-of-Thought & Reasoning
Asking a model to show its work isn't just for the reader's benefit — the reasoning becomes part of what the final answer is conditioned on.
Think step by step before giving your final answer.Explicitly asking the model to reason through a problem before answering measurably improves accuracy on multi-step logic, math, and analysis tasks.
Explain your reasoning, then give your answer in a clearly separate final section.Separating reasoning from the final answer — with a clear divider or tag — makes it easy to extract just the answer programmatically, without giving up the accuracy benefit of visible reasoning.
List the possible approaches before picking one.For genuinely ambiguous problems, asking the model to consider multiple approaches before committing surfaces options a single-shot answer would have skipped straight past.
Self-consistency: generate several independent attempts and take the majority answer.Run the same prompt more than once and compare. For problems with one correct answer, agreement across independent attempts is a strong signal of correctness — disagreement flags a genuinely hard case worth double-checking by hand.
Output Formatting & Structuring
'Respond in JSON' is an instruction. An explicit schema is a contract — only one of those two reliably survives contact with a real model.
Respond only in valid JSON matching this schema: {"summary": string, "tags": string[]}The single most reliable way to get structured, parseable output — pair it with an explicit schema or example. 'Respond in JSON' alone still leaves the shape ambiguous.
Use these exact section headers: ## Summary ## Details ## Next StepsNaming the literal headers you want gets far more consistent structure than describing the sections in prose.
Wrap the final answer in <answer></answer> tags.XML-style delimiter tags make it trivial to parse out just the part you need from a longer response — and it's a pattern Claude in particular was extensively trained to follow precisely.
If a field doesn't apply, output null — never omit the key.For anything you'll parse programmatically, explicitly defining the behavior for missing or inapplicable data prevents a parser from choking on an unexpectedly absent field.
System Prompts & Roles
System, user, and (where supported) a pre-filled assistant turn each carry different weight — mixing up what belongs where is a common source of a prompt that 'mostly' works.
System: You are {role}. Always {behavior}. Never {behavior}.System-level instructions set the persistent frame for the whole conversation and are generally treated as higher-priority than instructions embedded later in a user message. Put durable rules here, not one-off task details.
Keep the system prompt about behavior and identity, not one-off tasks.Mixing 'you are a helpful assistant' with 'today, summarize this specific document' in the same system prompt makes it harder to reuse across different requests. Task-specific detail belongs in the user message.
State what the assistant should do when it doesn't know the answer.Explicitly defining the fallback behavior — say you're not sure, versus give your best guess and flag the uncertainty — prevents confident-sounding hallucination on exactly the questions where a shrug would have been more honest.
Advanced Techniques
For once a single, well-written prompt has demonstrably stopped being enough.
Prompt chaining — break a complex task into a sequence of smaller prompts.Instead of one giant prompt trying to research, draft, and polish in a single pass, run three focused prompts in sequence. Each step is easier to verify, and easier to fix independently when something goes wrong.
Self-critique — ask the model to review and improve its own answer before finalizing.A second pass ('review the answer above for errors, then provide a corrected version') catches a meaningful fraction of mistakes the first pass made, because critiquing existing text is a different, often easier task than generating it from scratch.
Meta-prompting — ask the model to improve the prompt itself.When you're not sure why a prompt isn't working, asking 'how would you rewrite this prompt to get a more reliable answer?' often surfaces the exact ambiguity you missed.
Tree-of-thought — explore several reasoning branches, then evaluate which one to keep.For problems with no single obvious approach, having the model sketch 2-3 strategies and weigh their tradeoffs before picking one avoids committing early to the first idea it happened to think of.
Pitfalls & Anti-Patterns
The mistakes that quietly undo everything above.
Pair negative instructions with the positive version of what to do instead.Telling a model what NOT to do (don't be verbose) requires it to first model the thing you don't want in order to avoid it. Stating the positive target directly (answer in 2-3 sentences) is more reliable.
Contradictory constraints don't average out — they resolve unpredictably.Asking for a response that's both comprehensive and under 50 words forces the model to silently pick one requirement over the other, inconsistently. Resolve the tension yourself before the model has to.
Don't dump in every possibly-relevant document 'just in case.'More context isn't automatically better. Irrelevant material competes for the model's attention with the material you actually need it to use, and can measurably reduce accuracy on the parts that count.
Model-Specific Notes
Everything above transfers across models. These few things don't — worth knowing which is which.
XML-style tags are especially reliable structure with Claude specifically.Claude was extensively trained on XML-tagged structure, so wrapping distinct parts of a prompt in tags like <document>...</document> tends to produce more reliable adherence than the equivalent instruction written out in plain prose.
Markdown headers and numbered lists work reliably across most modern LLMs.If a prompt needs to work across different models or providers, plain markdown structure (##, numbered steps) is the safest common denominator — model-specific conventions don't transfer universally.
Check for a dedicated reasoning/thinking mode before manually asking for chain-of-thought.Some models expose an extended-reasoning mode that's more reliable and doesn't cost you visible output tokens the way manually requesting 'think step by step' does. Check the model or provider's docs first.
Quick Reference
Already know the techniques — just blanked on a name? Search instead of scrolling.
Be specificState the task, format, and constraints explicitly — not just the topic
Goal before constraintsPut what you want done before the rules for how to do it
Show, don't describeA concrete example beats a paragraph explaining the shape you want
IterateTreat the first prompt as a draft — edit based on exactly what went wrong
Role / PersonaFrames who the model is speaking as and what it treats as obvious
TaskThe one-sentence instruction stating the exact output wanted
ContextBackground the model needs but shouldn't have to guess
FormatThe explicit output shape, ideally with a mini example
ConstraintsBoundaries: length, tone, what's off-limits
Zero-shotAsk directly, no examples — fine for common, well-understood tasks
One-shotOne example, just to remove ambiguity about the output format
Few-shot3-5 diverse examples for consistent formatting and tone
Chain-of-thoughtAsk the model to reason step by step before answering
Separate reasoning from answerPut the final answer in its own clearly marked section
Self-consistencyCompare multiple independent attempts, trust the majority answer
Explicit schemaProvide the exact output shape, not just 'respond in JSON'
Named section headersSpecify literal headers instead of describing sections in prose
XML delimiter tagsWrap sections in tags for reliable, parseable structure
Define missing-data behaviorState what to output when a field doesn't apply
System promptPersistent rules and identity for the whole conversation
User messageThe actual task-specific request
Fallback behaviorDefine what to do when the model doesn't know the answer
Prompt chainingBreak a complex task into a sequence of smaller prompts
Self-critiqueAsk the model to review and correct its own answer
Meta-promptingAsk the model to improve the prompt itself
Tree-of-thoughtExplore multiple reasoning branches before picking one
Negative instructionsPair 'don't do X' with the positive version of what to do instead
Contradictory constraintsConflicting requirements resolve unpredictably, not by averaging
Context overloadIrrelevant material competes for attention with what actually matters
Prompt injectionUntrusted text can contain instructions — label it as data, not commands
XML tagsEspecially reliable structure for Claude specifically
Markdown structureThe safest common denominator across most LLMs
Native reasoning modeCheck for a dedicated thinking mode before manually asking for chain-of-thought
33 of 33 commands
Common Use Cases
Real situations, not just isolated techniques — the exact adjustment that fixes each one.
You need consistent JSON output every single time
Combine an explicit schema, one example, and a strict output-only instruction:
- Provide the exact schema, not just "respond in JSON"
- Add one worked example of the shape
- State: respond with JSON only, no other text
You want visible reasoning without shipping it to the end user
Ask for reasoning inside a section you strip out before displaying the answer:
- Request reasoning inside a clearly tagged section
- Parse the response and discard that section programmatically
- Show only the final answer to the user
Your results vary too much between runs on the same input
Narrow the range of acceptable answers instead of leaving it open-ended:
- Add 3-5 few-shot examples to anchor the format and tone
- Lower temperature if your API exposes it
- Make constraints explicit instead of implied
Summarizing a long document keeps missing the point
Split extraction from summarization instead of doing both in one pass:
- First prompt: extract the key points as a list
- Second prompt: summarize just those extracted points
You need the model to say 'I don't know' instead of guessing
Define the fallback explicitly — it won't happen on its own:
- State the fallback behavior in the system prompt
- Reward saying "not sure" over a confident guess
Your prompt has to work across GPT, Claude, and Gemini
Stick to the common denominator rather than one model's favorite convention:
- Use plain markdown structure (headers, numbered lists)
- Avoid model-specific conventions like XML tags
Debugging & Troubleshooting
The symptoms a badly-structured prompt actually produces, decoded.
The model ignores part of my instructionsInstructions buried in the middle of a long prompt get less weight than ones at the start or end. Move the most important rule to the very end of the prompt and restate it right before the actual request.
Output format keeps drifting from what I specifiedA description of the format is weaker than a concrete example of it. Add one worked example of the exact output shape you want — few-shot beats prose for format compliance.
The model refuses a legitimate, benign requestA vague or oddly-phrased version of a normal request can accidentally pattern-match something the model is trained to be cautious about. Add explicit context establishing legitimate intent, and be precise about exactly what you're asking for.
The response is padded with caveats and filler instead of the answerState explicitly that you want the direct answer only, with no preamble or disclaimers, and show one example of the terse style you're after.
The model confidently states something that's wrongA model under pressure to always sound confident will sound confident even when it's guessing. Ask it to cite where each claim comes from, or explicitly permit uncertainty — say so if you're not sure.
Few-shot examples aren't changing the output at allCheck that the examples actually vary along the dimension you're trying to teach. Five examples that are all subtly the same don't give the model anything new to generalize from.
Things to Remember
If you forget everything else on this page, keep these.
- A prompt is a spec — anything you leave ambiguous gets filled in with the model's best guess, not yours.
- Show a concrete example of the output you want; it teaches format and tone faster than describing them.
- Few-shot examples teach whatever pattern is common to all of them, including ones you didn't intend — vary them deliberately.
- Chain-of-thought helps genuinely multi-step problems and costs tokens on everything else — use it selectively.
- Positive instructions ('answer in 3 sentences') are more reliable than negative ones ('don't be verbose').
- Contradictory constraints don't average out — resolve the tension yourself before the model has to.
- Untrusted text inside a prompt can contain instructions of its own — label it as data, not commands.
- The first draft of a prompt is a hypothesis. Read the output, find exactly what went wrong, and edit that.
Common Use Cases
About Prompt Engineering Cheat Sheet
Prompt engineering gets treated as either mystical incantation ("add 'take a deep breath' for better results") or dismissed as "just typing clearly" — and most guides split the same way: a vague list of platitudes with no way to act on them, or a vendor-specific trick list with no explanation of why any of it works. Underneath both is a small number of concrete, testable techniques.
This one starts from what every prompt is built out of regardless of task — the principles and the anatomy: role, task, context, format, constraints. From there it moves into the core techniques that change output quality directly: zero/one/few-shot examples, chain-of-thought reasoning, and explicit output formatting. Then into how roles and system prompts frame an entire conversation, and the advanced composition techniques — prompt chaining, self-critique, meta-prompting — that come up once a single prompt stops being enough.
Every section calls out the mistakes that actually produce bad output: negative-only instructions that describe what to avoid instead of what to do, contradictory constraints that resolve unpredictably instead of averaging out, context windows overloaded with "just in case" material that dilutes what actually matters, and prompt injection — the very real risk the moment any untrusted text (a document, a webpage, a user message) becomes part of your prompt. There's a searchable quick reference for the moment you already know the technique's name, and a troubleshooting section built around the actual symptoms a bad prompt produces.
This page is deliberately model-agnostic — the techniques here transfer across GPT, Claude, Gemini, and open models. Where one model rewards a specific convention (like Claude's strong adherence to XML-style tags), it's called out explicitly rather than assumed universal. And like every tool on AllCoreKit, this is a static reference page: there's no model running here, no API call, no account. The quick-reference search filters entirely in your browser, and nothing you read or search for is ever sent anywhere or logged.
Frequently Asked Questions
Related Tools
View all Cheat SheetsGit Cheat Sheet
The Git commands developers actually use daily, organized by workflow — branching, rebasing, undoing mistakes, and recovery — with real examples and a searchable quick reference.
Regex Cheat Sheet
The regex syntax developers actually reach for — anchors, character classes, groups, and lookaround — with real patterns, common mistakes, and a searchable quick reference.
Linux Commands Cheat Sheet
The Linux commands developers actually use daily — navigation, permissions, piping, processes, and networking — with real examples, common mistakes, and a searchable quick reference.