Plan Mode instructs Claude to create a plan by analyzing the codebase with read-only operations, perfect for exploring codebases, planning complex changes, or reviewing code safely.
Turn on Plan Mode during a sessionYou can switch into Plan Mode during a session using Shift+Tab to cycle through permission modes.If you are in Normal Mode, Shift+Tab first switches into Auto-Accept Mode, indicated by ⏵⏵ accept edits on at the bottom of the terminal. A subsequent Shift+Tab will switch into Plan Mode, indicated by ⏸ plan mode on.Start a new session in Plan ModeTo start a new session in Plan Mode, use the --permission-mode plan flag:
Copy
Ask AI
claude --permission-mode plan
Run “headless” queries in Plan ModeYou can also run a query in Plan Mode directly with -p (that is, in “headless mode”):
Copy
Ask AI
claude --permission-mode plan -p "Analyze the authentication system and suggest improvements"
> find functions in NotificationsService.swift that are not covered by tests
2
Generate test scaffolding
Copy
Ask AI
> add tests for the notification service
3
Add meaningful test cases
Copy
Ask AI
> add test cases for edge conditions in the notification service
4
Run and verify tests
Copy
Ask AI
> run the new tests and fix any failures
Claude can generate tests that follow your project’s existing patterns and conventions. When asking for tests, be specific about what behavior you want to verify. Claude examines your existing test files to match the style, frameworks, and assertion patterns already in use.For comprehensive coverage, ask Claude to identify edge cases you might have missed. Claude can analyze your code paths and suggest tests for error conditions, boundary values, and unexpected inputs that are easy to overlook.
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.Extended 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.
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.
You can configure thinking mode for Claude Code in two ways:
Scope
How to enable
Details
Global default
Use /config to toggle thinking mode on
Sets your default across all projects. Saved as alwaysThinkingEnabled in ~/.claude/settings.json
You can include ultrathink as a keyword in your message to enable thinking for a single request:
Copy
Ask AI
> ultrathink: design a caching layer for our API
Note 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.The 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.Other phrases like “think”, “think hard”, and “think more” are interpreted as regular prompt instructions and don’t allocate thinking tokens.To view Claude’s thinking process, press Ctrl+O to toggle verbose mode and see the internal reasoning displayed as gray italic text.See the token budget section below for detailed budget information and cost implications.
Extended thinking uses a token budget that controls how much internal reasoning Claude can perform before responding.A larger thinking token budget provides:
More space to explore multiple solution approaches step-by-step
Room to analyze edge cases and evaluate tradeoffs thoroughly
Ability to revise reasoning and self-correct mistakes
Token budgets for thinking mode:
When thinking is enabled (via /config or ultrathink), Claude can use up to 31,999 tokens from your output budget for internal reasoning
When thinking is disabled, Claude uses 0 tokens for thinking
When starting Claude Code, you can resume a previous session:
claude --continue continues the most recent conversation in the current directory
claude --resume opens a conversation picker or resumes by name
From inside an active session, use /resume to switch to a different conversation.Sessions are stored per project directory. The /resume picker shows sessions from the same git repository, including worktrees.
The /resume command (or claude --resume without arguments) opens an interactive session picker with these features:Keyboard shortcuts in the picker:
Shortcut
Action
↑ / ↓
Navigate between sessions
→ / ←
Expand or collapse grouped sessions
Enter
Select and resume the highlighted session
P
Preview the session content
R
Rename the highlighted session
/
Search to filter sessions
A
Toggle between current directory and all projects
B
Filter to sessions from your current git branch
Esc
Exit the picker or search mode
Session organization:The picker displays sessions with helpful metadata:
Session name or initial prompt
Time elapsed since last activity
Message count
Git branch (if applicable)
Forked sessions (created with /rewind or --fork-session) are grouped together under their root session, making it easier to find related conversations.
Tips:
Name sessions early: Use /rename when starting work on a distinct task—it’s much easier to find “payment-integration” than “explain this function” later
Use --continue for quick access to your most recent conversation
Use --resume session-name when you know which session you need
Use --resume (without a name) when you need to browse and select
For scripts, use claude --continue --print "prompt" to resume in non-interactive mode
Press P in the picker to preview a session before resuming it
The resumed conversation starts with the same model and configuration as the original
How it works:
Conversation Storage: All conversations are automatically saved locally with their full message history
Message Deserialization: When resuming, the entire message history is restored to maintain context
Tool State: Tool usage and results from the previous conversation are preserved
Context Restoration: The conversation resumes with all previous context intact
Run parallel Claude Code sessions with Git worktrees
Suppose you need to work on multiple tasks simultaneously with complete code isolation between Claude Code instances.
1
Understand Git worktrees
Git worktrees allow you to check out multiple branches from the same
repository into separate directories. Each worktree has its own working
directory with isolated files, while sharing the same Git history. Learn
more in the official Git worktree
documentation.
2
Create a new worktree
Copy
Ask AI
# Create a new worktree with a new branch git worktree add ../project-feature-a -b feature-a# Or create a worktree with an existing branchgit worktree add ../project-bugfix bugfix-123
This creates a new directory with a separate working copy of your repository.
3
Run Claude Code in each worktree
Copy
Ask AI
# Navigate to your worktree cd ../project-feature-a# Run Claude Code in this isolated environmentclaude
4
Run Claude in another worktree
Copy
Ask AI
cd ../project-bugfixclaude
5
Manage your worktrees
Copy
Ask AI
# List all worktreesgit worktree list# Remove a worktree when donegit worktree remove ../project-feature-a
Tips:
Each worktree has its own independent file state, making it perfect for parallel Claude Code sessions
Changes made in one worktree won’t affect others, preventing Claude instances from interfering with each other
All worktrees share the same Git history and remote connections
For long-running tasks, you can have Claude working in one worktree while you continue development in another
Use descriptive directory names to easily identify which task each worktree is for
Remember to initialize your development environment in each new worktree according to your project’s setup. Depending on your stack, this might include:
Suppose you want to use Claude Code as a linter or code reviewer.Add Claude to your build script:
Copy
Ask AI
// package.json{ ... "scripts": { ... "lint:claude": "claude -p 'you are a linter. please look at the changes vs. main and report any issues related to typos. report the filename and line number on one line, and a description of the issue on the second line. do not return any other text.'" }}
Tips:
Use Claude for automated code review in your CI/CD pipeline
Customize the prompt to check for specific issues relevant to your project
Consider creating multiple scripts for different types of verification
Suppose you need Claude’s output in a specific format, especially when integrating Claude Code into scripts or other tools.
1
Use text format (default)
Copy
Ask AI
cat data.txt | claude -p 'summarize this data' --output-format text > summary.txt
This outputs just Claude’s plain text response (default behavior).
2
Use JSON format
Copy
Ask AI
cat code.py | claude -p 'analyze this code for bugs' --output-format json > analysis.json
This outputs a JSON array of messages with metadata including cost and duration.
3
Use streaming JSON format
Copy
Ask AI
cat log.txt | claude -p 'parse this log file for errors' --output-format stream-json
This outputs a series of JSON objects in real-time as Claude processes the request. Each message is a valid JSON object, but the entire output is not valid JSON if concatenated.
Tips:
Use --output-format text for simple integrations where you just need Claude’s response
Use --output-format json when you need the full conversation log
Use --output-format stream-json for real-time output of each conversation turn
Claude Code supports custom slash commands that you can create to quickly execute specific prompts or tasks.For more details, see the Slash commands reference page.
Suppose you want to create reusable slash commands for your project that all team members can use.
1
Create a commands directory in your project
Copy
Ask AI
mkdir -p .claude/commands
2
Create a Markdown file for each command
Copy
Ask AI
echo "Analyze the performance of this code and suggest three specific optimizations:" > .claude/commands/optimize.md
3
Use your custom command in Claude Code
Copy
Ask AI
> /optimize
Tips:
Command names are derived from the filename (for example, optimize.md becomes /optimize)
You can organize commands in subdirectories (for example, .claude/commands/frontend/component.md creates /component with “(project:frontend)” shown in the description)
Project commands are available to everyone who clones the repository
The Markdown file content becomes the prompt sent to Claude when the command is invoked
Suppose you want to create flexible slash commands that can accept additional input from users.
1
Create a command file with the $ARGUMENTS placeholder
Copy
Ask AI
echo 'Find and fix issue #$ARGUMENTS. Follow these steps: 1.Understand the issue described in the ticket 2. Locate the relevant code inour codebase 3. Implement a solution that addresses the root cause 4. Addappropriate tests 5. Prepare a concise PR description' >.claude/commands/fix-issue.md
2
Use the command with an issue number
In your Claude session, use the command with arguments.
Copy
Ask AI
> /fix-issue 123
This replaces $ARGUMENTS with “123” in the prompt.
Tips:
The $ARGUMENTS placeholder is replaced with any text that follows the command
You can position $ARGUMENTS anywhere in your command template
Other useful applications: generating test cases for specific functions, creating documentation for components, reviewing code in particular files, or translating content to specified languages
> how do I configure Claude Code for Amazon Bedrock?
Copy
Ask AI
> what are the limitations of Claude Code?
Claude provides documentation-based answers to these questions. For executable examples and hands-on demonstrations, refer to the specific workflow sections above.
Tips:
Claude always has access to the latest Claude Code documentation, regardless of the version you’re using
Ask specific questions to get detailed answers
Claude can explain complex features like MCP integration, enterprise configurations, and advanced workflows