Documentation Index
Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt Use this file to discover all available pages before exploring further.
Common workflows
Step-by-step guides for exploring codebases, fixing bugs, refactoring, testing, and other everyday tasks with Claude Code.This page covers practical workflows for everyday development: exploring unfamiliar code, debugging, refactoring, writing tests, creating PRs, and managing sessions. Each section includes example prompts you can adapt to your own projects. For higher-level patterns and tips, see Best practices.
Understand new codebases
Get a quick codebase overview
Suppose you’ve just joined a new project and need to understand its structure quickly.Navigate to the project root directory
Start Claude Code
Ask for a high-level overview
Dive deeper into specific components
Find relevant code
Suppose you need to locate code related to a specific feature or functionality.Ask Claude to find relevant files
Get context on how components interact
Understand the execution flow
Fix bugs efficiently
Suppose you’ve encountered an error message and need to find and fix its source.Share the error with Claude
Ask for fix recommendations
Apply the fix
Refactor code
Suppose you need to update old code to use modern patterns and practices.Identify legacy code for refactoring
Get refactoring recommendations
Apply the changes safely
Verify the refactoring
Use specialized subagents
Suppose you want to use specialized AI subagents to handle specific tasks more effectively.View available subagents
Use subagents automatically
Explicitly request specific subagents
Create custom subagents for your workflow
- A unique identifier that describes the subagent’s purpose (for example,
code-reviewer,api-designer). - When Claude should use this agent
- Which tools it can access
- A system prompt describing the agent’s role and behavior
Use Plan Mode for safe code analysis
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. In Plan Mode, Claude usesAskUserQuestion to gather requirements and clarify your goals before proposing a plan.
When to use Plan Mode
- Multi-step implementation: When your feature requires making edits to many files
- Code exploration: When you want to research the codebase thoroughly before changing anything
- Interactive development: When you want to iterate on the direction with Claude
How to use Plan Mode
Turn on Plan Mode during a session You 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 Mode
To start a new session in Plan Mode, use the --permission-mode plan flag:
-p (that is, in “headless mode”):
Example: Planning a complex refactor
Configure Plan Mode as default
Work with tests
Suppose you need to add tests for uncovered code.Identify untested code
Generate test scaffolding
Add meaningful test cases
Run and verify tests
Create pull requests
You can create pull requests by asking Claude directly (“create a pr for my changes”) or by using the/commit-push-pr skill, which commits, pushes, and opens a PR in one step.
Summarize your changes
Generate a pull request
Review and refine
gh pr create, the session is automatically linked to that PR. You can resume it later with claude --from-pr <number>.
Handle documentation
Suppose you need to add or update documentation for your code.Identify undocumented code
Generate documentation
Review and enhance
Verify documentation
Work with images
Suppose you need to work with images in your codebase, and you want Claude’s help analyzing image content.Add an image to the conversation
- Drag and drop an image into the Claude Code window
- Copy an image and paste it into the CLI with ctrl+v (Do not use cmd+v)
- Provide an image path to Claude. E.g., “Analyze this image: /path/to/your/image.png”
Ask Claude to analyze the image
Use images for context
Get code suggestions from visual content
Reference files and directories
Use @ to quickly include files or directories without waiting for Claude to read them.Reference a single file
Reference a directory
Reference MCP resources
Use extended thinking (thinking mode)
Extended thinking is enabled by default, reserving a portion of the output token budget (up to 31,999 tokens) for Claude to reason through complex problems step-by-step. This reasoning is visible in verbose mode, which you can toggle on withCtrl+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.
Configure thinking mode
Thinking is enabled by default, but you can adjust or disable it.Ctrl+O to toggle verbose mode and see the internal reasoning displayed as gray italic text.
How extended thinking token budgets work
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
- When thinking is enabled, Claude can use up to 31,999 tokens from your output budget for internal reasoning
- When thinking is disabled (via toggle or
/config), Claude uses 0 tokens for thinking
- Use the
MAX_THINKING_TOKENSenvironment variable to cap the thinking budget - When set, this value limits the maximum tokens Claude can use for thinking
- See the extended thinking documentation for valid token ranges
Resume previous conversations
When starting Claude Code, you can resume a previous session:claude --continuecontinues the most recent conversation in the current directoryclaude --resumeopens a conversation picker or resumes by nameclaude --from-pr 123resumes sessions linked to a specific pull request
/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.
Name your sessions
Give sessions descriptive names to find them later. This is a best practice when working on multiple tasks or features.Name the current session
/rename during a session to give it a memorable name:/resume, navigate to a session, and press R.Resume by name later
Use the session picker
The/resume command (or claude --resume without arguments) opens an interactive session picker with these features:
Keyboard shortcuts in the picker:
- Session name or initial prompt
- Time elapsed since last activity
- Message count
- Git branch (if applicable)
/rewind or --fork-session) are grouped together under their root session, making it easier to find related conversations.
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.Understand Git worktrees
Create a new worktree
Run Claude Code in each worktree
Run Claude in another worktree
Manage your worktrees
Use Claude as a unix-style utility
Add Claude to your verification process
Suppose you want to use Claude Code as a linter or code reviewer. Add Claude to your build script:Pipe in, pipe out
Suppose you want to pipe data into Claude, and get back data in a structured format. Pipe data through Claude:Control output format
Suppose you need Claude’s output in a specific format, especially when integrating Claude Code into scripts or other tools.Use text format (default)
Use JSON format
Use streaming JSON format
