> ## Documentation Index
> Fetch the complete documentation index at: https://agentic.proxify.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Patterns

> Proven patterns for working with Claude Code on real engineering tasks.

<Note>**You'll learn:** six workflow patterns for common engineering tasks — when to reach for each and the prompts that make them work.</Note>

## Quick Reference

| Pattern                                 | Best for                                         | Key benefit                                          |
| --------------------------------------- | ------------------------------------------------ | ---------------------------------------------------- |
| [Plan-Then-Execute](#plan-then-execute) | Features touching multiple files                 | Catches wrong assumptions before any code is written |
| [TDD Loop](#tdd-loop)                   | Utility functions, API endpoints, business logic | Tests drive correct behavior                         |
| [Bug Fix Cycle](#bug-fix-cycle)         | Any bug with an error message                    | Diagnoses root cause, not just the symptom           |
| [Refactor Cycle](#refactor-cycle)       | Code reorganization, extracting modules          | Safe and incremental with a green-test safety net    |
| [Code Review](#code-review-workflow)    | Before every PR                                  | Surfaces edge cases and security issues              |
| [Exploration](#exploration-pattern)     | New codebase or unfamiliar module                | Builds mental model before making changes            |

***

## Plan-Then-Execute

The most reliable pattern for non-trivial work. Separates thinking from doing.

<Steps>
  <Step title="Ask Claude to plan">
    "I need to add user authentication. Plan the implementation — what files to change, what approach to take, what to watch out for."
  </Step>

  <Step title="Review the plan">
    Read it, push back, ask questions. This is where you catch wrong assumptions.
  </Step>

  <Step title="Execute step by step">
    "Let's start with step 1." Review each change before moving on.
  </Step>
</Steps>

**When to use:** Features that touch multiple files, refactors, anything where a wrong first step is expensive to undo.

<Tip>Use `/plan` mode to enforce this — it prevents edits until you approve the plan. For complex features, write a lightweight PRD first (mission, in-scope, out-of-scope, architecture) to anchor the session and prevent scope creep across multiple planning rounds.</Tip>

***

## TDD Loop

Let tests drive the implementation. Claude is very effective at this pattern.

<Steps>
  <Step title="Write the test first">
    "Write a test for a function that calculates shipping cost based on weight and destination."
  </Step>

  <Step title="Run the test">
    "Run the tests — it should fail."
  </Step>

  <Step title="Implement">
    "Now implement the function to make the test pass."
  </Step>

  <Step title="Refactor">
    "Clean up the implementation while keeping tests green."
  </Step>
</Steps>

**When to use:** Well-defined behavior, utility functions, API endpoints, business logic.

***

## Bug Fix Cycle

A structured approach to debugging with Claude.

<Steps>
  <Step title="Reproduce">
    "Here's the error I'm seeing: \[paste error]. Help me understand what's happening."
  </Step>

  <Step title="Diagnose">
    Let Claude read the relevant code and trace the issue.
  </Step>

  <Step title="Fix">
    "Fix the root cause, not just the symptom."
  </Step>

  <Step title="Verify">
    "Run the tests. Add a regression test for this bug."
  </Step>
</Steps>

**When to use:** Any bug. The key is giving Claude the actual error output and letting it trace the cause rather than guessing.

***

## Refactor Cycle

Safe, incremental refactoring with a safety net.

<Steps>
  <Step title="Ensure tests pass">
    "Run all tests first — we need a green baseline."
  </Step>

  <Step title="Describe the goal">
    "I want to extract the payment logic from the order controller into its own service."
  </Step>

  <Step title="Incremental changes">
    Claude moves code, updates imports, adjusts tests — one logical step at a time.
  </Step>

  <Step title="Verify after each step">
    Tests should stay green throughout.
  </Step>
</Steps>

**When to use:** Code reorganization, extracting modules, renaming across the codebase.

***

## Code Review Workflow

Use Claude as a thorough reviewer before opening a PR.

<Steps>
  <Step title="Ask for review">
    "Review the changes in this branch compared to main. Focus on correctness, edge cases, and security."
  </Step>

  <Step title="Address feedback">
    Work through issues one by one.
  </Step>

  <Step title="Final check">
    "Any remaining concerns before I open the PR?"
  </Step>
</Steps>

**When to use:** Before every PR, especially for critical paths.

***

## Exploration Pattern

When you're new to a codebase or unfamiliar module.

<Steps>
  <Step title="Start broad">
    "Explain the architecture of this project. What are the main modules and how do they connect?"
  </Step>

  <Step title="Go deep">
    "How does the authentication flow work end to end?"
  </Step>

  <Step title="Build context">
    "What would I need to change to add OAuth support?"
  </Step>
</Steps>

**When to use:** Onboarding to a new repo, understanding unfamiliar code before making changes.

***

## General Tips

* **Be specific about what you want.** "Fix the bug" is worse than "The signup form throws a 500 when the email contains a plus sign."
* **Share error output.** Paste the actual error, stack trace, or unexpected behavior.
* **Review diffs, not just the outcome.** Claude may change more than necessary — check what actually changed.
* **Use `/compact` between tasks.** Frees context for the next piece of work.
* **Don't fight the agent.** If Claude is going in circles, step back and reframe the task rather than repeating the same instruction.

<Tip>**Want more?** — The official docs have a broader set of [common workflows](https://code.claude.com/docs/en/common-workflows) covering PR creation, CI integration, and more.</Tip>

***
