extended-thinking
# Claude Code Extended Thinking
What this skill does
# Claude Code Extended Thinking
Complete guide to extended thinking modes and thinking budget configuration.
## Overview
Extended thinking (also called "ultrathink") allows Claude to perform deeper reasoning before responding. This uses additional tokens for internal reasoning that improves quality on complex tasks.
## Thinking Modes
### Trigger Phrases (CLI)
Use these phrases in your prompts to activate thinking levels:
| Phrase | Thinking Tokens | Approx Cost |
|--------|----------------|-------------|
| `think` | ~4,000 tokens | ~$0.06 |
| `think hard` / `megathink` | ~10,000 tokens | ~$0.15 |
| `ultrathink` | ~32,000 tokens | ~$0.48 |
Example: `"ultrathink about how to refactor the auth module"`
### Toggle Shortcut
- `Option+T` — Toggle extended thinking on/off in interactive mode
### Environment Variable
```bash
CLAUDE_CODE_EFFORT_LEVEL=high # low, medium, high
```
### Default Thinking
Standard reasoning — Claude thinks internally as needed.
### Extended Thinking
More deliberate reasoning with configurable thinking budget.
### Ultrathink
Maximum reasoning depth for the most complex problems. Best for architecture decisions, debugging complex issues, and novel problem-solving.
## Configuration
### Via API (Claude Agent SDK)
```typescript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const response = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 16000,
thinking: {
type: "enabled",
budget_tokens: 10000 // Tokens allocated for thinking
},
messages: [
{ role: "user", content: "Solve this complex architecture problem..." }
]
});
// Access thinking content
for (const block of response.content) {
if (block.type === "thinking") {
console.log("Thinking:", block.thinking);
} else if (block.type === "text") {
console.log("Response:", block.text);
}
}
```
### Budget Tokens
| Budget | Use Case |
|--------|----------|
| 2,000-5,000 | Simple analysis, code review |
| 5,000-10,000 | Architecture decisions, debugging |
| 10,000-20,000 | Complex multi-step reasoning |
| 20,000+ | Deep research, novel problem solving |
### Streaming with Thinking
```typescript
const stream = await client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 16000,
thinking: {
type: "enabled",
budget_tokens: 10000
},
messages: [{ role: "user", content: "..." }]
});
for await (const event of stream) {
if (event.type === "content_block_start") {
if (event.content_block.type === "thinking") {
console.log("--- Thinking started ---");
}
}
if (event.type === "content_block_delta") {
if (event.delta.type === "thinking_delta") {
process.stdout.write(event.delta.thinking);
} else if (event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}
}
```
## In Claude Code
Within Claude Code sessions, extended thinking is managed automatically based on:
1. Model capabilities
2. Task complexity
3. Available token budget
### When Extended Thinking Activates
- Complex architectural decisions
- Multi-step debugging
- Code review requiring deep analysis
- Planning with many constraints
- Novel problem-solving
### Model Support
| Model | Extended Thinking |
|-------|------------------|
| Claude Opus 4.6 | Full support |
| Claude Sonnet 4.6 | Full support |
| Claude Haiku 4.5 | Limited support |
## Best Practices
1. **Use for complex tasks** — Don't waste thinking budget on simple questions
2. **Set appropriate budgets** — More isn't always better
3. **Monitor costs** — Thinking tokens count toward usage
4. **Combine with planning** — Extended thinking + plan mode for architecture
5. **Review thinking output** — Verify the reasoning, not just the conclusion
## Cost Implications
- Thinking tokens are billed as output tokens
- Higher thinking budgets increase cost per request
- Use `/cost` to monitor thinking token usage
- Consider model routing: use Haiku for simple, Opus for complex
## Thinking in Multi-Turn Conversations
- Thinking context carries across turns
- Each turn can have its own thinking budget
- Claude references previous thinking implicitly
- `/compact` preserves thinking conclusions but drops raw thinking
## API Response Structure
```json
{
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...\n1. First consideration...\n2. Second consideration..."
},
{
"type": "text",
"text": "Based on my analysis, here's what I recommend..."
}
],
"usage": {
"input_tokens": 500,
"output_tokens": 3000,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}
```
Related 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.