SpyBara
Go Premium

common-workflows.md 2026-01-07 21:01 UTC to 2026-01-08 21:02 UTC

3 added, 1 removed.

2026
Sat 31 03:42 Fri 30 18:07 Thu 29 21:03 Wed 28 15:06 Tue 27 21:01 Mon 26 21:03 Sun 25 03:34 Sat 24 03:29 Fri 23 21:01 Thu 22 21:03 Wed 21 21:05 Tue 20 21:03 Mon 19 21:01 Fri 16 21:01 Wed 14 06:02 Mon 12 21:02 Sun 11 18:02 Sat 10 21:01 Fri 9 21:01 Thu 8 21:02 Wed 7 21:01 Tue 6 21:01 Sat 3 18:02

Common workflows

Learn about common workflows with Claude Code.

Each task in this document includes clear instructions, example commands, and best practices to help you get the most from Claude Code.

Understand new codebases

Get a quick codebase overview

Suppose you've just joined a new project and need to understand its structure quickly.

1

Navigate to the project root directory

cd /path/to/project 
2

Start Claude Code

claude 
3

Ask for a high-level overview

> give me an overview of this codebase 
4

Dive deeper into specific components

> explain the main architecture patterns used here 
> what are the key data models?
> how is authentication handled?

Find relevant code

Suppose you need to locate code related to a specific feature or functionality.

1

Ask Claude to find relevant files

> find the files that handle user authentication 
2

Get context on how components interact

> how do these authentication files work together? 
3

Understand the execution flow

> trace the login process from front-end to database 

Fix bugs efficiently

Suppose you've encountered an error message and need to find and fix its source.

1

Share the error with Claude

> I'm seeing an error when I run npm test 
2

Ask for fix recommendations

> suggest a few ways to fix the @ts-ignore in user.ts 
3

Apply the fix

> update user.ts to add the null check you suggested 

Refactor code

Suppose you need to update old code to use modern patterns and practices.

1

Identify legacy code for refactoring

> find deprecated API usage in our codebase 
2

Get refactoring recommendations

> suggest how to refactor utils.js to use modern JavaScript features 
3

Apply the changes safely

> refactor utils.js to use ES2024 features while maintaining the same behavior 
4

Verify the refactoring

> run tests for the refactored code 

Use specialized subagents

Suppose you want to use specialized AI subagents to handle specific tasks more effectively.

1

View available subagents

> /agents

This shows all available subagents and lets you create new ones.

2

Use subagents automatically

Claude Code automatically delegates appropriate tasks to specialized subagents:

> review my recent code changes for security issues
> run all tests and fix any failures
3

Explicitly request specific subagents

> use the code-reviewer subagent to check the auth module
> have the debugger subagent investigate why users can't log in
4

Create custom subagents for your workflow

> /agents

Then select "Create New subagent" and follow the prompts to define:

  • 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.

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:

claude --permission-mode plan

Run "headless" queries in Plan Mode

You can also run a query in Plan Mode directly with -p (that is, in "headless mode"):

claude --permission-mode plan -p "Analyze the authentication system and suggest improvements"

Example: Planning a complex refactor

claude --permission-mode plan
> I need to refactor our authentication system to use OAuth2. Create a detailed migration plan.

Claude analyzes the current implementation and create a comprehensive plan. Refine with follow-ups:

> What about backward compatibility?
> How should we handle database migration?

Configure Plan Mode as default

// .claude/settings.json
{
  "permissions": {
    "defaultMode": "plan"
  }
}

See settings documentation for more configuration options.


Work with tests

Suppose you need to add tests for uncovered code.

1

Identify untested code

> find functions in NotificationsService.swift that are not covered by tests 
2

Generate test scaffolding

> add tests for the notification service 
3

Add meaningful test cases

> add test cases for edge conditions in the notification service 
4

Run and verify tests

> 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.


Create pull requests

Suppose you need to create a well-documented pull request for your changes.

1

Summarize your changes

> summarize the changes I've made to the authentication module 
2

Generate a pull request with Claude

> create a pr 
3

Review and refine

> enhance the PR description with more context about the security improvements 
4

Add testing details

> add information about how these changes were tested 

Handle documentation

Suppose you need to add or update documentation for your code.

1

Identify undocumented code

> find functions without proper JSDoc comments in the auth module 
2

Generate documentation

> add JSDoc comments to the undocumented functions in auth.js 
3

Review and enhance

> improve the generated documentation with more context and examples 
4

Verify documentation

> check if the documentation follows our project standards 

Work with images

Suppose you need to work with images in your codebase, and you want Claude's help analyzing image content.

1

Add an image to the conversation

You can use any of these methods:

  1. Drag and drop an image into the Claude Code window
  2. Copy an image and paste it into the CLI with ctrl+v (Do not use cmd+v)
  3. Provide an image path to Claude. E.g., "Analyze this image: /path/to/your/image.png"
2

Ask Claude to analyze the image

> What does this image show?
> Describe the UI elements in this screenshot
> Are there any problematic elements in this diagram?
3

Use images for context

> Here's a screenshot of the error. What's causing it?
> This is our current database schema. How should we modify it for the new feature?
4

Get code suggestions from visual content

> Generate CSS to match this design mockup
> What HTML structure would recreate this component?

Reference files and directories

Use @ to quickly include files or directories without waiting for Claude to read them.

1

Reference a single file

> Explain the logic in @src/utils/auth.js

This includes the full content of the file in the conversation.

2

Reference a directory

> What's the structure of @src/components?

This provides a directory listing with file information.

3

Reference MCP resources

> Show me the data from @github:repos/owner/repo/issues

This fetches data from connected MCP servers using the format @server:resource. See MCP resources for details.


Use extended thinking (thinking mode)

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.

You can configure thinking mode for Claude Code in several ways:

Scope How to enable Details
Toggle shortcut Press Option+T (macOS) or Alt+T (Windows/Linux) Toggle thinking on/off. May require terminal configuration to enable Option key shortcuts
Global default Use /config to toggle thinking mode on Sets your default across all projects.
Saved as alwaysThinkingEnabled in ~/.claude/settings.json
Environment variable override Set MAX_THINKING_TOKENS environment variable When set, applies a custom token budget to all requests, overriding your thinking mode configuration. Example: export MAX_THINKING_TOKENS=1024

Per-request thinking with ultrathink

You can include ultrathink as a keyword in your message to enable thinking for a single request:

> 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.

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

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

Custom token budgets:


Resume previous conversations

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.

Name your sessions

Give sessions descriptive names to find them later. This is a best practice when working on multiple tasks or features.

1

Name the current session

Use /rename during a session to give it a memorable name:

> /rename auth-refactor

You can also rename any session from the picker: run /resume, navigate to a session, and press R.

2

Resume by name later

From the command line:

claude --resume auth-refactor

Or from inside an active session:

> /resume auth-refactor

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:

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.


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

# Create a new worktree with a new branch 
git worktree add ../project-feature-a -b feature-a

# Or create a worktree with an existing branch
git 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

# Navigate to your worktree 
cd ../project-feature-a

# Run Claude Code in this isolated environment
claude
4

Run Claude in another worktree

cd ../project-bugfix
claude
5

Manage your worktrees

# List all worktrees
git worktree list

# Remove a worktree when done
git worktree remove ../project-feature-a

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:

// 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.'"
    }
}

Pipe in, pipe out

Suppose you want to pipe data into Claude, and get back data in a structured format.

Pipe data through Claude:

cat build-error.txt | claude -p 'concisely explain the root cause of this build error' > output.txt

Control output format

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)

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

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

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.


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.

1

Create a commands directory in your project

mkdir -p .claude/commands
2

Create a Markdown file for each command

echo "Analyze the performance of this code and suggest three specific optimizations:" > .claude/commands/optimize.md 
3

Use your custom command in Claude Code

> /optimize 

Add command arguments with $ARGUMENTS

Suppose you want to create flexible slash commands that can accept additional input from users.

1

Create a command file with the $ARGUMENTS placeholder

echo 'Find and fix issue #$ARGUMENTS. Follow these steps: 1.
Understand the issue described in the ticket 2. Locate the relevant code in
our codebase 3. Implement a solution that addresses the root cause 4. Add
appropriate 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.

> /fix-issue 123 

This replaces $ARGUMENTS with "123" in the prompt.

Create personal slash commands

Suppose you want to create personal slash commands that work across all your projects.

1

Create a commands directory in your home folder

mkdir -p ~/.claude/commands 
2

Create a Markdown file for each command

echo "Review this code for security vulnerabilities, focusing on:" >
~/.claude/commands/security-review.md 
3

Use your personal custom command

> /security-review 

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

> can Claude Code create pull requests?
> how does Claude Code handle permissions?
> what slash commands are available?
> how do I use MCP with Claude Code?
> how do I configure Claude Code for Amazon Bedrock?
> what are the limitations of Claude Code?

Next steps

code Claude Code reference implementation

Clone our development container reference implementation.


To find navigation and other pages in this documentation, fetch the llms.txt file at: https://code.claude.com/docs/llms.txt