Last Updated: December 24, 2025
Core Prompting Principles
Be clear and direct
State exactly what you want Claude to do
Use XML tags for structure
Claude responds well to <tags> for organization
Provide examples
Show Claude the desired output format
Assign a role
Give Claude a persona or expertise level
Think step-by-step
Ask Claude to break down complex tasks
XML Tag Structure
<task>
Analyze the following code for security vulnerabilities
</task>
<code>
function login(username, password) {
const query = "SELECT * FROM users WHERE username='" + username + "'";
// ... SQL execution
}
</code>
<output_format>
- Vulnerability type
- Severity (Critical/High/Medium/Low)
- Explanation
- Recommendation
</output_format>
System Prompts
System Prompt Examples:
# Expert Developer
You are an expert software engineer with 15 years of experience in Python,
Go, and distributed systems. You provide clear, production-ready code with
comprehensive error handling and documentation.
# Technical Writer
You are a technical documentation expert who writes clear, concise documentation
for developers. You use examples, code snippets, and diagrams when appropriate.
Always structure content with headings, bullet points, and tables.
# Data Analyst
You are a senior data analyst who specializes in SQL, Python, and data
visualization. You provide well-reasoned insights backed by data, explain
your analytical approach, and suggest actionable recommendations.
Few-Shot Learning
I need you to extract structured data from customer feedback.
<examples>
<example>
Input: "The product is great but shipping took forever"
Output: {
"sentiment": "mixed",
"product_feedback": "positive",
"shipping_feedback": "negative",
"topics": ["product_quality", "shipping_speed"]
}
</example>
<example>
Input: "Excellent customer service, very helpful team"
Output: {
"sentiment": "positive",
"product_feedback": null,
"shipping_feedback": null,
"topics": ["customer_service"]
}
</example>
</examples>
Now extract data from this feedback:
<feedback>
"Product broke after 2 days, but refund was quick"
</feedback>
Chain-of-Thought Prompting
# Basic Chain-of-Thought
Solve this problem step by step:
A store sells apples for $2 each. If you buy 10, you get 20% off.
How much do 15 apples cost?
Think through this carefully:
1. First, calculate the base price
2. Then, apply any discounts
3. Finally, show your work
# Advanced Chain-of-Thought with XML
<problem>
Design a caching strategy for a high-traffic API
</problem>
<thinking_process>
Before proposing a solution, please:
1. Analyze the requirements and constraints
2. Consider multiple caching approaches
3. Evaluate trade-offs of each approach
4. Recommend the best solution with justification
</thinking_process>
Prefilling Claude's Response
# Force JSON output
User: "Extract entities from: 'Apple announced iPhone 15 in Cupertino'"