# Workflow Tips

This guide covers how to integrate Claude Code into your daily development workflow, from personal efficiency to team collaboration, establishing efficient AI-assisted development processes.

## Plan-Execute Workflow

The most effective Claude Code pattern is **plan first, execute later**—avoid having AI write code directly.

### Basic Flow

```
1. Analyze Requirements → 2. Create Plan → 3. Confirm Plan → 4. Execute Step by Step → 5. Verify Results
```

### Practical Steps

**Step 1: Have Claude Understand Requirements**

```
> Read the code in @src/services/ directory and understand the existing architecture.
> Don't write any code, just analyze.
```

**Step 2: Create Implementation Plan**

```
> Based on your understanding of the existing code, create a detailed implementation plan for "user permission management".
> Include: file changes, new files, dependencies, risk points.
```

**Step 3: Confirm and Adjust Plan**

Review Claude's plan and suggest modifications:

```
> In step 3 of the plan, I want to use Redis cache instead of memory cache. Please adjust the plan.
```

**Step 4: Execute Step by Step**

```
> Now execute step 1 of the plan: create the permission model.
```

After completing each step, verify results before continuing.

## Feature Branch Workflow

### Git Branch Best Practices

```bash
# 1. Create feature branch
git checkout -b feature/user-permissions

# 2. Navigate to project and start Claude Code
cd your-project && claude

# 3. Commit frequently during development
> /commit  # First commit
# Continue developing...
> /commit  # Second commit

# 4. Feature complete, create PR
> Create a PR description for the current branch, summarizing all commit changes
```

### Commit Frequency Tips

- **Small commits**: Commit after each independent feature point

- **Commit messages**: Use `/commit` to auto-generate proper messages

- **Avoid large commits**: Don't accumulate too many changes before committing

## Code Review Workflow

### Self Review

Before submitting a PR, have Claude review:

```
> /review
> Focus on: security, performance, code style
```

### Reviewing Others' Code

```bash
# Get PR changes
gh pr diff 123 | claude "Review this PR, focus on:
1. Logic correctness
2. Edge case handling
3. Error handling
4. Code maintainability"
```

### Multi-Phase Review Process

For complex PRs, use structured review:

```
> Phase 1: Check if architecture design is reasonable
> Phase 2: Check if implementation matches design
> Phase 3: Check if test coverage is sufficient
> Phase 4: Check if documentation is complete
```

## Test-Driven Workflow

### TDD with Claude Code

```
1. Write Tests → 2. Run Tests (Fail) → 3. Write Code → 4. Run Tests (Pass) → 5. Refactor
```

### Practical Steps

**Step 1: Define Tests**

```
> Write test cases for user registration, covering:
> - Normal registration
> - Invalid email format
> - Weak password
> - User already exists
> Write tests first, don't implement the feature.
```

**Step 2: Verify Tests Fail**

```bash
npm test  # Expected: tests fail
```

**Step 3: Implement Feature**

```
> Now implement the code to make all tests pass.
```

**Step 4: Verify and Refactor**

```bash
npm test  # Expected: tests pass
```

```
> Tests pass. Now refactor the code for better readability without breaking tests.
```

## Debugging Workflow

### Structured Debugging

```
1. Reproduce Issue → 2. Gather Information → 3. Analyze Cause → 4. Verify Hypothesis → 5. Fix Issue
```

### Practical Steps

**Step 1: Describe the Issue**

```
> Issue: After login, clicking "My Orders" shows blank page
> Expected: Display user's order list
> Steps to reproduce: Login → Click "My Orders"
```

**Step 2: Gather Information**

```
> Analyze these files to find possible issues:
> @src/pages/MyOrders.tsx
> @src/services/OrderService.ts
> @src/api/orders.ts
```

**Step 3: Analyze Logs**

```bash
# Collect error logs
cat app.log | claude "Analyze these logs, find errors related to the orders page"
```

**Step 4: Fix and Verify**

```
> Based on the analysis, fix the issue in OrderService
> After fixing, I'll test to verify
```

## Subagent Collaboration Workflow

### Parallel Processing

Leverage subagents for parallel task processing:

```
> Execute these tasks simultaneously:
> 1. Use Explore agent to analyze project structure
> 2. Use Plan agent to design new feature approach
```

### Specialized Roles

Different subagents have different strengths:

| Agent | Specialty | Use Case |
|-------|-----------|----------|
| Explore | Fast search | Find code, understand structure |
| Plan | Architecture design | Complex feature planning |
| Background | Parallel processing | Batch tasks, long-running tasks |

## IDE Integration Workflow

### VS Code Integration

1. Install Claude Code VS Code extension

2. Use `Cmd+Esc` / `Ctrl+Esc` to quickly switch

3. Select code in editor then invoke Claude

### Terminal + IDE Collaboration

```
Terminal (Claude Code)          IDE (VS Code)
        ↓                           ↓
   Analyze, Plan              Manual adjustments, reading
        ↓                           ↓
   Generate Code  ←─────────→   View diff, test
        ↓                           ↓
   Commit Code                  Continue development
```

## Team Collaboration Workflow

### Standardized CLAUDE.md

Share CLAUDE.md configuration across team:

```markdown
# Team Development Standards

## Code Style
- ESLint config: .eslintrc.js
- Prettier config: .prettierrc

## Git Standards
- Branch naming: feature/xxx, fix/xxx, hotfix/xxx
- Commit format: type(scope): description

## Testing Requirements
- Unit test coverage > 80%
- E2E tests cover core flows
```

### PR Templates

Have Claude use unified PR templates:

```
> Create PR description using this template:
> ## Changes
> ## Test Plan
> ## Screenshots (if UI changes)
> ## Checklist
```

## Workflow Checklist

### Before Starting New Task

- [ ] Create feature branch

- [ ] Use `/clear` to clear context

- [ ] Have Claude understand existing code first

- [ ] Create implementation plan

### During Development

- [ ] Execute step by step, verify each step

- [ ] Small commits, frequent `/commit`

- [ ] Monitor context with `/context`

- [ ] Use `/compact` when needed

### Before Submission

- [ ] Run `/review` for self-review

- [ ] Run all tests

- [ ] Check for lint errors

- [ ] Generate PR description

## Next Steps

- Learn [CLI Tips](/docs/usage/cli-tips) for more commands

- Explore [Custom Commands](/docs/usage/cli-tips) to create team-specific commands

- Check [Best Practices](/docs/usage/best-practices) to further optimize workflows