Claude Prompt Engineering
Claude by Anthropic responds best to well-structured prompts that use XML tags, clear section boundaries, and explicit instructions. Learning Claude-specific prompt engineering techniques helps you get more accurate, detailed, and reliable output.
Explore our Claude-focused resources including CLAUDE.md configuration templates, XML-structured prompt patterns, and model-specific tips. Use the Prompt Score tool to check whether your prompts follow Claude best practices before you send them.
Claude Prompt Engineering Techniques
Production-ready prompts using XML structure, chain-of-thought, role assignment, and other Claude-optimized patterns.
Claude XML-Structured Analysis
<task> Analyze {{topic}} and provide a comprehensive assessment. </task> <context> Domain: {{domain}} Audience: {{audience}} Depth: detailed, with actionable recommendations </context> <instructions> 1. Start with a one-paragraph executive summary 2. Break the analysis into 3-5 key dimensions 3. For each dimension, provide: - Current state assessment - Key evidence or data points - Specific recommendations 4. End with a prioritized action plan (top 3 next steps) </instructions> <constraints> - Use concrete examples, not abstract generalizations - When uncertain, state your confidence level explicitly - Keep total response under 1000 words - Use markdown headers for structure </constraints> <output_format> ## Executive Summary [one paragraph] ## Analysis ### [Dimension 1] ... ## Action Plan 1. ... 2. ... 3. ... </output_format>
Why it works: Claude excels with XML-tagged sections because it can parse each section as a distinct instruction. Separating task, context, constraints, and format prevents Claude from conflating them.
Claude Chain-of-Thought Reasoner
I need you to solve this problem using explicit step-by-step reasoning.
<problem>
{{problem_statement}}
</problem>
<approach>
Think through this step by step:
1. First, identify what type of problem this is and what information you have
2. State any assumptions you need to make
3. Work through the solution, showing each reasoning step
4. Check your work by verifying the solution against the original problem
5. If you find an error, correct it before giving the final answer
</approach>
<thinking_guidelines>
- Show your work in a <thinking> block before your final answer
- If multiple approaches exist, briefly note why you chose yours
- Flag any steps where you are less than 90% confident
- Distinguish between facts you know and inferences you are making
</thinking_guidelines>
<output>
Provide your final answer after the reasoning, clearly separated. Format: a direct answer first, then supporting explanation.
</output>Why it works: Claude responds well to explicit thinking instructions. Asking it to verify its own work and flag low-confidence steps catches errors that one-shot prompts miss.
Claude Role-Based Expert
<role> You are a {{expert_role}} with {{years_experience}} years of experience specializing in {{specialty}}. </role> <context> I am a {{user_role}} working on {{project_description}}. </context> <task> {{specific_question}} </task> <instructions> Respond as the expert described above would: - Draw on deep domain knowledge, not surface-level advice - Reference specific methodologies, frameworks, or tools a real expert would use - Distinguish between established best practices and your professional opinion - If the question touches areas outside your expertise, say so explicitly rather than guessing - Provide the level of detail you would give a colleague, not a textbook definition </instructions> <format> Start with your direct recommendation, then explain the reasoning. Use bullet points for actionable steps. End with one thing I should watch out for that most people overlook. </format>
Why it works: Claude follows role assignments deeply when the role is specific and the instructions reinforce domain-expert behavior. The "say so explicitly" constraint prevents hallucinated expertise.
Claude Multi-Document Synthesizer
<task> Synthesize the following {{document_count}} sources into a unified analysis. </task> <sources> <source id="1" type="{{source_1_type}}"> {{source_1_content}} </source> <source id="2" type="{{source_2_type}}"> {{source_2_content}} </source> <source id="3" type="{{source_3_type}}"> {{source_3_content}} </source> </sources> <synthesis_instructions> 1. Identify the key claims or findings from each source 2. Map where sources agree, disagree, or cover different aspects 3. Note the credibility and potential bias of each source 4. Synthesize into a unified view that accounts for all perspectives 5. Flag any contradictions you cannot resolve — do not silently pick a side </synthesis_instructions> <output_format> ## Key Findings (agreed across sources) ## Points of Disagreement ## Synthesis ## Confidence Assessment ## Gaps (what none of the sources address) </output_format>
Why it works: Claude handles long context well. Using numbered source IDs lets it cite specific documents, and the explicit disagreement section prevents it from smoothing over conflicts.
Claude Iterative Refinement
<task> Improve this {{content_type}} through iterative refinement. </task> <original> {{original_content}} </original> <refinement_criteria> Optimize for: {{optimization_goals}} Audience: {{target_audience}} Tone: {{desired_tone}} </refinement_criteria> <process> Please perform 3 rounds of refinement: Round 1 — Structural: Fix organization, flow, and logical gaps. Show the revised version. Round 2 — Precision: Tighten language, remove filler, strengthen weak claims. Show the revised version. Round 3 — Polish: Optimize word choice, rhythm, and impact for the target audience. Show the final version. After each round, note in one sentence what you changed and why. </process> <constraints> - Each round should build on the previous — do not restart from scratch - Preserve the original voice and intent - If something in the original is already strong, leave it alone - The final version should be noticeably better, not just different </constraints>
Why it works: Explicit multi-round refinement leverages Claude's ability to self-critique. Separating structural, precision, and polish passes prevents conflating different types of improvement.
Claude Guardrailed Code Generator
<task> Write {{language}} code for: {{code_task}} </task> <context> Framework: {{framework}} Existing patterns in my codebase: {{existing_patterns}} </context> <requirements> {{requirements}} </requirements> <guardrails> - Follow the existing patterns described above — do not introduce new patterns - Use TypeScript strict mode conventions (no any types, explicit return types) - Handle all error cases — never let an error silently pass - Add JSDoc comments for public functions only - Keep functions under 30 lines; extract helpers if longer - Do not install new dependencies unless absolutely necessary — if you must, explain why </guardrails> <output_format> 1. The code, ready to paste into my project 2. A brief explanation of design decisions (3-5 bullet points) 3. Edge cases the code handles 4. Edge cases the code does NOT handle (and why) 5. Any assumptions made about the codebase </output_format>
Why it works: Guardrails prevent Claude from generating technically correct but stylistically inconsistent code. Requiring it to list unhandled edge cases builds trust and catches oversights.
Recommended tools & resources
Claude-specific prompting techniques and best practices.
AI Configs — CLAUDE.mdProduction-ready CLAUDE.md templates for your projects.
Prompt PatternsXML-structured patterns that Claude handles best.
Prompt BuilderGenerate Claude-optimized prompts step by step.
Prompt TemplatesCopy-ready templates tested with Claude models.
Prompt ScoreCheck if your prompt follows Claude best practices.