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.
| Phase | Main question | Claude should edit files? |
|---|---|---|
| Explore | What exists now? | No |
| Plan | What is the smallest safe change? | No |
| Code | Which approved step should be implemented? | Yes, narrowly |
| Verify | Did the project prove the change works? | Maybe, only related fixes |
| Handoff | What 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 point | Best use |
|---|---|
Shift+Tab | Switch an active CLI session into Plan Mode before more edits. |
/plan | Make one prompt planning-only, especially after exploration. |
| CLI startup flag | Start a sensitive session with claude --permission-mode plan. |
| Project default | Set permissions.defaultMode to plan for a cautious repo. |
A good plan should include:
| Section | What to expect |
|---|---|
| Scope | What will change and what will not change. |
| Steps | Small implementation units in order. |
| Tests | Exact commands or manual checks. |
| Risks | Data, auth, performance, compatibility, or UX risks. |
| Rollback | How 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 type | Useful checks |
|---|---|
| UI component | Component tests, local browser preview, responsive check. |
| API route | Unit tests, integration tests, request examples. |
| Auth or payment | Existing regression tests, manual flow, permission review. |
| Content or docs | Build, route status, metadata, internal links. |
| Database | Migration 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
| Mistake | Fix |
|---|---|
| Starting with "build this feature" | Start with a file map and current behavior. |
| Planning without tests | Require exact verification commands. |
| Approving the whole plan at once | Approve one implementation step at a time. |
| Letting Claude refactor nearby code | Restate scope and reject optional cleanup. |
| Continuing after assumptions change | Return 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.Related Pages
- Plan Mode workflow
- Direction correction
- Context management
- Architecture analysis
- Test-driven development
Official Sources
Next: Test-Driven Development - Add tests as part of the verification phase.