使用指南:常用工作流
Common workflows
Step-by-step guides for exploring codebases, fixing bugs, refactoring, testing, and other everyday tasks with Claude Code.
This page collects short recipes for everyday development. For higher-level guidance on prompting and context management, see Best practices.
This page covers:
- Prompt recipes for exploring code, fixing bugs, refactoring, testing, PRs, and documentation
- Resume previous conversations so a task can span multiple sittings
- Run parallel sessions with worktrees so concurrent edits don’t collide
- Plan before editing to review changes before they touch disk
- Delegate research to subagents to keep your main context clean
- Pipe Claude into scripts for CI and batch processing
Prompt recipes
These are prompt patterns for everyday tasks like exploring unfamiliar code, debugging, refactoring, writing tests, and creating PRs. Each works in any Claude Code surface; adapt the wording to your project.
Understand new codebases
For configuring Claude Code in a monorepo or large codebase, see Monorepos and large repos.
Get a quick codebase overview
Suppose you’ve just joined a new project and need to understand its structure quickly.
bash theme={null}
cd /path/to/project
Replace /path/to/project with the path to your project.
bash theme={null}
claude
text wrap theme={null}
give me an overview of this codebase
text wrap theme={null}
explain the main architecture patterns used here
text wrap theme={null}
what are the key data models?
text wrap theme={null}
how is authentication handled?
Find relevant code
Suppose you need to locate code related to a specific feature or functionality.
text wrap theme={null}
find the files that handle user authentication
text wrap theme={null}
how do these authentication files work together?
text wrap theme={null}
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.
text wrap theme={null}
I'm seeing an error when I run npm test
text wrap theme={null}
suggest a few ways to fix the @ts-ignore in user.ts
text wrap theme={null}
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.
For porting an entire codebase to a new language, see how Anthropic runs large-scale code migrations with Claude Code on the blog.
text wrap theme={null}
find deprecated API usage in our codebase
text wrap theme={null}
suggest how to refactor utils.js to use modern JavaScript features
text wrap theme={null}
refactor utils.js to use ES2024 features while maintaining the same behavior
text wrap theme={null}
run tests for the refactored code
Work with tests
Suppose you need to add tests for uncovered code.
text wrap theme={null}
find functions in NotificationsService.swift that are not covered by tests
text wrap theme={null}
add tests for the notification service
text wrap theme={null}
add test cases for edge conditions in the notification service
text wrap theme={null}
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
You can create pull requests by asking Claude directly (“create a pr for my changes”), or guide Claude through it step-by-step:
text wrap theme={null}
summarize the changes I've made to the authentication module
text wrap theme={null}
create a pr
text wrap theme={null}
enhance the PR description with more context about the security improvements
To find the session later, run claude --from-pr 1234 with your own PR number, which opens the session picker filtered to sessions linked to that PR, or paste the PR URL into the /resume picker search. Claude Code links the session to the PR when Claude creates it with gh pr create or glab mr create, and when Claude works on an existing PR.
Handle documentation
Suppose you need to add or update documentation for your code.
text wrap theme={null}
find functions without proper JSDoc comments in the auth module
text wrap theme={null}
add JSDoc comments to the undocumented functions in auth.js
text wrap theme={null}
improve the generated documentation with more context and examples
text wrap theme={null}
check if the documentation follows our project standards
Work in notes and non-code folders
Claude Code works in any directory. Run it inside a notes vault, a documentation folder, or any collection of markdown files to search, edit, and reorganize content the same way you would code.
The .claude/ directory and CLAUDE.md sit alongside other tools’ config directories without conflict. Claude reads files fresh on each tool call, so it sees edits you make in another application the next time it reads that file.
Work with images
Suppose you need to work with images in your codebase, and you want Claude’s help analyzing image content.
Ctrl+V, or with Alt+V on Windows and WSL
3. Provide an image path to Claude, for example “Analyze this image: /path/to/your/image.png”
text wrap theme={null}
What does this image show?
text wrap theme={null}
Describe the UI elements in this screenshot
text wrap theme={null}
Are there any problematic elements in this diagram?
text wrap theme={null}
Here's a screenshot of the error. What's causing it?
text wrap theme={null}
This is our current database schema. How should we modify it for the new feature?
text wrap theme={null}
Generate CSS to match this design mockup
text wrap theme={null}
What HTML structure would recreate this component?
[Image #1]), Cmd+Click (Mac) or Ctrl+Click (Windows/Linux) the link to open the image in your default viewer
Reference files and directories
Use @ to quickly include files or directories without waiting for Claude to read them.
text wrap theme={null}
Explain the logic in @src/utils/auth.js
This includes the full content of the file in the conversation.
text wrap theme={null}
What's the structure of @src/components?
text wrap theme={null}
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.
@ to open a path suggestion menu, then press Enter or Tab to accept the highlighted path and Enter again to send the message
@ 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 (for example, “@file1.js and @file2.js”)
Run Claude on a schedule
Suppose you want Claude to handle a task automatically on a recurring basis, like reviewing open PRs every morning, auditing dependencies weekly, or checking for CI failures overnight.
Pick a scheduling option based on where you want the task to run:
| Option | Where it runs | Best for |
|---|---|---|
| Routines | Cloud, Anthropic-managed by default | Tasks that should run even when your computer is off. Can also trigger on API calls or GitHub events in addition to a schedule. Configure at claude.ai/code/routines. |
| Desktop scheduled tasks | Your machine, via the desktop app | Tasks that need direct access to local files, tools, or uncommitted changes. |
| GitHub Actions | Your CI pipeline | Tasks tied to repo events like opened PRs, or cron schedules that should live alongside your workflow config. |
/loop |
The current CLI session | Quick polling while a session is open. --resume and --continue restore unexpired fixed-interval loops. |
needs-review, leave inline comments on any issues, and post a summary in the #eng-reviews Slack channel.”
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
```text wrap theme={null} can Claude Code create pull requests?
```text wrap theme={null}
how does Claude Code handle permissions?
```text wrap theme={null} what skills are available?
```text wrap theme={null}
how do I use MCP with Claude Code?
```text wrap theme={null} how do I configure Claude Code for Amazon Bedrock?
```text wrap theme={null}
what are the limitations of Claude Code?
/powerup for interactive lessons with animated demos, or refer to the specific workflow sections above.
Resume previous conversations
When a task spans multiple sittings, pick up where you left off instead of re-explaining context. Claude Code saves every conversation locally.
```bash theme={null} claude —continue
This resumes the most recent session in the current directory; if there isn't one yet, it prints `No conversation found to continue` and exits. Use `claude --resume` to choose from a list, or `/resume` from inside a running session. See [Manage sessions](/docs/en/sessions) for naming, branching, and the full picker reference.
## Run parallel sessions with worktrees
Work on a feature in one terminal while Claude fixes a bug in another, without the edits colliding. Each [git worktree](https://git-scm.com/docs/git-worktree) is a separate checkout on its own branch, created from an existing commit, so the repository needs at least one commit first.
```bash theme={null}
claude --worktree feature-auth
Run the same command with a different name in a second terminal to start an isolated parallel session. In a repository with no commits, the command fails with Failed to resolve base branch "HEAD": git rev-parse failed. See Worktrees for cleanup, .worktreeinclude, and non-git VCS support. To monitor parallel sessions from one screen instead of separate terminals, see background agents.
Plan before editing
For changes you want to review before they touch disk, switch to plan mode. Claude reads files and proposes a plan but makes no edits until you approve. The status bar shows ⏸ plan mode on while plan mode is active.
```bash theme={null} claude —permission-mode plan
You can also press `Shift+Tab` mid-session until the status bar shows `⏸ plan mode on`. See [Plan mode](/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) for the approval flow and editing the plan in your text editor.
## Delegate research to subagents
Exploring a large codebase fills your context with file reads. Delegate the exploration so only the findings come back.
```text wrap theme={null}
use a subagent to investigate how our auth system handles token refresh
The subagent reads files in its own context window and reports a summary. See Subagents for defining custom agents with their own tools and prompts.
Pipe Claude into scripts
Run Claude non-interactively for CI, pre-commit hooks, or batch processing. Stdin and stdout work like any Unix tool.
bash theme={null}
git log --oneline -20 | claude -p "summarize these recent commits"
See Non-interactive mode for output formats, permission flags, and fan-out patterns.
