Exploring an Unfamiliar Codebase1
> give me an overview of this codebase
> explain the main architecture patterns used here
> what are the key data models?
> how does authentication work?
Start broad, then narrow down. Claude reads files, follows imports, and builds up a mental model of the project. Use /compact focus on X afterward to re-focus context on a specific area.
Fixing Bugs
> the login form crashes when the email field is empty — find and fix the bug
> there's a race condition in the payment processing — investigate and fix it
Claude’s typical approach:
- Search for relevant files (Grep/Glob)
- Read context around the problem
- Identify root cause
- Implement the fix
- Run tests to verify
- Course-correct if tests still fail
For complex bugs, provide error messages, stack traces, or reproduction steps to help Claude narrow the search.
Writing Tests
> write unit tests for the UserService class
> add integration tests for the /api/orders endpoints
> the calculateDiscount function has no test coverage — add comprehensive tests
Claude reads the implementation, understands the behavior, and generates tests covering happy paths, edge cases, and error conditions.
Code Review
> review the changes in this PR
> /review
> review my changes and suggest improvements
Claude examines diffs, identifies potential issues (bugs, security vulnerabilities, style violations, performance concerns), and provides structured feedback.
Refactoring
> refactor the auth module to use the repository pattern
> extract the validation logic from the controller into a separate service
> rename getUserData to fetchUserProfile across the codebase
Claude handles multi-file refactors, updating imports, references, and tests consistently.
Git and PR Workflows
> commit these changes with a descriptive message
> create a PR for this feature branch
> look at the failing CI checks and fix them
Claude manages the full git lifecycle — staging, committing, branching, and PR creation via gh CLI2.
Multi-File Bulk Operations
> add TypeScript types to all the API route handlers
> migrate all class components to functional components with hooks
> update all imports to use the new module paths
Claude excels at repetitive changes that span many files, maintaining consistency across the codebase.
Piping and Scripting
Claude Code follows Unix philosophy3 — composable with pipes:
# Analyze logs
tail -f app.log | claude -p "alert me if you see any anomalies"
# Review changed files
git diff main --name-only | claude -p "review these changed files for security issues"
# Translate content
cat strings.en.json | claude -p "translate to French"
# Automate in CI
claude -p "translate new strings into French and raise a PR for review"Parallel Work with Sub-Agents
For large tasks, Claude can spawn sub-agents to work in parallel:
> refactor the entire API layer to use dependency injection
Claude may:
- Plan the approach in the main conversation
- Spawn sub-agents for independent modules
- Coordinate results back in the main context
You can also be explicit: “use a sub-agent to investigate the auth module while you work on the database layer.”
Tips for Effective Prompting4
- Be specific — “fix the bug in the login form” > “fix the bug”
- Provide context — mention file names, error messages, or stack traces
- State the goal — “I want users to reset their password via email” gives Claude room to design
- Iterate — start with a high-level request, then refine based on output
- Use CLAUDE.md — codify recurring instructions so you don’t repeat them
- Use
/compact— before shifting focus to a new area of the codebase - Use plan mode — for complex tasks, have Claude plan first, then execute
- Leverage skills — create reusable workflows for common tasks (deploy, review, etc.)
Footnotes
References
- Claude Code Documentation
- Claude Code CLI Usage
- Claude Code Best Practices
- Claude Code GitHub Action