This guide walks through the everyday prompt patterns Anthropic documents for Claude Code: getting an overview of an unfamiliar codebase, locating relevant files, fixing bugs from error messages, refactoring legacy code safely, adding tests for uncovered code, creating pull requests, and generating documentation. It also notes related workflows the docs cover, such as resuming sessions, running parallel sessions with worktrees, planning before edits, delegating research to subagents, and piping Claude into scripts.
Claude Code's official documentation collects short recipes for everyday development tasks. The prompt patterns below work in any Claude Code surface — adapt the wording to your own project. The docs also point to a separate Best practices page for higher-level guidance on prompting and context management.
How do I get an overview of a new codebase?
If you've just joined a project, start by navigating to the project root and launching Claude Code:
Then ask for a high-level overview:
give me an overview of this codebase
From there, dive deeper into specific components:
explain the main architecture patterns used here
what are the key data models?
how is authentication handled?
The docs suggest starting with broad questions, then narrowing down to specific areas. You can also ask about coding conventions used in the project or request a glossary of project-specific terms. For monorepos and large codebases, there's a dedicated docs page on configuration.
Ask Claude to locate relevant files, then build context step by step:
find the files that handle user authentication
how do these authentication files work together?
trace the login process from front-end to database
Be specific about what you're looking for and use domain language from the project. The docs also recommend installing a code intelligence plugin for your language to give Claude precise "go to definition" and "find references" navigation.
How do I fix a bug with Claude Code?
When you hit an error, share it with Claude, ask for fix recommendations, then apply the fix:
I'm seeing an error when I run npm test
suggest a few ways to fix the @ts-ignore in user.ts
update user.ts to add the null check you suggested
Tips from the docs: tell Claude the command to reproduce the issue so it can get a stack trace, mention any reproduction steps, and say whether the error is intermittent or consistent.
How do I refactor legacy code safely?
The documented flow moves from identification to verification:
find deprecated API usage in our codebase
suggest how to refactor utils.js to use modern JavaScript features
refactor utils.js to use ES2024 features while maintaining the same behavior
run tests for the refactored code
The docs advise doing refactoring in small, testable increments, asking Claude to explain the benefits of the modern approach, and requesting backward compatibility when needed. For porting an entire codebase to a new language, Anthropic has a blog post on running large-scale code migrations with Claude Code.
How do I add tests for uncovered code?
Start by identifying gaps, then generate and verify tests:
find functions in NotificationsService.swift that are not covered by tests
add tests for the notification service
add test cases for edge conditions in the notification service
run the new tests and fix any failures
Claude examines your existing test files to match the style, frameworks, and assertion patterns already in use, so be specific about what behavior you want to verify. For broader coverage, ask Claude to identify edge cases you might have missed — it can suggest tests for error conditions, boundary values, and unexpected inputs.
How do I create a pull request with Claude Code?
You can simply ask Claude directly ("create a pr for my changes"), or guide it step-by-step:
summarize the changes I've made to the authentication module
enhance the PR description with more context about the security improvements
When a PR is created using gh pr create, the session is automatically linked to that PR. To find it later, run claude --from-pr 1234 with your own PR number — this opens the session picker filtered to sessions linked to that PR. You can also paste the PR URL into the /resume picker search. The docs recommend reviewing Claude's generated PR before submitting and asking Claude to highlight potential risks or considerations.
How do I generate documentation for my code?
Start by finding what's undocumented, then generate docs:
find functions without proper JSDoc comments in the auth module
add JSDoc comments to the undocumented functions in auth.js
What other workflows does this docs page cover?
Beyond prompt recipes, the same documentation page covers several session-level workflows:
- 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
See the full page at Anthropic's documentation for details on each of these.
claudedetails.com is an independent publication and is not affiliated with or endorsed by Anthropic.
claudedetails.com is an independent publication and is not affiliated with, endorsed by, or sponsored by Anthropic. "Claude" is a trademark of Anthropic, PBC, used here for identification purposes only. Product details can change — always confirm specifics on Anthropic's own site before making decisions based on this post.