Install command
Not provided
How to use Claude's extended thinking: the API `thinking` config with budget_tokens, when to spend more reasoning, and the think/ultrathink prompting convention in Claude Code.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Not provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
52/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 1 risk area. Review closely: credentials & tokens.
## Overview
Extended thinking gives Claude an explicit, step-by-step reasoning pass before it writes its final answer. When you enable it, Claude emits `thinking` content blocks that contain its internal reasoning, then uses that reasoning to craft the response. It is most useful for problems where a single forward pass tends to be brittle: multi-step math and logic, complex code changes, careful analysis, and tasks where you would normally ask a person to "show their work."
There are two ways you typically interact with it:
- **Through the API**, where you turn on extended thinking by adding a `thinking` object with a token budget to your request.
- **Inside Claude Code**, where you can nudge Claude to spend more reasoning effort using natural-language keywords like "think" and "ultrathink." This keyword tiering is a prompting convention, not a documented API parameter (more on that below).
This guide covers both, sticking to what the official docs actually specify.
## Enabling extended thinking via the API
To turn on extended thinking, add a `thinking` block to your Messages API request. The block takes `type: "enabled"` and a `budget_tokens` value:
```json
{
"model": "claude-sonnet-4-6",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "Your question here"
}
]
}
```
The two required fields:
- **`type`** — set to `"enabled"` to activate extended thinking.
- **`budget_tokens`** — the maximum number of tokens Claude may spend on internal reasoning. This is separate from, and must be **less than**, `max_tokens`. `budget_tokens` caps the thinking; `max_tokens` caps the whole response.
A few important consequences of that relationship:
- Claude does not always consume the entire budget. The docs note this especially at larger ranges (above ~32k), where the model may stop reasoning before hitting the cap.
- Because `budget_tokens` must be below `max_tokens`, you cannot combine extended thinking with `max_tokens: 0` (the prompt-caching pre-warming pattern).
- You are billed for the **full thinking tokens generated**, even when the response only shows summarized thinking. The billed output token count therefore will not match the visible token count in the response.
Not every model supports manual extended thinking. The newest models (for example `claude-opus-4-8`) instead use **adaptive thinking** (`thinking: {"type": "adaptive"}`), where the model decides on its own when and how much to think rather than taking a fixed `budget_tokens`. Check the current model support list in the docs before wiring a specific model to a `budget_tokens` value.
### Streaming
Streaming is **not required** at any size threshold, but it is useful for long thinking passes so you can surface progress instead of waiting for the full response. When streaming is enabled, thinking text arrives via `thinking_delta` events:
```python
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
messages=[...],
) as stream:
for event in stream:
if event.type == "content_block_delta":
if event.delta.type == "thinking_delta":
print(event.delta.thinking, end="", flush=True)
```
### Passing thinking blocks back during tool use and multi-turn
This is the rule that most often trips people up. During tool use and multi-turn conversations, you **must pass any `thinking` blocks back to the API unmodified**, in their original order. Each thinking block carries a `signature` field (encrypted reasoning state); rearranging, editing, or dropping blocks in a turn that used them causes a validation error.
```python
# First request
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
tools=[weather_tool],
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
)
# Extract the thinking and tool_use blocks from the response
thinking_block = next((b for b in response.content if b.type == "thinking"), None)
tool_use_block = next((b for b in response.content if b.type == "tool_use"), None)
# Second request — the thinking block MUST be passed back with the tool result
continuation = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
tools=[weather_tool],
messages=[
{"role": "user", "content": "What's the weather in Paris?"},
{"role": "assistant", "content": [thinking_block, tool_use_block]},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": tool_use_block.id,
"content": "Current temperature: 88°F",
}
],
},
],
)
```
Two related tool-use constraints with thinking enabled: only `tool_choice: {"type": "auto"}` (the default) or `tool_choice: {"type": "none"}` are allowed — forcing a specific tool returns an error — and you cannot toggle thinking on or off partway through a tool-use loop.
### Summarized vs. omitted thinking
On Claude 4 models the Messages API returns **summarized** thinking by default: a condensed version of the full reasoning. You still pay for the full thinking tokens; the summary is produced by a separate model. You can also set `display: "omitted"` so no thinking text comes over the wire (the `signature` still carries the encrypted reasoning needed for multi-turn continuity), which gives faster time-to-first-text in streaming pipelines that never surface reasoning to a user.
```json
{
"thinking": {
"type": "enabled",
"budget_tokens": 10000,
"display": "omitted"
}
}
```
## When to spend more thinking
Larger budgets can improve quality on genuinely hard problems by giving Claude room for more thorough analysis — but more thinking is not free (you pay for every thinking token) and it adds latency. The docs' guidance is to start with a reasonable value such as `10000` and adjust by problem complexity. Use the table below as a starting heuristic.
| Task profile | Suggested approach | Why |
| --- | --- | --- |
| Simple lookups, formatting, short rewrites | Leave thinking off | A direct answer is faster and cheaper; reasoning adds little |
| Moderate reasoning: multi-step questions, small refactors | Start near `budget_tokens: 10000` | The docs' recommended starting point; usually enough headroom |
| Hard problems: tricky math/logic, complex multi-file changes, deep analysis | Raise the budget, then measure | Bigger budgets help on complex work; verify the gain is real for your task |
| Very large budgets (above ~32k) | Raise only if measurements justify it | Claude often won't use the whole budget here, so extra budget may not pay off |
Always confirm `budget_tokens` stays below `max_tokens`, and treat budget tuning empirically: raise it only while quality keeps improving on your own evals.
## The think / ultrathink convention in Claude Code
In Claude Code you don't set `budget_tokens` directly. Instead, people use natural-language cues in the prompt — "think", "think hard", "think harder", "ultrathink" — to signal that they want Claude to spend more effort reasoning before acting.
Important caveats, so you don't build on shaky assumptions:
- These keyword tiers are a **community/prompting convention**, not a documented API parameter. The official Claude Code best-practices page does not define them or publish their exact token budgets.
- Because the budgets are **not published**, treat the tiers as *relative* effort levels rather than precise numbers. Do not hard-code or quote specific token counts for them — any such figures circulating online are unofficial.
| Keyword cue | Relative effort | Good fit for |
| --- | --- | --- |
| (no cue) | Default | Routine edits, questions, small fixes |
| "think" | More than default | Tasks that benefit from a brief planning pass |
| "think hard" / "think harder" | Higher | Trickier changes, ambiguous requirements |
| "ultrathink" | Highest | The hardest problems where you explicitly want maximum deliberation |
What the official Claude Code best-practices *do* recommend, and which pairs naturally with more reasoning:
- **Explore, then plan, then code.** Use plan mode to let Claude read the relevant files and produce an implementation plan before it edits anything, so it doesn't solve the wrong problem.
- **Give Claude a way to verify its work.** A test suite, a build, a linter, or a screenshot comparison closes the loop so Claude can iterate to a pass on its own instead of relying on "looks done."
- **Provide specific context.** Reference exact files with `@`, name constraints, point to existing patterns, and describe the symptom and what "fixed" looks like.
- **Add an adversarial review step.** Have a fresh subagent review the diff against your plan and report gaps before you treat the task as done.
Reasoning effort is most worthwhile precisely where these practices say planning matters: multi-file changes, unfamiliar code, and tasks where the approach is uncertain.
## Troubleshooting
- **Validation error on a follow-up request.** You almost certainly dropped, edited, or reordered a `thinking` block from a previous turn. Pass thinking blocks back unmodified, in original order, including their `signature`.
- **Forced tool choice fails with thinking on.** Only `auto` or `none` tool choice is supported with extended thinking. Remove the forced `tool` / `any` choice, or disable thinking for that call.
- **Billed token count doesn't match what you see.** Expected with summarized thinking — you are billed for the full thinking tokens, not the visible summary.
- **`max_tokens: 0` rejected with thinking enabled.** `budget_tokens` must be below `max_tokens`, so the cache pre-warming pattern can't be combined with extended thinking.
- **Your model rejects `budget_tokens`.** The newest models use adaptive thinking (`type: "adaptive"`) instead of a manual budget. Confirm your model is on the manual-thinking support list.
## References
- Extended thinking — Anthropic docs: https://platform.claude.com/docs/en/build-with-claude/extended-thinking
- Claude Code best practices: https://code.claude.com/docs/en/best-practicesExtended thinking gives Claude an explicit, step-by-step reasoning pass before it writes its final answer. When you enable it, Claude emits thinking content blocks that contain its internal reasoning, then uses that reasoning to craft the response. It is most useful for problems where a single forward pass tends to be brittle: multi-step math and logic, complex code changes, careful analysis, and tasks where you would normally ask a person to "show their work."
There are two ways you typically interact with it:
thinking object with a token budget to your request.This guide covers both, sticking to what the official docs actually specify.
To turn on extended thinking, add a thinking block to your Messages API request. The block takes type: "enabled" and a budget_tokens value:
{
"model": "claude-sonnet-4-6",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "Your question here"
}
]
}
The two required fields:
type — set to "enabled" to activate extended thinking.budget_tokens — the maximum number of tokens Claude may spend on internal reasoning. This is separate from, and must be less than, max_tokens. budget_tokens caps the thinking; max_tokens caps the whole response.A few important consequences of that relationship:
budget_tokens must be below max_tokens, you cannot combine extended thinking with max_tokens: 0 (the prompt-caching pre-warming pattern).Not every model supports manual extended thinking. The newest models (for example claude-opus-4-8) instead use adaptive thinking (thinking: {"type": "adaptive"}), where the model decides on its own when and how much to think rather than taking a fixed budget_tokens. Check the current model support list in the docs before wiring a specific model to a budget_tokens value.
Streaming is not required at any size threshold, but it is useful for long thinking passes so you can surface progress instead of waiting for the full response. When streaming is enabled, thinking text arrives via thinking_delta events:
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
messages=[...],
) as stream:
for event in stream:
if event.type == "content_block_delta":
if event.delta.type == "thinking_delta":
print(event.delta.thinking, end="", flush=True)
This is the rule that most often trips people up. During tool use and multi-turn conversations, you must pass any thinking blocks back to the API unmodified, in their original order. Each thinking block carries a signature field (encrypted reasoning state); rearranging, editing, or dropping blocks in a turn that used them causes a validation error.
# First request
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
tools=[weather_tool],
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
)
# Extract the thinking and tool_use blocks from the response
thinking_block = next((b for b in response.content if b.type == "thinking"), None)
tool_use_block = next((b for b in response.content if b.type == "tool_use"), None)
# Second request — the thinking block MUST be passed back with the tool result
continuation = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={"type": "enabled", "budget_tokens": 10000},
tools=[weather_tool],
messages=[
{"role": "user", "content": "What's the weather in Paris?"},
{"role": "assistant", "content": [thinking_block, tool_use_block]},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": tool_use_block.id,
"content": "Current temperature: 88°F",
}
],
},
],
)
Two related tool-use constraints with thinking enabled: only tool_choice: {"type": "auto"} (the default) or tool_choice: {"type": "none"} are allowed — forcing a specific tool returns an error — and you cannot toggle thinking on or off partway through a tool-use loop.
On Claude 4 models the Messages API returns summarized thinking by default: a condensed version of the full reasoning. You still pay for the full thinking tokens; the summary is produced by a separate model. You can also set display: "omitted" so no thinking text comes over the wire (the signature still carries the encrypted reasoning needed for multi-turn continuity), which gives faster time-to-first-text in streaming pipelines that never surface reasoning to a user.
{
"thinking": {
"type": "enabled",
"budget_tokens": 10000,
"display": "omitted"
}
}
Larger budgets can improve quality on genuinely hard problems by giving Claude room for more thorough analysis — but more thinking is not free (you pay for every thinking token) and it adds latency. The docs' guidance is to start with a reasonable value such as 10000 and adjust by problem complexity. Use the table below as a starting heuristic.
| Task profile | Suggested approach | Why |
|---|---|---|
| Simple lookups, formatting, short rewrites | Leave thinking off | A direct answer is faster and cheaper; reasoning adds little |
| Moderate reasoning: multi-step questions, small refactors | Start near budget_tokens: 10000 |
The docs' recommended starting point; usually enough headroom |
| Hard problems: tricky math/logic, complex multi-file changes, deep analysis | Raise the budget, then measure | Bigger budgets help on complex work; verify the gain is real for your task |
| Very large budgets (above ~32k) | Raise only if measurements justify it | Claude often won't use the whole budget here, so extra budget may not pay off |
Always confirm budget_tokens stays below max_tokens, and treat budget tuning empirically: raise it only while quality keeps improving on your own evals.
In Claude Code you don't set budget_tokens directly. Instead, people use natural-language cues in the prompt — "think", "think hard", "think harder", "ultrathink" — to signal that they want Claude to spend more effort reasoning before acting.
Important caveats, so you don't build on shaky assumptions:
| Keyword cue | Relative effort | Good fit for |
|---|---|---|
| (no cue) | Default | Routine edits, questions, small fixes |
| "think" | More than default | Tasks that benefit from a brief planning pass |
| "think hard" / "think harder" | Higher | Trickier changes, ambiguous requirements |
| "ultrathink" | Highest | The hardest problems where you explicitly want maximum deliberation |
What the official Claude Code best-practices do recommend, and which pairs naturally with more reasoning:
@, name constraints, point to existing patterns, and describe the symptom and what "fixed" looks like.Reasoning effort is most worthwhile precisely where these practices say planning matters: multi-file changes, unfamiliar code, and tasks where the approach is uncertain.
thinking block from a previous turn. Pass thinking blocks back unmodified, in original order, including their signature.auto or none tool choice is supported with extended thinking. Remove the forced tool / any choice, or disable thinking for that call.max_tokens: 0 rejected with thinking enabled. budget_tokens must be below max_tokens, so the cache pre-warming pattern can't be combined with extended thinking.budget_tokens. The newest models use adaptive thinking (type: "adaptive") instead of a manual budget. Confirm your model is on the manual-thinking support list.Show that Claude Extended Thinking is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/guides/claude-4-extended-thinking-tutorial)Claude Extended Thinking side by side with 2 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
1 trust signal differ across this comparison (Submitter).
| Field | How to use Claude's extended thinking: the API `thinking` config with budget_tokens, when to spend more reasoning, and the think/ultrathink prompting convention in Claude Code. Open dossier | A repeatable explore-plan-implement-verify workflow for large code migrations and refactors with Claude Code, using plan mode, /rewind checkpoints, subagents, and claude -p fan-out for batch file changes. Open dossier | A source-backed review workflow for pull requests that include AI-generated code. Treat generated diffs as untrusted implementation work, verify behavior in CI, inspect security-sensitive paths first, and merge only after a reviewer-owned checklist passes. Open dossier |
|---|---|---|---|
| Next steps | |||
| Trust | |||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed |
| SubmitterDiffers | — | — | MkDev11 |
| Install risk | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — |
| Category | guides | guides | guides |
| Source | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | MkDev11 |
| Added | 2025-10-27 | 2025-10-27 | 2026-06-04 |
| Platforms | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — |
| Safety notes | ✓The API examples make live, billed model requests; set a sensible budget_tokens / MAX_THINKING_TOKENS and test before using high thinking budgets in production. | ✓The claude -p fan-out loop runs Claude non-interactively across many files. Scope it with --allowedTools (for example "Edit,Bash(git commit *)") so unattended runs cannot perform actions you did not intend, and test on 2-3 files before running at scale. Checkpoints only track Claude's direct file edits, not changes made by bash commands (rm, mv, cp) or other processes, so commit to git before a large migration. | ✓Treat AI-generated changes as untrusted code until a human reviewer verifies behavior, security impact, and rollback risk. Block merge when the PR changes authentication, authorization, data deletion, payment, networking, serialization, or release automation without focused tests. Do not accept generated explanations as proof; require CI output, reproducible commands, or links to authoritative project docs. Inspect package manifests, lockfiles, package-manager configuration, and dependency choices before installing from an untrusted branch. Run install, build, and test commands for untrusted PRs in a disposable sandbox or container, with package-manager lifecycle scripts disabled unless the changed scripts and packages have been reviewed and approved. |
| Privacy notes | ✓Extended thinking sends your prompt and context to the configured model provider and the thinking tokens are billed; the think/ultrathink keyword tiers are a Claude Code convention whose token budgets are not published. | ✓Claude Code sends the files it reads and command output to the model as context. Avoid piping secrets or credentials into prompts, and exclude sensitive paths from migration runs. | ✓Do not paste private code, secrets, customer data, logs, or incident details into external AI review tools unless your organization has approved that workflow. Keep review notes in the pull request or internal tracker so security decisions remain auditable. |
| Prerequisites | — none listed | — none listed |
|
| Install | — | — | — |
| Config | — | — | — |
| Citations | |||
| Claim | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Get productive with Claude Code if you're coming from ChatGPT.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.