Skill
Extended Thinking Patterns Skill
Metadata
name: extended-thinking-patterns
version: 1.0.0
category: orchestration
status: active
priority: P0
derived_from: Claude Operating Preferences v6.0
When to Use This Skill
Use this skill when:
- Configuring Claude Opus 4.5 extended thinking capabilities
- Selecting appropriate thinking budgets for tasks
- Implementing interleaved thinking for multi-tool workflows
- Optimizing accuracy vs cost tradeoffs
Core Patterns
ThinkingTier Enumeration
from enum import Enum
class ThinkingTier(Enum):
"""Thinking budget tiers for Claude Opus 4.5"""
NONE = 0 # No thinking - fastest, cheapest
QUICK = 1024 # 1K tokens - simple tasks
STANDARD = 4096 # 4K tokens - normal tasks
DEEP = 16000 # 16K tokens - complex reasoning
EXTENDED = 32000 # 32K tokens - research tasks
MAXIMUM = 64000 # 64K tokens - autonomous long tasks
ThinkingBudget Configuration
from dataclasses import dataclass
from typing import Optional, Dict, Any
@dataclass
class ThinkingBudget:
"""Configure extended thinking for API calls"""
tier: ThinkingTier
interleaved: bool = False
effort_level: Optional[str] = None # "low", "medium", "high"
def get_api_config(self) -> Dict[str, Any]:
"""Generate API configuration dictionary"""
config = {
"model": "claude-opus-4-5-20251101",
"max_tokens": min(self.tier.value * 2, 32000),
}
if self.tier != ThinkingTier.NONE:
config["thinking"] = {
"type": "enabled",
"budget_tokens": self.tier.value
}
if self.interleaved:
config.setdefault("betas", []).append(
"interleaved-thinking-2025-05-14"
)
return config
def estimate_cost(self) -> float:
"""Estimate thinking token cost in dollars"""
COST_PER_1K = 0.005 # $5 per million
return (self.tier.value / 1000) * COST_PER_1K
Interleaved Thinking Configuration
@dataclass
class InterleavedThinkingConfig:
"""Enable reasoning between tool calls"""
enabled: bool = True
persist_between_calls: bool = True
summarize_on_exhaustion: bool = True
def get_beta_header(self) -> str:
return "interleaved-thinking-2025-05-14"
def should_enable(self, task_has_tools: bool, tool_count: int) -> bool:
"""Determine if interleaved thinking should be enabled"""
return (
self.enabled and
task_has_tools and
tool_count > 1
)
Budget Selection Logic
def select_thinking_tier(
task_complexity: float, # 0.0-1.0
reasoning_depth: int, # 1-5 steps
error_tolerance: float, # 0.0-1.0 (0=no errors, 1=errors ok)
budget_constraint: Optional[float] = None # Max $ to spend
) -> ThinkingTier:
"""Select optimal thinking tier based on task requirements"""
# Base selection on complexity
if task_complexity < 0.2:
base_tier = ThinkingTier.NONE
elif task_complexity < 0.4:
base_tier = ThinkingTier.QUICK
elif task_complexity < 0.6:
base_tier = ThinkingTier.STANDARD
elif task_complexity < 0.8:
base_tier = ThinkingTier.DEEP
else:
base_tier = ThinkingTier.EXTENDED
# Adjust for reasoning depth
if reasoning_depth > 3:
base_tier = ThinkingTier(min(base_tier.value * 2, 64000))
# Adjust for error tolerance
if error_tolerance < 0.1: # Very low error tolerance
base_tier = ThinkingTier(min(base_tier.value * 2, 64000))
# Apply budget constraint
if budget_constraint:
budget = ThinkingBudget(tier=base_tier)
while budget.estimate_cost() > budget_constraint and base_tier.value > 0:
# Step down to lower tier
tiers = list(ThinkingTier)
idx = tiers.index(base_tier)
if idx > 0:
base_tier = tiers[idx - 1]
else:
break
return base_tier
API Call with Extended Thinking
import anthropic
async def call_with_thinking(
prompt: str,
thinking_budget: ThinkingBudget,
tools: Optional[list] = None
) -> dict:
"""Make API call with extended thinking configured"""
client = anthropic.Anthropic()
config = thinking_budget.get_api_config()
if tools:
config["tools"] = tools
response = await client.messages.create(
messages=[{"role": "user", "content": prompt}],
**config
)
return {
"response": response,
"thinking_used": getattr(response, 'thinking_tokens_used', 0),
"thinking_budget": thinking_budget.tier.value,
"utilization": getattr(response, 'thinking_tokens_used', 0) / thinking_budget.tier.value
}
Task-to-Tier Mapping
| Task Type | Complexity | Reasoning | Tier | Budget |
|---|---|---|---|---|
| Format code | 0.1 | 1 | NONE | 0 |
| Extract data | 0.2 | 1 | QUICK | 1K |
| Write tests | 0.4 | 2 | STANDARD | 4K |
| Debug issue | 0.6 | 3 | DEEP | 16K |
| Design system | 0.8 | 4 | EXTENDED | 32K |
| Research paper | 0.9 | 5 | MAXIMUM | 64K |
Accuracy vs Budget Curve
Based on Anthropic research: accuracy improves logarithmically with thinking tokens.
Accuracy Improvement (approx):
- 1K tokens: +5% vs no thinking
- 4K tokens: +10% vs no thinking
- 16K tokens: +15% vs no thinking
- 32K tokens: +18% vs no thinking
- 64K tokens: +20% vs no thinking
Diminishing returns above 32K - only use MAXIMUM for truly complex autonomous tasks.
Integration
# Usage in SubagentTask
task = SubagentTask(
objective="Debug authentication race condition",
thinking_budget=ThinkingTier.DEEP,
interleaved_thinking=True,
# ... other fields
)
# Usage in AgentRouter
router = AgentRouter()
config = router.get_thinking_config(task)
Success Output
When successfully applying extended thinking patterns:
✅ SKILL COMPLETE: extended-thinking-patterns
Completed:
- [x] ThinkingTier enumeration selected based on task complexity
- [x] ThinkingBudget configuration generated with appropriate tier
- [x] Interleaved thinking enabled for multi-tool workflows (if applicable)
- [x] Cost estimate calculated and validated against constraints
- [x] API configuration generated and ready for use
Outputs:
- ThinkingBudget configuration with tier selection justification
- Estimated cost in dollars
- API configuration dictionary
- Accuracy improvement estimate for selected tier
Completion Checklist
Before marking this skill as complete, verify:
- Task complexity and reasoning depth analyzed (0.0-1.0 scale, 1-5 steps)
- Appropriate ThinkingTier selected (NONE/QUICK/STANDARD/DEEP/EXTENDED/MAXIMUM)
- ThinkingBudget configuration created with correct tier and interleaved settings
- Cost estimate calculated and within budget constraint (if specified)
- API configuration generated via
get_api_config() - Interleaved thinking enabled for multi-tool tasks (tool_count > 1)
- Expected accuracy improvement documented for selected tier
Failure Indicators
This skill has FAILED if:
- ❌ Selected thinking tier does not match task complexity (e.g., MAXIMUM for simple formatting)
- ❌ Budget constraint violated (estimated cost exceeds specified maximum)
- ❌ Interleaved thinking disabled for multi-tool workflow requiring reasoning between calls
- ❌ ThinkingTier value invalid or not from enumeration
- ❌ API configuration missing required fields (model, max_tokens, thinking)
- ❌ Cost estimate not calculated before execution
- ❌ No justification provided for tier selection
When NOT to Use
Do NOT use this skill when:
- Task is simple single-step operation (use ThinkingTier.NONE instead)
- No API call configuration needed (use direct task-to-tier mapping table)
- Budget constraints already determined externally (use pre-configured budget)
- Working with non-Opus models (extended thinking is Opus 4.5 specific)
- Task requires instant response (thinking adds latency)
Use alternatives instead:
- For simple tier lookup → Use task-to-tier mapping table directly
- For pre-configured budgets → Skip selection logic, use provided config
- For non-thinking tasks → Remove thinking configuration entirely
- For cost analysis only → Use
scripts/thinking-budget-calculator.py
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Using MAXIMUM for simple tasks | Wastes tokens, minimal accuracy gain | Use task-to-tier mapping table |
| Skipping cost estimation | Budget overruns, unexpected costs | Always call estimate_cost() before execution |
| Disabling interleaved for multi-tool | Miss reasoning between tool calls | Check should_enable() for tool count > 1 |
| Hardcoding tier selection | Ignores task complexity variations | Use select_thinking_tier() logic |
| No budget constraint checking | May exceed allocated budget | Apply budget constraint in selection |
| Using thinking for format-only tasks | Unnecessary cost for trivial work | Set ThinkingTier.NONE for complexity < 0.1 |
Principles
This skill embodies CODITECT automation principles:
- #1 Recycle → Extend → Re-Use → Create - Reuses ThinkingTier enum and ThinkingBudget dataclass across all thinking configurations
- #4 Keep It Simple - Provides clear tier enumeration and selection logic without over-engineering
- #5 Eliminate Ambiguity - Explicit tier definitions with token counts and use case mappings
- #6 Clear, Understandable, Explainable - Task-to-tier mapping table makes decisions transparent
- #8 No Assumptions - Validates budget constraints and calculates costs before execution
- #11 Token Efficiency - Logarithmic accuracy curve guides optimal tier selection to avoid diminishing returns
Full Standard: CODITECT-STANDARD-AUTOMATION.md
Related Components
agents/thinking-budget-manager.md- Agent for budget decisionscommands/thinking-config.md- CLI configurationscripts/thinking-budget-calculator.py- Cost estimationhooks/thinking-exhausted- Budget depletion handler