Claude Prompt Engineering: The Complete Playbook
Master Claude prompts with tags, examples, CoT, and chaining. Copy our templates and checklist to get fast, reliable outputs every time.

Quick answer: the Claude prompting playbook
Do these eight things and your Claude results will jump fast:
- Be direct: state the job, the goal, and the success check.
- Use XML-style tags to mark parts: instructions, data, examples, and output.
- Show 3–5 short examples (few-shot) to teach format and tone.
- Let Claude think step by step, then give the final answer in a clean tag.
- Break big tasks into smaller prompts (prompt chaining) when steps are easy to check.
- For long inputs, put data first and key instructions at the end.
- Match the style you want; Claude mirrors your format.
- Use Anthropic tools like the Prompt Improver to upgrade rough prompts.
Grab the checklist: Download the free Claude Prompting Checklist and templates via Claude 4 best practices and the Prompt Improver guide.
Why Claude needs its own approach
Claude has quirks. It pays close attention to XML-like tags and prompt structure. Clear tags help it follow your plan and format. This is shown in AWS write-up and Anthropic best practices. A tool can also help. A Claude prompt generator or the official Prompt Improver can turn a vague idea into a strong prompt that avoids safety triggers and fits each model.
The framework: 5 steps to great Claude prompts
1) Frame the task
- Role: who Claude should be.
- Goal: one job to be done.
- Success: short acceptance test (format, checks).
<role>You are a precise data extractor.</role>
<task>Return JSON with fields: name, price_usd, url.</task>
<success>Valid JSON, exact keys, no extra text.</success>
2) Structure with XML tags
Claude is tuned to notice tags. Use them to split instructions, context, and output. See AWS guide and Anthropic best practices.
<instructions>Read the product list. Return a JSON array of matched items under $50.</instructions>
<data>
Acme Mug - $19 - https://shop.example/mug
Steel Bottle - $59 - https://shop.example/bottle
</data>
<output_format>[{{"name":"string","price_usd":number,"url":"string"}}]</output_format>
<answer>JSON only.</answer>
3) Add examples (few-shot)
Examples teach structure and tone fast. Anthropic recommends multishot prompting; see Use examples to guide Claude.
<examples>
<input>Acme Mug - $19 - https://shop.example/mug</input>
<output>{{"name":"Acme Mug","price_usd":19,"url":"https://shop.example/mug"}}</output>
</examples>
4) Let Claude think (then answer)
Ask Claude to think step by step, then give the final output. You can hide the thinking by keeping it inside tags and only reading the answer tag. See AWS CoT tip and Vellum step-by-step format.
<thinking>Think step by step. Check prices. Filter <= 50. Map to JSON.</thinking>
<answer>Provide only the final JSON.</answer>
5) Lock the format
- Repeat the output format at the end (Claude favors the end on long prompts).
- Match your desired style in the prompt. See formatting steerability and the end-weighting tip from Vellum.
<final_format>Output: JSON array only. No notes.</final_format>
When to chain vs. one prompt
| Use prompt chaining when | Use one prompt when |
|---|---|
| There are clear, checkable steps (parse, rank, write). | The task is simple and tightly scoped. |
| Quality varies by step and you need to debug one stage. | All rules fit on one page and are easy to follow. |
| You need to reuse a step across workflows. | Latency matters more than step control. |
Learn more in Walturn chaining guide and the AWS tutorial.
Templates you can copy
Drop these into your editor and swap the parts in <tags>.
1) JSON data extractor
<role>You extract structured data.</role>
<task>Return JSON with keys: company, product, price_usd.</task>
<data>
Acme Co - Trail Shoes - $129
Beta Inc - Socks - $12
</data>
<examples>
<input>Beta Inc - Socks - $12</input>
<output>{{"company":"Beta Inc","product":"Socks","price_usd":12}}</output>
</examples>
<thinking>Think step by step. Split lines. Parse price.</thinking>
<answer>[{{"company":"Beta Inc","product":"Socks","price_usd":12}},{{"company":"Acme Co","product":"Trail Shoes","price_usd":129}}]</answer>
2) Transcript editor
Start with data, end with instructions. See this tip in this guide.
<transcript>[paste raw text]</transcript>
<instructions>Light edit only. Keep voice. Remove filler words. Fix grammar.</instructions>
<output>Return the cleaned transcript text only.</output>
3) Research synthesis
<role>You are a careful researcher.</role>
<sources>[bullets or quotes]</sources>
<steps>1) List claims. 2) Note evidence. 3) Flag gaps. 4) Summarize in 5 bullets.</steps>
<format>{"bullets":["..."],"gaps":["..."],"sources":["..."]}</format>
<answer>JSON only.</answer>
4) Ticket triage (classification)
Anthropic shows how to structure classification with steps in the Prompt Improver docs.
<labels>["billing","bug","how_to","feature_request"]</labels>
<ticket>"The app crashes after login when I tap settings."</ticket>
<instructions>Pick one label. Give one-sentence reason.</instructions>
<format>{"label":"bug","reason":"..."}</format>
<answer>JSON only.</answer>
5) Code refactor with tests
<role>Senior engineer.</role>
<code>[paste function]</code>
<goals>Speed up by 20%+. Keep behavior. Add docstring.</goals>
<tests>List 3 edge cases and confirm behavior is unchanged.</tests>
<format>{"refactor":"...","rationale":"...","tests":["..."]}</format>
<answer>JSON only.</answer>
6) Marketing outline (tone + format)
<role>Content strategist.</role>
<topic>"Beginner's guide to VPNs"</topic>
<audience>Non-technical readers</audience>
<constraints>6th-grade reading level. Short sentences.</constraints>
<format>{"h2":["..."],"bullets":["..."],"cta":"..."}</format>
<answer>JSON only.</answer>
Long context and ordering tips
- Claude can read long context. Use it. See these tips.
- Put the important question at the end for long prompts, per Vellum.
- Try starting with data and ending with instructions to lift quality, as shared in this article.
Model-specific notes (Haiku, Sonnet, Opus)
- Haiku: fastest. Great for light transforms. Keep prompts short and explicit.
- Sonnet: balanced speed + quality. Good default for apps. Use examples to lock formats.
- Opus: strongest reasoning. Best for complex analysis. Give it room to think.
Tool use may differ by model. Per Anthropic, Opus thinks before tool calls; Sonnet/Haiku may call tools more eagerly. If tools are enabled, ask Sonnet/Haiku to assess first. See Tool use with Claude.
Use Anthropic Prompt Improver (step-by-step)
- Open the Prompt Improver in the console. See the announcement here.
- Paste your rough prompt (even if it was for another model).
- Set ideal outputs and examples to steer format.
- Review the rewrite: it clarifies structure, fixes grammar, and can add prefill to guide Claude's first tokens.
- Test and compare. Keep the best version.
“The prompt improver… enabled us to get to production faster.” — Kapa.ai, via Anthropic note here.
Curious about auto-generated prompts? See how a Claude prompt generator crafts model-aware prompts for Haiku, Sonnet, or Opus.
Testing and evaluation
- Define success: exact format, accuracy checks, latency budget.
- Create test cases: normal, edge, and adversarial.
- Evaluate: compare versions and track failures. Anthropic docs outline testing under Test & evaluate.
- Harden guardrails: be explicit about what to refuse and how to respond.
FAQ
How many examples should I include?
Start with 3–5 short, diverse examples. Add more if the task is tricky. See multishot prompting.
Do XML tag names matter?
No special names needed. Any clear tags work. Just be consistent. See AWS tip.
Where should I put the most important instruction?
At the end of a long prompt. Claude weights the end more, per Vellum.
How do I force plain text or JSON?
Match the style in your prompt and repeat the format tag at the end. See formatting tips.
Should I include chain-of-thought steps in the output?
Usually no. Ask Claude to think in a <thinking> tag and place the clean result in <answer>. You can then ignore the thinking.
Mini-checklist (tape this above your monitor)
- One job per prompt. State success criteria.
- Use tags: <role>, <task>, <data>, <examples>, <answer>.
- 3–5 examples. Keep them short.
- “Think step by step,” then “final answer” in one tag.
- Repeat output format at the end.
- For long inputs: data first, key instruction last.
- Chaining for multi-step work. One prompt for simple tasks.
- Test, measure, iterate. Try the Prompt Improver.
Bonus: tips from Anthropic and the community
- Describe the task clearly, use tags, give examples, use long context, and add thinking tags—see this roundup.
- Match your prompt style to the output you want; avoid markdown if you want plain text—see best practices.
- Move prompts from other models using the Prompt Improver.
You now have a full playbook: a framework, a checklist, and copy-paste templates. Start small. Ship one win. Then scale with chaining and testing.


