Skip to main content

Plan Mode

What is Plan Mode?

Plan Mode is Claude Code's intelligent workflow for handling complex, multi-step tasks. When facing major refactoring, new feature development, or systematic changes, Claude will first create a detailed plan, then execute it step by step.

This is like an architect drawing blueprints before construction begins.

Why do we need Plan Mode?

Traditional Problems

Complex tasks without planning often lead to:

  • 🔄 Directional confusion: Discovering design flaws mid-way requiring rework
  • 🧩 Missing details: Forgetting to handle dependencies and edge cases
  • Time waste: Repeatedly modifying and adjusting approaches
  • 🐛 Introducing errors: Rushed implementation causing bugs and inconsistencies

Plan Mode Advantages

  • 🎯 Holistic perspective: Consider overall architecture before taking action
  • 📋 Clear steps: Break complex tasks into executable small steps
  • Trackable progress: Each step has clear completion criteria
  • 🔄 Adjustable approach: Discuss and optimize plans before execution

Plan Mode Workflow

1. Triggering Plan Mode

Automatic Triggering

Claude will automatically enter Plan Mode in the following situations:

> Refactor the entire user authentication system, support multiple login methods and enhance security
# Complexity: High → Automatically enter Plan Mode

> Add internationalization support to the application, including frontend, backend, and database
# Impact scope: Large → Automatically enter Plan Mode

Manual Triggering

You can also manually enable Plan Mode:

> /plan Implement real-time chat functionality
> /plan Optimize application performance, target halving first screen load time

2. Plan Creation Phase

Claude will analyze the task and generate a structured plan:

## 📋 Task: User Authentication System Refactoring

### 🎯 Objectives
- Support email/username login
- Integrate third-party OAuth (Google, GitHub)
- Implement JWT + Refresh Token mechanism
- Add two-factor authentication (2FA)
- Enhance security and user experience

### 🔍 Impact Analysis
- **Frontend**: Login components, authentication state management, route guards
- **Backend**: Authentication APIs, middleware, database models
- **Security**: Password policies, session management, attack protection

### 📝 Execution Plan

#### Phase 1: Preparation (Estimated 30 minutes)
- [ ] Backup existing authentication code
- [ ] Analyze current user data structure
- [ ] Design new database schema
- [ ] Prepare migration scripts

#### Phase 2: Backend Refactoring (Estimated 2 hours)
- [ ] Update user model and database tables
- [ ] Implement new authentication service
- [ ] Create JWT utility class
- [ ] Implement OAuth integration
- [ ] Add 2FA support

#### Phase 3: Frontend Adaptation (Estimated 1.5 hours)
- [ ] Refactor login components
- [ ] Update authentication state management
- [ ] Implement OAuth login interface
- [ ] Add 2FA settings page

#### Phase 4: Testing and Validation (Estimated 1 hour)
- [ ] Write unit tests
- [ ] Execute integration tests
- [ ] Security checks
- [ ] User experience testing

### ⚠️ Risk Points
- Data migration may affect existing users
- OAuth configuration requires external service support
- 2FA implementation needs additional dependency packages

### 🎯 Success Criteria
- [ ] All tests pass
- [ ] Existing user data migrated completely
- [ ] New authentication features work normally
- [ ] No significant performance degradation

3. Plan Confirmation Phase

Claude will present the plan and request confirmation:

Claude: I have created a detailed plan for authentication system refactoring. Please review the above plan.

What would you like to do:
1. 🚀 Start executing this plan
2. ✏️ Modify certain parts of the plan
3. 📋 View more implementation details
4. ⏸️ Pause, execute later

What's your choice?

4. Execution Phase

Once the plan is confirmed, Claude begins step-by-step execution:

[✅ Phase 1.1 Complete] Backed up existing authentication code to backup/auth-legacy/
[🔄 Phase 1.2 In Progress] Analyzing current user data structure...

Found:
- User table contains email, username, password_hash
- Missing OAuth-related fields
- No 2FA configuration fields

[✅ Phase 1.2 Complete] Data structure analysis complete
[🔄 Phase 1.3 In Progress] Designing new database schema...

Plan Mode Types

1. Sequential Plan (Linear Plan)

Steps must be executed in order:

1. Design database schema
2. Implement backend API
3. Develop frontend interface
4. Integration testing

Suitable for: Architecture changes, data migration, deployment processes

2. Parallel Plan

Some steps can be performed simultaneously:

Parallel Group A:
- Implement user authentication API
- Design login interface

Parallel Group B:
- Write unit tests
- Prepare documentation updates

Convergence Point: Integration testing

Suitable for: Feature development, performance optimization, multi-module projects

3. Iterative Plan

Complete in multiple iteration cycles:

Iteration 1: Basic Authentication (MVP)
- Email/password login
- Basic session management

Iteration 2: Enhanced Features
- OAuth third-party login
- Password reset functionality

Iteration 3: Security Enhancement
- Two-factor authentication
- Login anomaly detection

Suitable for: Large projects, progressive improvement, MVP development

Best Practices

1. Plan Granularity

✅ Appropriate Granularity

- [ ] Implement user registration API endpoint
- [ ] Add email verification logic
- [ ] Create registration form component
- [ ] Integrate form validation

❌ Too Coarse

- [ ] Complete user system
- [ ] Do frontend interface

❌ Too Granular

- [ ] Create register.js file
- [ ] Add first line of code
- [ ] Import express module
- [ ] Write a variable declaration

2. Risk Management

Identify and flag risks in the plan:

### ⚠️ High Risk Steps
- **Database Migration** (Risk: Data loss)
- Mitigation: Validate in test environment first
- Contingency: Prepare rollback scripts

- **Third-party Service Integration** (Risk: Service unavailable)
- Mitigation: Implement graceful degradation
- Contingency: Provide manual login option

3. Checkpoint Setting

Set verification at key nodes:

#### Checkpoint 1: Data Migration Complete
Verification Conditions:
- [ ] All user data successfully migrated
- [ ] Both old and new password hashes can verify
- [ ] Test users can login normally

#### Checkpoint 2: API Functionality Verification
Verification Conditions:
- [ ] All authentication endpoints respond normally
- [ ] Error handling covers various scenarios
- [ ] API documentation updated

4. Progress Tracking

Update plan progress in real-time:

> How's the current progress?

Claude:
📊 Overall Progress: 60% (12/20 steps completed)

✅ Completed:
- Database schema design
- Backend API implementation
- JWT utility class development

🔄 In Progress:
- Frontend login component development (70%)

⏳ Pending:
- OAuth integration
- Testing and documentation

Advanced Techniques

1. Conditional Branch Planning

### Branch Decision Point: Existing User Data Handling

**Option A**: Online Migration
- Advantage: User-transparent
- Risk: May affect performance
- Condition: User count < 100k

**Option B**: Offline Migration
- Advantage: Safe and reliable
- Risk: Requires maintenance window
- Condition: User count > 100k

**Decision Basis**: Current user count and business requirements

2. Rollback Planning

### 🔄 Rollback Strategy

If major issues are encountered during execution:

**Immediate Rollback Triggers**:
- Data loss or corruption
- System crash or unavailability
- Security vulnerability discovered

**Rollback Steps**:
1. Stop new deployments
2. Restore database backup
3. Rollback code to previous version
4. Notify relevant teams

3. Quality Gates

### ✅ Quality Standards

Each phase completion must meet:

**Code Quality**:
- ESLint 0 errors, 0 warnings
- TypeScript strict mode passes
- Test coverage > 80%

**Functional Quality**:
- All user scenarios tested
- Performance metrics met
- Security scan shows no high-risk issues

Common Scenario Applications

Scenario 1: Performance Optimization Project

> /plan Optimize application performance, reduce first screen load time from 5 seconds to under 2 seconds

Claude will create a comprehensive plan including:

  • Performance issue diagnosis
  • Optimization solution design
  • Code splitting implementation
  • Cache strategy optimization
  • Image and resource optimization
  • Validation and monitoring

Scenario 2: Tech Stack Migration

> /plan Migrate project from React Class components to Function components + Hooks

Plan includes:

  • Migration strategy formulation
  • Component priority sorting
  • Progressive migration implementation
  • Test validation process
  • Team training arrangement

Scenario 3: New Feature Development

> /plan Add complete shopping cart and checkout functionality to e-commerce website

Covers:

  • Requirements analysis and technical design
  • Data model design
  • API development
  • Frontend interface implementation
  • Payment integration
  • Testing and deployment

After mastering Plan Mode, you can learn Auto Plan Mode to understand how to make Claude more intelligently determine when to use Plan Mode.