feat: initialize monorepo with package.json for CCW workflow platform

This commit is contained in:
catlog22
2026-02-03 14:42:20 +08:00
parent 5483a72e9f
commit 39b80b3386
267 changed files with 99597 additions and 2658 deletions

View File

@@ -0,0 +1,375 @@
---
title: Workflow FAQ
description: Frequently asked questions about CCW workflows
sidebar_position: 7
---
import Mermaid from '@theme/Mermaid';
# Workflow FAQ
Common questions and answers about CCW workflows.
## General Questions
### What is the difference between Main Workflow and Issue Workflow?
**Main Workflow** is for primary development (Levels 1-5), while **Issue Workflow** is for post-development maintenance.
| Aspect | Main Workflow | Issue Workflow |
|--------|---------------|----------------|
| **Purpose** | Feature development | Post-development fixes |
| **Timing** | Development phase | After main workflow completes |
| **Parallelism** | Dependency analysis | Worktree isolation (optional) |
### How do I choose the right workflow level?
<Mermaid
chart={`
flowchart TD
Start([Start]) --> Q1{Post-development?}
Q1 -->|Yes| Issue["Issue Workflow"]
Q1 -->|No| Q2{Uncertain commands?}
Q2 -->|Yes| L5["Level 5: ccw-coordinator"]
Q2 -->|No| Q3{Requirements clear?}
Q3 -->|No| L4["Level 4: brainstorm"]
Q3 -->|Yes| Q4{Need persistent session?}
Q4 -->|Yes| Q5{Development type?}
Q4 -->|No| Q6{Multi-perspective?}
Q5 -->|Standard| L3Std["Level 3: plan"]
Q5 -->|TDD| L3TDD["Level 3: tdd-plan"]
Q5 -->|Test Fix| L3Test["Level 3: test-fix-gen"]
Q6 -->|Yes| L2Multi["Level 2: multi-cli-plan"]
Q6 -->|No| Q7{Bug fix?}
Q7 -->|Yes| L2Fix["Level 2: lite-fix"]
Q7 -->|No| Q8{Need planning?}
Q8 -->|Yes| L2Plan["Level 2: lite-plan"]
Q8 -->|No| L1["Level 1: lite-lite-lite"]
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef decision fill:#fff9c4,stroke:#f57c00
classDef level fill:#e3f2fd,stroke:#1976d2
class Start startend,Q1,Q2,Q3,Q4,Q6,Q7,Q8 decision,Issue,L1,L2Plan,L2Fix,L2Multi,L3Std,L3TDD,L3Test,L4,L5 level
`}
/>
### What are Minimum Execution Units?
**Minimum Execution Units** are sets of commands that must execute together as atomic groups. Splitting these commands breaks logical flow and creates incomplete states.
**Example**: The unit `lite-plan -> lite-execute` must complete together. Stopping after `lite-plan` leaves you with a plan but no implementation.
## Level 1 Questions
### When should I use Level 1?
Use Level 1 (`lite-lite-lite`) when:
- Quick fixes (typos, minor adjustments)
- Simple features (single function, small utility)
- Config changes (environment variables, timeout values)
- Documentation updates (readme, comments)
**Don't use** when:
- Multi-module changes
- Need persistent records
- Complex refactoring
- Test-driven development
## Level 2 Questions
### What's the difference between lite-plan, lite-fix, and multi-cli-plan?
| Workflow | Purpose | When to Use |
|----------|---------|-------------|
| `lite-plan` | Clear requirements | Single-module features |
| `lite-fix` | Bug diagnosis | Bug fixes, production issues |
| `multi-cli-plan` | Multi-perspective analysis | Technology selection, solution comparison |
### What is hotfix mode?
```bash
/workflow:lite-fix --hotfix "Production database connection failing"
```
**Hotfix mode**:
- Skips most diagnosis phases
- Minimal planning (direct execution)
- Auto-generates follow-up tasks for complete fix + post-mortem
- Use for **production emergencies only**
### When should I use multi-cli-plan vs lite-plan?
Use `multi-cli-plan` when:
- Need multiple perspectives (Gemini, Codex, Claude)
- Technology selection decisions
- Solution comparison
- Architecture trade-offs
Use `lite-plan` when:
- Requirements are clear
- Single-perspective sufficient
- Faster iteration needed
## Level 3 Questions
### What is the difference between plan, tdd-plan, and test-fix-gen?
| Workflow | Purpose | Key Feature |
|----------|---------|-------------|
| `plan` | Standard development | 5-phase planning with verification |
| `tdd-plan` | Test-driven development | Red-Green-Refactor cycles |
| `test-fix-gen` | Test fixes | Progressive test layers (L0-L3) |
### What is TDD (Test-Driven Development)?
**TDD** follows the Red-Green-Refactor cycle:
1. **Red**: Write a failing test
2. **Green**: Write minimal code to pass the test
3. **Refactor**: Improve code while keeping tests green
**The Iron Law**:
```
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
```
### Why does TDD require tests to be written first?
| Aspect | Test-First | Test-After |
|--------|-----------|------------|
| **Proof** | Tests fail before implementation | Tests pass immediately (proves nothing) |
| **Discovery** | Edge cases found before coding | Edge cases found after coding |
| **Verification** | Verifies requirements | Verifies implementation |
### What are the test layers in test-fix-gen?
| Layer | Type | Description |
|-------|------|-------------|
| **L0** | Static | Type checking, linting |
| **L1** | Unit | Function-level tests |
| **L2** | Integration | Component interaction |
| **L3** | E2E | Full system tests |
## Level 4 Questions
### When should I use brainstorm:auto-parallel?
Use Level 4 (`brainstorm:auto-parallel`) when:
- New feature design
- System architecture refactoring
- Exploratory requirements
- Uncertain implementation approach
- Multi-dimensional trade-offs needed
### What roles are available in brainstorm?
| Role | Description |
|------|-------------|
| `system-architect` | System design |
| `ui-designer` | UI design |
| `ux-expert` | User experience |
| `product-manager` | Product requirements |
| `product-owner` | Business value |
| `data-architect` | Data structure |
| `scrum-master` | Process and team |
| `subject-matter-expert` | Domain expertise |
| `test-strategist` | Testing strategy |
### What are With-File workflows?
**With-File workflows** provide documented exploration with multi-CLI collaboration:
| Workflow | Purpose | Level |
|----------|---------|-------|
| `brainstorm-with-file` | Multi-perspective ideation | 4 |
| `debug-with-file` | Hypothesis-driven debugging | 3 |
| `analyze-with-file` | Collaborative analysis | 3 |
## Level 5 Questions
### When should I use ccw-coordinator?
Use Level 5 (`ccw-coordinator`) when:
- Complex multi-step workflows
- Uncertain which commands to use
- Desire end-to-end automation
- Need full state tracking and resumability
- Team collaboration with unified execution flow
### How does ccw-coordinator differ from other levels?
| Aspect | Level 1-4 | Level 5 |
|--------|----------|--------|
| **Command Selection** | Manual | Auto |
| **Orchestration** | Manual | Intelligent |
| **State Tracking** | Varies | Full persistence |
## Execution Questions
### What is lite-execute?
`lite-execute` is the unified execution command for Level 2 workflows:
```bash
/workflow:lite-execute --in-memory
```
**Features**:
- Parallel execution for independent tasks
- Sequential phases for dependent tasks
- Progress tracking via TodoWrite
- Optional code review
### What is execute?
`execute` is the unified execution command for Level 3 workflows:
```bash
/workflow:execute --session WFS-{session-id}
```
**Features**:
- Dependency analysis
- Parallel/sequential task execution
- Session-based progress tracking
- Task completion summaries
## Session Questions
### How do I resume a paused session?
```bash
/workflow:session:resume # Resume most recent session
/workflow:session:resume WFS-{session-id} # Resume specific session
```
### How do I complete a session?
```bash
/workflow:session:complete --session WFS-{session-id}
```
This archives the session with lessons learned and updates the manifest.
### How do I list all sessions?
```bash
/workflow:session:list
```
## Artifact Questions
### Where are workflow artifacts stored?
| Level | Artifact Location |
|-------|-------------------|
| Level 1 | None (stateless) |
| Level 2 | `memory://plan` or `.workflow/.lite-fix/`, `.workflow/.multi-cli-plan/` |
| Level 3 | `.workflow/active/WFS-{session}/` |
| Level 4 | `.workflow/active/WFS-{session}/.brainstorming/` |
| Level 5 | `.workflow/.ccw-coordinator/{session}/` |
### What files are in a session?
```
.workflow/active/WFS-{session}/
├── workflow-session.json # Session metadata
├── IMPL_PLAN.md # Implementation plan
├── TODO_LIST.md # Progress tracking
├── .task/
│ ├── IMPL-001.json # Task definitions
│ ├── IMPL-002.json
│ └── ...
└── .process/
├── context-package.json # Project context
└── planning-notes.md
```
## Testing Questions
### How do I add tests to existing code?
```bash
# Session Mode (from existing session)
/workflow:test-fix-gen WFS-user-auth-v2
# Prompt Mode (direct description)
/workflow:test-fix-gen "Add unit tests for the auth API"
```
### How do I fix failing tests?
```bash
/workflow:test-fix-gen "Tests failing for user registration"
/workflow:test-cycle-execute
```
The workflow will:
1. Analyze test failures
2. Identify root causes
3. Fix issues iteratively
4. Verify >= 95% pass rate
## Troubleshooting
### My workflow failed. What should I do?
1. **Check the error message** - Identify the root cause
2. **Review state.json** - Check `.workflow/.ccw-coordinator/{session}/state.json`
3. **Resume the session** - Use `/workflow:session:resume` to continue
4. **Adjust and retry** - Modify approach based on error
### How do I skip a failing task?
Edit the task JSON to set status to "completed":
```bash
jq '.status = "completed"' .workflow/active/WFS-{session}/.task/IMPL-001.json
```
### How do I clean up old sessions?
```bash
# List sessions
/workflow:session:list
# Remove specific session
rm -rf .workflow/active/WFS-{session-id}
# Clean all completed sessions
/workflow:clean
```
## Best Practices
### What are the workflow best practices?
1. **Start simple** - Use the lowest level that meets your needs
2. **Plan before executing** - Use verification steps when available
3. **Test continuously** - Integrate testing into your workflow
4. **Review code** - Use built-in review workflows
5. **Document decisions** - Use brainstorm workflows for complex decisions
### When should I use worktree isolation?
**Worktree isolation** is primarily for **Issue Workflow**:
- After main development is complete
- Merged to `main` branch
- Issues discovered requiring fixes
- Need to fix without affecting current development
**Main Workflow** doesn't need worktree because:
- Dependency analysis solves parallelism
- Agents execute independent tasks in parallel
- No filesystem isolation needed
## Related Documentation
- [Introduction](./introduction.mdx) - Workflow overview
- [Level 1](./level-1-ultra-lightweight.mdx) - Ultra-lightweight workflows
- [Level 2](./level-2-rapid.mdx) - Rapid workflows
- [Level 3](./level-3-standard.mdx) - Standard workflows
- [Level 4](./level-4-brainstorm.mdx) - Brainstorm workflows
- [Level 5](./level-5-intelligent.mdx) - Intelligent workflows
- [Commands](../commands/general/ccw.mdx) - Command reference

View File

@@ -0,0 +1,313 @@
---
title: Workflow Introduction
description: Comprehensive overview of CCW workflows - from rapid execution to intelligent orchestration
sidebar_position: 1
---
import Mermaid from '@theme/Mermaid';
# Workflow Introduction
CCW provides two workflow systems: **Main Workflow** and **Issue Workflow**, working together to cover the complete software development lifecycle.
## Workflow Architecture Overview
<Mermaid
chart={`
graph TB
subgraph Main["Main Workflow (5 Levels)"]
L1["Level 1: Rapid<br/>lite-lite-lite"]
L2["Level 2: Lightweight<br/>lite-plan, lite-fix, multi-cli-plan"]
L3["Level 3: Standard<br/>plan, tdd-plan, test-fix-gen"]
L4["Level 4: Brainstorm<br/>brainstorm:auto-parallel"]
L5["Level 5: Intelligent<br/>ccw-coordinator"]
L1 --> L2 --> L3 --> L4 --> L5
end
subgraph Issue["Issue Workflow (Post-Development)"]
I1["Phase 1: Accumulation<br/>discover, new"]
I2["Phase 2: Resolution<br/>plan, queue, execute"]
I1 --> I2
end
Main -.->|After development| Issue
classDef level1 fill:#e3f2fd,stroke:#1976d2
classDef level2 fill:#bbdefb,stroke:#1976d2
classDef level3 fill:#90caf9,stroke:#1976d2
classDef level4 fill:#64b5f6,stroke:#1976d2
classDef level5 fill:#42a5f5,stroke:#1976d2
classDef issue fill:#fff3e0,stroke:#f57c00
class L1 level1,L2 level2,L3 level3,L4 level4,L5 level5,I1,I2 issue
`}
/>
## Main Workflow vs Issue Workflow
| Aspect | Main Workflow | Issue Workflow |
|--------|---------------|----------------|
| **Purpose** | Primary development cycle | Post-development maintenance |
| **Timing** | Feature development phase | After main workflow completes |
| **Scope** | Complete feature implementation | Targeted fixes/enhancements |
| **Parallelism** | Dependency analysis + Agent parallel | Worktree isolation (optional) |
| **Branch Model** | Work on current branch | Can use isolated worktree |
### Why Main Workflow Doesn't Use Worktree Automatically?
**Dependency analysis already solves parallelism**:
1. Planning phase (`/workflow:plan`) performs dependency analysis
2. Automatically identifies task dependencies and critical paths
3. Partitions into **parallel groups** (independent tasks) and **serial chains** (dependent tasks)
4. Agents execute independent tasks in parallel without filesystem isolation
<Mermaid
chart={`
graph TD
subgraph Dependency["Dependency Analysis"]
A["Task A"]
B["Task B"]
C["Task C"]
D["Task D"]
A & B --> PG["Parallel Group 1<br/>Agent 1"]
C --> SC["Serial Chain<br/>Agent 2"]
D --> SC
PG --> R["Results"]
SC --> R
end
classDef pg fill:#c8e6c9,stroke:#388e3c
classDef sc fill:#fff9c4,stroke:#f57c00
class PG pg,SC sc
`}
/>
### Why Issue Workflow Supports Worktree?
Issue Workflow serves as a **supplementary mechanism** with different scenarios:
1. Main development complete, merged to `main`
2. Issues discovered requiring fixes
3. Need to fix without affecting current development
4. Worktree isolation keeps main branch stable
<Mermaid
chart={`
graph LR
Dev["Development"] --> Rel["Release"]
Rel --> Issue["Discover Issue"]
Issue --> Fix["Worktree Fix"]
Fix --> Merge["Merge back"]
Merge --> NewDev["Continue new feature"]
NewDev -.-> Dev
`}
/>
## 15 Workflow Levels Explained
### Level 1: Rapid Execution
**Complexity**: Low | **Artifacts**: None | **State**: Stateless
| Workflow | Description |
|----------|-------------|
| `lite-lite-lite` | Ultra-lightweight direct execution with zero overhead |
**Best for**: Quick fixes, simple features, config adjustments
---
### Level 2: Lightweight Planning
**Complexity**: Low-Medium | **Artifacts**: Memory/Lightweight files | **State**: Session-scoped
| Workflow | Description |
|----------|-------------|
| `lite-plan` | In-memory planning for clear requirements |
| `lite-fix` | Intelligent bug diagnosis and fix |
| `multi-cli-plan` | Multi-CLI collaborative analysis |
**Best for**: Single-module features, bug fixes, technology selection
---
### Level 2.5: Bridge Workflow
**Complexity**: Low-Medium | **Purpose**: Lightweight to Issue transition
| Workflow | Description |
|----------|-------------|
| `rapid-to-issue` | Bridge from quick planning to issue workflow |
**Best for**: Converting lightweight plans to issue tracking
---
### Level 3: Standard Planning
**Complexity**: Medium-High | **Artifacts**: Persistent session files | **State**: Full session management
| Workflow | Description |
|----------|-------------|
| `plan` | Complex feature development with 5 phases |
| `tdd-plan` | Test-driven development with Red-Green-Refactor |
| `test-fix-gen` | Test fix generation with progressive layers |
**Best for**: Multi-module changes, refactoring, TDD development
---
### With-File Workflows (Level 3-4)
**Complexity**: Medium-High | **Artifacts**: Documented exploration | **Multi-CLI**: Yes
| Workflow | Description | Level |
|----------|-------------|-------|
| `brainstorm-with-file` | Multi-perspective ideation | 4 |
| `debug-with-file` | Hypothesis-driven debugging | 3 |
| `analyze-with-file` | Collaborative analysis | 3 |
**Best for**: Documented exploration with multi-CLI collaboration
---
### Level 4: Brainstorming
**Complexity**: High | **Artifacts**: Multi-role analysis docs | **Roles**: 3-9
| Workflow | Description |
|----------|-------------|
| `brainstorm:auto-parallel` | Multi-role brainstorming with synthesis |
**Best for**: New feature design, architecture refactoring, exploratory requirements
---
### Level 5: Intelligent Orchestration
**Complexity**: All levels | **Artifacts**: Full state persistence | **Automation**: Complete
| Workflow | Description |
|----------|-------------|
| `ccw-coordinator` | Auto-analyze & recommend command chains |
**Best for**: Complex multi-step workflows, uncertain commands, end-to-end automation
---
### Issue Workflow
**Complexity**: Variable | **Artifacts**: Issue records | **Isolation**: Worktree optional
| Phase | Commands |
|-------|----------|
| **Accumulation** | `discover`, `discover-by-prompt`, `new` |
| **Resolution** | `plan --all-pending`, `queue`, `execute` |
**Best for**: Post-development issue fixes, maintaining main branch stability
## Choosing the Right Workflow
### Quick Selection Table
| Scenario | Recommended Workflow | Level |
|----------|---------------------|-------|
| Quick fixes, config adjustments | `lite-lite-lite` | 1 |
| Clear single-module features | `lite-plan -> lite-execute` | 2 |
| Bug diagnosis and fix | `lite-fix` | 2 |
| Production emergencies | `lite-fix --hotfix` | 2 |
| Technology selection, solution comparison | `multi-cli-plan -> lite-execute` | 2 |
| Multi-module changes, refactoring | `plan -> verify -> execute` | 3 |
| Test-driven development | `tdd-plan -> execute -> tdd-verify` | 3 |
| Test failure fixes | `test-fix-gen -> test-cycle-execute` | 3 |
| New features, architecture design | `brainstorm:auto-parallel -> plan -> execute` | 4 |
| Complex multi-step workflows, uncertain commands | `ccw-coordinator` | 5 |
| Post-development issue fixes | Issue Workflow | - |
### Decision Flowchart
<Mermaid
chart={`
flowchart TD
Start([Start New Task]) --> Q0{Post-development<br/>maintenance?}
Q0 -->|Yes| IssueW["Issue Workflow<br/>discover -> plan -> queue -> execute"]
Q0 -->|No| Q1{Uncertain which<br/>commands to use?}
Q1 -->|Yes| L5["Level 5: ccw-coordinator<br/>Auto-analyze & recommend"]
Q1 -->|No| Q2{Requirements<br/>clear?}
Q2 -->|Uncertain| L4["Level 4: brainstorm:auto-parallel<br/>Multi-role exploration"]
Q2 -->|Clear| Q3{Need persistent<br/>session?}
Q3 -->|Yes| Q4{Development type?}
Q3 -->|No| Q5{Need multi-<br/>perspective?}
Q4 -->|Standard| L3Std["Level 3: plan -> verify -> execute"]
Q4 -->|TDD| L3TDD["Level 3: tdd-plan -> execute -> verify"]
Q4 -->|Test Fix| L3Test["Level 3: test-fix-gen -> test-cycle"]
Q5 -->|Yes| L2Multi["Level 2: multi-cli-plan"]
Q5 -->|No| Q6{Bug fix?}
Q6 -->|Yes| L2Fix["Level 2: lite-fix"]
Q6 -->|No| Q7{Need planning?}
Q7 -->|Yes| L2Plan["Level 2: lite-plan -> lite-execute"]
Q7 -->|No| L1["Level 1: lite-lite-lite"]
IssueW --> End([Complete])
L5 --> End
L4 --> End
L3Std --> End
L3TDD --> End
L3Test --> End
L2Multi --> End
L2Fix --> End
L2Plan --> End
L1 --> End
classDef level1 fill:#e3f2fd,stroke:#1976d2
classDef level2 fill:#bbdefb,stroke:#1976d2
classDef level3 fill:#90caf9,stroke:#1976d2
classDef level4 fill:#64b5f6,stroke:#1976d2
classDef level5 fill:#42a5f5,stroke:#1976d2
classDef issue fill:#fff3e0,stroke:#f57c00
class L1 level1,L2Plan,L2Fix,L2Multi level2,L3Std,L3TDD,L3Test level3,L4 level4,L5 level5,IssueW issue
`}
/>
### Complexity Indicators
System auto-evaluates complexity based on keywords:
| Weight | Keywords |
|--------|----------|
| +2 | refactor, migrate, architect, system |
| +2 | multiple, across, all, entire |
| +1 | integrate, api, database |
| +1 | security, performance, scale |
- **High complexity** (&gt;=4): Auto-select Level 3-4
- **Medium complexity** (2-3): Auto-select Level 2
- **Low complexity** (&lt;2): Auto-select Level 1
## Minimum Execution Units
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone.
| Unit Name | Commands | Purpose |
|-----------|----------|---------|
| **Quick Implementation** | lite-plan -> lite-execute | Lightweight plan and execution |
| **Multi-CLI Planning** | multi-cli-plan -> lite-execute | Multi-perspective analysis and execution |
| **Bug Fix** | lite-fix -> lite-execute | Bug diagnosis and fix execution |
| **Verified Planning** | plan -> plan-verify -> execute | Planning with verification and execution |
| **TDD Planning** | tdd-plan -> execute | Test-driven development planning and execution |
| **Test Validation** | test-fix-gen -> test-cycle-execute | Generate test tasks and execute test-fix cycle |
| **Code Review** | review-session-cycle -> review-cycle-fix | Complete review cycle and apply fixes |
## Next Steps
- [Level 1: Ultra-Lightweight Workflows](./level-1-ultra-lightweight.mdx) - Learn about rapid execution
- [Level 2: Rapid Workflows](./level-2-rapid.mdx) - Lightweight planning and bug fixes
- [Level 3: Standard Workflows](./level-3-standard.mdx) - Complete planning and TDD
- [Level 4: Brainstorm Workflows](./level-4-brainstorm.mdx) - Multi-role exploration
- [Level 5: Intelligent Workflows](./level-5-intelligent.mdx) - Automated orchestration
- [FAQ](./faq.mdx) - Common questions and answers

View File

@@ -0,0 +1,250 @@
---
title: Level 1 - Ultra-Lightweight Workflows
description: Rapid execution workflow for simple tasks with zero overhead
sidebar_position: 2
---
import Mermaid from '@theme/Mermaid';
# Level 1: Ultra-Lightweight Workflows
**Complexity**: Low | **Artifacts**: None | **State**: Stateless | **Iteration**: Via AskUser
The simplest workflow for immediate simple tasks - minimal overhead, direct execution.
## Overview
Level 1 workflows are designed for quick, straightforward tasks that don't require planning, documentation, or persistent state. They execute directly from input to completion.
<Mermaid
chart={`
flowchart LR
Input([User Input]) --> Clarify[Clarification<br/>Optional]
Clarify --> Select{Auto-select<br/>CLI}
Select --> Analysis[Parallel Analysis<br/>Multi-tool exploration]
Analysis --> Results[Show Results]
Results --> Execute[Direct Execute]
Execute --> Done([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
class Input,Done startend,Clarify,Select,Analysis,Results,Execute action,Select decision
`}
/>
## Included Workflow: lite-lite-lite
### Command
```bash
/workflow:lite-lite-lite
# Or CCW auto-selects for simple tasks
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([User Input]) --> B{Clarification<br/>Needed?}
B -->|Yes| C[AskUserQuestion<br/>Goal/Scope/Constraints]
B -->|No| D[Task Analysis]
C --> D
D --> E{CLI Selection}
E --> F[Gemini<br/>Analysis]
E --> G[Codex<br/>Implementation]
E --> H[Claude<br/>Reasoning]
F --> I[Aggregate Results]
G --> I
H --> I
I --> J{Direct<br/>Execute?}
J -->|Yes| K[Execute Directly]
J -->|Iterate| L[Refine via AskUser]
L --> K
K --> M([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
class A,M startend,B,E,J decision,C,D,F,G,H,I,K action
`}
/>
### Characteristics
| Property | Value |
|----------|-------|
| **Complexity** | Low |
| **Artifacts** | None (no intermediate files) |
| **State** | Stateless |
| **CLI Selection** | Auto-analyze task type |
| **Iteration** | Via AskUser interaction |
### Process Phases
1. **Input Analysis**
- Parse user input for task intent
- Detect complexity level
- Identify required CLI tools
2. **Optional Clarification** (if clarity_score < 2)
- Goal: Create/Fix/Optimize/Analyze
- Scope: Single file/Module/Cross-module
- Constraints: Backward compat/Skip tests/Urgent hotfix
3. **CLI Auto-Selection**
- Task type -> CLI tool mapping
- Parallel analysis across multiple tools
- Aggregated result presentation
4. **Direct Execution**
- Execute changes immediately
- No intermediate artifacts
- Optional iteration via AskUser
### CLI Selection Logic
```javascript
function selectCLI(task) {
const patterns = {
'gemini': /analyze|review|understand|explore/,
'codex': /implement|generate|create|write code/,
'claude': /debug|fix|optimize|refactor/,
'qwen': /consult|discuss|compare/
};
for (const [cli, pattern] of Object.entries(patterns)) {
if (pattern.test(task)) return cli;
}
return 'gemini'; // Default
}
```
## Use Cases
### When to Use
- Quick fixes (simple typos, minor adjustments)
- Simple feature additions (single function, small utility)
- Configuration adjustments (environment variables, config files)
- Small-scope renaming (variable names, function names)
- Documentation updates (readme, comments)
### When NOT to Use
- Multi-module changes (use Level 2+)
- Need persistent records (use Level 3+)
- Complex refactoring (use Level 3-4)
- Test-driven development (use Level 3 TDD)
- Architecture design (use Level 4-5)
## Examples
### Example 1: Quick Fix
```bash
/workflow:lite-lite-lite "Fix typo in function name: getUserData"
```
**Flow**:
1. Detect: Simple typo fix
2. Select: Codex for refactoring
3. Execute: Direct rename across files
4. Complete: No artifacts generated
### Example 2: Simple Feature
```bash
/workflow:lite-lite-lite "Add logging to user login function"
```
**Flow**:
1. Detect: Single-module feature
2. Select: Claude for implementation
3. Clarify: Log level? Output destination?
4. Execute: Add log statements
5. Complete: Working code
### Example 3: Config Adjustment
```bash
/workflow:lite-lite-lite "Update API timeout to 30 seconds"
```
**Flow**:
1. Detect: Config change
2. Select: Gemini for analysis
3. Analysis: Find all timeout configs
4. Execute: Update values
5. Complete: Configuration updated
## Pros & Cons
### Pros
| Benefit | Description |
|---------|-------------|
| **Speed** | Fastest workflow, zero overhead |
| **Simplicity** | No planning or documentation |
| **Direct** | Input -> Execute -> Complete |
| **No Artifacts** | Clean workspace, no file clutter |
| **Low Cognitive Load** | Simple, straightforward execution |
### Cons
| Limitation | Description |
|------------|-------------|
| **No Trace** | No record of changes made |
| **No Planning** | Can't handle complex tasks |
| **No Review** | No built-in code review |
| **Limited Scope** | Single-module only |
| **No Rollback** | Changes are immediate |
## Comparison with Other Levels
| Aspect | Level 1 | Level 2 | Level 3 |
|--------|---------|---------|---------|
| **Planning** | None | In-memory | Persistent |
| **Artifacts** | None | Memory files | Session files |
| **Complexity** | Low | Low-Medium | Medium-High |
| **Traceability** | No | Partial | Full |
| **Review** | No | Optional | Built-in |
## When to Graduate to Higher Levels
**Signs you need Level 2+**:
- Task involves multiple modules
- Need to track progress
- Requirements need clarification
- Want code review
- Need test generation
**Migration path**:
<Mermaid
chart={`
graph LR
L1["Level 1:<br/>lite-lite-lite"] --> L2["Level 2:<br/>lite-plan"]
L2 --> L3["Level 3:<br/>plan"]
L3 --> L4["Level 4:<br/>brainstorm"]
L4 --> L5["Level 5:<br/>ccw-coordinator"]
classDef node fill:#e3f2fd,stroke:#1976d2
class L1,L2,L3,L4,L5 node
`}
/>
## Related Workflows
- [Level 2: Rapid Workflows](./level-2-rapid.mdx) - Next level up with planning
- [Level 3: Standard Workflows](./level-3-standard.mdx) - Full session management
- [FAQ](./faq.mdx) - Common questions

View File

@@ -0,0 +1,453 @@
---
title: Level 2 - Rapid Workflows
description: Lightweight planning and bug diagnosis workflows for single-module features
sidebar_position: 3
---
import Mermaid from '@theme/Mermaid';
# Level 2: Rapid Workflows
**Complexity**: Low-Medium | **Artifacts**: Memory/Lightweight files | **State**: Session-scoped
Level 2 workflows provide lightweight planning or single analysis with fast iteration. They're designed for tasks with relatively clear requirements that don't need full session persistence.
## Overview
<Mermaid
chart={`
flowchart TD
Start([User Input]) --> Select{Select Workflow}
Select -->|Clear<br/>requirements| LP[lite-plan]
Select -->|Bug fix| LF[lite-fix]
Select -->|Multi-CLI<br/>needed| MCP[multi-cli-plan]
LP --> LE[lite-execute]
LF --> LE
MCP --> LE
LE --> Test{Tests?}
Test -->|Yes| TFG[test-fix-gen]
Test -->|No| Done([Complete])
TFG --> TCE[test-cycle-execute]
TCE --> Done
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef workflow fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef execute fill:#c5e1a5,stroke:#388e3c
class Start,Done startend,Select,Test decision,LP,LF,MCP workflow,LE execute,TFG,TCE execute
`}
/>
## Included Workflows
| Workflow | Purpose | Artifacts | Execution |
|----------|---------|-----------|-----------|
| `lite-plan` | Clear requirement development | memory://plan | -> `lite-execute` |
| `lite-fix` | Bug diagnosis and fix | `.workflow/.lite-fix/` | -> `lite-execute` |
| `multi-cli-plan` | Multi-perspective tasks | `.workflow/.multi-cli-plan/` | -> `lite-execute` |
### Common Characteristics
| Property | Value |
|----------|-------|
| **Complexity** | Low-Medium |
| **State** | Session-scoped / Lightweight persistence |
| **Execution** | Unified via `lite-execute` |
| **Use Case** | Relatively clear requirements |
---
## Workflow 1: lite-plan -> lite-execute
**In-memory planning + Direct execution**
### Command
```bash
/workflow:lite-plan "Add user authentication API"
/workflow:lite-execute
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Code Exploration]
B --> C{Code<br/>Exploration?}
C -->|Yes| D[cli-explore-agent<br/>Multi-angle analysis]
C -->|No| E[Skip exploration]
D --> F[Phase 2: Complexity Assessment]
E --> F
F --> G{Complexity}
G -->|Low| H[Direct Claude<br/>Planning]
G -->|Medium| H
G -->|High| I[cli-lite-planning<br/>-agent]
H --> J[Phase 3: Planning]
I --> J
J --> K[Phase 4: Confirmation]
K --> L{Confirm?}
L -->|Modify| M[Adjust plan]
M --> K
L -->|Allow| N[Phase 5: Execute]
L -->|Cancel| O([Abort])
N --> P[Build executionContext]
P --> Q[/workflow:lite-execute]
Q --> R([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef agent fill:#ffecb3,stroke:#ffa000
class A,R,O startend,B,D,E,J,M,P,Q action,C,G,L decision,F,H,I agent
`}
/>
### Process Phases
**Phase 1: Code Exploration** (Optional)
```bash
# If -e flag specified
/workflow:lite-plan -e "Add user authentication API"
```
- Multi-angle code analysis via cli-explore-agent
- Identifies patterns, dependencies, integration points
**Phase 2: Complexity Assessment**
- Low: Direct planning without agent
- Medium/High: Use cli-lite-planning-agent
**Phase 3: Planning**
- Load plan schema: `~/.claude/workflows/cli-templates/schemas/plan-json-schema.json`
- Generate plan.json following schema
**Phase 4: Confirmation & Selection**
- Display plan summary (tasks, complexity, estimated time)
- Ask user selections:
- Confirm: Allow / Modify / Cancel
- Execution: Agent / Codex / Auto
- Review: Gemini / Agent / Skip
**Phase 5: Execute**
- Build executionContext (plan + explorations + clarifications + selections)
- Execute via `/workflow:lite-execute --in-memory`
### Artifacts
- **In-memory**: `memory://plan` (not persisted)
- **Optional**: `.workflow/.lite-exploration/` (if code exploration used)
### Use Case
Clear single-module features
**Example**:
```bash
/workflow:lite-plan "Add email validation to user registration form"
/workflow:lite-execute
```
---
## Workflow 2: lite-fix
**Intelligent diagnosis + Fix (5 phases)**
### Command
```bash
/workflow:lite-fix "Login timeout after 30 seconds"
/workflow:lite-execute --in-memory --mode bugfix
# Emergency hotfix mode
/workflow:lite-fix --hotfix "Production database connection failing"
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Bug Analysis<br/>& Diagnosis]
B --> C[Severity Pre-assessment<br/>Low/Medium/High/Critical]
C --> D[Parallel cli-explore<br/>-agent Diagnosis<br/>1-4 angles]
D --> E[Phase 2: Clarification]
E --> F{More info<br/>needed?}
F -->|Yes| G[AskUserQuestion<br/>Aggregate clarifications]
F -->|No| H[Phase 3: Fix Planning]
G --> H
H --> I{Severity}
I -->|Low/Medium| J[Direct Claude<br/>Planning]
I -->|High/Critical| K[cli-lite-planning<br/>-agent]
J --> L[Phase 4: Confirmation]
K --> L
L --> M[User confirms<br/>execution method]
M --> N[Phase 5: Execute]
N --> O[/workflow:lite-execute<br/>--in-memory --mode bugfix/]
O --> P([Complete])
Q[Hotfix Mode] --> R[Skip diagnosis<br/>Minimal planning]
R --> N
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef agent fill:#ffecb3,stroke:#ffa000
classDef hotfix fill:#ffccbc,stroke:#bf360c
class A,P startend,B,E,G,H,L,M,N,O action,F,I decision,C,D,J,K agent,Q,R hotfix
`}
/>
### Process Phases
**Phase 1: Bug Analysis & Diagnosis**
- Intelligent severity pre-assessment (Low/Medium/High/Critical)
- Parallel cli-explore-agent diagnosis (1-4 angles)
**Phase 2: Clarification** (Optional)
- Aggregate clarification needs
- AskUserQuestion for missing info
**Phase 3: Fix Planning**
- Low/Medium severity -> Direct Claude planning
- High/Critical severity -> cli-lite-planning-agent
**Phase 4: Confirmation & Selection**
- Display fix-plan summary
- User confirms execution method
**Phase 5: Execute**
- Execute via `/workflow:lite-execute --in-memory --mode bugfix`
### Artifacts
**Location**: `.workflow/.lite-fix/{bug-slug}-{YYYY-MM-DD}/`
```
.workflow/.lite-fix/
└── login-timeout-fix-2025-02-03/
├── diagnosis-root-cause.json
├── diagnosis-impact.json
├── diagnosis-code-flow.json
├── diagnosis-similar.json
├── diagnoses-manifest.json
├── fix-plan.json
└── README.md
```
### Severity Levels
| Severity | Description | Planning Method |
|----------|-------------|-----------------|
| **Low** | Simple fix, clear root cause | Direct Claude (optional rationale) |
| **Medium** | Moderate complexity, some investigation | Direct Claude (with rationale) |
| **High** | Complex, multiple components affected | cli-lite-planning-agent (full schema) |
| **Critical** | Production incident, urgent | cli-lite-planning-agent + hotfix mode |
### Hotfix Mode
```bash
/workflow:lite-fix --hotfix "Production API returning 500 errors"
```
**Characteristics**:
- Skip most diagnosis phases
- Minimal planning (direct execution)
- Auto-generate follow-up tasks for complete fix + post-mortem
### Use Cases
- Bug diagnosis
- Production emergencies
- Root cause analysis
---
## Workflow 3: multi-cli-plan -> lite-execute
**Multi-CLI collaborative analysis + Consensus convergence**
### Command
```bash
/workflow:multi-cli-plan "Compare Redis vs Memcached for caching"
/workflow:lite-execute
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Context Gathering]
B --> C[ACE semantic search<br/>Build context package]
C --> D[Phase 2: Multi-CLI Discussion<br/>Iterative]
D --> E[cli-discuss-agent]
E --> F[Gemini + Codex + Claude]
F --> G{Converged?}
G -->|No| H[Cross-verification<br/>Synthesize solutions]
H --> D
G -->|Yes| I[Phase 3: Present Options]
I --> J[Display solutions<br/>with trade-offs]
J --> K[Phase 4: User Decision]
K --> L[User selects solution]
L --> M[Phase 5: Plan Generation]
M --> N[cli-lite-planning<br/>-agent]
N --> O[-> lite-execute]
O --> P([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef agent fill:#ffecb3,stroke:#ffa000
class A,P startend,B,C,E,H,J,L,M,O action,G,K decision,F,N agent
`}
/>
### Process Phases
**Phase 1: Context Gathering**
- ACE semantic search
- Build context package
**Phase 2: Multi-CLI Discussion** (Iterative)
- cli-discuss-agent executes Gemini + Codex + Claude
- Cross-verification, synthesize solutions
- Loop until convergence or max rounds
**Phase 3: Present Options**
- Display solutions with trade-offs
**Phase 4: User Decision**
- User selects solution
**Phase 5: Plan Generation**
- cli-lite-planning-agent generates plan
- -> lite-execute
### Artifacts
**Location**: `.workflow/.multi-cli-plan/{MCP-task-slug-date}/`
```
.workflow/.multi-cli-plan/
└── redis-vs-memcached-2025-02-03/
├── context-package.json
├── rounds/
│ ├── round-1/
│ │ ├── gemini-analysis.md
│ │ ├── codex-analysis.md
│ │ ├── claude-analysis.md
│ │ └── synthesis.json
│ ├── round-2/
│ └── ...
├── selected-solution.json
├── IMPL_PLAN.md
└── plan.json
```
### vs lite-plan Comparison
| Aspect | multi-cli-plan | lite-plan |
|--------|---------------|-----------|
| **Context** | ACE semantic search | Manual file patterns |
| **Analysis** | Multi-CLI cross-verification | Single planning |
| **Iteration** | Multiple rounds until convergence | Single round |
| **Confidence** | High (consensus-driven) | Medium (single perspective) |
| **Time** | Longer (multi-round) | Faster |
### Use Cases
- Multi-perspective analysis
- Technology selection
- Solution comparison
- Architecture decisions
---
## Level 2 Comparison Table
| Aspect | lite-plan | lite-fix | multi-cli-plan |
|--------|-----------|----------|----------------|
| **Purpose** | Clear requirements | Bug diagnosis | Multi-perspective |
| **Planning** | In-memory | Severity-based | Consensus-driven |
| **Artifacts** | memory://plan | .lite-fix/ | .multi-cli-plan/ |
| **Code Exploration** | Optional (-e flag) | Built-in diagnosis | ACE search |
| **Multi-CLI** | No | No | Yes (Gemini/Codex/Claude) |
| **Best For** | Single-module features | Bug fixes | Technology decisions |
## Execution: lite-execute
All Level 2 workflows execute via `lite-execute`:
```bash
/workflow:lite-execute --in-memory
```
### Execution Flow
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Initialize tracking<br/>previousExecutionResults]
B --> C[Task grouping<br/>& batch creation]
C --> D[Extract explicit<br/>depends_on]
D --> E[Group: independent<br/>tasks -> parallel batch]
E --> F[Group: dependent<br/>tasks -> sequential phases]
F --> G[Create TodoWrite<br/>list for batches]
G --> H[Launch execution]
H --> I[Phase 1: All independent<br/>tasks - Single batch]
I --> J[Phase 2+: Dependent tasks<br/>by dependency order]
J --> K[Track progress<br/>TodoWrite updates]
K --> L{Code review?}
L -->|Yes| M[Review process]
L -->|No| N([Complete])
M --> N
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
class A,N startend,B,D,E,F,G,I,J,K,M action,C,L decision
`}
/>
### Features
- **Parallel execution** for independent tasks
- **Sequential phases** for dependent tasks
- **Progress tracking** via TodoWrite
- **Optional code review**
## Related Workflows
- [Level 1: Ultra-Lightweight](./level-1-ultra-lightweight.mdx) - Simpler workflow
- [Level 3: Standard](./level-3-standard.mdx) - Full session management
- [Level 4: Brainstorm](./level-4-brainstorm.mdx) - Multi-role exploration
- [FAQ](./faq.mdx) - Common questions

View File

@@ -0,0 +1,507 @@
---
title: Level 3 - Standard Workflows
description: Complete planning with persistent session management for multi-module changes
sidebar_position: 4
---
import Mermaid from '@theme/Mermaid';
# Level 3: Standard Workflows
**Complexity**: Medium-High | **Artifacts**: Persistent session files | **State**: Full session management
Level 3 workflows provide complete planning with persistent session management. They're designed for multi-module changes that require traceability, verification, and structured execution.
## Overview
<Mermaid
chart={`
flowchart TD
Start([User Input]) --> Select{Select Workflow}
Select -->|Standard<br/>development| Plan[plan]
Select -->|Test-driven| TDD[tdd-plan]
Select -->|Test fix| TestFix[test-fix-gen]
Plan --> Verify[plan-verify<br/>Optional]
TDD --> Verify
Verify --> Execute[execute]
TestFix --> TestCycle[test-cycle-execute]
Execute --> Review{Review?}
TestCycle --> Review
Review -->|Yes| RevCycle[review-session-cycle]
Review -->|No| TestQ{Tests?}
RevCycle --> RevFix[review-cycle-fix]
RevFix --> TestQ
TestQ -->|Yes| TFG[test-fix-gen]
TestQ -->|No| Complete([session:complete])
TFG --> TCE[test-cycle-execute]
TCE --> Complete
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef workflow fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef execute fill:#c5e1a5,stroke:#388e3c
class Start,Complete startend,Select,Review,TestQ decision,Plan,TDD,TestFix workflow,Verify,Execute,TestCycle,RevCycle,RevFix,TFG,TCE execute
`}
/>
## Included Workflows
| Workflow | Purpose | Phases | Artifact Location |
|----------|---------|--------|-------------------|
| `plan` | Complex feature development | 5 phases | `.workflow/active/{session}/` |
| `tdd-plan` | Test-driven development | 6 phases | `.workflow/active/{session}/` |
| `test-fix-gen` | Test fix generation | 5 phases | `.workflow/active/WFS-test-{session}/` |
### Common Characteristics
| Property | Value |
|----------|-------|
| **Complexity** | Medium-High |
| **Artifacts** | Persistent files (`.workflow/active/{session}/`) |
| **State** | Full session management |
| **Verification** | Built-in verification steps |
| **Execution** | `/workflow:execute` |
| **Use Case** | Multi-module, traceable tasks |
---
## Workflow 1: plan -> verify -> execute
**5-phase complete planning workflow**
### Command
```bash
/workflow:plan "Implement OAuth2 authentication system"
/workflow:plan-verify # Verify plan (recommended)
/workflow:execute
/workflow:review # (optional) Review
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Session Discovery]
B --> C[/workflow:session:start<br/>--auto/]
C --> D[Return: sessionId]
D --> E[Phase 2: Context Gathering]
E --> F[/workflow:tools:context-gather/]
F --> G[Return: context-package.json<br/>+ conflict_risk]
G --> H{conflict_risk<br/>>= medium?}
H -->|Yes| I[Phase 3: Conflict Resolution]
H -->|No| J[Phase 4: Task Generation]
I --> K[/workflow:tools:conflict<br/>-resolution/]
K --> J
J --> L[/workflow:tools:task-generate<br/>-agent/]
L --> M[Return: IMPL_PLAN.md<br/>+ IMPL-*.json<br/>+ TODO_LIST.md]
M --> N[Return Summary<br/>+ Next Steps]
N --> O([Plan Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef tool fill:#ffecb3,stroke:#ffa000
class A,O startend,H decision,B,E,G,J,M,N action,C,F,K,L tool
`}
/>
### Process Phases
**Phase 1: Session Discovery**
```bash
/workflow:session:start --auto "Implement OAuth2 authentication system"
```
- Creates or discovers workflow session
- Returns: `sessionId`
**Phase 2: Context Gathering**
```bash
/workflow:tools:context-gather
```
- Analyzes codebase structure
- Identifies tech stack and patterns
- Returns: `context-package.json` + `conflict_risk`
**Phase 3: Conflict Resolution** (Conditional)
```bash
# Only if conflict_risk >= medium
/workflow:tools:conflict-resolution
```
- Detects potential conflicts
- Resolves dependency issues
- Ensures clean execution path
**Phase 4: Task Generation**
```bash
/workflow:tools:task-generate-agent
```
- Generates structured tasks
- Creates dependency graph
- Returns: `IMPL_PLAN.md` + `IMPL-*.json` + `TODO_LIST.md`
### Artifacts
**Location**: `.workflow/active/{WFS-session}/`
```
.workflow/active/WFS-oauth2-auth-2025-02-03/
├── workflow-session.json # Session metadata
├── IMPL_PLAN.md # Implementation plan
├── TODO_LIST.md # Progress tracking
├── .task/
│ ├── IMPL-001.json # Main task
│ ├── IMPL-002.json
│ └── ...
└── .process/
├── context-package.json # Project context
├── conflict-resolution.json # Conflict analysis
└── planning-notes.md
```
### Use Cases
- Multi-module changes
- Refactoring
- Dependency analysis needed
---
## Workflow 2: tdd-plan -> execute -> tdd-verify
**6-phase test-driven development workflow**
### Command
```bash
/workflow:tdd-plan "Implement user registration with TDD"
/workflow:execute # Follow Red-Green-Refactor
/workflow:tdd-verify # Verify TDD compliance
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Session Discovery]
B --> C[/workflow:session:start<br/>--type tdd --auto/]
C --> D[Parse: sessionId]
D --> E[Phase 2: Context Gathering]
E --> F[/workflow:tools:context-gather/]
F --> G[Return: context-package.json]
G --> H[Phase 3: Test Coverage Analysis]
H --> I[/workflow:tools:test-context<br/>-gather/]
I --> J[Detect test framework<br/>Analyze coverage]
J --> K{conflict_risk<br/>>= medium?}
K -->|Yes| L[Phase 4: Conflict Resolution]
K -->|No| M[Phase 5: TDD Task Generation]
L --> N[/workflow:tools:conflict<br/>-resolution/]
N --> M
M --> O[/workflow:tools:task-generate<br/>-tdd/]
O --> P[Generate IMPL tasks with<br/>Red-Green-Refactor cycles]
P --> Q[Phase 6: TDD Structure Validation]
Q --> R[Verify TDD compliance]
R --> S([TDD Plan Complete])
T[Execute] --> U[/workflow:execute/]
U --> V[Follow Red-Green-Refactor<br/>cycles in each task]
V --> W[Verify]
W --> X[/workflow:tdd-verify/]
X --> Y([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef tool fill:#ffecb3,stroke:#ffa000
class A,S,Y startend,K decision,B,E,G,H,J,M,P,Q,R,T,U,V,X action,C,F,I,N,O,W tool
`}
/>
### Process Phases
**Phase 1: Session Discovery**
```bash
/workflow:session:start --type tdd --auto "TDD: User Registration"
```
**TDD Structured Format**:
```
TDD: [Feature Name]
GOAL: [Objective]
SCOPE: [Included/excluded]
CONTEXT: [Background]
TEST_FOCUS: [Test scenarios]
```
**Phase 2: Context Gathering**
```bash
/workflow:tools:context-gather
```
**Phase 3: Test Coverage Analysis**
```bash
/workflow:tools:test-context-gather
```
- Detect test framework
- Analyze existing test coverage
- Identify coverage gaps
**Phase 4: Conflict Resolution** (Conditional)
```bash
# Only if conflict_risk >= medium
/workflow:tools:conflict-resolution
```
**Phase 5: TDD Task Generation**
```bash
/workflow:tools:task-generate-tdd
```
- Generate IMPL tasks with built-in Red-Green-Refactor cycles
- `meta.tdd_workflow: true`
- `flow_control.implementation_approach` contains 3 steps (red/green/refactor)
**Phase 6: TDD Structure Validation**
- Verify TDD structure compliance
### TDD Task Structure
```json
{
"id": "IMPL-001",
"title": "Implement user registration",
"meta": {
"tdd_workflow": true
},
"flow_control": {
"implementation_approach": [
{
"step": 1,
"title": "Red: Write failing test",
"description": "Write test that fails"
},
{
"step": 2,
"title": "Green: Make test pass",
"description": "Implement minimal code to pass",
"test_fix_cycle": {
"max_iterations": 3,
"pass_threshold": 0.95
}
},
{
"step": 3,
"title": "Refactor: Improve code",
"description": "Refactor while keeping tests green"
}
]
}
}
```
### The Iron Law
```
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
```
**Enforcement Method**:
- Phase 5: `implementation_approach` includes test-first steps (Red -> Green -> Refactor)
- Green phase: Includes test-fix-cycle configuration (max 3 iterations)
- Auto-revert: Triggered when max iterations reached without passing tests
**Why Order Matters**:
- Tests written after code pass immediately -> proves nothing
- Test-first forces edge case discovery before implementation
- Tests-after verify what was built, not what's required
### Use Cases
- Test-driven development
- High-quality feature requirements
- Critical system components
---
## Workflow 3: test-fix-gen -> test-cycle-execute
**5-phase test fix generation workflow**
### Command
```bash
# Session Mode
/workflow:test-fix-gen WFS-user-auth-v2
/workflow:test-cycle-execute
# Prompt Mode
/workflow:test-fix-gen "Test the auth API"
/workflow:test-cycle-execute
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B{Input Mode?}
B -->|Session<br/>Mode| C[Phase 1: Use Source<br/>Session]
B -->|Prompt<br/>Mode| D[Phase 1: Create<br/>Test Session]
C --> E[/workflow:session:start<br/>--type test --resume/]
D --> F[/workflow:session:start<br/>--type test --new/]
E --> G[Phase 2: Gather Test Context]
F --> H[Phase 2: Gather Test Context]
G --> I[/workflow:tools:test-context<br/>-gather/]
H --> I
I --> J[Phase 3: Test Generation Analysis]
J --> K[/workflow:tools:test-concept<br/>-enhanced/]
K --> L[Multi-layer test requirements<br/>L0: Static, L1: Unit<br/>L2: Integration, L3: E2E]
L --> M[Phase 4: Generate Test Tasks]
M --> N[/workflow:tools:test-task-generate/]
N --> O[IMPL-001: generate<br/>+ IMPL-001.5: quality gate<br/>+ IMPL-002: execute fix]
O --> P[Phase 5: Return Summary]
P --> Q[-> test-cycle-execute]
Q --> R([Test Fix Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef tool fill:#ffecb3,stroke:#ffa000
class A,R startend,B decision,C,D,E,F,G,H,J,M,P,Q action,I,K,N tool
`}
/>
### Process Phases
**Phase 1: Create/Use Test Session**
**Session Mode** (uses existing session):
```bash
/workflow:session:start --type test --resume WFS-user-auth-v2
```
**Prompt Mode** (creates new session):
```bash
/workflow:session:start --type test --new
```
**Phase 2: Gather Test Context**
```bash
/workflow:tools:test-context-gather
```
**Phase 3: Test Generation Analysis**
```bash
/workflow:tools:test-concept-enhanced
```
- Multi-layer test requirements:
- **L0: Static** - Type checking, linting
- **L1: Unit** - Function-level tests
- **L2: Integration** - Component interaction
- **L3: E2E** - Full system tests
**Phase 4: Generate Test Tasks**
```bash
/workflow:tools:test-task-generate
```
- `IMPL-001.json`: Test understanding & generation
- `IMPL-001.5-review.json`: Quality gate
- `IMPL-002.json`: Test execution & fix cycle
**Phase 5: Return Summary**
- -> `/workflow:test-cycle-execute`
### Dual-Mode Support
| Mode | Input Pattern | Context Source |
|------|---------------|----------------|
| **Session Mode** | `WFS-xxx` | Source session summaries |
| **Prompt Mode** | Text/file path | Direct codebase analysis |
### Artifacts
**Location**: `.workflow/active/WFS-test-{session}/`
```
.workflow/active/WFS-test-user-auth-2025-02-03/
├── workflow-session.json
├── .task/
│ ├── IMPL-001.json # Test understanding & generation
│ ├── IMPL-001.5-review.json # Quality gate
│ └── IMPL-002.json # Test execution & fix cycle
└── .process/
├── TEST_ANALYSIS_RESULTS.md
└── test-context-package.json
```
### Use Cases
- Test failure fixes
- Coverage improvement
- Test suite generation
---
## Level 3 Comparison Table
| Aspect | plan | tdd-plan | test-fix-gen |
|--------|------|----------|--------------|
| **Purpose** | Complex features | Test-driven dev | Test fixes |
| **Phases** | 5 | 6 | 5 |
| **TDD** | No | Yes (Red-Green-Refactor) | Optional |
| **Artifacts** | `.workflow/active/` | `.workflow/active/` | `.workflow/active/WFS-test-*/` |
| **Verification** | plan-verify | tdd-verify | Built-in quality gate |
| **Best For** | Multi-module changes | High-quality features | Test improvements |
## Execution: execute
All Level 3 workflows execute via `execute`:
```bash
/workflow:execute --session WFS-{session-id}
```
### Key Features
- **Dependency analysis** - Automatic task dependency resolution
- **Parallel execution** - Independent tasks run in parallel
- **Progress tracking** - Session-based TODO updates
- **Summaries** - Task completion summaries for dependent tasks
## Related Workflows
- [Level 2: Rapid](./level-2-rapid.mdx) - Simpler workflow
- [Level 4: Brainstorm](./level-4-brainstorm.mdx) - Multi-role exploration
- [Level 5: Intelligent](./level-5-intelligent.mdx) - Automated orchestration
- [FAQ](./faq.mdx) - Common questions

View File

@@ -0,0 +1,336 @@
---
title: Level 4 - Brainstorm Workflows
description: Multi-role brainstorming workflows for complex feature design and architecture exploration
sidebar_position: 5
---
import Mermaid from '@theme/Mermaid';
# Level 4: Brainstorm Workflows
**Complexity**: High | **Artifacts**: Multi-role analysis docs | **Roles**: 3-9 | **Execution**: Phase 1/3 sequential, Phase 2 parallel
Level 4 workflows provide multi-role brainstorming with complete planning and execution. They're designed for exploratory requirements, uncertain implementation approaches, and multi-dimensional trade-offs.
## Overview
<Mermaid
chart={`
flowchart TD
Start([User Input]) --> BS[brainstorm:auto-parallel]
BS --> P1[Phase 1: Interactive<br/>Framework Generation]
P1 --> P2[Phase 2: Parallel<br/>Role Analysis]
P2 --> P3[Phase 3: Synthesis<br/>Integration]
P3 --> Plan{Need detailed<br/>planning?}
Plan -->|Yes| Verify[plan-verify]
Plan -->|No| Execute[execute]
Verify --> Execute
Execute --> Review{Review?}
Review -->|Yes| Rev[review-session-cycle]
Review -->|No| Test{Tests?}
Rev --> RevFix[review-cycle-fix]
RevFix --> Test
Test -->|Yes| TFG[test-fix-gen]
Test -->|No| Complete([session:complete])
TFG --> TCE[test-cycle-execute]
TCE --> Complete
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef workflow fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef execute fill:#c5e1a5,stroke:#388e3c
class Start,Complete startend,Plan,Review,Test decision,BS,Verify,Rev,RevFix,TFG,TCE workflow,P1,P2,P3,Execute execute
`}
/>
## Included Workflow: brainstorm:auto-parallel
**Multi-role brainstorming + Complete planning + Execution**
### Command
```bash
/workflow:brainstorm:auto-parallel "Real-time notification system architecture" [--count N] [--style-skill package]
/workflow:plan --session {sessionId}
/workflow:plan-verify
/workflow:execute
```
### Flow Diagram
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Interactive<br/>Framework Generation]
B --> C[/workflow:brainstorm:artifacts/]
C --> D[Topic analysis<br/>Generate questions]
D --> E[Role selection<br/>User confirmation]
E --> F[Role question collection]
F --> G[Conflict detection<br/>and resolution]
G --> H[Generate guidance-<br/>specification.md]
H --> I[Phase 2: Parallel Role Analysis]
I --> J1[N x Task<br/>conceptual-planning-<br/>agent]
J1 --> K1{Role 1}
J1 --> K2{Role 2}
J1 --> K3{Role 3}
J1 --> K4{Role N}
K1 --> L1[Analyze independently]
K2 --> L2[Analyze independently]
K3 --> L3[Analyze independently]
K4 --> L4[Analyze independently]
L1 --> M[Parallel generate<br/>{role}/analysis.md]
L2 --> M
L3 --> M
L4 --> M
M --> N[Phase 3: Synthesis Integration]
N --> O[/workflow:brainstorm:<br/>synthesis/]
O --> P[Integrate all role<br/>analyses]
P --> Q[Synthesize into<br/>synthesis-specification.md]
Q --> R([Brainstorm Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef action fill:#e3f2fd,stroke:#1976d2
classDef phase fill:#fff9c4,stroke:#f57c00
classDef parallel fill:#ffecb3,stroke:#ffa000
class A,R startend,B,C,H,N,O,P,Q action,D,E,F,G,J1,K1,K2,K3,K4,L1,L2,L3,L4,M phase
`}
/>
### Characteristics
| Property | Value |
|----------|-------|
| **Complexity** | High |
| **Artifacts** | Multi-role analysis docs + `IMPL_PLAN.md` |
| **Role Count** | 3-9 (default 3) |
| **Execution Mode** | Phase 1/3 sequential, Phase 2 parallel |
### Process Phases
#### Phase 1: Interactive Framework Generation
```bash
/workflow:brainstorm:artifacts "Real-time notification system architecture"
```
**Steps**:
1. **Topic Analysis** - Analyze the topic, generate key questions
2. **Role Selection** - User confirms role selection
3. **Role Question Collection** - Assign questions to roles
4. **Conflict Detection** - Detect and resolve role conflicts
5. **Generate Framework** - Create `guidance-specification.md`
#### Phase 2: Parallel Role Analysis
```bash
# Executes N conceptual-planning-agent tasks in parallel
Task(subagent_type: "conceptual-planning-agent", prompt: "Role: {role}, Topic: {topic}, Questions: {questions}")
```
**Each role**:
- Receives role-specific guidance
- Analyzes topic independently
- Generates `{role}/analysis.md`
- Optional: Sub-documents (max 5)
#### Phase 3: Synthesis Integration
```bash
/workflow:brainstorm:synthesis --session {sessionId}
```
**Steps**:
1. **Collect** all role analyses
2. **Integrate** perspectives into synthesis
3. **Generate** `synthesis-specification.md`
4. **Identify** key decisions and trade-offs
### Available Roles
| Role | Description |
|------|-------------|
| `system-architect` | System Architect - Overall system design |
| `ui-designer` | UI Designer - User interface design |
| `ux-expert` | UX Expert - User experience optimization |
| `product-manager` | Product Manager - Product requirements |
| `product-owner` | Product Owner - Business value |
| `data-architect` | Data Architect - Data structure design |
| `scrum-master` | Scrum Master - Process and team |
| `subject-matter-expert` | Domain Expert - Subject matter expertise |
| `test-strategist` | Test Strategist - Testing strategy |
### Artifact Structure
```
.workflow/active/WFS-realtime-notifications/
├── workflow-session.json
└── .brainstorming/
├── guidance-specification.md # Framework (Phase 1)
├── system-architect/
│ ├── analysis.md # Main document
│ └── analysis-scale-{}.md # Sub-documents (optional, max 5)
├── ux-expert/
│ ├── analysis.md
│ └── analysis-accessibility.md
├── data-architect/
│ ├── analysis.md
│ └── analysis-storage.md
└── synthesis-specification.md # Integration (Phase 3)
```
### Use Cases
### When to Use
- New feature design
- System architecture refactoring
- Exploratory requirements
- Uncertain implementation approach
- Multi-dimensional trade-offs needed
### When NOT to Use
- Clear requirements (use Level 2-3)
- Time-sensitive tasks (use Level 2)
- Single-perspective sufficient (use Level 2-3)
### Examples
#### Example 1: Architecture Design
```bash
/workflow:brainstorm:auto-parallel "Microservices architecture for e-commerce platform" --count 5
```
**Roles**: system-architect, data-architect, ux-expert, product-manager, test-strategist
**Output**:
- Multiple architectural perspectives
- Data flow considerations
- User experience implications
- Business requirements alignment
- Testing strategy recommendations
#### Example 2: Feature Exploration
```bash
/workflow:brainstorm:auto-parallel "AI-powered recommendations" --count 3
```
**Roles**: system-architect, product-manager, subject-matter-expert
**Output**:
- Technical feasibility analysis
- Business value assessment
- Domain-specific considerations
## With-File Workflows
**With-File workflows** provide documented exploration with multi-CLI collaboration. They are self-contained and generate comprehensive session artifacts.
| Workflow | Purpose | Level | Key Features |
|----------|---------|-------|--------------|
| **brainstorm-with-file** | Multi-perspective ideation | 4 | Gemini/Codex/Claude perspectives, diverge-converge cycles |
| **debug-with-file** | Hypothesis-driven debugging | 3 | Gemini validation, understanding evolution, NDJSON logging |
| **analyze-with-file** | Collaborative analysis | 3 | Multi-round Q&A, CLI exploration, documented discussions |
### brainstorm-with-file
**Multi-perspective ideation with documented exploration**
```bash
/workflow:brainstorm-with-file "Notification system redesign"
```
**Output Folder**: `.workflow/.brainstorm/`
**Characteristics**:
- Diverge-converge cycles
- Multiple CLI perspectives (Gemini, Codex, Claude)
- Built-in post-completion options (create plan, issue, deep analysis)
### debug-with-file
**Hypothesis-driven debugging with documented investigation**
```bash
/workflow:debug-with-file "System randomly crashes under load"
```
**Output Folder**: `.workflow/.debug/`
**Characteristics**:
- Hypothesis-driven iteration
- Gemini validation for hypotheses
- Understanding evolution tracking
- NDJSON logging for reproducibility
### analyze-with-file
**Collaborative analysis with documented discussions**
```bash
/workflow:analyze-with-file "Understand authentication architecture design decisions"
```
**Output Folder**: `.workflow/.analysis/`
**Characteristics**:
- Multi-round Q&A
- CLI exploration integration
- Documented discussion threads
## Detection Keywords
| Workflow | Keywords |
|----------|----------|
| **brainstorm** | 头脑风暴, 创意, 发散思维, multi-perspective, compare perspectives, 探索可能 |
| **debug-file** | 深度调试, 假设验证, systematic debug, hypothesis debug, 调试记录 |
| **analyze-file** | 协作分析, 深度理解, collaborative analysis, explore concept, 理解架构 |
## Comparison: With-File vs Standard Workflows
| Aspect | With-File Workflows | Standard Workflows |
|--------|---------------------|-------------------|
| **Documentation** | E evolving documents | Session artifacts |
| **Multi-CLI** | Built-in (Gemini/Codex/Claude) | Optional |
| **Iteration** | Self-contained loop | Manual continuation |
| **Post-Completion** | Built-in options | Manual next steps |
| **Best For** | Documented exploration | Structured execution |
## Level 4 Summary
| Aspect | Value |
|--------|-------|
| **Complexity** | High |
| **Artifacts** | Multi-role analysis + Session |
| **Planning** | Multi-perspective convergence |
| **Execution** | Standard Level 3 execution |
| **Best For** | Complex, exploratory tasks |
## Related Workflows
- [Level 3: Standard](./level-3-standard.mdx) - Standard planning workflows
- [Level 5: Intelligent](./level-5-intelligent.mdx) - Automated orchestration
- [FAQ](./faq.mdx) - Common questions
## Command Reference
See [Commands Documentation](../commands/general/ccw.mdx) for:
- `/workflow:brainstorm:auto-parallel` - Multi-role brainstorming
- `/workflow:brainstorm-with-file` - Documented ideation
- `/workflow:debug-with-file` - Hypothesis-driven debugging
- `/workflow:analyze-with-file` - Collaborative analysis

View File

@@ -0,0 +1,442 @@
---
title: Level 5 - Intelligent Workflows
description: Automated command orchestration with intelligent analysis and recommendation
sidebar_position: 6
---
import Mermaid from '@theme/Mermaid';
# Level 5: Intelligent Workflows
**Complexity**: All levels | **Artifacts**: Full state persistence | **Automation**: Complete
Level 5 workflows provide the most intelligent automation - automated command chain orchestration with sequential execution and state persistence. They auto-analyze requirements, recommend optimal command chains, and execute end-to-end.
## Overview
<Mermaid
chart={`
flowchart TD
Start([User Input]) --> Analyze[Phase 1: Analyze<br/>Requirements]
Analyze --> Recommend[Phase 2: Discover Commands<br/>& Recommend Chain]
Recommend --> Confirm[User Confirmation<br/>Optional]
Confirm --> Execute[Phase 3: Execute Sequential<br/>Command Chain]
Execute --> State[State Persistence<br/>state.json]
State --> Check{Complete?}
Check -->|No| Execute
Check -->|Yes| Complete([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef phase fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef state fill:#ffecb3,stroke:#ffa000
class Start,Complete startend,Confirm,Check decision,Analyze,Recommend,Execute phase,State state
`}
/>
## Included Workflow: ccw-coordinator
**Auto-analyze & recommend command chains with sequential execution**
### Command
```bash
/ccw-coordinator "Implement user authentication with OAuth2"
# Or simply
/ccw "Add user authentication"
```
### Core Concept: Minimum Execution Units
**Definition**: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone.
**Why This Matters**:
- **Prevents Incomplete States**: Avoid stopping after task generation without execution
- **User Experience**: User gets complete results, not intermediate artifacts requiring manual follow-up
- **Workflow Integrity**: Maintains logical coherence of multi-step operations
### Minimum Execution Units
#### Planning + Execution Units
| Unit Name | Commands | Purpose | Output |
|-----------|----------|---------|--------|
| **Quick Implementation** | lite-plan -> lite-execute | Lightweight plan and immediate execution | Working code |
| **Multi-CLI Planning** | multi-cli-plan -> lite-execute | Multi-perspective analysis and execution | Working code |
| **Bug Fix** | lite-fix -> lite-execute | Quick bug diagnosis and fix execution | Fixed code |
| **Full Planning + Execution** | plan -> execute | Detailed planning and execution | Working code |
| **Verified Planning + Execution** | plan -> plan-verify -> execute | Planning with verification and execution | Working code |
| **Replanning + Execution** | replan -> execute | Update plan and execute changes | Working code |
| **TDD Planning + Execution** | tdd-plan -> execute | Test-driven development planning and execution | Working code |
| **Test Generation + Execution** | test-gen -> execute | Generate test suite and execute | Generated tests |
#### Testing Units
| Unit Name | Commands | Purpose | Output |
|-----------|----------|---------|--------|
| **Test Validation** | test-fix-gen -> test-cycle-execute | Generate test tasks and execute test-fix cycle | Tests passed |
#### Review Units
| Unit Name | Commands | Purpose | Output |
|-----------|----------|---------|--------|
| **Code Review (Session)** | review-session-cycle -> review-fix | Complete review cycle and apply fixes | Fixed code |
| **Code Review (Module)** | review-module-cycle -> review-fix | Module review cycle and apply fixes | Fixed code |
### 3-Phase Workflow
<Mermaid
chart={`
flowchart TD
A([Start]) --> B[Phase 1: Analyze Requirements]
B --> C[Parse task description]
C --> D[Extract: goal, scope, constraints,<br/>complexity, task type]
D --> E[Phase 2: Discover Commands<br/>& Recommend Chain]
E --> F[Dynamic command chain<br/>assembly]
F --> G[Port-based matching]
G --> H{User Confirmation}
H -->|Confirm| I[Phase 3: Execute Sequential<br/>Command Chain]
H -->|Adjust| J[Modify chain]
H -->|Cancel| K([Abort])
J --> H
I --> L[Initialize state]
L --> M[For each command]
M --> N[Assemble prompt]
N --> O[Launch CLI in background]
O --> P[Save checkpoint]
P --> Q{Complete?}
Q -->|No| M
Q -->|Yes| R([Complete])
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef phase fill:#e3f2fd,stroke:#1976d2
classDef decision fill:#fff9c4,stroke:#f57c00
classDef execute fill:#c5e1a5,stroke:#388e3c
class A,K,R startend,H,Q decision,B,E,I phase,C,D,F,G,J,L,M,N,O,P execute
`}
/>
#### Phase 1: Analyze Requirements
Parse task description to extract: goal, scope, constraints, complexity, and task type.
```javascript
function analyzeRequirements(taskDescription) {
return {
goal: extractMainGoal(taskDescription), // e.g., "Implement user registration"
scope: extractScope(taskDescription), // e.g., ["auth", "user_management"]
constraints: extractConstraints(taskDescription), // e.g., ["no breaking changes"]
complexity: determineComplexity(taskDescription), // 'simple' | 'medium' | 'complex'
task_type: detectTaskType(taskDescription) // See task type patterns below
};
}
// Task Type Detection Patterns
function detectTaskType(text) {
// Priority order (first match wins)
if (/fix|bug|error|crash|fail|debug|diagnose/.test(text)) return 'bugfix';
if (/tdd|test-driven|test first/.test(text)) return 'tdd';
if (/test fail|fix test|failing test/.test(text)) return 'test-fix';
if (/generate test|add test/.test(text)) return 'test-gen';
if (/review/.test(text)) return 'review';
if (/explore|brainstorm/.test(text)) return 'brainstorm';
if (/multi-perspective|comparison/.test(text)) return 'multi-cli';
return 'feature'; // Default
}
// Complexity Assessment
function determineComplexity(text) {
let score = 0;
if (/refactor|migrate|architect|system/.test(text)) score += 2;
if (/multiple|across|all|entire/.test(text)) score += 2;
if (/integrate|api|database/.test(text)) score += 1;
if (/security|performance|scale/.test(text)) score += 1;
return score >= 4 ? 'complex' : score >= 2 ? 'medium' : 'simple';
}
```
#### Phase 2: Discover Commands & Recommend Chain
Dynamic command chain assembly using port-based matching.
**Display to user**:
```
Recommended Command Chain:
Pipeline (visual):
Requirement -> lite-plan -> Plan -> lite-execute -> Code -> test-cycle-execute -> Tests Passed
Commands:
1. /workflow:lite-plan
2. /workflow:lite-execute
3. /workflow:test-cycle-execute
Proceed? [Confirm / Show Details / Adjust / Cancel]
```
#### Phase 3: Execute Sequential Command Chain
```javascript
async function executeCommandChain(chain, analysis) {
const sessionId = `ccw-coord-${Date.now()}`;
const stateDir = `.workflow/.ccw-coordinator/${sessionId}`;
// Initialize state
const state = {
session_id: sessionId,
status: 'running',
created_at: new Date().toISOString(),
analysis: analysis,
command_chain: chain.map((cmd, idx) => ({ ...cmd, index: idx, status: 'pending' })),
execution_results: [],
prompts_used: []
};
// Save initial state
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
for (let i = 0; i < chain.length; i++) {
const cmd = chain[i];
// Assemble prompt
let prompt = formatCommand(cmd, state.execution_results, analysis);
prompt += `\n\nTask: ${analysis.goal}`;
if (state.execution_results.length > 0) {
prompt += '\n\nPrevious results:\n';
state.execution_results.forEach(r => {
if (r.session_id) {
prompt += `- ${r.command}: ${r.session_id}\n`;
}
});
}
// Launch CLI in background
const taskId = Bash(
`ccw cli -p "${escapePrompt(prompt)}" --tool claude --mode write`,
{ run_in_background: true }
).task_id;
// Save checkpoint
state.execution_results.push({
index: i,
command: cmd.command,
status: 'in-progress',
task_id: taskId,
session_id: null,
artifacts: [],
timestamp: new Date().toISOString()
});
// Stop here - wait for hook callback
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
break;
}
state.status = 'waiting';
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
return state;
}
```
### State File Structure
**Location**: `.workflow/.ccw-coordinator/{session_id}/state.json`
```json
{
"session_id": "ccw-coord-20250203-143025",
"status": "running|waiting|completed|failed",
"created_at": "2025-02-03T14:30:25Z",
"updated_at": "2025-02-03T14:35:45Z",
"analysis": {
"goal": "Implement user registration",
"scope": ["authentication", "user_management"],
"constraints": ["no breaking changes"],
"complexity": "medium",
"task_type": "feature"
},
"command_chain": [
{
"index": 0,
"command": "/workflow:plan",
"name": "plan",
"status": "completed"
},
{
"index": 1,
"command": "/workflow:execute",
"name": "execute",
"status": "running"
}
],
"execution_results": [
{
"index": 0,
"command": "/workflow:plan",
"status": "completed",
"task_id": "task-001",
"session_id": "WFS-plan-20250203",
"artifacts": ["IMPL_PLAN.md"],
"timestamp": "2025-02-03T14:30:25Z",
"completed_at": "2025-02-03T14:30:45Z"
}
]
}
```
### Complete Lifecycle Decision Flowchart
<Mermaid
chart={`
flowchart TD
Start([Start New Task]) --> Q0{Is this a bug fix?}
Q0 -->|Yes| BugFix["Bug Fix Process"]
Q0 -->|No| Q1{Do you know what to do?}
BugFix --> BugSeverity{Understand root cause?}
BugSeverity -->|Clear| LiteFix["/workflow:lite-fix<br/>Standard fix"]
BugSeverity -->|Production incident| HotFix["/workflow:lite-fix --hotfix<br/>Emergency hotfix"]
BugSeverity -->|Unclear| BugDiag["/workflow:lite-fix<br/>Auto-diagnose root cause"]
BugDiag --> LiteFix
LiteFix --> BugComplete["Bug fixed"]
HotFix --> FollowUp["Auto-generate follow-up tasks<br/>Complete fix + post-mortem"]
FollowUp --> BugComplete
BugComplete --> End(["Task Complete"])
Q1 -->|No| Ideation["Exploration Phase<br/>Clarify requirements"]
Q1 -->|Yes| Q2{Do you know how to do it?}
Ideation --> BrainIdea["/workflow:brainstorm:auto-parallel<br/>Explore product direction"]
BrainIdea --> Q2
Q2 -->|No| Design["Design Exploration<br/>Explore architecture"]
Q2 -->|Yes| Q3{Need planning?}
Design --> BrainDesign["/workflow:brainstorm:auto-parallel<br/>Explore technical solutions"]
BrainDesign --> Q3
Q3 -->|Quick and simple| LitePlan["Lightweight Planning<br/>/workflow:lite-plan"]
Q3 -->|Complex and complete| FullPlan["Standard Planning<br/>/workflow:plan"]
LitePlan --> Q4{Need code exploration?}
Q4 -->|Yes| LitePlanE["/workflow:lite-plan -e"]
Q4 -->|No| LitePlanNormal["/workflow:lite-plan"]
LitePlanE --> LiteConfirm["Three-dimensional confirmation:<br/>1. Task approval<br/>2. Execution method<br/>3. Code review"]
LitePlanNormal --> LiteConfirm
LiteConfirm --> Q5{Select execution method}
Q5 -->|Agent| LiteAgent["/workflow:lite-execute<br/>Use @code-developer"]
Q5 -->|CLI tool| LiteCLI["CLI Execution<br/>Gemini/Qwen/Codex"]
Q5 -->|Plan only| UserImpl["User manual implementation"]
FullPlan --> PlanVerify{Verify plan quality?}
PlanVerify -->|Yes| Verify["/workflow:plan-verify"]
PlanVerify -->|No| Execute
Verify --> Q6{Verification passed?}
Q6 -->|No| FixPlan["Fix plan issues"]
Q6 -->|Yes| Execute
FixPlan --> Execute
Execute["Execution Phase<br/>/workflow:execute"]
LiteAgent --> TestDecision
LiteCLI --> TestDecision
UserImpl --> TestDecision
Execute --> TestDecision
TestDecision{Need tests?}
TestDecision -->|TDD mode| TDD["/workflow:tdd-plan<br/>Test-driven development"]
TestDecision -->|Post-test| TestGen["/workflow:test-gen<br/>Generate tests"]
TestDecision -->|Tests exist| TestCycle["/workflow:test-cycle-execute<br/>Test-fix cycle"]
TestDecision -->|Not needed| Review
TDD --> TDDExecute["/workflow:execute<br/>Red-Green-Refactor"]
TDDExecute --> TDDVerify["/workflow:tdd-verify<br/>Verify TDD compliance"]
TDDVerify --> Review
TestGen --> TestExecute["/workflow:execute<br/>Execute test tasks"]
TestExecute --> TestResult{Tests passed?}
TestResult -->|No| TestCycle
TestResult -->|Yes| Review
TestCycle --> TestPass{Pass rate >= 95%?}
TestPass -->|No, continue fixing| TestCycle
TestPass -->|Yes| Review
Review["Review Phase"]
Review --> Q7{Need specialized review?}
Q7 -->|Security| SecurityReview["/workflow:review<br/>--type security"]
Q7 -->|Architecture| ArchReview["/workflow:review<br/>--type architecture"]
Q7 -->|Quality| QualityReview["/workflow:review<br/>--type quality"]
Q7 -->|General| GeneralReview["/workflow:review<br/>General review"]
Q7 -->|Not needed| Complete
SecurityReview --> Complete
ArchReview --> Complete
QualityReview --> Complete
GeneralReview --> Complete
Complete["Completion Phase<br/>/workflow:session:complete"]
Complete --> End
classDef startend fill:#c8e6c9,stroke:#388e3c
classDef bugfix fill:#ffccbc,stroke:#bf360c
classDef ideation fill:#fff9c4,stroke:#ffa000
classDef planning fill:#e3f2fd,stroke:#1976d2
classDef execute fill:#c5e1a5,stroke:#388e3c
classDef review fill:#d1c4e9,stroke:#512da8
class Start,End startend,BugFix,LiteFix,HotFix,BugDiag,BugComplete bugfix,Ideation,BrainIdea,BrainDesign ideation,LitePlan,LitePlanE,LitePlanNormal,LiteConfirm,FullPlan,PlanVerify,Verify,FixPlan planning,Execute,LiteAgent,LiteCLI,UserImpl,TDD,TDDExecute,TDDVerify,TestGen,TestExecute,TestCycle execute,Review,SecurityReview,ArchReview,QualityReview,GeneralReview,Complete review
`}
/>
### Use Cases
### When to Use
- Complex multi-step workflows
- Uncertain which commands to use
- Desire end-to-end automation
- Need full state tracking and resumability
- Team collaboration with unified execution flow
### When NOT to Use
- Simple single-command tasks (use Level 1-4 directly)
- Already know exact commands needed (use Level 1-4 directly)
### Relationship with Other Levels
| Level | Manual Degree | CCW Coordinator Role |
|-------|---------------|-----------------------|
| Level 1-4 | Manual command selection | Auto-combine these commands |
| Level 5 | Auto command selection | Intelligent orchestrator |
**CCW Coordinator uses Level 1-4 internally**:
- Analyzes task -> Auto-selects appropriate Level
- Assembles command chain -> Includes Level 1-4 commands
- Executes sequentially -> Follows Minimum Execution Units
## Related Workflows
- [Level 1: Ultra-Lightweight](./level-1-ultra-lightweight.mdx) - Rapid execution
- [Level 2: Rapid](./level-2-rapid.mdx) - Lightweight planning
- [Level 3: Standard](./level-3-standard.mdx) - Complete planning
- [Level 4: Brainstorm](./level-4-brainstorm.mdx) - Multi-role exploration
- [FAQ](./faq.mdx) - Common questions
## Command Reference
See [Commands Documentation](../commands/general/ccw.mdx) for:
- `/ccw-coordinator` - Intelligent workflow orchestrator
- `/ccw` - Main workflow orchestrator