Skip to main content

How to Write Prompts for Claude: 6 Core Principles from the Official Docs

Six practical prompting principles distilled from Anthropic's official documentation — clarity, context, examples, XML structure, roles, and long-context handling.

💬 1 copy-ready prompt in this article →

Good answers start with good prompts. What you ask Claude — and how — dramatically affects the quality of the result. This guide distills Anthropic's official prompt engineering documentation into six practical principles you can apply right away, even if you don't write code.

🟢 Model references match the current lineup · model notice · Fable subscription
🟢 Model references match the current lineup · Claude Opus 5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.

Fable 5 and 5.1 subscription (updated September 7, 2026): Claude Fable 5.1, released September 1, 2026, is the current Fable model and Fable 5 is now legacy. Plan terms are the same for both — Max and Team Premium plans include Fable at up to 50% of the weekly usage limit; Pro and Team Standard use usage credits (

🟢 Model references match the current lineup · Claude Opus 5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
0/M input, $50/M output tokens). The one-time
🟢 Model references match the current lineup · Claude Opus 5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
00 credit applied only to the Fable 5 transition and is not offered for 5.1. Some coding and debugging requests may be answered by an Opus model due to a security classifier (both models). See the Fable 5.1 guide and the Fable 5 availability guide for details.

6 prompting principles (official) 1 Be clear & direct 2 Add context 3 Use examples 4 XML tags 5 Give a role 6 Long context Source: Anthropic prompt engineering docs. Works across model versions.

Why prompting matters

Anthropic's docs compare Claude to "a brilliant but new employee who has zero context" on your project. However capable, it can't read your mind about goals, norms, or preferences. The clearer you are, the better it performs. The docs also note that prompt engineering is faster and cheaper than fine-tuning, keeps everything human-readable, and works across model updates without retraining.

Six core principles (official)

1. Be clear and direct

Claude responds well to explicit, specific instructions. State the desired output format and constraints, and use numbered lists when step order matters. The official golden rule: "Show your prompt to a colleague with minimal context and ask them to follow it. If they'd be confused, Claude will be too."

  • Less effective: "Create an analytics dashboard"
  • More effective: "Create an analytics dashboard. Include as many relevant features and interactions as possible. Go beyond the basics to create a fully-featured implementation."

2. Add context

Explaining the reason or motivation behind an instruction helps Claude understand your goal and respond more precisely.

  • Less effective: "NEVER use ellipses"
  • More effective: "Your response will be read aloud by a text-to-speech engine, so never use ellipses since it won't know how to pronounce them."

Claude generalizes from the explanation to handle similar cases.

3. Use examples

Examples are one of the most reliable ways to steer output format, tone, and structure. A few well-crafted examples (few-shot / multishot) sharply improve accuracy and consistency. The docs recommend examples that are:

  • Relevant: mirror your actual use case
  • Diverse: cover edge cases so Claude doesn't pick up unintended patterns
  • Structured: wrap them in <example> tags (multiple in <examples>)

The official suggestion is 3–5 examples. You can also ask Claude to evaluate or generate examples for you.

4. Structure with XML tags

When a prompt mixes instructions, context, examples, and inputs, wrapping each in its own tag (e.g. <instructions>, <context>, <input>) lets Claude parse it unambiguously.

  • Use consistent, descriptive tag names.
  • Nest tags when content has a natural hierarchy (e.g. each <document> inside <documents>).

5. Give Claude a role

Setting a role in the system prompt focuses Claude's behavior and tone. Even one sentence helps — e.g. "You are a helpful coding assistant specializing in Python." It's set via the API system parameter, but stating a role up front in normal chat has a similar effect.

6. Long context

For large documents or data (20k+ tokens), the docs recommend:

  • Put longform data at the top, above your query and instructions. In tests, putting the query at the end improved response quality by up to 30% on complex multi-document inputs.
  • Structure documents with XML tags — wrap each in <document> with <document_content> and <source> subtags.
  • Ground responses in quotes — ask Claude to quote relevant passages first, which cuts through document noise.

Practical tips

  • Start small, iterate: Once a prompt works, trim redundant phrasing to make it shorter and cheaper without losing performance.
  • Ask for action explicitly: If you want changes made rather than suggested, say "Make these edits," not "Can you suggest changes?"
  • Use Console tools: The Claude Console offers a prompt generator, templates/variables, and a prompt improver.
Same ask, different result✗ Vague ask"Write something"Missing what/who/how —results vary wildly✓ Specific ask"Launch tweet, under280 chars, friendly tone,one key benefit + CTA"Includes audience, format, tone, limits

A copy-paste template

This combines the principles above (a role, XML structure, an example, and an explicit output format) into one block. Change only the bracketed parts and use it as is.

[Role] You are a data analyst who classifies customer feedback.
[Task] Sort the feedback below by category (UI / Performance / Feature request / Other),
       sentiment (Positive / Neutral / Negative), and priority (High / Medium / Low).
[Format] A table, one item per row.

<feedback>
{paste the items to classify here}
</feedback>

<example>
Input: The new dashboard loads far too slowly → Performance / Negative / High
</example>

For long documents, put the document near the top of the prompt and your question at the end, then add “quote the relevant parts first, then analyze” to improve accuracy.

Summary

Clarity, context, examples, XML structure, roles, and long-context handling — these six fundamentals hold up across model versions. Rather than writing the perfect prompt on the first try, apply these principles, test quickly, and refine.

Source: Anthropic official prompt engineering documentation (overview, prompting best practices).

To lock tone, format, and length instead of asking each time, pair this with Claude Styles.

💬 Prompts for this problem

Copy, paste into Claude, and swap the parenthesised bits for your own situation.

  • 이 프롬프트, 더 잘 먹히게 다듬어줘

    Use when: 쓰던 프롬프트를 개선하고 싶을 때

    쓰고 있는 프롬프트를 다듬어줘. 지금은 결과가 들쭉날쭉해.
    
    (여기에 지금 쓰는 프롬프트를 그대로 붙여넣어줘)
    
    고칠 때는 이렇게 해줘: 원하는 결과를 앞에 분명히 두고, 지켜야 할 규칙은 목록으로, 출력 형식은 마지막에 한 줄로. 예시가 필요한 자리에는 예시를 넣을 자리를 만들어줘.
    
    다듬은 프롬프트를 먼저 보여주고, 뭘 왜 바꿨는지 세 줄로 설명해줘.

All prompts →

Was this helpful?

Keep reading