mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat(commands): add ccw-plan and ccw-test coordinators with arrow-style documentation
- Add ccw-plan.md: Planning coordinator with 10 modes (lite/multi-cli/full/plan-verify/replan + cli/issue/rapid-to-issue/brainstorm-with-file/analyze-with-file) - Add ccw-test.md: Test coordinator with 4 modes (gen/fix/verify/tdd) and auto-iteration support - Refactor ccw-debug.md: Convert JavaScript pseudocode to arrow instruction format for better readability - Fix command format: Use /ccw* skill call syntax instead of ccw* across all command files Key features: - CLI integration for quick analysis and recommendations - Issue workflow integration (rapid-to-issue bridge) - With-File workflows for documented multi-CLI collaboration - Consistent arrow-based flow diagrams across all coordinators - TodoWrite tracking with mode-specific prefixes (CCWP/CCWT/CCWD) - Dual tracking system (TodoWrite + status.json)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
456
.claude/commands/ccw-plan.md
Normal file
456
.claude/commands/ccw-plan.md
Normal file
@@ -0,0 +1,456 @@
|
||||
---
|
||||
name: ccw-plan
|
||||
description: Planning coordinator - analyze requirements, select planning strategy, execute planning workflow in main process
|
||||
argument-hint: "[--mode lite|multi-cli|full|plan-verify|replan|cli|issue|rapid-to-issue|brainstorm-with-file|analyze-with-file] [--yes|-y] \"task description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*)
|
||||
---
|
||||
|
||||
# CCW-Plan Command - Planning Coordinator
|
||||
|
||||
Planning orchestrator: requirement analysis → strategy selection → planning execution.
|
||||
|
||||
## Core Concept: Planning Units (规划单元)
|
||||
|
||||
**Definition**: Planning commands are grouped into logical units based on verification requirements and collaboration strategies.
|
||||
|
||||
**Planning Units**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Quick Planning** | plan-cmd (no verify) | lite-plan |
|
||||
| **Verified Planning** | plan-cmd → verify-cmd | plan → plan-verify |
|
||||
| **Collaborative Planning** | multi-cli-plan (implicit verify) | multi-cli-plan |
|
||||
| **With-File Planning** | brainstorm-with-file or analyze-with-file | brainstorm + plan options |
|
||||
| **CLI-Assisted Planning** | ccw cli (analysis) → recommendations | quick analysis + decision |
|
||||
| **Issue Workflow Planning** | plan → issue workflow (discover/queue/execute) | rapid-to-issue bridge |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. Lite mode: No verification (fast iteration)
|
||||
2. Plan-verify mode: Mandatory quality gate
|
||||
3. Multi-cli/Full mode: Optional verification (via --skip-verify flag)
|
||||
4. With-File modes: Self-contained iteration with built-in post-completion options
|
||||
5. CLI mode: Quick analysis, user-driven decisions
|
||||
6. Issue modes: Planning integrated into issue workflow lifecycle
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Planning commands execute via Skill, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Requirements → Select Strategy → [Confirm] → Execute Planning
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Generate Artifacts
|
||||
```
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Requirements
|
||||
|
||||
**Input** → Extract (goal, scope, constraints) → Assess (complexity, clarity, criticality) → **Analysis**
|
||||
|
||||
| Field | Values |
|
||||
|-------|--------|
|
||||
| complexity | low \| medium \| high |
|
||||
| clarity | 0-3 (≥2 = clear) |
|
||||
| criticality | normal \| high \| critical |
|
||||
| scope | single-module \| cross-module \| system \| batch-issues |
|
||||
|
||||
**Output**: `Type: [task_type] | Goal: [goal] | Complexity: [complexity] | Clarity: [clarity]/3 | Criticality: [criticality]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Requirement Clarification (if clarity < 2)
|
||||
|
||||
```
|
||||
Analysis → Check clarity ≥ 2?
|
||||
↓
|
||||
YES → Continue to Phase 2
|
||||
↓
|
||||
NO → Ask Questions → Update Analysis
|
||||
```
|
||||
|
||||
**Questions Asked**: Goal (Create/Fix/Optimize/Analyze), Scope (Single file/Module/Cross-module/System), Constraints (Backward compat/Skip tests/Urgent hotfix)
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Planning Strategy & Build Command Chain
|
||||
|
||||
```
|
||||
Analysis → Detect Mode (keywords) → Build Command Chain → Planning Workflow
|
||||
```
|
||||
|
||||
#### Mode Detection (Priority Order)
|
||||
|
||||
```
|
||||
Input Keywords → Mode
|
||||
───────────────────────────────────────────────────────────────────────────────
|
||||
quick|fast|immediate|recommendation|suggest → cli
|
||||
issues?|batch|issue workflow|structured workflow|queue → issue
|
||||
issue transition|rapid.*issue|plan.*issue|convert.*issue → rapid-to-issue
|
||||
brainstorm|ideation|头脑风暴|创意|发散思维|multi-perspective → brainstorm-with-file
|
||||
analyze.*document|explore.*concept|collaborative analysis → analyze-with-file
|
||||
production|critical|payment|auth → plan-verify
|
||||
adjust|modify|change plan → replan
|
||||
uncertain|explore → full
|
||||
complex|multiple module|integrate → multi-cli
|
||||
(default) → lite
|
||||
```
|
||||
|
||||
#### Command Chain Mapping
|
||||
|
||||
| Mode | Command Chain | Verification | Use Case |
|
||||
|------|---------------|--------------|----------|
|
||||
| **cli** | ccw cli --mode analysis --rule planning-* | None | Quick planning recommendation |
|
||||
| **issue** | /issue:discover → /issue:plan → /issue:queue → /issue:execute | Optional | Batch issue planning & execution |
|
||||
| **rapid-to-issue** | lite-plan → /issue:convert-to-plan → queue → execute | Optional | Quick planning → Issue workflow bridge |
|
||||
| **brainstorm-with-file** | /workflow:brainstorm-with-file → (plan/issue options) | Self-contained | Multi-perspective ideation |
|
||||
| **analyze-with-file** | /workflow:analyze-with-file → (plan/issue options) | Self-contained | Collaborative architecture analysis |
|
||||
| **lite** | lite-plan | None | Fast simple planning |
|
||||
| **multi-cli** | multi-cli-plan → [plan-verify] | Optional | Multi-model collaborative planning |
|
||||
| **full** | brainstorm → plan → [plan-verify] | Optional | Comprehensive brainstorm + planning |
|
||||
| **plan-verify** | plan → **plan-verify** | **Mandatory** | Production/critical features |
|
||||
| **replan** | replan | None | Plan refinement/adjustment |
|
||||
|
||||
**Note**:
|
||||
- `[ ]` = optional verification
|
||||
- **bold** = mandatory quality gate
|
||||
- With-File modes include built-in post-completion options to create plans/issues
|
||||
|
||||
**Output**: `Mode: [mode] | Strategy: [strategy] | Commands: [1. /cmd1 2. /cmd2]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```
|
||||
Planning Chain → Show Strategy → Ask User → User Decision:
|
||||
- ✓ Confirm → Continue to Phase 4
|
||||
- ⚙ Adjust → Change Mode (back to Phase 2)
|
||||
- ✗ Cancel → Abort
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```
|
||||
Planning Chain → Create Session Dir → Initialize Tracking → Tracking State
|
||||
```
|
||||
|
||||
**Session Structure**:
|
||||
```
|
||||
Session ID: CCWP-{goal-slug}-{date}
|
||||
Session Dir: .workflow/.ccw-plan/{session_id}/
|
||||
|
||||
TodoWrite:
|
||||
CCWP:{mode}: [1/n] /command1 [in_progress]
|
||||
CCWP:{mode}: [2/n] /command2 [pending]
|
||||
...
|
||||
|
||||
status.json:
|
||||
{
|
||||
"session_id": "CCWP-...",
|
||||
"mode": "plan-verify",
|
||||
"status": "running",
|
||||
"command_chain": [...],
|
||||
"quality_gate": "pending" // plan-verify mode only
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCWP:plan-verify: [1/2] /workflow:plan | ...`
|
||||
- Status File: `.workflow/.ccw-plan/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Planning Chain
|
||||
|
||||
```
|
||||
Start Command → Update status (running) → Execute via Skill → Result
|
||||
```
|
||||
|
||||
#### For Plan-Verify Mode (Quality Gate)
|
||||
|
||||
```
|
||||
Quality Gate → PASS → Mark completed → Next command
|
||||
↓ FAIL (plan-verify mode)
|
||||
Ask User → Refine: replan + re-verify
|
||||
→ Override: continue anyway
|
||||
→ Abort: stop planning
|
||||
```
|
||||
|
||||
#### Error Handling Pattern
|
||||
|
||||
```
|
||||
Command Error → Update status (failed) → Ask User:
|
||||
- Retry → Re-execute (same index)
|
||||
- Skip → Continue next command
|
||||
- Abort → Stop execution
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Planning Pipeline Examples
|
||||
|
||||
| Input | Mode | Pipeline | Use Case |
|
||||
|-------|------|----------|----------|
|
||||
| "Quick: should we use OAuth2?" | cli | ccw cli --mode analysis → recommendation | Immediate planning advice |
|
||||
| "Plan user login system" | lite | lite-plan | Fast simple planning |
|
||||
| "Implement OAuth2 auth" | multi-cli | multi-cli-plan → [plan-verify] | Multi-model collaborative planning |
|
||||
| "Design notification system" | full | brainstorm → plan → [plan-verify] | Comprehensive brainstorm + planning |
|
||||
| "Payment processing (prod)" | plan-verify | plan → **plan-verify** | Production critical (mandatory gate) |
|
||||
| "头脑风暴: 用户通知系统重新设计" | brainstorm-with-file | brainstorm-with-file → (plan/issue options) | Multi-perspective ideation |
|
||||
| "协作分析: 认证架构设计决策" | analyze-with-file | analyze-with-file → (plan/issue options) | Collaborative analysis |
|
||||
| "Batch plan: handle 10 pending issues" | issue | /issue:discover → plan → queue → execute | Batch issue planning |
|
||||
| "Plan and create issues" | rapid-to-issue | lite-plan → convert-to-plan → queue → execute | Quick plan → Issue workflow |
|
||||
| "Update existing plan" | replan | replan | Plan refinement/adjustment |
|
||||
|
||||
**Legend**:
|
||||
- `[ ]` = optional verification
|
||||
- **bold** = mandatory quality gate
|
||||
- **With-File modes** include built-in post-completion options to create plans/issues
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display):
|
||||
|
||||
```
|
||||
// Plan-verify mode (mandatory quality gate)
|
||||
CCWP:plan-verify: [1/2] /workflow:plan [in_progress]
|
||||
CCWP:plan-verify: [2/2] /workflow:plan-verify [pending]
|
||||
|
||||
// CLI mode (quick recommendations)
|
||||
CCWP:cli: [1/1] ccw cli --mode analysis [in_progress]
|
||||
|
||||
// Issue mode (batch planning)
|
||||
CCWP:issue: [1/4] /issue:discover [in_progress]
|
||||
CCWP:issue: [2/4] /issue:plan [pending]
|
||||
CCWP:issue: [3/4] /issue:queue [pending]
|
||||
CCWP:issue: [4/4] /issue:execute [pending]
|
||||
|
||||
// Rapid-to-issue mode (planning → issue bridge)
|
||||
CCWP:rapid-to-issue: [1/4] /workflow:lite-plan [in_progress]
|
||||
CCWP:rapid-to-issue: [2/4] /issue:convert-to-plan [pending]
|
||||
CCWP:rapid-to-issue: [3/4] /issue:queue [pending]
|
||||
CCWP:rapid-to-issue: [4/4] /issue:execute [pending]
|
||||
|
||||
// Brainstorm-with-file mode (self-contained)
|
||||
CCWP:brainstorm-with-file: [1/1] /workflow:brainstorm-with-file [in_progress]
|
||||
|
||||
// Analyze-with-file mode (self-contained)
|
||||
CCWP:analyze-with-file: [1/1] /workflow:analyze-with-file [in_progress]
|
||||
|
||||
// Lite mode (fast simple planning)
|
||||
CCWP:lite: [1/1] /workflow:lite-plan [in_progress]
|
||||
|
||||
// Multi-CLI mode (collaborative planning)
|
||||
CCWP:multi-cli: [1/1] /workflow:multi-cli-plan [in_progress]
|
||||
|
||||
// Full mode (brainstorm + planning with optional verification)
|
||||
CCWP:full: [1/2] /workflow:brainstorm [in_progress]
|
||||
CCWP:full: [2/2] /workflow:plan [pending]
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state for planning monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw-plan/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWP-oauth-auth-2025-02-02",
|
||||
"mode": "plan-verify",
|
||||
"status": "running|completed|failed",
|
||||
"created_at": "2025-02-02T10:00:00Z",
|
||||
"updated_at": "2025-02-02T10:05:00Z",
|
||||
"analysis": {
|
||||
"goal": "Implement OAuth2 authentication",
|
||||
"complexity": "high",
|
||||
"clarity_score": 2,
|
||||
"criticality": "high"
|
||||
},
|
||||
"command_chain": [
|
||||
{ "index": 0, "command": "/workflow:plan", "mandatory": false, "status": "completed" },
|
||||
{ "index": 1, "command": "/workflow:plan-verify", "mandatory": true, "status": "running" }
|
||||
],
|
||||
"current_index": 1,
|
||||
"quality_gate": "pending|PASS|FAIL"
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Planning in progress
|
||||
- `completed`: Planning finished successfully
|
||||
- `failed`: Planning aborted or quality gate failed
|
||||
|
||||
**Quality Gate Values** (plan-verify mode only):
|
||||
- `pending`: Verification not started
|
||||
- `PASS`: Plan meets quality standards
|
||||
- `FAIL`: Plan needs refinement
|
||||
|
||||
**Mode-Specific Fields**:
|
||||
- **plan-verify**: `quality_gate` field (pending|PASS|FAIL)
|
||||
- **cli**: No command_chain, stores CLI recommendations and user decision
|
||||
- **issue**: includes issue discovery results and queue configuration
|
||||
- **rapid-to-issue**: includes plan output and conversion to issue
|
||||
- **with-file modes**: stores session artifacts and post-completion options
|
||||
- **other modes**: basic command_chain tracking
|
||||
|
||||
---
|
||||
|
||||
## Extended Planning Modes
|
||||
|
||||
### CLI-Assisted Planning (cli mode)
|
||||
|
||||
```
|
||||
Quick Input → ccw cli --mode analysis --rule planning-* → Recommendations → User Decision:
|
||||
- ✓ Accept → Create lite-plan from recommendations
|
||||
- ↗ Escalate → Switch to multi-cli or full mode
|
||||
- ✗ Done → Stop (recommendation only)
|
||||
```
|
||||
|
||||
**Use Cases**:
|
||||
- Quick architecture decision questions
|
||||
- Planning approach recommendations
|
||||
- Pattern/library selection advice
|
||||
|
||||
**CLI Rules** (auto-selected based on context):
|
||||
- `planning-plan-architecture-design` - Architecture decisions
|
||||
- `planning-breakdown-task-steps` - Task decomposition
|
||||
- `planning-design-component-spec` - Component specifications
|
||||
|
||||
---
|
||||
|
||||
### With-File Planning Workflows
|
||||
|
||||
**With-File workflows** provide documented exploration with multi-CLI collaboration, generating comprehensive session artifacts.
|
||||
|
||||
| Mode | Purpose | Key Features | Output Folder |
|
||||
|------|---------|--------------|---------------|
|
||||
| **brainstorm-with-file** | Multi-perspective ideation | Gemini/Codex/Claude perspectives, diverge-converge | `.workflow/.brainstorm/` |
|
||||
| **analyze-with-file** | Collaborative architecture analysis | Multi-round Q&A, CLI exploration, documented discussions | `.workflow/.analysis/` |
|
||||
|
||||
**Detection Keywords**:
|
||||
- **brainstorm-with-file**: 头脑风暴, 创意, 发散思维, multi-perspective, ideation
|
||||
- **analyze-with-file**: 协作分析, 深度理解, collaborative analysis, explore concept
|
||||
|
||||
**Characteristics**:
|
||||
1. **Self-Contained**: Each workflow handles its own iteration loop
|
||||
2. **Documented Process**: Creates evolving documents (brainstorm.md, discussion.md)
|
||||
3. **Multi-CLI**: Uses Gemini/Codex/Claude for different perspectives
|
||||
4. **Built-in Post-Completion**: Offers follow-up options (create plan, create issue, deep dive)
|
||||
|
||||
---
|
||||
|
||||
### Issue Workflow Integration
|
||||
|
||||
| Mode | Purpose | Command Chain | Typical Use |
|
||||
|------|---------|---------------|-------------|
|
||||
| **issue** | Batch issue planning | discover → plan → queue → execute | Multiple issues in codebase |
|
||||
| **rapid-to-issue** | Quick plan → Issue workflow | lite-plan → convert-to-plan → queue → execute | Fast iteration → structured execution |
|
||||
|
||||
**Issue Workflow Bridge**:
|
||||
```
|
||||
lite-plan (in-memory) → /issue:convert-to-plan → Creates issue JSON
|
||||
↓
|
||||
/issue:queue → Form execution queue
|
||||
↓
|
||||
/issue:execute → DAG-based parallel execution
|
||||
```
|
||||
|
||||
**When to use Issue Workflow**:
|
||||
- Need structured multi-stage execution (queue-based)
|
||||
- Want parallel DAG execution
|
||||
- Multiple related changes as individual commits
|
||||
- Converting brainstorm/plan output to executable tasks
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Planning-Focused** - Pure planning coordination, no execution
|
||||
2. **Mode-Driven** - 10 planning modes for different needs (lite/multi-cli/full/plan-verify/replan + cli/issue/rapid-to-issue/brainstorm-with-file/analyze-with-file)
|
||||
3. **CLI Integration** - Quick analysis for immediate recommendations
|
||||
4. **With-File Support** - Multi-CLI collaboration with documented artifacts
|
||||
5. **Issue Workflow Bridge** - Seamless transition from planning to structured execution
|
||||
6. **Quality Gates** - Mandatory verification for production features
|
||||
7. **Flexible Verification** - Optional for exploration, mandatory for critical features
|
||||
8. **Progressive Clarification** - Low clarity triggers requirement questions
|
||||
9. **TODO Tracking** - Use CCWP prefix to isolate planning todos
|
||||
10. **Handoff Ready** - Generates artifacts ready for execution phase
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select mode (keyword-based detection)
|
||||
/ccw-plan "Add user authentication"
|
||||
|
||||
# Standard planning modes
|
||||
/ccw-plan --mode lite "Add logout endpoint"
|
||||
/ccw-plan --mode multi-cli "Implement OAuth2"
|
||||
/ccw-plan --mode full "Design notification system"
|
||||
/ccw-plan --mode plan-verify "Payment processing (production)"
|
||||
/ccw-plan --mode replan --session WFS-auth-2025-01-28
|
||||
|
||||
# CLI-assisted planning (quick recommendations)
|
||||
/ccw-plan --mode cli "Quick: should we use OAuth2 or JWT?"
|
||||
/ccw-plan --mode cli "Which state management pattern for React app?"
|
||||
|
||||
# With-File workflows (multi-CLI collaboration)
|
||||
/ccw-plan --mode brainstorm-with-file "头脑风暴: 用户通知系统重新设计"
|
||||
/ccw-plan --mode analyze-with-file "协作分析: 认证架构的设计决策"
|
||||
|
||||
# Issue workflow integration
|
||||
/ccw-plan --mode issue "Batch plan: handle all pending security issues"
|
||||
/ccw-plan --mode rapid-to-issue "Plan user profile feature and create issue"
|
||||
|
||||
# Auto mode (skip confirmations)
|
||||
/ccw-plan --yes "Quick feature: user profile endpoint"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-plan "task description"
|
||||
|
||||
├─ Keywords: "quick", "fast", "recommendation"
|
||||
│ └─ Mode: CLI (quick analysis → recommendations)
|
||||
│
|
||||
├─ Keywords: "issue", "batch", "queue"
|
||||
│ └─ Mode: Issue (batch planning → execution queue)
|
||||
│
|
||||
├─ Keywords: "plan.*issue", "rapid.*issue"
|
||||
│ └─ Mode: Rapid-to-Issue (lite-plan → issue bridge)
|
||||
│
|
||||
├─ Keywords: "头脑风暴", "brainstorm", "ideation"
|
||||
│ └─ Mode: Brainstorm-with-file (multi-CLI ideation)
|
||||
│
|
||||
├─ Keywords: "协作分析", "analyze.*document"
|
||||
│ └─ Mode: Analyze-with-file (collaborative analysis)
|
||||
│
|
||||
├─ Keywords: "production", "critical", "payment"
|
||||
│ └─ Mode: Plan-Verify (mandatory quality gate)
|
||||
│
|
||||
├─ Keywords: "adjust", "modify", "change plan"
|
||||
│ └─ Mode: Replan (refine existing plan)
|
||||
│
|
||||
├─ Keywords: "uncertain", "explore"
|
||||
│ └─ Mode: Full (brainstorm → plan → [verify])
|
||||
│
|
||||
├─ Keywords: "complex", "multiple module"
|
||||
│ └─ Mode: Multi-CLI (collaborative planning)
|
||||
│
|
||||
└─ Default → Lite (fast simple planning)
|
||||
```
|
||||
387
.claude/commands/ccw-test.md
Normal file
387
.claude/commands/ccw-test.md
Normal file
@@ -0,0 +1,387 @@
|
||||
---
|
||||
name: ccw-test
|
||||
description: Test coordinator - analyze testing needs, select test strategy, execute test workflow in main process
|
||||
argument-hint: "[--mode gen|fix|verify|tdd] [--yes|-y] \"test description\""
|
||||
allowed-tools: Skill(*), TodoWrite(*), AskUserQuestion(*), Read(*), Bash(*)
|
||||
---
|
||||
|
||||
# CCW-Test Command - Test Coordinator
|
||||
|
||||
Test orchestrator: testing needs analysis → strategy selection → test execution.
|
||||
|
||||
## Core Concept: Test Units (测试单元)
|
||||
|
||||
**Definition**: Test commands grouped into logical units based on testing objectives.
|
||||
|
||||
**Test Units**:
|
||||
|
||||
| Unit Type | Pattern | Example |
|
||||
|-----------|---------|---------|
|
||||
| **Generation Only** | test-gen (no execution) | test-fix-gen |
|
||||
| **Test + Fix Cycle** | test-gen → test-execute-fix | test-fix-gen → test-cycle-execute |
|
||||
| **Verification Only** | existing-tests → execute | execute-tests |
|
||||
| **TDD Cycle** | tdd-plan → tdd-execute → verify | Red-Green-Refactor |
|
||||
|
||||
**Atomic Rules**:
|
||||
1. Gen mode: Generate tests only (no execution)
|
||||
2. Fix mode: Generate + auto-iteration until ≥95% pass
|
||||
3. Verify mode: Execute existing tests + report
|
||||
4. TDD mode: Full Red-Green-Refactor cycle compliance
|
||||
|
||||
## Execution Model
|
||||
|
||||
**Synchronous (Main Process)**: Test commands execute via Skill, blocking until complete.
|
||||
|
||||
```
|
||||
User Input → Analyze Testing Needs → Select Strategy → [Confirm] → Execute Tests
|
||||
↓
|
||||
Skill (blocking)
|
||||
↓
|
||||
Update TodoWrite
|
||||
↓
|
||||
Generate Tests/Results
|
||||
```
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Analyze Testing Needs
|
||||
|
||||
**Input** → Extract (description, target_module, existing_tests) → Assess (testing_goal, framework, coverage_target) → **Analysis**
|
||||
|
||||
| Field | Values |
|
||||
|-------|--------|
|
||||
| testing_goal | generate \| fix \| verify \| tdd |
|
||||
| framework | jest \| vitest \| pytest \| ... |
|
||||
| coverage_target | 0-100 (default: 80) |
|
||||
| existing_tests | true \| false |
|
||||
|
||||
#### Mode Detection (Priority Order)
|
||||
|
||||
```
|
||||
Input Keywords → Mode
|
||||
─────────────────────────────────────────────────────────
|
||||
generate|create|write test|need test → gen
|
||||
fix|repair|failing|broken → fix
|
||||
verify|validate|check|run test → verify
|
||||
tdd|test-driven|test first → tdd
|
||||
(default) → fix
|
||||
```
|
||||
|
||||
**Output**: `TestingGoal: [goal] | Mode: [mode] | Target: [module] | Framework: [framework]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.5: Testing Clarification (if needed)
|
||||
|
||||
```
|
||||
Analysis → Check testing_goal known?
|
||||
↓
|
||||
YES → Check target_module set?
|
||||
↓
|
||||
YES → Continue to Phase 2
|
||||
↓
|
||||
NO → Ask Questions → Update Analysis
|
||||
```
|
||||
|
||||
**Questions Asked**: Testing Goal, Target Module/Files, Coverage Requirements, Test Framework
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Select Test Strategy & Build Command Chain
|
||||
|
||||
```
|
||||
Analysis → Detect Mode (keywords) → Build Command Chain → Test Workflow
|
||||
```
|
||||
|
||||
#### Command Chain Mapping
|
||||
|
||||
| Mode | Command Chain | Behavior |
|
||||
|------|---------------|----------|
|
||||
| **gen** | test-fix-gen | Generate only, no execution |
|
||||
| **fix** | test-fix-gen → test-cycle-execute (iterate) | Auto-iteration until ≥95% pass or max iterations |
|
||||
| **verify** | execute-existing-tests → coverage-report | Execute + report only |
|
||||
| **tdd** | tdd-plan → execute → tdd-verify | Red-Green-Refactor cycle compliance |
|
||||
|
||||
**Note**: `(iterate)` = auto-iteration until pass_rate ≥ 95% or max_iterations reached
|
||||
|
||||
**Output**: `Mode: [mode] | Strategy: [strategy] | Commands: [1. /cmd1 2. /cmd2]`
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: User Confirmation
|
||||
|
||||
```
|
||||
Test Chain → Show Strategy → Ask User → User Decision:
|
||||
- ✓ Confirm → Continue to Phase 4
|
||||
- ⚙ Change Mode → Select Different Mode (back to Phase 2)
|
||||
- ✗ Cancel → Abort
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Setup TODO Tracking & Status File
|
||||
|
||||
```
|
||||
Test Chain → Create Session Dir → Initialize Tracking → Tracking State
|
||||
```
|
||||
|
||||
**Session Structure**:
|
||||
```
|
||||
Session ID: CCWT-{target-module-slug}-{date}
|
||||
Session Dir: .workflow/.ccw-test/{session_id}/
|
||||
|
||||
TodoWrite:
|
||||
CCWT:{mode}: [1/n] /command1 [in_progress]
|
||||
CCWT:{mode}: [2/n] /command2 [pending]
|
||||
...
|
||||
|
||||
status.json:
|
||||
{
|
||||
"session_id": "CCWT-...",
|
||||
"mode": "gen|fix|verify|tdd",
|
||||
"status": "running",
|
||||
"testing": { description, target_module, framework, coverage_target },
|
||||
"command_chain": [...],
|
||||
"test_metrics": { total_tests, passed, failed, pass_rate, iteration_count, coverage }
|
||||
}
|
||||
```
|
||||
|
||||
**Output**:
|
||||
- TODO: `-> CCWT:fix: [1/2] /workflow:test-fix-gen | CCWT:fix: [2/2] /workflow:test-cycle-execute`
|
||||
- Status File: `.workflow/.ccw-test/{session_id}/status.json`
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Execute Test Chain
|
||||
|
||||
#### For All Modes (Sequential Execution)
|
||||
|
||||
```
|
||||
Start Command → Update status (running) → Execute via Skill → Result
|
||||
↓
|
||||
Update test_metrics → Next Command
|
||||
↓
|
||||
Error? → YES → Ask Action (Retry/Skip/Abort)
|
||||
→ NO → Continue
|
||||
```
|
||||
|
||||
#### For Fix Mode (Auto-Iteration)
|
||||
|
||||
```
|
||||
test-fix-gen completes → test-cycle-execute begins
|
||||
↓
|
||||
Check pass_rate ≥ 95%?
|
||||
↓ ↓
|
||||
YES → Complete NO → Check iteration < max?
|
||||
↓ ↓
|
||||
YES → Iteration NO → Complete
|
||||
| (analyze failures
|
||||
| generate fix
|
||||
| re-execute tests)
|
||||
|
|
||||
└→ Loop back to pass_rate check
|
||||
```
|
||||
|
||||
#### Error Handling Pattern
|
||||
|
||||
```
|
||||
Command Error → Update status (failed) → Ask User:
|
||||
- Retry → Re-execute (same index)
|
||||
- Skip → Continue next command
|
||||
- Abort → Stop execution
|
||||
```
|
||||
|
||||
#### Test Metrics Update
|
||||
|
||||
```
|
||||
After Each Execution → Collect test_metrics:
|
||||
- total_tests: number
|
||||
- passed/failed: count
|
||||
- pass_rate: percentage
|
||||
- iteration_count: increment (fix mode)
|
||||
- coverage: line/branch/function
|
||||
↓
|
||||
Update status.json → Update TODO with iteration info (if fix mode)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Execution Flow Summary
|
||||
|
||||
```
|
||||
User Input
|
||||
|
|
||||
Phase 1: Analyze Testing Needs
|
||||
|-- Extract: description, testing_goal, target_module, existing_tests
|
||||
+-- If unclear -> Phase 1.5: Clarify Testing Needs
|
||||
|
|
||||
Phase 2: Select Test Strategy & Build Chain
|
||||
|-- Detect mode: gen | fix | verify | tdd
|
||||
|-- Build command chain based on mode
|
||||
+-- Configure iteration limits (fix mode)
|
||||
|
|
||||
Phase 3: User Confirmation (optional)
|
||||
|-- Show test strategy
|
||||
+-- Allow mode change
|
||||
|
|
||||
Phase 4: Setup TODO Tracking & Status File
|
||||
|-- Create todos with CCWT prefix
|
||||
+-- Initialize .workflow/.ccw-test/{session_id}/status.json
|
||||
|
|
||||
Phase 5: Execute Test Chain
|
||||
|-- For each command:
|
||||
| |-- Update status.json (current=running)
|
||||
| |-- Execute via Skill
|
||||
| |-- Test-fix cycle: iterate until ≥95% pass or max iterations
|
||||
| |-- Update test_metrics in status.json
|
||||
| +-- Update TODO status
|
||||
+-- Mark status.json as completed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test Pipeline Examples
|
||||
|
||||
| Input | Mode | Pipeline | Iteration |
|
||||
|-------|------|----------|-----------|
|
||||
| "Generate tests for auth module" | gen | test-fix-gen | No execution |
|
||||
| "Fix failing authentication tests" | fix | test-fix-gen → test-cycle-execute (iterate) | Max 3 iterations |
|
||||
| "Run existing test suite" | verify | execute-tests → coverage-report | One-time |
|
||||
| "Implement user profile with TDD" | tdd | tdd-plan → execute → tdd-verify | Red-Green-Refactor |
|
||||
|
||||
**Legend**: `(iterate)` = auto-iteration until ≥95% pass rate
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual Tracking System
|
||||
|
||||
**1. TodoWrite-Based Tracking** (UI Display):
|
||||
|
||||
```
|
||||
// Initial state (fix mode)
|
||||
CCWT:fix: [1/2] /workflow:test-fix-gen [in_progress]
|
||||
CCWT:fix: [2/2] /workflow:test-cycle-execute [pending]
|
||||
|
||||
// During iteration (fix mode, iteration 2/3)
|
||||
CCWT:fix: [1/2] /workflow:test-fix-gen [completed]
|
||||
CCWT:fix: [2/2] /workflow:test-cycle-execute [in_progress] (iteration 2/3, pass rate: 78%)
|
||||
|
||||
// Gen mode (no execution)
|
||||
CCWT:gen: [1/1] /workflow:test-fix-gen [in_progress]
|
||||
|
||||
// Verify mode (one-time)
|
||||
CCWT:verify: [1/2] execute-existing-tests [in_progress]
|
||||
CCWT:verify: [2/2] generate-coverage-report [pending]
|
||||
|
||||
// TDD mode (Red-Green-Refactor)
|
||||
CCWT:tdd: [1/3] /workflow:tdd-plan [in_progress]
|
||||
CCWT:tdd: [2/3] /workflow:execute [pending]
|
||||
CCWT:tdd: [3/3] /workflow:tdd-verify [pending]
|
||||
```
|
||||
|
||||
**2. Status.json Tracking**: Persistent state for test monitoring.
|
||||
|
||||
**Location**: `.workflow/.ccw-test/{session_id}/status.json`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"session_id": "CCWT-auth-module-2025-02-02",
|
||||
"mode": "fix",
|
||||
"status": "running|completed|failed",
|
||||
"created_at": "2025-02-02T10:00:00Z",
|
||||
"updated_at": "2025-02-02T10:05:00Z",
|
||||
"testing": {
|
||||
"description": "Fix failing authentication tests",
|
||||
"target_module": "src/auth/**/*.ts",
|
||||
"framework": "jest",
|
||||
"coverage_target": 80
|
||||
},
|
||||
"command_chain": [
|
||||
{ "index": 0, "command": "/workflow:test-fix-gen", "unit": "sequential", "status": "completed" },
|
||||
{ "index": 1, "command": "/workflow:test-cycle-execute", "unit": "test-fix-cycle", "max_iterations": 3, "status": "in_progress" }
|
||||
],
|
||||
"current_index": 1,
|
||||
"test_metrics": {
|
||||
"total_tests": 42,
|
||||
"passed": 38,
|
||||
"failed": 4,
|
||||
"pass_rate": 90.5,
|
||||
"iteration_count": 2,
|
||||
"coverage": {
|
||||
"line": 82.3,
|
||||
"branch": 75.6,
|
||||
"function": 88.1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `running`: Test workflow in progress
|
||||
- `completed`: Tests passing (≥95%) or generation complete
|
||||
- `failed`: Test workflow aborted
|
||||
|
||||
**Test Metrics** (updated during execution):
|
||||
- `total_tests`: Number of tests executed
|
||||
- `pass_rate`: Percentage of passing tests (target: ≥95%)
|
||||
- `iteration_count`: Number of test-fix iterations (fix mode)
|
||||
- `coverage`: Line/branch/function coverage percentages
|
||||
|
||||
---
|
||||
|
||||
## Key Design Principles
|
||||
|
||||
1. **Testing-Focused** - Pure test coordination, no implementation
|
||||
2. **Mode-Driven** - 4 test strategies for different needs
|
||||
3. **Auto-Iteration** - Fix mode iterates until ≥95% pass rate
|
||||
4. **Metrics Tracking** - Real-time test metrics in status.json
|
||||
5. **Coverage-Driven** - Coverage targets guide test generation
|
||||
6. **TODO Tracking** - Use CCWT prefix to isolate test todos
|
||||
7. **TDD Compliance** - TDD mode enforces Red-Green-Refactor cycle
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Auto-select mode
|
||||
/ccw-test "Test user authentication module"
|
||||
|
||||
# Explicit mode selection
|
||||
/ccw-test --mode gen "Generate tests for payment module"
|
||||
/ccw-test --mode fix "Fix failing authentication tests"
|
||||
/ccw-test --mode verify "Validate current test suite"
|
||||
/ccw-test --mode tdd "Implement user profile with TDD"
|
||||
|
||||
# Custom configuration
|
||||
/ccw-test --mode fix --max-iterations 5 --pass-threshold 98 "Fix all tests"
|
||||
/ccw-test --target "src/auth/**/*.ts" "Test authentication module"
|
||||
|
||||
# Auto mode (skip confirmations)
|
||||
/ccw-test --yes "Quick test validation"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode Selection Decision Tree
|
||||
|
||||
```
|
||||
User calls: /ccw-test "test description"
|
||||
|
||||
├─ Keywords: "generate", "create", "write test"
|
||||
│ └─ Mode: Gen (generate only, no execution)
|
||||
│
|
||||
├─ Keywords: "fix", "repair", "failing"
|
||||
│ └─ Mode: Fix (auto-iterate until ≥95% pass)
|
||||
│
|
||||
├─ Keywords: "verify", "validate", "run test"
|
||||
│ └─ Mode: Verify (execute existing tests)
|
||||
│
|
||||
├─ Keywords: "tdd", "test-driven", "test first"
|
||||
│ └─ Mode: TDD (Red-Green-Refactor cycle)
|
||||
│
|
||||
└─ Default → Fix (most common: fix failing tests)
|
||||
```
|
||||
@@ -644,23 +644,23 @@ todos = [
|
||||
|
||||
```bash
|
||||
# Auto-select workflow
|
||||
ccw "Add user authentication"
|
||||
/ccw "Add user authentication"
|
||||
|
||||
# Complex requirement (triggers clarification)
|
||||
ccw "Optimize system performance"
|
||||
/ccw "Optimize system performance"
|
||||
|
||||
# Bug fix
|
||||
ccw "Fix memory leak in WebSocket handler"
|
||||
/ccw "Fix memory leak in WebSocket handler"
|
||||
|
||||
# TDD development
|
||||
ccw "Implement user registration with TDD"
|
||||
/ccw "Implement user registration with TDD"
|
||||
|
||||
# Exploratory task
|
||||
ccw "Uncertain about architecture for real-time notifications"
|
||||
/ccw "Uncertain about architecture for real-time notifications"
|
||||
|
||||
# With-File workflows (documented exploration with multi-CLI collaboration)
|
||||
ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file
|
||||
ccw "从头脑风暴 BS-通知系统-2025-01-28 创建 issue" # → brainstorm-to-issue (bridge)
|
||||
ccw "深度调试: 系统随机崩溃问题" # → debug-with-file
|
||||
ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file
|
||||
/ccw "头脑风暴: 用户通知系统重新设计" # → brainstorm-with-file
|
||||
/ccw "从头脑风暴 BS-通知系统-2025-01-28 创建 issue" # → brainstorm-to-issue (bridge)
|
||||
/ccw "深度调试: 系统随机崩溃问题" # → debug-with-file
|
||||
/ccw "协作分析: 理解现有认证架构的设计决策" # → analyze-with-file
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user