claude-prompting
Prompt engineering guidance for Claude (Anthropic) model. Use when crafting prompts for Claude to leverage XML-style tags, long-context capabilities, extended thinking, and strong instruction following.
What this skill does
# Claude Prompt Engineering
Claude is Anthropic's AI assistant designed to be helpful, harmless, and honest. It excels at long-context tasks, follows complex instructions precisely, and works best with well-structured prompts using XML-style tags.
## When to Invoke This Skill
Use this skill when:
- Crafting prompts specifically for Claude/Anthropic models (default: Claude Sonnet 4.5)
- Working with long documents or large context (up to 1M tokens with Sonnet 4.5 beta)
- Using structured prompts with XML-style tags
- Implementing extended thinking for complex reasoning
- Requiring precise instruction following
- Building agentic workflows with parallel tool use
## Claude's Identity & Characteristics
| Attribute | Description |
|-----------|-------------|
| **Personality** | Helpful, harmless, honest |
| **Constitutional AI** | Built-in safety and ethical guidelines |
| **Context Window** | Up to 1M tokens (Sonnet 4.5 beta), 200K standard |
| **Strengths** | Long-context analysis, instruction following, document understanding, agentic tasks |
| **Prompt Style** | Structured, clear, XML-style formatting |
| **Extended Thinking** | Optional reasoning trace feature with tool use |
## Universal Prompting Techniques (Claude-Adapted)
### 1. Zero-Shot Prompting
Claude responds well to clear, direct zero-shot prompts.
**Good Example:**
```
Extract the key dates and events from the following text:
<text>
[paste text]
</text>
Output format: JSON with keys "date", "event", "description"
```
**Less Effective:**
```
Can you tell me what dates are in this text?
```
### 2. Few-Shot Prompting (Multishot)
Use well-formatted examples with XML structure.
```
<examples>
<example>
<input>
The conference is scheduled for March 15, 2025 in San Francisco.
</input>
<output>
{
"date": "2025-03-15",
"event": "conference",
"location": "San Francisco"
}
</output>
</example>
<example>
<input>
Our next board meeting is on June 22nd.
</input>
<output>
{
"date": "2025-06-22",
"event": "board meeting"
}
</output>
</examples>
<input>
The product launches on September 1st in New York.
</input>
<output>
```
### 3. Chain-of-Thought Prompting
Claude has an **Extended Thinking** feature that shows reasoning (enabled via API, output in response):
```
I need to decide between these two job offers. Let me think through this step by step.
<job_offer_a>
[details]
</job_offer_a>
<job_offer_b>
[details]
</job_offer_b>
Please analyze both offers, show your reasoning, and provide a recommendation.
```
**API enables extended thinking; response includes:**
```
<thinking>
First, let me analyze the compensation...
Then consider the growth potential...
The work-life balance factors are...
The company stability differs by...
</thinking>
<answer>
[conclusion]
</answer>
```
### 4. Zero-Shot CoT
Simply add "Let's think step by step" or similar:
```
What's the most efficient route to visit all these cities?
Let's think step by step.
```
### 5. Prompt Chaining with XML Tags
Break complex tasks using XML delimiters:
**Chain Step 1:**
```
<task>
Extract relevant quotes from this document related to [topic].
</task>
<document>
[paste document]
</document>
<output_format>
<quotes>
<quote>[relevant quote 1]</quote>
<quote>[relevant quote 2]</quote>
</quotes>
</output_format>
```
**Chain Step 2:**
```
<task>
Summarize the extracted quotes and synthesize key insights.
</task>
<quotes>
[from previous response]
</quotes>
<output_format>
<summary>
[executive summary]
</summary>
<key_insights>
<insight>[insight 1]</insight>
<insight>[insight 2]</insight>
</key_insights>
</output_format>
```
### 6. ReAct Prompting
Use structured thought-action-observation cycles:
```
<question>
[research question]
</question>
<thought_1>
[what needs to be done first]
</thought_1>
<action_1>
[tool use or information gathering]
</action_1>
<observation_1>
[result from action]
</observation_1>
<thought_2>
[next step based on observation]
</thought_2>
<final_answer>
[conclusion]
</final_answer>
```
### 7. Tree of Thoughts
Use multiple reasoning paths with XML structure:
```
<problem>
[complex problem]
</problem>
<thought_paths>
<path_1>
<assumption>[approach 1]</assumption>
<reasoning>[step-by-step]</reasoning>
<conclusion>[result]</conclusion>
</path_1>
<path_2>
<assumption>[approach 2]</assumption>
<reasoning>[step-by-step]</reasoning>
<conclusion>[result]</conclusion>
</path_2>
<path_3>
<assumption>[approach 3]</assumption>
<reasoning>[step-by-step]</reasoning>
<conclusion>[result]</conclusion>
</path_3>
</thought_paths>
<synthesis>
[best path and why]
</synthesis>
```
## Claude-Specific Best Practices
### 1. Use XML-Style Tags for Structure
Claude's official courses extensively use XML tags:
```xml
<context>
[background information]
</context>
<task>
[what needs to be done]
</task>
<examples>
[example inputs and outputs]
</examples>
<input>
[the actual input to process]
</input>
<output_format>
[expected format]
</output_format>
```
### 2. Structure Long Prompts Hierarchically
From Anthropic's official courses:
```
[TASK_CONTEXT]
Setting the stage and overall context
[TONE_CONTEXT]
How Claude should approach the task
[INPUT_DATA]
The actual data to work with
[EXAMPLES]
Few-shot examples
[TASK_DESCRIPTION]
Specific task details
[IMMEDIATE_TASK]
The immediate action to take
[OUTPUT_FORMATTING]
Expected output structure
```
### 3. Leverage Extended Thinking
For complex reasoning, enable Claude's extended thinking via the API:
**API Syntax (Python SDK):**
```python
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=4096,
thinking={
"type": "enabled",
"budget_tokens": 8192
},
messages=[{
"role": "user",
"content": "Analyze this complex problem..."
}]
)
```
**Prompt-Side (XML structure for expected output):**
```
<task>
[complex reasoning task]
</task>
<thinking>
[Claude will show its reasoning here]
</thinking>
<answer>
[final answer]
</answer>
```
**Key Points:**
- `budget_tokens` sets max tokens for reasoning (must be < `max_tokens`)
- Claude 4.5 returns summarized thinking by default
- First few lines are more verbose (useful for prompt engineering)
- You're billed for full thinking tokens, not summary tokens
### 4. Use System Prompts Effectively
System prompts set Claude's behavior:
```
System: You are a technical writer specializing in API documentation. Your responses are always:
- Clear and concise
- Technically accurate
- Formatted with Markdown
- Focused on developer needs
User: [your actual query]
```
### 5. Prefill Claude's Response
Guide the format by starting Claude's response:
```
<task>
Analyze this document and extract key findings.
</task>
<document>
[paste document]
</document>
<response>
<summary>
[Claude continues from here]
```
### 6. Cache Control for Long Prompts
Optimize for repeated prompts:
```
<cached_content cache_control="{\"type\":\"ephemeral\"}">
[large context that doesn't change]
</cached_content>
<task>
[specific task that varies]
</task>
```
### 7. Claude 4.5 Agent Features
Claude 4.5 introduces powerful agent capabilities:
**Parallel Tool Use** - Claude can use multiple tools simultaneously:
```xml
<task>
Analyze this data and create a visualization.
</task>
<tools>
- Web search for market data
- Code execution for analysis
- File write for chart output
</tools>
Claude will execute these in parallel when possible.
```
**Memory Files** - Claude can maintain knowledge across sessions:
```xml
<task>
When working on ongoing projects, create a memory file to track:
- Key decisions and rationale
- Project context and constraints
- Preferences and patterns
</task>
Claude will automatically update and reference memory files when given local file access.
```
**Extended Thinking with Tools** - Reasoning can pause to use tools:
```python
# API: Enable extended thinking with tool use
response = client.messages.create(
modRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.