Claude Code Common Workflows
A curated playbook of prompt patterns, git commands, and parallel workflows for day-to-day software engineering. Whether you are navigating an unfamiliar monorepo, fixing a race condition, or automating PR generation, these recipes deliver verified outputs.
1. Understand Unfamiliar Codebases
When joining a new project or onboarding onto a legacy service, guide Claude from the macro architecture down to specific execution traces:
# 1. Macro architectural overview: give me an overview of this codebase and explain the core design patterns # 2. Domain data models: what are the primary data models and how do they map to our database schemas? # 3. Trace end-to-end execution: trace the user registration flow from the HTTP route in src/routes/auth.ts to the database insert2. Fix Bugs Efficiently with Stack Traces
Do not describe an error when you can hand Claude the exact failure. Pipe the test failure directly or state reproduction steps:
# In the interactive terminal: users report login fails after session timeout. Look at token refresh in src/auth/, write a failing unit test that reproduces the timeout condition, then fix the bug and verify all tests pass.Claude writes the reproduction test, sees it fail (red), updates the implementation logic, and re-executes the test until it passes (green).
3. Modernize & Refactor Legacy Code
Ask Claude to modernize deprecated APIs while strictly guaranteeing zero backward-breaking changes:
refactor src/utils/http.ts to use modern native fetch and async/await instead of axios, preserving the exact same return types and exported function signatures. Run the existing test suite to verify.4. Scaffold Comprehensive Test Suites
Claude inspects your existing test files to match frameworks (Jest, Vitest, Pytest, Go testing) and assertion styles:
# Identify untested surface area: find functions in src/services/billing.ts that lack test coverage # Scaffold unit and edge cases: add test cases for edge conditions in billing.ts: currency rounding, zero balance, and network timeout retries. Run the suite and fix any assertion errors.5. Referencing Files & Resources with @
Use @ to include file contents, directory listings, or MCP resources directly in your prompt without waiting for Claude to search:
Explain the query logic in @src/db/queries.tsWhat is the structure of @src/components/checkout?Fetch issue details from @github:repos/my-org/core-api/issues/402
6. Parallel Sessions with Git Worktrees
When working on multiple features or fixing bugs in parallel, avoid dirty working trees and git stash conflicts. Use Claude's native git worktree integration:
# In Terminal 1 (Feature work): claude --worktree feature-user-profiles # In Terminal 2 (Parallel bugfix): claude --worktree hotfix-cors-headersEach session runs in a separate git checkout with its own branch. When you exit an unnamed worktree session without uncommitted work, Claude Code automatically cleans it up.
.worktreeinclude file in your repository root listing gitignored files (like .env.local) that should be copied into each new worktree checkout.7. Pipe Claude into Headless Scripts & CI/CD
Claude Code functions as a Unix composable CLI using the -p (prompt) flag:
# Summarize recent git commits into release notes: git log --oneline -20 | claude -p "summarize these commits into user-facing release notes" # Batch migration script across files: for file in $(cat affected_files.txt); do claude --bare -p "Migrate $file to LoggerV2 API and commit" \ --allowedTools "Read,Edit,Bash(git add *),Bash(git commit *)" \ --permission-mode dontAsk \ --max-turns 15 done8. Create Formatted Pull Requests
Generate review-ready pull requests directly from your session:
summarize my recent changes and create a pull request with gh pr createTo resume a session associated with a pull request later, simply run:
claude --from-pr 1245