Three-Phase Workflow
Configuring Claude Code to follow a “Research → Plan → Implement” process is the single most impactful change you can make to improve code quality and reduce rework.
Part 1: Why You Need to Define a Workflow
The Problem Without a Workflow
Without a workflow defined in CLAUDE.md, Claude’s default behavior is to start writing code as soon as it receives a requirement.
No Workflow
User: “Add user registration”
↓
Claude: Starts writing code immediately…
↓
Problem 1: Didn’t check the existing auth module
Problem 2: Used an incompatible validation library
Problem 3: Missed the email verification requirement
↓
Start over from scratch
With Workflow
User: “Add user registration”
↓
Claude: Searches existing code first…
Claude: Finds the existing auth module
Claude: Proposes an extension plan
Claude: Lists questions that need confirmation
↓
User: Confirms the plan
↓
High-quality delivery
Typical Problem Scenarios
| Scenario | Without Workflow | With Workflow |
|---|---|---|
| Misunderstood requirements | Discovered only after writing | Caught and confirmed in the planning phase |
| Missed existing code | Reinventing the wheel | Reuse opportunities found in the research phase |
| Flawed approach | Problems only visible after implementation | Risks identified in the planning phase |
| Wrong tech choice | Used an incompatible library | Tech stack confirmed in the research phase |
The core value of a workflow: Move problem discovery earlier. Catching problems during research and planning costs almost nothing to fix; catching them after implementation may require starting over.
Part 2: The Three-Phase Workflow Explained
2.1 Research Phase (RESEARCH)
Goal: Understand the current state, avoid reinventing the wheel, and ensure the plan is based on solid information.
Configuration example:
## Core Workflow
### 1. Research Phase (RESEARCH)
**Must do before starting any task:**
- Use Glob to search for related files: `*.ts`, `*.tsx`, `*.service.ts`, etc.
- Use Grep to search for keywords: function names, class names, related business terms
- Check the codebase for similar existing implementations
- Read READMEs or comments in related modules
- Understand the project's architecture and dependencies
**Search online when uncertain:**
- Best practices for new technologies/frameworks
- Latest API docs for specific libraries
- Solutions for error messagesKey point: Don’t rush to start coding in the research phase. Spending 2 minutes searching existing code can save 2 hours of redundant development.
2.2 Plan Phase (PLAN)
Goal: Define the implementation approach clearly, get user confirmation, and avoid going in the wrong direction.
Configuration example:
### 2. Plan Phase (PLAN)
**Must output the following:**
1. **File list**: All files to be modified or created
2. **Implementation approach**: Key steps and rationale for technology choices
3. **Risk identification**: Potential issues and edge cases
4. **Questions to confirm**: Items that need clarification from the user
**Important: Do not start coding until the user confirms**
- Only proceed to implementation if the user says "go ahead", "start", "OK", etc.
- If the plan has significant changes, request confirmation again
- Do not assume consent — wait for an explicit confirmation signalThe most important rule: Do not start coding until the user confirms. This is the critical checkpoint of the entire workflow — it prevents enormous amounts of wasted effort.
2.3 Implement Phase (IMPLEMENT)
Goal: High-quality delivery — code that meets standards and is verified.
Configuration example:
### 3. Implement Phase (IMPLEMENT)
**Coding requirements:**
- Follow the project's existing code style (naming, indentation, organization)
- Complete error handling (never skip)
- Write tests alongside the implementation
- Add comments where needed (complex logic, key decisions)
**Must run after completion:**
- Linter: zero warnings, zero errors
- Formatter: consistent code format
- Type check: type-safe
- Tests: all passing
**Never allowed:**
- Committing code that fails any check
- Using TODO/FIXME in final code
- Skipping error handling
- Hardcoding sensitive informationCore principle of the implement phase: Every commit should be “production-ready” — not “good enough for now, polish later”.
Part 3: Full Configuration Template
Copy this directly into your CLAUDE.md:
## Core Workflow
**Important: Every task must follow this process — no phase may be skipped**
### 1. Research Phase (RESEARCH)
Before starting any task:
- Check the codebase for similar existing implementations
- Use Glob/Grep to search for related code
- Understand the project's architecture and dependencies
- Read comments and docs in related files
**Search online when uncertain:**
- Best practices for new technologies/frameworks
- Latest API docs for specific libraries
- Solutions for error messages
### 2. Plan Phase (PLAN)
After research, output:
- **File list**: Files to be modified/created
- **Implementation approach**: Key steps and technology choices
- **Risk identification**: Potential issues and edge cases
- **Questions to confirm**: Items that need user clarification
**Important: Do not start coding until the user confirms**
### 3. Implement Phase (IMPLEMENT)
After confirmation, execute the plan:
- Follow the project's existing code style
- Complete error handling (never skip)
- Write tests alongside the implementation
- Run linter/formatter/type-checker
**Done criteria:**
- Linter: zero warnings, zero errors
- All tests passing
- Type check passing
- Code formatted
---
**For complex architecture questions: think deeply first, then propose a plan**Part 4: Advanced Configuration Tips
4.1 Extensions for Complex Tasks
For complex architecture decisions or significant technical choices, require Claude to think deeply:
## Handling Complex Tasks
For the following types of tasks, deep thinking is required during the plan phase:
- Architecture changes spanning multiple modules
- Introducing a new technology or framework
- Performance optimization plans
- Database schema design
**Deep thinking requirements:**
1. List at least 2–3 viable approaches
2. Analyze the pros and cons of each
3. Explain why the recommended approach is preferred
4. Identify potential technical debt4.2 Variants for Different Scenarios
Research focus: Reproduce the bug, find root cause, check related code
Plan focus: Fix approach, affected scope, regression test points
Implement focus: Minimal change, add regression tests
Research focus: Understand requirements, find reuse opportunities, confirm tech stack
Plan focus: Module design, interface definition, test strategy
Implement focus: Progressive development, continuous testing, keep docs in sync
Research focus: Analyze existing code, dependencies, blast radius
Plan focus: Refactoring steps, backwards compatibility, rollback plan
Implement focus: Small incremental steps, keep tests green, commit frequently
Scenario-specific configuration example:
## Scenario-Based Workflow
### Bug Fix Flow
1. **Research**: Reproduce → Find root cause → Check related code
2. **Plan**: Explain root cause → Fix approach → Affected scope
3. **Implement**: Minimal change → Add regression tests → Verify fix
### New Feature Flow
1. **Research**: Understand requirements → Find reuse opportunities → Confirm tech stack
2. **Plan**: Module design → Interface definition → Test strategy
3. **Implement**: Progressive development → Parallel testing → Update docs
### Refactoring Flow
1. **Research**: Analyze current state → Identify problems → Assess impact
2. **Plan**: Refactoring approach → Step-by-step plan → Rollback strategy
3. **Implement**: Small incremental steps → Keep tests green → Commit frequentlyPart 5: Frequently Asked Questions
Q: Claude still skips the research phase — what can I do?
Solution: Use stronger constraint language in the configuration, with explicit consequences.
## Research Phase (MANDATORY)
**Skipping the research phase is never allowed**
Before outputting any code, you must first show:
- Which files/keywords you searched
- Which related code you found
- The relevant technologies/patterns the project uses
Writing code without showing the above is a workflow violation.Q: How can I get Claude to provide more detailed plans?
Solution: Explicitly specify the required format and content of the plan.
## Plan Phase Output Format
The plan must include the following sections:
### File Change List
| File path | Action | Change description |
|---------|------|---------|
| src/xxx | Create | ... |
| src/yyy | Modify | ... |
### Implementation Steps
1. Step one: ...
2. Step two: ...
### Risk Assessment
- Risk 1: ...
- Risk 2: ...
### Questions to Confirm
- [ ] Question 1
- [ ] Question 2Q: How do I enforce code quality in the implement phase?
Solution: Pair this with the Quality Gates configuration to define explicit done criteria.
## Implement Phase Done Criteria
Before committing, all of the following must be satisfied:
- [ ] Linter passes (zero warnings)
- [ ] Type check passes (TypeScript strict mode)
- [ ] All tests pass
- [ ] New code has corresponding tests
- [ ] No leftover TODO/FIXME
- [ ] No hardcoded config/secretsPart 6: Summary
The three-phase workflow is one of the most important modules in your CLAUDE.md configuration:
| Phase | Core Value | Key Output |
|---|---|---|
| Research | Avoid reinventing the wheel | Analysis of existing code |
| Plan | Avoid going in the wrong direction | Implementation approach and file list |
| Implement | High-quality delivery | Code that meets standards |
Works best with:
- Quality Gates: Enforce code quality in the implement phase
- Coding Standards: Maintain consistent code style
Next Steps
- Quality Gates Configuration — Set the floor for code quality
- Coding Standards Configuration — Unify code style
- Back to Configuration Guide