Real-World Workflows

TL;DR

Claude Code is most effective when you follow structured workflows. The key patterns: explore-plan-code-verify for features, TDD loop, PR review, codebase exploration, debugging, and multi-agent orchestration.

Explain Like I'm 12
Think of Claude Code workflows like a cookbook with recipes for common developer tasks. Instead of just winging it and hoping for the best, you follow a proven recipe — gather ingredients (explore), read the recipe (plan), cook (code), and taste-test (verify). Each recipe works best for a specific type of meal.

Workflow Overview (Visual)

This diagram shows the seven core workflows and when to use each one. Every workflow follows a similar rhythm: understand first, act second, verify last.

Diagram showing seven Claude Code workflows: Explore-Plan-Code-Verify, TDD, PR Review, Debugging, Codebase Exploration, Multi-Agent, and Refactoring

Workflow 1: Explore → Plan → Code → Verify

This is the default workflow for building new features. It is the most commonly used pattern and the one you should reach for first when you are unsure which workflow fits.

Why this order matters

If you skip straight to coding, Claude will make assumptions about your codebase that may be wrong. The explore step grounds Claude in reality. The plan step aligns you before any code is written. This prevents wasted work.

Step 1: Explore

Start by asking Claude to understand the relevant parts of your codebase. Do not tell it what to build yet. Let it read and learn.

# Start in plan mode to prevent premature coding
claude --plan

# Then ask Claude to explore
> Read the auth module in src/auth/ and explain how login currently works.
> What middleware runs before protected routes?

Step 2: Plan

Once Claude understands the codebase, ask it to create a plan. Review the plan before any code is written. This is your checkpoint.

> Now plan how to add OAuth2 support. List every file you'd change and why.
> Don't write code yet — just the plan.

Step 3: Code

After you approve the plan, let Claude implement it. Be specific about which part to start with.

> Good plan. Start with step 1: create the OAuth2 provider config file.

Step 4: Verify

After implementation, have Claude verify its own work. This catches mistakes before you commit.

> Run the existing auth tests. Do they still pass?
> Write a new test for the OAuth2 login flow.
Advertisement

Workflow 2: Test-Driven Development

Write the test first, then let Claude make it pass. This is the fastest way to get correct, well-tested code. Claude excels at implementing code to satisfy a spec.

Best for

Functions with clear inputs and outputs, utility libraries, data transformations, API endpoints with defined contracts.

The TDD Loop

# Step 1: You write the test (or ask Claude to write it from a spec)
> Write a test for a function that validates email addresses.
> It should accept "[email protected]" and reject "not-an-email".

# Step 2: Run the test — it should fail (red)
> Run the test. It should fail since we haven't implemented the function yet.

# Step 3: Let Claude implement until green
> Now implement validateEmail() to make the test pass.

# Step 4: Refactor if needed
> Clean up the implementation. Keep the tests passing.

The beauty of TDD with Claude is that the test acts as an unambiguous specification. Claude cannot misinterpret what you want when a failing test tells it exactly what "correct" means.

Workflow 3: PR Review

Use Claude to review pull requests before merging. It catches bugs, suggests improvements, and checks for consistency with the rest of the codebase.

Two ways to review

You can either pipe a PR diff to Claude as a one-shot command, or review interactively inside a session.

One-shot review

# Pipe the diff directly to Claude
gh pr diff 123 | claude -p "Review this PR for bugs, security issues,
  and style problems. Be specific about line numbers."

Interactive review

# Inside a Claude session
> Review the changes in this PR branch compared to main.
> Focus on: security issues, error handling, test coverage gaps.

# Follow up on specific findings
> Explain the race condition you found in more detail.
> How would you fix it?

Workflow 4: Debugging

When you hit a bug, Claude can read logs, trace execution paths, and propose targeted fixes. The key is giving Claude the right context upfront.

Common mistake

Do not just say "it's broken." Paste the exact error message, stack trace, or unexpected output. The more context you give, the faster Claude finds the root cause.

The Debugging Flow

# Step 1: Describe the bug with evidence
> I'm getting this error when I submit the login form:
> "TypeError: Cannot read property 'token' of undefined"
> at src/auth/login.ts:42

# Step 2: Let Claude investigate
> Read src/auth/login.ts and trace where the token should come from.
> Check the API response handling.

# Step 3: Apply the fix
> Fix the null check and add proper error handling for missing token.

# Step 4: Verify
> Write a test that reproduces this bug and confirm the fix resolves it.

Workflow 5: Codebase Exploration

When you join a new project or need to understand unfamiliar code, Claude can read, trace, and explain entire subsystems for you.

Pro tip

Start broad, then narrow down. Ask "how does authentication work?" before asking "what does line 42 do?" Claude builds a better mental model when it sees the big picture first.

# Broad exploration
> How is this project structured? What are the main modules?
> How does a request flow from the API endpoint to the database?

# Targeted deep-dive
> Explain the caching layer in src/cache/. When does it invalidate?
> What happens if Redis is down — is there a fallback?

# Architecture questions
> Draw the dependency graph between these modules.
> Which parts of the codebase would I need to change to add a new API endpoint?

This workflow turns Claude into a senior engineer who has read the entire codebase. The answers are grounded in actual code, not generic advice.

Workflow 6: Multi-Agent Orchestration

For large tasks, you can launch multiple Claude agents working in parallel. Each agent handles an independent piece of work, and you merge the results.

Use git worktrees for isolation

Each agent should work in its own git worktree so they do not conflict. Never run multiple agents on the same working directory — they will overwrite each other's changes.

Setting up parallel agents

# Create worktrees for each agent
git worktree add ../feature-auth feature-auth
git worktree add ../feature-dashboard feature-dashboard

# Launch agents in separate terminals
cd ../feature-auth && claude "Implement OAuth2 login flow"
cd ../feature-dashboard && claude "Build the analytics dashboard"

Headless mode for background tasks

# Launch a background agent using the SDK
claude -p "Refactor the logging module to use structured logs" \
  --output-format stream-json

Multi-agent works best when the tasks are truly independent. If agent B depends on agent A's output, run them sequentially instead.

Advertisement

Workflow 7: Refactoring

Refactoring with Claude follows a disciplined cycle: identify the scope, plan the changes, execute across files, and verify nothing broke.

Safety net first

Before any refactoring, make sure your test suite passes. If you do not have tests for the code you are refactoring, write them first. Claude is excellent at generating test scaffolding for existing code.

The Refactoring Cycle

# Step 1: Identify scope
> Which files use the old Logger class? List all imports and usages.

# Step 2: Plan changes
> Plan the migration from Logger to StructuredLogger.
> Show me every file that needs to change and what the change looks like.

# Step 3: Execute
> Start with src/utils/logger.ts — update the class definition first.
> Then update all import sites one module at a time.

# Step 4: Verify after each batch
> Run the full test suite. Are there any failures?
> Check for any remaining references to the old Logger class.

The key is to refactor in small, verifiable steps rather than changing everything at once. Claude can track which files are done and which remain.

Anti-patterns: What NOT to Do

These patterns lead to poor results. Recognizing them will save you time and frustration.

Avoid these mistakes

  • Vague prompts. "Fix everything" or "make it better" gives Claude no direction. Be specific about what you want and where.
  • Skipping plan mode for complex tasks. Jumping straight to code for a multi-file feature means Claude will make assumptions. Use --plan first.
  • Not verifying output. Claude can introduce subtle bugs. Always run tests and review diffs before accepting changes.
  • Over-delegating without context. Saying "build the entire payment system" with no context about your stack, constraints, or existing code will get generic results.
  • Ignoring the conversation window. Long conversations degrade quality. Use /compact or start fresh sessions for new tasks.
  • Copy-pasting error messages without the stack trace. The stack trace is the most valuable part. Always include it.

Test Yourself

Q: What are the four steps in the explore-plan-code-verify workflow?

Explore the codebase to understand context, Plan the changes before writing code, Code the implementation, and Verify by running tests. The key insight is that skipping the first two steps leads to incorrect assumptions and wasted work.

Q: In the TDD workflow, why does the test act as a better spec than a natural-language prompt?

A test defines exact inputs, expected outputs, and edge cases in executable code. Natural language is ambiguous — Claude might interpret "validate email" differently than you intend. A failing test removes all ambiguity: the code is correct when the test passes.

Q: Why should you use git worktrees when running multiple Claude agents in parallel?

Each agent needs its own isolated working directory. Without worktrees, multiple agents would edit the same files simultaneously, causing conflicts and overwritten changes. Git worktrees give each agent a separate checkout of the repo.

Q: What is the most common anti-pattern when debugging with Claude?

Giving vague bug descriptions like "it's broken" instead of providing the exact error message, stack trace, and steps to reproduce. The more context you give Claude, the faster it can identify the root cause.

Q: Before starting a refactoring workflow, what should you ensure exists first?

A passing test suite that covers the code you are about to refactor. Tests are your safety net — they confirm that your refactoring did not break existing behavior. If tests do not exist yet, write them before refactoring.

Interview Questions

Q: You are building a new feature that touches multiple modules in an unfamiliar codebase. Describe the workflow you would follow with an AI coding assistant like Claude Code.

Follow the explore-plan-code-verify pattern. First, ask Claude to read and explain the relevant modules so you understand the current architecture. Then have it create a detailed plan listing every file to change and why. Review the plan for correctness before any code is written. Implement the plan in small steps, and after each step, run the test suite to verify nothing is broken. This structured approach prevents the assistant from making wrong assumptions and lets you course-correct early.

Q: How does test-driven development change when you have an AI assistant that can write code? What are the benefits and risks?

Benefits: The TDD loop becomes faster because the AI can implement code to pass tests almost instantly. Tests serve as unambiguous specs that eliminate the misinterpretation problems of natural-language prompts. You also get built-in verification at every step. Risks: The AI might write code that passes the tests but uses poor patterns (overfitting to the test). You still need to review the implementation for readability, performance, and maintainability. Another risk is writing too few tests — if your spec is incomplete, the AI will produce incomplete code that technically passes.

Q: When would you choose to run multiple AI agents in parallel versus keeping everything in a single session? What isolation strategies are important?

Use parallel agents when the tasks are truly independent — they touch different files and do not depend on each other's output. Examples: building separate UI components, writing tests for different modules, migrating independent services. Keep tasks in a single session when there are dependencies between steps. For isolation, use git worktrees so each agent has its own working directory. Never run parallel agents on the same directory. After all agents finish, merge the branches and resolve any integration conflicts.