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
- Start with broad questions, then narrow down to specific areas
- Ask about coding conventions and patterns used in the project
- Request a glossary of project-specific terms
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
- Be specific about what you’re looking for
- Use domain language from the project
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
- Tell Claude the command to reproduce the issue and get a stack trace
- Mention any steps to reproduce the error
- Let Claude know if the error is intermittent or consistent
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
- Ask Claude to explain the benefits of the modern approach
- Request that changes maintain backward compatibility when needed
- Do refactoring in small, testable increments
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
- Subagent type (e.g.,
api-designer
,performance-optimizer
) - When to use it
- Which tools it can access
- Its specialized system prompt
- Create project-specific subagents in
.claude/agents/
for team sharing - Use descriptive
description
fields to enable automatic delegation - Limit tool access to what each subagent actually needs
- Check the subagents documentation for detailed examples
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.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 will first switch 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
(i.e., 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
- Ask for tests that cover edge cases and error conditions
- Request both unit and integration tests when appropriate
- Have Claude explain the testing strategy
Create pull requests
Suppose you need to create a well-documented pull request for your changes.Summarize your changes
Generate a PR with Claude
Review and refine
Add testing details
- Ask Claude directly to make a PR for you
- Review Claude’s generated PR before submitting
- Ask Claude to highlight potential risks or considerations
Handle documentation
Suppose you need to add or update documentation for your code.Identify undocumented code
Generate documentation
Review and enhance
Verify documentation
- Specify the documentation style you want (JSDoc, docstrings, etc.)
- Ask for examples in the documentation
- Request documentation for public APIs, interfaces, and complex logic
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
- Use images when text descriptions would be unclear or cumbersome
- Include screenshots of errors, UI designs, or diagrams for better context
- You can work with multiple images in a conversation
- Image analysis works with diagrams, screenshots, mockups, and more
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
- File paths can be relative or absolute
- @ file references add CLAUDE.md in the file’s directory and parent directories to context
- Directory references show file listings, not contents
- You can reference multiple files in a single message (e.g., “@file1.js and @file2.js”)
Use extended thinking
Suppose you’re working on complex architectural decisions, challenging bugs, or planning multi-step implementations that require deep reasoning.Provide context and ask Claude to think
Refine the thinking with follow-up prompts
- Planning complex architectural changes
- Debugging intricate issues
- Creating implementation plans for new features
- Understanding complex codebases
- Evaluating tradeoffs between different approaches
- “think” triggers basic extended thinking
- intensifying phrases such as “keep thinking”, “think more”, “think a lot”, or “think longer” triggers deeper thinking
Resume previous conversations
Suppose you’ve been working on a task with Claude Code and need to continue where you left off in a later session. Claude Code provides two options for resuming previous conversations:--continue
to automatically continue the most recent conversation--resume
to display a conversation picker
Continue the most recent conversation
Continue in non-interactive mode
--print
with --continue
to resume the most recent conversation in non-interactive mode, perfect for scripts or automation.Show conversation picker
- Conversation start time
- Initial prompt or conversation summary
- Message count
- Conversation history is stored locally on your machine
- Use
--continue
for quick access to your most recent conversation - Use
--resume
when you need to select a specific past conversation - When resuming, you’ll see the entire conversation history before continuing
- The resumed conversation starts with the same model and configuration as the original
- 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.Understand Git worktrees
Create a new worktree
Run Claude Code in each worktree
Run Claude in another worktree
Manage your worktrees
- 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:
- JavaScript projects: Running dependency installation (
npm install
,yarn
) - Python projects: Setting up virtual environments or installing with package managers
- Other languages: Following your project’s standard setup process
- JavaScript projects: Running dependency installation (
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:- 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
Pipe in, pipe out
Suppose you want to pipe data into Claude, and get back data in a structured format. Pipe data through Claude:- Use pipes to integrate Claude into existing shell scripts
- Combine with other Unix tools for powerful workflows
- Consider using —output-format for structured output
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
- 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
Create custom slash commands
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.Create project-specific commands
Suppose you want to create reusable slash commands for your project that all team members can use.Create a commands directory in your project
Create a Markdown file for each command
Use your custom command in Claude Code
- Command names are derived from the filename (e.g.,
optimize.md
becomes/optimize
) - You can organize commands in subdirectories (e.g.,
.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
Add command arguments with $ARGUMENTS
Suppose you want to create flexible slash commands that can accept additional input from users.Create a command file with the $ARGUMENTS placeholder
Use the command with an issue number
- 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
Create personal slash commands
Suppose you want to create personal slash commands that work across all your projects.Create a commands directory in your home folder
Create a Markdown file for each command
Use your personal custom command
- Personal commands show “(user)” in their description when listed with
/help
- Personal commands are only available to you and not shared with your team
- Personal commands work across all your projects
- You can use these for consistent workflows across different codebases
Ask Claude about its capabilities
Claude has built-in access to its documentation and can answer questions about its own features and limitations.Example questions
- 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