Skip to Main Content

Model Guide • 12 min read

How to Prompt Claude: The Complete Guide

Quick Answer

To prompt Claude effectively, use XML tags to isolate instructions (<role>, <task>, <constraints>), write rich persona definitions in the system prompt, prefill the assistant response to enforce output format, and leverage Claude's 200K token context for multi-turn refinement. Claude's XML parsing is its biggest differentiator — treat XML tags as structural instructions, not just formatting.

200K
Token context window
XML
Preferred prompt format
5
Key techniques covered

Core Prompting Techniques

🏷️

XML Tag Isolation

Claude's Superpower

Claude is uniquely optimised for XML-delimited prompts. Wrapping each section in descriptive tags creates discrete instruction blocks that the model parses with exceptional accuracy.

Example
<role>
You are a senior security auditor specialising in web applications.
</role>

<context>
The client runs an e-commerce platform processing 50K transactions/day.
</context>

<task>
Review the following code for SQL injection vulnerabilities.
</task>

<output_format>
For each vulnerability: severity (Critical/High/Medium/Low), line number, description, and remediation code.
</output_format>

💡 Use semantic tag names (<context>, <task>, <constraints>) — Claude parses the tag name as a structural cue, not just a delimiter.

🎭

Deep Role Setting

High Impact

Claude responds exceptionally well to rich, detailed persona definitions. Go beyond "You are an expert" — specify years of experience, communication style, decision-making framework, and what the persona explicitly avoids.

Example
<role>
You are Dr. Sarah Chen, a principal ML engineer with 12 years of experience deploying production LLM systems at scale. You:
- Prioritise reliability over cleverness
- Always quantify recommendations (latency, cost, error rate)
- Refuse to recommend approaches you haven't seen succeed in production
- Communicate in concise technical prose, never marketing language
</role>

💡 Claude maintains persona consistency across very long conversations — invest in a detailed role definition upfront.

🔄

Multi-Turn Strategies

Advanced

Claude maintains context exceptionally well across turns (up to 200K tokens). Use this for progressive refinement: draft → critique → refine, or for complex workflows where each turn builds on the previous.

Example
Turn 1: "Analyse this codebase architecture and identify the top 5 risks."

Turn 2: "For risk #2 (the database bottleneck), propose 3 solutions ranked by implementation effort."

Turn 3: "Draft the migration plan for Solution A, including rollback strategy."

💡 Claude's 200K context means you can paste entire codebases, long documents, or full conversation histories without chunking.

✍️

Prefilling Responses

Pro Technique

Start Claude's response for it by including the beginning of the assistant message. This steers output format, prevents preamble, and enforces structure from the first token.

Example
User: Extract entities from this text and return JSON.

Assistant (prefill): {"entities": [

💡 Prefilling is Claude's most underused feature. Use it to enforce JSON output, skip "Sure, I'd be happy to help" preamble, or start a specific section.

🧠

Thinking & Reasoning

Claude 3.5+

Claude supports extended thinking where it reasons step-by-step in a dedicated thinking block before producing the final answer. This dramatically improves accuracy on complex reasoning tasks.

Example
<instructions>
Solve this problem. Think through it carefully before answering.
</instructions>

<problem>
A company has 3 pricing tiers. Enterprise customers get 30% volume discount on the base price of £500/seat. If they commit to 3 years, they get an additional 15% loyalty discount applied after the volume discount. What does a 200-seat, 3-year enterprise deal cost per year?
</problem>

💡 For complex reasoning, explicitly ask Claude to "think step by step" or use the extended thinking API parameter.

What NOT To Do

Being vague about output format
Wrap format spec in <output_format> tags with exact schema
Using markdown headers for structure
Use XML tags — Claude parses them as instruction blocks, not decoration
Overly short system prompts
Claude benefits from detailed system prompts — invest in role depth
Ignoring prefilling
Start Claude's response to enforce format and skip preamble
Treating it like GPT
Claude has different strengths — use XML tags, longer context, richer roles

When to Choose Claude

Long-form analysis & writing
200K context, exceptional coherence at length
Complex multi-constraint tasks
XML isolation prevents instruction blending
Code review & explanation
Strong reasoning, detailed annotations
Safety-critical applications
Constitutional AI reduces harmful outputs
Document processing
PDF handling, large text summarisation
Multi-turn refinement
Maintains context across extended sessions

📌 Key Takeaways

Frequently Asked Questions

What is the best prompt format for Claude?

XML tags. Claude is uniquely optimised for XML-delimited prompts — wrapping sections in tags like <instructions>, <context>, <examples>, and <constraints> dramatically improves instruction following, output structure, and consistency. This is Claude's single biggest differentiator from GPT and Gemini. Combine XML tags with clear role assignments and explicit output format specifications for optimal results.

How do system prompts work in Claude?

Claude treats system prompts as the highest-priority instruction layer. Use the system prompt for: persona definition, output format rules, safety boundaries, and persistent context. Claude respects system prompt authority more strictly than most models — instructions placed here override conflicting user-level requests. Keep system prompts focused: one clear role, 3-5 behavioural rules, explicit output format.

Why is Claude better at following complex instructions?

Two reasons: (1) XML tag isolation — Claude parses XML-delimited sections as discrete instruction blocks, reducing instruction blending and interference. (2) Constitutional AI training — Claude is trained to follow multi-layered instruction hierarchies faithfully, making it exceptionally reliable for complex, multi-constraint prompts where other models drift or hallucinate.

When should I choose Claude over GPT or Gemini?

Choose Claude for: long-form analysis and writing (200K context, excellent coherence), complex multi-constraint tasks (superior instruction following), code review and explanation (strong reasoning), safety-critical applications (constitutional AI reduces harmful outputs), and document processing (PDF and large text handling). For tool calling and function-heavy workflows, GPT may be stronger. For multimodal (images/video/audio) tasks, Gemini excels.

Generate Claude-Optimised Prompts

AI Prompt Architect builds prompts with XML tags, rich personas, and Claude-specific formatting — automatically.

Prompt Claude Better →

Claude Prompting: The Evidence

Every claim below is sourced from peer-reviewed research and industry reports.Browse all 141 citations →

Few-shot extraction minimizes context window usage vs zero-shot verbose.

3 well-crafted few-shot examples (150 tokens) outperform a 600-token verbose instruction block, saving 75% on input costs per request.

Without concise few-shot examples, developers write lengthy prose instructions that consume 4x more tokens for equivalent or inferior output quality.

Brown et al., 'Language Models are Few-Shot Learners', NeurIPS 2020

JSON Schema enforcement eliminates parse errors.

OpenAI structured outputs with JSON Schema achieve 99.9% schema adherence vs <70% with unconstrained generation — a 30x reduction in parse failures.

Without schema enforcement, every 1M requests generate 300K+ malformed responses requiring retries, error handling, and downstream data corruption.

OpenAI, 'Structured Outputs: JSON Schema' documentation, 2024

Chain-of-thought prompting improves complex reasoning accuracy.

Adding 'Let's think step by step' improves accuracy on GSM8K math benchmarks from 17.7% to 78.7% — a 4.4x improvement on multi-step reasoning tasks.

Without chain-of-thought, models attempt to produce answers in a single leap, failing on problems requiring intermediate steps.

Wei et al., 'Chain-of-Thought Prompting Elicits Reasoning in Large Language Models', Google Research, 2022

AI chatbots with structured prompts resolve 45% of L1 support tickets without human intervention, saving an estimated $1.Intercom, 'Fin AI Agent' product documentation, 20…