Claude Code workflows

Useful Claude Code work is usually a sequence: understand the repository, define a bounded change, implement it, verify it, and review the result. Skipping those steps is what turns agent work into unreviewable output.

Last verified
Applies to
Claude Code 2.1.x. CLI spellings were checked on local version 2.1.198; current official docs may describe newer 2.1.x behavior.
Verification method
Official documentation, CLI reference, and changelog reviewed on 2026-07-19. The workflow sequence is editorial synthesis; Claude commands are documented, while project commands and outcomes must be verified in each repository.
Official sources
Common workflowsCLI referenceChangelog

Reproducible practice

Diagnose and fix one failing test without scope drift

Separate reproduction, localization, implementation, and regression review so a plausible patch is not confused with a verified fix.

Prerequisites

  • A reproducible failing command and the first actionable error.
  • A known baseline git state and permission to edit the affected area.
  • A rollback path such as a task branch or reviewed working-tree diff.

Steps

  1. Reproduce before prompting

    Capture the exact command and smallest stable error excerpt; redact secrets and personal data.

    Step 1
    # Run the repository-specific failing test
    git status --short
  2. Localize in plan mode

    Ask for the failure path, candidate files, competing hypotheses, and a narrow validation plan.

    Step 2
    claude --permission-mode plan
  3. Implement one hypothesis

    Allow edits only after the plan identifies why the observed failure should change. Avoid opportunistic refactors.

  4. Run the evidence ladder

    Run the original failing check first, then adjacent tests, then the broader project gate.

    Step 4
    # 1. Original failing command
    # 2. Adjacent test group
    # 3. Project lint, typecheck, or build
    git diff --check

Expected result

The original failure is no longer reproducible, adjacent behavior remains intact, and the diff contains only evidence-supported changes.

Validation

  • The original command must pass, not merely a newly added test.
  • Review the diff for unrelated formatting, dependency, and generated-file changes.
  • Document any broader gate that could not run and why.

Failure handling

Failure is flaky

Repeat the baseline and record conditions; do not claim a fix from one green run.

Hypothesis fails

Revert only that experiment, retain the evidence, and test the next hypothesis instead of stacking patches.

Cleanup or rollback

  • Use the reviewed diff or task branch to remove only the failed experiment.
  • Restore generated files with their owning generator, not by hand.

Boundaries and when not to use it

  • This workflow is not enough for destructive migrations, incident response, or changes requiring external production verification.
  • A passing local test does not prove deployment, permissions, network, or data-dependent behavior.

Explore before editing

Start by asking Claude Code to map the relevant files, entry points, tests, and build commands. This lowers the chance that it edits the wrong layer or creates a duplicate implementation.

Plan high-impact changes

For migrations, shared components, security-sensitive code, or broad refactors, require a plan before edits. A good plan names files, verification commands, and risks.

Verify with project commands

Verification should use the repository's own tools: type checks, lint, unit tests, integration tests, browser checks, or targeted manual QA. A summary without commands is weaker evidence.

Review and package the result

Ask for a diff summary, known limitations, and follow-up risks. When using git or pull requests, keep the commit message tied to the tested behavior rather than the conversation history.

Example workflow prompt
claude "Map the auth flow files, propose a plan, implement the fix, run pnpm test auth, then summarize the diff and remaining risks."

Workflow patterns by task type

Different tasks benefit from different sequences. Bug fixes need reproduction and regression checks; refactors need boundary definition; features need acceptance criteria.

Bug fix

Reproduce the failure, inspect the first actionable error, patch narrowly, then rerun the failing test and one related suite.

Read guide

Refactor

Define the module boundary, require a plan, keep behavior stable, and verify with type checks plus targeted tests.

Read guide

Feature work

State acceptance criteria, identify affected files, implement in small steps, and verify with build plus manual or browser checks.

Read guide

Workflow checklist

Related topics