499 499
500***500***
501 501
502## Use extended thinking502## Use extended thinking (thinking mode)
503 503
504Suppose you're working on complex architectural decisions, challenging bugs, or planning multi-step implementations that require deep reasoning.504[Extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) reserves a portion of the total output token budget for Claude to reason through complex problems step-by-step. This reasoning is visible in verbose mode, which you can toggle on with `Ctrl+O`.
505
506Extended thinking is particularly valuable for complex architectural decisions, challenging bugs, multi-step implementation planning, and evaluating tradeoffs between different approaches. It provides more space for exploring multiple solutions, analyzing edge cases, and self-correcting mistakes.
505 507
506<Note>508<Note>
507 [Extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) is disabled by default in Claude Code. You can enable it on-demand by using `Tab` to toggle Thinking on, or by using prompts like "think" or "think hard". You can also enable it permanently by setting the [`MAX_THINKING_TOKENS` environment variable](/en/settings#environment-variables) in your settings.509 Sonnet 4.5 and Opus 4.5 have thinking enabled by default. All other models have thinking disabled by default. Use `/model` to view or switch your current model.
508</Note>510</Note>
509 511
510<Steps>512You can configure thinking mode for Claude Code in two ways:
511 <Step title="Provide context and ask Claude to think">
512 ```
513 > I need to implement a new authentication system using OAuth2 for our API. Think deeply about the best approach for implementing this in our codebase.
514 ```
515 513
516 Claude gathers relevant information from your codebase and514| Scope | How to enable | Details |
517 uses extended thinking, which is visible in the interface.515| --------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
518 </Step>516| **Global default** | Use `/config` to toggle thinking mode on | Sets your default across all projects.<br />Saved as `alwaysThinkingEnabled` in `~/.claude/settings.json` |
517| **Environment variable override** | Set [`MAX_THINKING_TOKENS`](/en/settings#environment-variables) environment variable | When set, applies a custom token budget to all requests, overriding your thinking mode configuration. Example: `export MAX_THINKING_TOKENS=1024` |
519 518
520 <Step title="Refine the thinking with follow-up prompts">519### Per-request thinking with `ultrathink`
521 ```
522 > think about potential security vulnerabilities in this approach
523 ```
524 520
525 ```521You can include `ultrathink` as a keyword in your message to enable thinking for a single request:
526 > think hard about edge cases we should handle
527 ```
528 </Step>
529</Steps>
530 522
531<Tip>523```
532 Tips to get the most value out of extended thinking:524> ultrathink: design a caching layer for our API
525```
533 526
534 [Extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) is most valuable for complex tasks such as:527Note that `ultrathink` both allocates the thinking budget AND semantically signals to Claude to reason more thoroughly, which may result in deeper thinking than necessary for your task.
535 528
536 * Planning complex architectural changes529The `ultrathink` keyword only works when `MAX_THINKING_TOKENS` is not set. When `MAX_THINKING_TOKENS` is configured, it takes priority and controls the thinking budget for all requests.
537 * Debugging intricate issues
538 * Creating implementation plans for new features
539 * Understanding complex codebases
540 * Evaluating tradeoffs between different approaches
541 530
542 Use `Tab` to toggle Thinking on and off during a session.531Other phrases like "think", "think hard", and "think more" are interpreted as regular prompt instructions and don't allocate thinking tokens.
543 532
544 The way you prompt for thinking results in varying levels of thinking depth:533To view Claude's thinking process, press `Ctrl+O` to toggle verbose mode and see the internal reasoning displayed as gray italic text.
545 534
546 * "think" triggers basic extended thinking535See the [token budget section below](#how-extended-thinking-token-budgets-work) for detailed budget information and cost implications.
547 * intensifying phrases such as "keep hard", "think more", "think a lot", or "think longer" triggers deeper thinking
548 536
549 For more extended thinking prompting tips, see [Extended thinking tips](https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/extended-thinking-tips).537### How extended thinking token budgets work
550</Tip>
551 538
552<Note>539Extended thinking uses a **token budget** that controls how much internal reasoning Claude can perform before responding.
553 Claude displays its thinking process as italic gray text above the540
554 response.541A larger thinking token budget provides:
555</Note>542
543* More space to explore multiple solution approaches step-by-step
544* Room to analyze edge cases and evaluate tradeoffs thoroughly
545* Ability to revise reasoning and self-correct mistakes
546
547Token budgets for thinking mode:
548
549* When thinking is **enabled** (via `/config` or `ultrathink`), Claude can use up to **31,999 tokens** from your output budget for internal reasoning
550* When thinking is **disabled**, Claude uses **0 tokens** for thinking
551
552**Custom token budgets:**
553
554* You can set a custom thinking token budget using the [`MAX_THINKING_TOKENS` environment variable](/en/settings#environment-variables)
555* This takes highest priority and overrides the default 31,999 token budget
556* See the [extended thinking documentation](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for valid token ranges
557
558<Warning>
559 You're charged for all thinking tokens used, even though Claude 4 models show summarized thinking
560</Warning>
556 561
557***562***
558 563