Workflows

Explore-Plan-Code Workflow

Use the Explore-Plan-Code workflow in Claude Code to inspect a codebase, approve a plan, implement safely, verify results, and avoid task drift.

Explore-Plan-Code is a practical Claude Code workflow for most non-trivial development tasks. It separates discovery, planning, implementation, and verification so Claude does not start editing before it understands the project.

Quick Answer

Use Explore-Plan-Code when a task touches more than one file, an unfamiliar module, or anything risky like auth, billing, database, deployment, MCP, or shared architecture.

PhaseMain questionClaude should edit files?
ExploreWhat exists now?No
PlanWhat is the smallest safe change?No
CodeWhich approved step should be implemented?Yes, narrowly
VerifyDid the project prove the change works?Maybe, only related fixes
HandoffWhat changed and what risk remains?No

Phase 1: Explore

The first job is to map the relevant files and behavior:

Find the files involved in user search. Explain the route, UI components, data fetching, server validation, tests, and risky assumptions. Do not edit files.

Good exploration returns:

  • Relevant files and why they matter.
  • Current data flow.
  • Existing conventions to follow.
  • Commands that appear to validate this area.
  • Unknowns that need user confirmation.

Phase 2: Plan

Ask for a reviewable plan, not a vague intention:

/plan Based on the file map, propose the smallest safe plan to add user search. Include affected files, implementation order, tests, rollback steps, and open questions.

There are four practical ways to enter Plan Mode:

Entry pointBest use
Shift+TabSwitch an active CLI session into Plan Mode before more edits.
/planMake one prompt planning-only, especially after exploration.
CLI startup flagStart a sensitive session with claude --permission-mode plan.
Project defaultSet permissions.defaultMode to plan for a cautious repo.

A good plan should include:

SectionWhat to expect
ScopeWhat will change and what will not change.
StepsSmall implementation units in order.
TestsExact commands or manual checks.
RisksData, auth, performance, compatibility, or UX risks.
RollbackHow to undo the change safely.

When Claude Code presents a plan, treat approval as a mode switch. Approving the plan exits Plan Mode and starts implementation in the permission mode you choose, such as auto, accept edits, or manual review. If the plan is too broad, keep planning with feedback instead of approving it.

Phase 3: Code

Approve one step at a time:

Implement step 1 only. Keep the diff small. Do not touch the UI yet. After editing, show the changed files and run the relevant test command.

Keep implementation narrow:

  • One module or step per approval.
  • No opportunistic refactors.
  • No new dependencies unless the plan justified them.
  • No unrelated cleanup.
  • Pause when the plan no longer matches the code.

Phase 4: Verify

Ask Claude Code to use the project's own checks:

Run the existing tests for user search and the production build. If something fails, explain whether it is related before fixing it.

Verification can include:

Change typeUseful checks
UI componentComponent tests, local browser preview, responsive check.
API routeUnit tests, integration tests, request examples.
Auth or paymentExisting regression tests, manual flow, permission review.
Content or docsBuild, route status, metadata, internal links.
DatabaseMigration dry run, rollback plan, affected table review.

Phase 5: Handoff

End with a short summary that another developer can trust:

Summarize changed files, behavior changes, validation results, and remaining risks. Keep it concise and include commands that were run.

For long sessions, use /compact or write a handoff before switching tasks.

Common Mistakes

MistakeFix
Starting with "build this feature"Start with a file map and current behavior.
Planning without testsRequire exact verification commands.
Approving the whole plan at onceApprove one implementation step at a time.
Letting Claude refactor nearby codeRestate scope and reject optional cleanup.
Continuing after assumptions changeReturn to Plan Mode and update the plan.

Prompt Templates

Feature Work

Explore the current onboarding flow. Do not edit files. Return the relevant files, data flow, existing validation, and smallest safe path to add a company-name step.

Bug Fix

Reproduce the likely cause of this bug from the code. Do not edit files. Identify the affected files, root-cause hypothesis, and one minimal fix.

Refactor

/plan Analyze this refactor first. Separate behavior-preserving changes from behavior-changing changes, list tests, and propose rollback steps.

Official Sources


Next: Test-Driven Development - Add tests as part of the verification phase.