Claude Code Practical Scenarios and Workflows
These are the most common and practical Claude Code workflows, covering everyday tasks like taking over a new project, fixing bugs, refactoring, adding tests, and writing documentation.
Common Workflows
- Understanding a new codebase: after entering the project directory, run
claudeand start by asking "Give me an overview of the codebase", "Explain the main architectural patterns", or "What are the key data models". - Fixing bugs efficiently: paste the full error and reproduction steps directly, e.g. "I'm seeing this error when running npm test — please help me find and fix the problem".
- Refactoring: first have Claude locate legacy APIs or duplicated logic, then explicitly ask it to refactor while "keeping the existing behavior unchanged".
- Handling tests: have Claude identify uncovered code first, then add tests and edge cases, and finally run the tests to verify.
- Creating a Pull Request: summarize the changes first, then ask for a PR title, summary, and test notes, adding security notes when necessary.
- Handling documentation: ask Claude to find functions missing comments and add JSDoc, README snippets, or migration notes.
- Using images: drag and drop screenshots, design mockups, or error images — great for debugging UI issues and reproducing visual designs.
- Setting up project memory: use
/initto generateCLAUDE.md, recording common commands, architectural conventions, and coding standards. - Unix pipe integration: use
claude -pto consume logs, build output, and diffs — well suited for scripting and CI pipelines. - MCP server configuration: use
claude mcp add/list/get/removeto manage external capability extensions.
MCP Server Configuration Example
bash
claude mcp add my-server -e API_KEY=123 -- /path/to/server
claude mcp list
claude mcp get my-server
claude mcp remove my-serverPipe Integration Example
bash
cat build-error.txt | claude -p "concisely explain the root cause of this build error" > output.txt