← Back to Blog
["prompt engineering""Claude""Anthropic"]

"How to Write Prompts for Claude: Tips, Examples, and Best Practices"

7/2/2026

# How to Write Prompts for Claude: Tips, Examples, and Best Practices

Claude by Anthropic is a powerful large language model known for its strong reasoning capabilities, nuanced writing, and ability to handle long, complex documents. But writing prompts that get the best out of Claude requires understanding how it differs from other AI models. This guide covers everything you need to know about prompt engineering for Claude, with practical examples and best practices you can apply immediately.

## Why Claude Requires Different Prompts

Claude is trained differently from ChatGPT and other models. Anthropic uses a technique called Constitutional AI, which gives Claude strong capabilities in careful reasoning, safety, and following detailed instructions. Claude also has an exceptionally large context window — up to 200,000 tokens in its current versions — which makes it ideal for long-document analysis, multi-file code projects, and extended conversations.

These characteristics mean Claude thrives when you:

- **Provide detailed, structured instructions**: Claude follows multi-step directions well when they're clearly organized.
- **Use XML tags to structure prompts**: Claude is trained to recognize XML-formatted structure, making this a powerful technique for complex prompts.
-- **Give it the full context**: Thanks to the large context window, you can include entire documents, multiple files, or long conversation histories. Don't summarize unnecessarily — paste the full source material.
- **Specify the reasoning approach**: Claude responds well when you ask it to think step-by-step or to use a specific framework for analysis.
- **Use clear role definitions**: Claude performs better when you explicitly state who it is, who the audience is, and what the goal is.

## Core Prompting Principles for Claude

### Be Explicit and Detailed

Claude rewards specificity. Instead of "summarize this," write:

```
Summarize the following document in 3-5 bullet points.
Focus on the key arguments, not the examples.
Each point should be under 25 words and written for a
non-technical audience. Do not include introductory or
concluding sentences — just the bullet points.

Document:
[Insert document]
```

### Use XML Tags for Structure

Claude is trained to respond well to XML-formatted prompts. Use tags to separate instructions, context, and input data:

```xml
<instructions>
You are a financial analyst. Review the quarterly report
and identify three risks the company faces.
</instructions>

<context>
The company is a mid-sized SaaS business with 200 employees
and $15M ARR. Growth has slowed from 80% to 25% year-over-year.
</context>

<data>
[Insert quarterly report text here]
</data>

<output_format>
Return your analysis as a numbered list. For each risk:
1. Risk name (bold)
2. Severity (high/medium/low)
3. Evidence from the report (quote specific numbers)
4. Recommended mitigation (2-3 sentences)
</output_format>
```

This XML structure helps Claude understand exactly which parts are instructions, which are background, and what format the output should take.

### Assign a Clear Role

Claude takes role instructions seriously. Start with a precise role definition:

```
You are a senior UX researcher with 10 years of experience
in qualitative research, specializing in SaaS products.
Your writing style is concise and evidence-based. You always
support claims with data or user quotes.

Your task: [Describe the task]
```

### Specify the Output Format

Claude is excellent at following formatting instructions when they're explicit. Rather than hoping for the right format, describe it precisely:

```
Output format:
- Use a markdown table with columns: Feature, Benefit, Example
- Keep each table row to one line
- After the table, add a "Key Takeaway" section in 2 sentences
- Do not add any preamble or explanation before the table
```

## Writing Prompts for Different Tasks

### Content Writing with Claude

Claude is particularly strong at long-form content writing because it maintains coherence over long outputs better than many other models. Here's a prompt template for article writing:

```xml
<role>
You are an expert content writer who specializes in
[topic/industry]. Your writing is clear, engaging, and
well-structured. You avoid clichés and jargon.
</role>

<task>
Write a [length]-word article about [topic] for [audience].
</task>

<requirements>
- Use a conversational but informative tone
- Open with a specific, surprising fact or anecdote
- Use H2 and H3 headings for structure
- Include at least 2 practical examples
- End with a summary and a question for readers
- Do not use the words "delve," "tapestry," or "navigate"
</requirements>

<context>
Key points to cover:
1. [Point 1]
2. [Point 2]
3. [Point 3]
</context>
```

### Code Analysis and Generation

Claude's large context window makes it excellent for code analysis where you need to include multiple files. Here's a prompt template:

```xml
<instructions>
Analyze the following codebase for potential bugs.
Focus on:
1. Null/None handling errors
2. Race conditions in async code
3. SQL injection vulnerabilities
4. Unhandled exceptions
</instructions>

<files>
<file name="models.py">
[Insert file content]
</file>

<file name="handlers.py">
[Insert file content]
</file>

<file name="database.py">
[Insert file content]
</file>
</files>

<output_format>
For each issue found:
- File and line number
- Issue category (bug/security/performance)
- Severity (critical/high/medium/low)
- Description of the problem
- Suggested fix with code snippet
</output_format>
```

### Document Analysis and Q&A

Claude excels at answering questions about long documents. This is a common use case that leverages its large context window:

```xml
<instructions>
Answer questions about the following document.
For each answer:
1. Quote the relevant section of the document
2. Provide your answer based only on the document
3. If the document doesn't contain the answer, say so explicitly
4. Rate your confidence (high/medium/low)
</instructions>

<document>
[Insert full document — Claude can handle 200K+ tokens]
</document>

<question>
[Your question here]
</question>
```

### Data Extraction

Claude is excellent at extracting structured data from unstructured text:

```xml
<instructions>
Extract all company names, revenue figures, and dates
from the following text. Return as a markdown table with
columns: Company, Revenue, Date, Source Quote.
</instructions>

<text>
[Insert text with embedded financial information]
</text>

<rules>
- Only include explicitly stated revenue figures, not estimates
- Normalize date formats to YYYY-MM-DD
- Include the exact sentence where each data point appears
- If a data point is ambiguous, mark it with an asterisk
</rules>
```

## Advanced Techniques

### Chain-of-Thought Prompting

Claude is a strong reasoner. You can unlock better reasoning by explicitly asking Claude to think through a problem step by step:

```
Analyze this problem step by step before answering.
First, identify all the variables and constraints.
Second, consider each possible approach and its trade-offs.
Third, select the best approach and explain why.
Fourth, work through the solution using that approach.
Finally, state your answer clearly.

Problem:
[Insert problem that requires reasoning]
```

For especially complex problems, you can use a technique called "extended thinking" by asking Claude to think in a dedicated block:

```xml
<thinking>
Work through this problem before writing your final answer.
Consider multiple approaches and their trade-offs.
</thinking>

<answer>
Provide your final, polished answer here.
</answer>
```

### Multi-Turn Refinement

Claude handles multi-turn conversations well. Use a sequence of prompts to refine output:

**Turn 1**: "Draft a product description for [product]."

**Turn 2**: "Make it more concise — cut to 100 words. Add a sensory detail about how the product feels to use."

**Turn 3**: "Now write three variant headlines for this description, each targeting a different emotional appeal."

This iterative approach often produces better results than one massive prompt.

### Few-Shot Examples

Claude benefits from examples, just like other models. Provide 2-3 examples of the input-output pattern you want:

```xml
<instructions>
Classify the sentiment of each customer review.
</instructions>

<examples>
<example>
<review>"The product works well but shipping was slow."</review>
<classification>Mixed — Positive product feedback, negative delivery experience.</classification>
</example>

<example>
<review>"Absolutely love it! Exceeded expectations."</review>
<classification>Positive — Strong satisfaction, enthusiasm.</classification>
</example>
</examples>

<task>
<review>"[New review to classify]"</review>
<classification>[You fill this in]</classification>
</task>
```

## Comparing Claude and ChatGPT Prompting

While the core principles of prompt engineering apply to both Claude and ChatGPT, there are key differences:

| Aspect | Claude | ChatGPT |
|--------|--------|---------|
| Context window | Up to 200K tokens | Varies by model |
| Structure preference | XML tags | Plain text or markdown |
| Long-document handling | Excellent | Good |
| Tone | Thoughtful, nuanced | Conversational |
| Safety focus | High | High |
| Best for | Analysis, reasoning, long content | General tasks, creative work |

This isn't about one being better — it's about writing prompts that match the model's strengths. Use Claude's large context window to include full documents. Use XML tags to structure complex prompts. Ask for explicit reasoning when the task requires it.

## Best Practices Checklist

Before sending a prompt to Claude, check:

- [ ] **Clear role defined**: Does the prompt specify who Claude is?
- [ ] **Detailed instructions**: Are all requirements explicit, not implied?
- [ ] **Output format specified**: Does the prompt describe exactly how the output should look?
- [ ] **Context included**: Is all necessary background information provided?
- [ ] **Constraints stated**: Are length, tone, and content boundaries clear?
- [ ] **Examples included**: For complex patterns, are there 2-3 examples?
- [ ] **XML tags used**: For complex prompts, are sections clearly marked?
- [ ] **Reasoning requested**: For analytical tasks, is step-by-step thinking requested?

## Common Mistakes to Avoid

### Being Too Brief

A common mistake is assuming Claude will infer your intent. Instead of "make it better," write "improve the clarity by shortening sentences, using active voice, and removing adverbs."

### Not Using the Context Window

Many users summarize documents to fit other models. With Claude, paste the full document. The model is built for long context and performs better with complete information.

### Mixing Instructions and Data

When instructions and data are tangled together, Claude may get confused. Use XML tags to clearly separate what is instruction from what is input data.

### Forgetting to Say "Don't"

Claude is thorough — sometimes too thorough. If you don't want a preamble, say so: "Do not include introductory text. Start directly with the table." If you don't want certain words, list them to exclude.

## Tools to Help You Write Better Claude Prompts

Building and testing prompts by hand is time-consuming. Tools like [PromptWright](https://promptwright.net/signup) let you:

- **Save and organize prompts** with variables so you can reuse them
- **Test prompts side-by-side** to compare variations
- **Version prompts** so you can track which version performs best
- **Share prompt templates** with your team

This is especially valuable when you're working with Claude, where prompts tend to be longer and more structured. A prompt management tool turns one-off prompts into a reusable system.

## Conclusion

Writing great prompts for Claude comes down to three things: be explicit about what you want, use structure (especially XML tags) to organize your prompt, and leverage Claude's large context window by including complete information. Claude rewards detailed, well-organized prompts with precise, thoughtful output that takes full advantage of its reasoning capabilities.

Start with the templates in this guide, adapt them to your work, and pay attention to which patterns produce the best results. Prompt engineering for Claude is a skill that improves quickly with deliberate practice. To build, test, and manage your Claude prompts systematically, [try PromptWright free](https://promptwright.net/signup) and turn your prompt workflow into a repeatable system.

Enjoyed This Article?

Get more prompt engineering tips delivered weekly. Free, no spam.

Join 500+ prompt engineers. Unsubscribe anytime.

Ready to build better prompts?

Try PromptWright free — structured prompt editor with multi-model testing.

Get Started Free →