Common workflows - Claude Code Docs
Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. 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. 1 Navigate to the project root directory cd /path/to/project Replace /path/to/project with the path to your 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? Tips: 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.
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 Tips: Be specific about what you’re looking for Use domain language from the project Install a code intelligence plugin for your language to give Claude precise “go to definition” and “find references” navigation 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 Tips: 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.
For porting an entire codebase to a new language, see how Anthropic runs large-scale code migrations with Claude Code on the blog. 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 Tips: Ask Claude to explain the benefits of the modern approach Request that changes maintain backward compatibility when needed Do refactoring in small, testable increments 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. To improve 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 often overlooked. 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: 1 Summarize your changes summarize the changes I've made to the authentication module 2 Generate a pull request create a pr 3 Review and refine 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 . Review Claude’s generated PR before submitting and ask Claude to highlight potential risks or considerations. 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 Tips: 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 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.
1 Add an image to the conversation You can use any of these methods: Drag and drop an image into the Claude Code window Copy an image and paste it into the CLI with Ctrl+V , or with Alt+V on Windows and WSL Provide an image path to Claude, for example “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? Tips: 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 When Claude references images (for example, [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.
1 Reference a single file Explain the logic in @src/utils/auth.js This includes the content of the file in the conversation when it fits the Read tool ’s token limit, 25,000 tok
The rest of this page is on the live site.