/ccw-workflow:ccw-coordinator [task description]from ccw-workflow
Command orchestration tool - analyze requirements, recommend chain, execute sequentially with state persistence
Ships in ccw-workflow. Installing the plugin adds it to Claude Code.
Interactive orchestration tool: analyze task → discover commands → recommend chain → execute sequentially → track state.
Execution Model: Pseudocode guidance. Claude intelligently executes each phase based on context.
命令端口定义中的 workflow 操作通过 Skill() 调用。
| Skill | 包含操作 |
|---|---|
workflow-lite-plan | lite-plan (Skill handoff to lite-execute) |
workflow-lite-execute | lite-execute (multi-mode execution engine) |
workflow-plan | plan, plan-verify, replan |
workflow-execute | execute |
workflow-multi-cli-plan | multi-cli-plan (includes execution phase internally) |
workflow-test-fix | test-fix-gen, test-cycle-execute |
workflow-tdd-plan | tdd-plan, tdd-verify |
review-cycle | review-session-cycle, review-module-cycle, review-cycle-fix |
brainstorm | auto-parallel, artifacts, role-analysis, synthesis |
spec-generator | product-brief → PRD → architecture → epics |
workflow:collaborative-plan-with-file | understanding agent → parallel agents → plan-note.md |
workflow:roadmap-with-file | strategic requirement roadmap → issue creation → execution-plan.json |
workflow:integration-test-cycle | explore → test dev → test-fix cycle → reflection |
workflow:refactor-cycle | tech debt discovery → prioritize → execute → validate |
team-planex | planner + executor wave pipeline(适合大量零散 issue 或 roadmap 产出的清晰 issue) |
Definition: A set of commands that must execute together as an atomic group to achieve a meaningful workflow milestone. Splitting these commands breaks the logical flow and creates incomplete states.
Why This Matters:
Planning + Execution Units (规划+执行单元):
| Unit Name | Commands | Purpose | Output |
|---|---|---|---|
| Quick Implementation | lite-plan (Phase 1: plan → Phase 2: execute) | Lightweight plan and immediate execution | Working code |
| Multi-CLI Planning | multi-cli-plan (Phase 1: plan → Phase 2: execute) | Multi-perspective analysis and execution | Working code |
| Bug Fix | lite-plan --bugfix (Phase 1: plan → Phase 2: 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 |
| Spec-Driven Full Pipeline | spec-generator → plan → execute | Specification-driven development | Working code |
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-cycle-fix | Complete review cycle and apply fixes | Fixed code |
| Code Review (Module) | review-module-cycle → review-cycle-fix | Module review cycle and apply fixes | Fixed code |
Issue Units (Issue单元):
| Unit Name | Commands | Purpose | Output |
|---|---|---|---|
| Issue Workflow | discover → plan → queue → execute | Complete issue lifecycle | Completed issues |
| Rapid-to-Issue | lite-plan → convert-to-plan → queue → execute | Bridge lite workflow to issue workflow | Completed issues |
| Brainstorm-to-Issue | from-brainstorm → queue → execute | Bridge brainstorm session to issue workflow | Completed issues |
With-File Units (文档化单元):
| Unit Name | Commands | Purpose | Output |
|---|---|---|---|
| Analyze to Plan | analyze-with-file → lite-plan | Collaborative analysis → auto chain to lite-plan | discussion.md + code |
| Brainstorm to Plan | brainstorm-with-file → plan → execute | Multi-perspective ideation → formal planning | brainstorm.md + code |
| Debug With File | debug-with-file | Hypothesis-driven debugging with documentation | understanding.md |
| Collaborative Plan | collaborative-plan-with-file → unified-execute-with-file | Multi-agent collaborative planning and execution | plan-note.md + code |
| Roadmap Plan | roadmap-with-file → team-planex | Requirement decomposition and wave execution | execution-plan.json + code |
Cycle Units (循环单元):
| Unit Name | Commands | Purpose | Output |
|---|---|---|---|
| Integration Test Cycle | integration-test-cycle | Self-iterating integration test with reflection | Tests passed |
| Refactor Cycle | refactor-cycle | Tech debt discovery and refactoring | Refactored code |
| Command | Can Precede | Atomic Units |
|---|---|---|
| lite-plan | convert-to-plan | Quick Implementation, Rapid-to-Issue, Bug Fix |
| multi-cli-plan | (execution is internal) | Multi-CLI Planning |
| plan | plan-verify, execute | Full Planning + Execution, Verified Planning + Execution |
| plan-verify | execute | Verified Planning + Execution |
| replan | execute | Replanning + Execution |
| test-gen | execute | Test Generation + Execution |
| tdd-plan | execute | TDD Planning + Execution |
| spec-generator | plan | Spec-Driven Full Pipeline |
| review-session-cycle | review-cycle-fix | Code Review (Session) |
| review-module-cycle | review-cycle-fix | Code Review (Module) |
| test-fix-gen | test-cycle-execute | Test Validation |
| issue:discover | issue:plan | Issue Workflow |
| issue:plan | issue:queue | Issue Workflow |
| convert-to-plan | issue:queue | Rapid-to-Issue |
| issue:queue | issue:execute | Issue Workflow, Rapid-to-Issue, Brainstorm-to-Issue |
| issue:from-brainstorm | issue:queue | Brainstorm-to-Issue |
| analyze-with-file | lite-plan (auto) | Analyze to Plan |
| brainstorm-with-file | plan (auto), issue:from-brainstorm | Brainstorm to Plan, Brainstorm-to-Issue |
| collaborative-plan-with-file | unified-execute-with-file | Collaborative Plan |
| roadmap-with-file | team-planex | Roadmap Plan |
| unified-execute-with-file | (terminal) | Collaborative Plan |
| integration-test-cycle | (standalone) | Integration Test Cycle |
| refactor-cycle | (standalone) | Refactor Cycle |
| team-planex | (standalone) | Roadmap Plan (executor) |
| debug-with-file | (standalone) | Debug With File |
【 】 markersExample Pipeline with Units:
需求 → 【lite-plan】→ 代码 → 【test-fix-gen → test-cycle-execute】→ 测试通过
└── Quick Implementation ──┘ └────── Test Validation ──────┘
Parse task to extract: goal, scope, constraints, complexity, and task type.
function analyzeRequirements(taskDescription) {
return {
goal: extractMainGoal(taskDescription),
scope: extractScope(taskDescription),
constraints: extractConstraints(taskDescription),
complexity: determineComplexity(taskDescription),
task_type: detectTaskType(taskDescription)
};
}
Instead of regex, extract a structured intent tuple using LLM semantic understanding, then route via action × object × style matrix.
Step 1 — Extract structured intent from user input:
{
"action": "<create|fix|analyze|plan|execute|explore|debug|test|review|refactor|convert>",
"object": "<feature|bug|issue|code|test|spec|doc|ui|performance|security|architecture|project|team>",
"style": "<quick|documented|collaborative|structured|iterative|tdd|default>",
"urgency": "<low|normal|high>"
}
Disambiguation rules for "问题" / "issue" / "problem":
object: "bug" (routes to bugfix)object: "issue" (routes to issue workflow)"bug" — it routes to fix workflows which are more actionableStep 2 — Route via action × object × style matrix:
function detectTaskType(intent) {
const { action, object, style, urgency } = intent;
// Urgency override
if (urgency === 'high' && (action === 'fix' || object === 'bug')) return 'bugfix-hotfix';
// Style-first routing
if (style === 'tdd') return 'tdd';
if (style === 'collaborative' && action === 'plan') return 'collaborative-plan';
if (style === 'collaborative' && action !== 'plan') return 'multi-cli';
if (style === 'iterative' && object === 'test') return 'integration-test';
if (style === 'iterative' && action === 'refactor') return 'refactor';
// Action × Object matrix
const matrix = {
'create': { 'project': 'greenfield', 'feature': 'feature', 'spec': 'spec-driven', 'test': 'test-gen', 'doc': 'documentation', 'ui': 'ui-design', 'issue': 'issue-batch', '_default': 'feature' },
'fix': { 'bug': 'bugfix', 'test': 'test-fix', 'issue': 'issue-batch', 'code': 'bugfix', 'performance': 'bugfix', 'security': 'bugfix', '_default': 'bugfix' },
'analyze':{ 'architecture': 'analyze-file', 'code': 'analyze-file', 'bug': 'debug-file', '_default': 'analyze-file' },
'explore':{ 'feature': 'brainstorm-file', 'architecture': 'brainstorm-file', 'issue': 'issue-batch', '_default': 'exploration' },
'plan': { 'feature': 'feature', 'project': 'greenfield', 'issue': 'issue-transition', '_default': 'feature' },
'execute':{ 'issue': 'issue-transition', '_default': 'feature' },
'debug': { 'bug': style === 'documented' ? 'debug-file' : 'bugfix', '_default': style === 'documented' ? 'debug-file' : 'bugfix' },
'test': { 'test': 'test-fix', 'code': 'test-gen', 'feature': 'integration-test', '_default': 'test-gen' },
'review': { '_default': 'review' },
'refactor':{ '_default': 'refactor' },
'convert':{ 'issue': 'brainstorm-to-issue', '_default': 'issue-transition' },
};
// Special: roadmap keyword, team planex
if (action === 'plan' && style === 'structured' && /roadmap|路线.*图/.test(rawInput)) return 'roadmap';
if (object === 'team') return 'team-planex';
const actionMap = matrix[action];
if (!actionMap) return 'feature';
return actionMap[object] || actionMap['_default'] || 'feature';
}
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';
}
Display to user:
Analysis Complete:
Goal: [extracted goal]
Scope: [identified areas]
Constraints: [identified constraints]
Complexity: [level]
Task Type: [detected type] (via {action, object, style})
Dynamic command chain assembly using port-based matching.
Each command has input/output ports (tags) for pipeline composition:
const commandPorts = {
'lite-plan': {
name: 'lite-plan',
input: ['requirement', 'discussion-document', 'brainstorm-document'],
output: ['plan'],
tags: ['planning'],
atomic_group: 'quick-implementation'
},
// lite-execute is now an internal phase of lite-plan and multi-cli-plan (not a standalone command)
'plan': {
name: 'plan',
input: ['requirement', 'specification'],
output: ['detailed-plan'],
tags: ['planning'],
atomic_groups: ['full-planning-execution', 'verified-planning-execution', 'spec-driven']
},
'plan-verify': {
name: 'plan-verify',
input: ['detailed-plan'],
output: ['verified-plan'],
tags: ['planning'],
atomic_group: 'verified-planning-execution'
},
'replan': {
name: 'replan',
input: ['session', 'feedback'],
output: ['replan'],
tags: ['planning'],
atomic_group: 'replanning-execution'
},
'execute': {
name: 'execute',
input: ['detailed-plan', 'verified-plan', 'replan', 'test-tasks', 'tdd-tasks'],
output: ['code'],
tags: ['execution'],
atomic_groups: ['full-planning-execution', 'verified-planning-execution', 'replanning-execution', 'test-generation-execution', 'tdd-planning-execution', 'spec-driven']
},
'test-cycle-execute': {
name: 'test-cycle-execute',
input: ['test-tasks'],
output: ['test-passed'],
tags: ['testing'],
atomic_group: 'test-validation',
note: '需要先执行test-fix-gen生成测试任务,再由此命令执行测试周期'
},
'tdd-plan': {
name: 'tdd-plan',
input: ['requirement'],
output: ['tdd-tasks'],
tags: ['planning', 'tdd'],
atomic_group: 'tdd-planning-execution'
},
'tdd-verify': {
name: 'tdd-verify',
input: ['code'],
output: ['tdd-verified'],
tags: ['testing'],
note: 'Internal sub-command of workflow-tdd-plan Skill, not in explicit pipelines'
},
'lite-plan-bugfix': {
name: 'lite-plan',
input: ['bug-report'],
output: ['plan'],
tags: ['bugfix', 'planning'],
atomic_group: 'bug-fix',
type: 'skill',
note: '通过 --bugfix 参数传递 bugfix 语义'
},
'debug': {
name: 'debug',
input: ['bug-report'],
output: ['debug-log'],
tags: ['bugfix'],
note: 'Standalone debug sub-command, used internally by lite-plan --bugfix'
},
'test-gen': {
name: 'test-gen',
input: ['code', 'session'],
output: ['test-tasks'],
tags: ['testing'],
atomic_group: 'test-generation-execution'
},
'test-fix-gen': {
name: 'test-fix-gen',
input: ['failing-tests', 'session'],
output: ['test-tasks'],
tags: ['testing'],
atomic_group: 'test-validation',
note: '生成测试任务供test-cycle-execute执行'
},
'review': {
name: 'review',
input: ['code', 'session'],
output: ['review-findings'],
tags: ['review'],
note: 'Base review command, pipelines use review-session-cycle or review-module-cycle instead'
},
'review-cycle-fix': {
name: 'review-cycle-fix',
input: ['review-findings', 'review-verified'],
output: ['fixed-code'],
tags: ['review'],
atomic_group: 'code-review'
},
'brainstorm': {
name: 'brainstorm',
input: ['exploration-topic'],
output: ['brainstorm-analysis'],
tags: ['brainstorm'],
type: 'skill'
},
'multi-cli-plan': {
name: 'multi-cli-plan',
input: ['requirement'],
output: ['multi-cli-plan'],
tags: ['planning', 'multi-cli'],
atomic_group: 'multi-cli-planning'
},
'review-session-cycle': {
name: 'review-session-cycle',
input: ['code', 'session'],
output: ['review-verified'],
tags: ['review'],
atomic_group: 'code-review'
},
'review-module-cycle': {
name: 'review-module-cycle',
input: ['module-pattern'],
output: ['review-verified'],
tags: ['review'],
atomic_group: 'code-review'
},
// Issue workflow commands
'issue:discover': {
name: 'issue:discover',
input: ['codebase'],
output: ['pending-issues'],
tags: ['issue'],
atomic_group: 'issue-workflow'
},
'issue:plan': {
name: 'issue:plan',
input: ['pending-issues'],
output: ['issue-plans'],
tags: ['issue'],
atomic_group: 'issue-workflow'
},
'issue:queue': {
name: 'issue:queue',
input: ['issue-plans', 'converted-plan'],
output: ['execution-queue'],
tags: ['issue'],
atomic_groups: ['issue-workflow', 'rapid-to-issue']
},
'issue:execute': {
name: 'issue:execute',
input: ['execution-queue'],
output: ['completed-issues'],
tags: ['issue'],
atomic_groups: ['issue-workflow', 'rapid-to-issue']
},
'issue:convert-to-plan': {
name: 'issue:convert-to-plan',
input: ['plan'],
output: ['converted-plan'],
tags: ['issue', 'planning'],
atomic_group: 'rapid-to-issue'
},
// With-File workflows
'brainstorm-with-file': {
name: 'brainstorm-with-file',
input: ['exploration-topic'],
output: ['brainstorm-document'],
tags: ['brainstorm', 'with-file'],
atomic_group: 'brainstorm-to-plan',
note: 'Auto chains to workflow-plan with brainstorm artifacts'
},
'issue:from-brainstorm': {
name: 'issue:from-brainstorm',
input: ['brainstorm-document'],
output: ['converted-plan'],
tags: ['issue', 'brainstorm'],
atomic_group: 'brainstorm-to-issue'
},
'debug-with-file': {
name: 'debug-with-file',
input: ['bug-report'],
output: ['understanding-document'],
tags: ['bugfix', 'with-file'],
note: 'Self-contained workflow with hypothesis-driven iteration'
},
'analyze-with-file': {
name: 'analyze-with-file',
input: ['analysis-topic'],
output: ['discussion-document'],
tags: ['analysis', 'with-file'],
atomic_group: 'analyze-to-plan',
note: 'Auto chains to lite-plan with analysis artifacts'
},
// Collaborative planning workflows
'collaborative-plan-with-file': {
name: 'collaborative-plan-with-file',
input: ['requirement'],
output: ['plan-note'],
tags: ['planning', 'with-file'],
atomic_group: 'collaborative-plan',
note: 'Multi-agent collaborative planning with Plan Note shared doc'
},
'unified-execute-with-file': {
name: 'unified-execute-with-file',
input: ['plan-note', 'brainstorm-document', 'discussion-document'],
output: ['code'],
tags: ['execution', 'with-file'],
atomic_group: 'collaborative-plan'
},
'roadmap-with-file': {
name: 'roadmap-with-file',
input: ['requirement'],
output: ['execution-plan'],
tags: ['planning', 'with-file'],
atomic_group: 'roadmap-plan',
note: 'Requirement decomposition with issue creation'
},
// Spec-driven workflow
'spec-generator': {
name: 'spec-generator',
input: ['requirement'],
output: ['specification'],
tags: ['planning', 'specification'],
atomic_group: 'spec-driven',
note: '6-phase specification: product-brief → PRD → architecture → epics'
},
// Cycle workflows (self-iterating with reflection)
'integration-test-cycle': {
name: 'integration-test-cycle',
input: ['requirement'],
output: ['test-passed'],
tags: ['testing', 'cycle'],
note: 'Self-contained: explore → test dev → test-fix cycle → reflection'
},
'refactor-cycle': {
name: 'refactor-cycle',
input: ['codebase'],
output: ['refactored-code'],
tags: ['refactoring', 'cycle'],
note: 'Self-contained: tech debt discovery → prioritize → execute → validate'
},
// Team workflows (kept: team-planex only)
'team-planex': {
name: 'team-planex',
input: ['requirement', 'execution-plan'],
output: ['code'],
tags: ['team'],
note: 'Self-contained: planner + executor wave pipeline'
}
};
async function recommendCommandChain(analysis) {
const { inputPort, outputPort } = determinePortFlow(analysis.task_type, analysis.constraints);
const chain = selectChainByPorts(inputPort, outputPort, analysis);
return chain;
}
function determinePortFlow(taskType, constraints) {
const flows = {
'bugfix': { inputPort: 'bug-report', outputPort: constraints?.includes('skip-tests') ? 'fixed-code' : 'test-passed' },
'tdd': { inputPort: 'requirement', outputPort: 'tdd-verified' },
'test-fix': { inputPort: 'failing-tests', outputPort: 'test-passed' },
'test-gen': { inputPort: 'code', outputPort: 'test-passed' },
'review': { inputPort: 'code', outputPort: 'review-verified' },
'brainstorm': { inputPort: 'exploration-topic', outputPort: 'test-passed' },
'multi-cli': { inputPort: 'requirement', outputPort: 'test-passed' },
// Issue workflow types
'issue-batch': { inputPort: 'codebase', outputPort: 'completed-issues' },
'issue-transition': { inputPort: 'requirement', outputPort: 'completed-issues' },
// 0→1 Greenfield (exploration → formal planning → execution)
'greenfield': { inputPort: 'exploration-topic', outputPort: 'test-passed' },
// With-File workflow types (auto chain to plan)
'brainstorm-file': { inputPort: 'exploration-topic', outputPort: 'test-passed' },
'brainstorm-to-issue': { inputPort: 'brainstorm-document', outputPort: 'completed-issues' },
'debug-file': { inputPort: 'bug-report', outputPort: 'understanding-document' },
'analyze-file': { inputPort: 'analysis-topic', outputPort: 'code' },
'collaborative-plan': { inputPort: 'requirement', outputPort: 'code' },
'roadmap': { inputPort: 'requirement', outputPort: 'code' },
'spec-driven': { inputPort: 'requirement', outputPort: 'test-passed' },
// Cycle workflow types
'integration-test': { inputPort: 'requirement', outputPort: 'test-passed' },
'refactor': { inputPort: 'codebase', outputPort: 'refactored-code' },
// Team workflows (kept: team-planex only)
'team-planex': { inputPort: 'requirement', outputPort: 'code' },
// Additional task types
'bugfix-hotfix': { inputPort: 'bug-report', outputPort: 'fixed-code' },
'exploration': { inputPort: 'exploration-topic', outputPort: 'test-passed' },
'quick-task': { inputPort: 'requirement', outputPort: constraints?.includes('skip-tests') ? 'code' : 'test-passed' },
'ui-design': { inputPort: 'requirement', outputPort: 'code' },
'documentation': { inputPort: 'requirement', outputPort: 'code' },
'feature': { inputPort: 'requirement', outputPort: constraints?.includes('skip-tests') ? 'code' : 'test-passed' }
};
return flows[taskType] || flows['feature'];
}
Recommended Command Chain:
Pipeline (管道视图):
需求 → lite-plan → 代码 → test-cycle-execute → 测试通过
Commands (命令列表):
1. /ccw-workflow:workflow-lite-plan
2. /ccw-workflow:workflow-test-fix
Proceed? [Confirm / Show Details / Adjust / Cancel]
async function getUserConfirmation(chain) {
const response = await AskUserQuestion({
questions: [{
question: 'Proceed with this command chain?',
header: 'Confirm',
options: [
{ label: 'Confirm and execute', description: 'Proceed with commands' },
{ label: 'Show details', description: 'View each command' },
{ label: 'Adjust chain', description: 'Remove or reorder' },
{ label: 'Cancel', description: 'Abort' }
]
}]
});
if (response.confirm === 'Cancel') throw new Error('Cancelled');
if (response.confirm === 'Show details') {
displayCommandDetails(chain);
return getUserConfirmation(chain);
}
if (response.confirm === 'Adjust chain') {
return await adjustChain(chain);
}
return chain;
}
async function executeCommandChain(chain, analysis) {
const sessionId = `ccw-coord-${Date.now()}`;
const stateDir = `.workflow/.ccw-coordinator/${sessionId}`;
Bash(`mkdir -p "${stateDir}"`);
const state = {
session_id: sessionId,
status: 'running',
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
analysis: analysis,
command_chain: chain.map((cmd, idx) => ({ ...cmd, index: idx, status: 'pending' })),
execution_results: [],
prompts_used: []
};
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
for (let i = 0; i < chain.length; i++) {
const cmd = chain[i];
console.log(`[${i+1}/${chain.length}] ${cmd.command}`);
state.command_chain[i].status = 'running';
state.updated_at = new Date().toISOString();
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
let promptContent = formatCommand(cmd, state.execution_results, analysis);
let prompt = `${promptContent}\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} (${r.artifacts?.join(', ') || 'completed'})\n`;
}
});
}
state.prompts_used.push({ index: i, command: cmd.command, prompt: prompt });
try {
const taskId = Bash(
`ccw cli -p "${escapePrompt(prompt)}" --tool claude --mode write`,
{ run_in_background: true }
).task_id;
state.execution_results.push({
index: i, command: cmd.command, status: 'in-progress',
task_id: taskId, session_id: null, artifacts: [],
timestamp: new Date().toISOString()
});
state.command_chain[i].status = 'running';
state.updated_at = new Date().toISOString();
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
console.log(`[${i+1}/${chain.length}] ${cmd.command}\n`);
break; // Stop, wait for hook callback
} catch (error) {
state.command_chain[i].status = 'failed';
state.updated_at = new Date().toISOString();
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
const action = await AskUserQuestion({
questions: [{
question: `${cmd.command} failed to start: ${error.message}. What to do?`,
header: 'Error',
options: [
{ label: 'Retry', description: 'Try again' },
{ label: 'Skip', description: 'Continue next command' },
{ label: 'Abort', description: 'Stop execution' }
]
}]
});
if (action.error === 'Retry') { state.command_chain[i].status = 'pending'; state.execution_results.pop(); i--; }
else if (action.error === 'Skip') { state.execution_results[state.execution_results.length - 1].status = 'skipped'; }
else if (action.error === 'Abort') { state.status = 'failed'; break; }
}
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
}
if (state.status !== 'failed') state.status = 'waiting';
state.updated_at = new Date().toISOString();
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
return state;
}
// Smart parameter assembly
function formatCommand(cmd, previousResults, analysis) {
let prompt = `/workflow:${cmd.name} -y`;
const name = cmd.name;
// Planning commands - take task description
if (['lite-plan', 'plan', 'tdd-plan', 'multi-cli-plan'].includes(name)) {
prompt += ` "${analysis.goal}"`;
// lite-execute is now an internal phase of lite-plan (not invoked separately)
} else if (name === 'execute') {
const plan = previousResults.find(r => r.command.includes('plan'));
if (plan?.session_id) prompt += ` --resume-session="${plan.session_id}"`;
} else if (name === 'lite-plan' && analysis.task_type === 'bugfix') {
prompt += ` --bugfix "${analysis.goal}"`;
} else if (name === 'debug') {
prompt += ` "${analysis.goal}"`;
} else if (name === 'brainstorm') {
prompt = `/ccw-workflow:brainstorm -y "${analysis.goal}"`;
} else if (name === 'spec-generator') {
prompt = `/ccw-workflow:spec-generator -y "${analysis.goal}"`;
} else if (name === 'test-gen') {
const impl = previousResults.find(r => r.command.includes('execute'));
prompt += impl?.session_id ? ` "${impl.session_id}"` : ` "${analysis.goal}"`;
} else if (name === 'test-fix-gen') {
const latest = previousResults.filter(r => r.session_id).pop();
prompt += latest?.session_id ? ` "${latest.session_id}"` : ` "${analysis.goal}"`;
} else if (name === 'review') {
const latest = previousResults.filter(r => r.session_id).pop();
if (latest?.session_id) prompt += ` --session="${latest.session_id}"`;
} else if (name === 'review-cycle-fix') {
const review = previousResults.find(r => r.command.includes('review'));
const latest = review || previousResults.filter(r => r.session_id).pop();
if (latest?.session_id) prompt += ` --session="${latest.session_id}"`;
} else if (name === 'tdd-verify') {
const exec = previousResults.find(r => r.command.includes('execute'));
if (exec?.session_id) prompt += ` --session="${exec.session_id}"`;
} else if (name.includes('test') || name.includes('review') || name.includes('verify')) {
const latest = previousResults.filter(r => r.session_id).pop();
if (latest?.session_id) prompt += ` --session="${latest.session_id}"`;
// Issue workflow commands
} else if (name === 'issue:discover') {
prompt = `/ccw-workflow:issue:discover -y`;
} else if (name === 'issue:plan') {
prompt = `/ccw-workflow:issue:plan -y --all-pending`;
} else if (name === 'issue:queue') {
prompt = `/ccw-workflow:issue:queue -y`;
} else if (name === 'issue:execute') {
prompt = `/ccw-workflow:issue:execute -y --queue auto`;
} else if (name === 'issue:convert-to-plan' || name === 'convert-to-plan') {
prompt = `/ccw-workflow:issue:convert-to-plan -y --latest-lite-plan`;
// With-File workflows
} else if (name === 'brainstorm-with-file') {
prompt = `/ccw-workflow:workflow:brainstorm-with-file -y "${analysis.goal}"`;
} else if (name === 'debug-with-file') {
prompt = `/ccw-workflow:workflow:debug-with-file -y "${analysis.goal}"`;
} else if (name === 'analyze-with-file') {
prompt = `/ccw-workflow:workflow:analyze-with-file -y "${analysis.goal}"`;
} else if (name === 'issue:from-brainstorm' || name === 'from-brainstorm') {
const sessionMatch = analysis.goal.match(/BS-[\w-]+/);
prompt = sessionMatch
? `/ccw-workflow:issue:from-brainstorm -y SESSION="${sessionMatch[0]}" --auto`
: `/ccw-workflow:issue:from-brainstorm -y --auto`;
// Collaborative planning workflows
} else if (name === 'collaborative-plan-with-file') {
prompt = `/workflow:collaborative-plan-with-file -y "${analysis.goal}"`;
} else if (name === 'unified-execute-with-file') {
prompt = `/workflow:unified-execute-with-file -y`;
} else if (name === 'roadmap-with-file') {
prompt = `/ccw-workflow:workflow:roadmap-with-file -y "${analysis.goal}"`;
// Cycle workflows (self-contained)
} else if (name === 'integration-test-cycle') {
prompt = `/ccw-workflow:workflow:integration-test-cycle -y "${analysis.goal}"`;
} else if (name === 'refactor-cycle') {
prompt = `/ccw-workflow:workflow:refactor-cycle -y "${analysis.goal}"`;
// Team workflows (kept: team-planex only)
} else if (name === 'team-planex') {
prompt = `/ccw-workflow:team-planex -y "${analysis.goal}"`;
}
return prompt;
}
// Hook callback: Called when background CLI completes
async function handleCliCompletion(sessionId, taskId, output) {
const stateDir = `.workflow/.ccw-coordinator/${sessionId}`;
const state = JSON.parse(Read(`${stateDir}/state.json`));
const pendingIdx = state.execution_results.findIndex(r => r.task_id === taskId);
if (pendingIdx === -1) return;
const parsed = parseOutput(output);
const cmdIdx = state.execution_results[pendingIdx].index;
state.execution_results[pendingIdx] = {
...state.execution_results[pendingIdx],
status: parsed.sessionId ? 'completed' : 'failed',
session_id: parsed.sessionId,
artifacts: parsed.artifacts,
completed_at: new Date().toISOString()
};
state.command_chain[cmdIdx].status = parsed.sessionId ? 'completed' : 'failed';
state.updated_at = new Date().toISOString();
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
const nextIdx = cmdIdx + 1;
if (nextIdx < state.command_chain.length) {
await resumeChainExecution(sessionId, nextIdx);
} else {
state.status = 'completed';
Write(`${stateDir}/state.json`, JSON.stringify(state, null, 2));
}
}
Location: .workflow/.ccw-coordinator/{session_id}/state.json
{
"session_id": "ccw-coord-20250124-143025",
"status": "running|waiting|completed|failed",
"created_at": "2025-01-24T14:30:25Z",
"updated_at": "2025-01-24T14:35:45Z",
"analysis": {
"goal": "Implement user registration",
"scope": ["authentication", "user_management"],
"constraints": ["no breaking changes"],
"complexity": "medium"
},
"command_chain": [
{ "index": 0, "command": "/ccw-workflow:workflow-plan", "name": "plan", "status": "completed" },
{ "index": 1, "command": "/ccw-workflow:workflow-execute", "name": "execute", "status": "running" }
],
"execution_results": [
{
"index": 0, "command": "/ccw-workflow:workflow-plan", "status": "completed",
"task_id": "task-001", "session_id": "WFS-plan-20250124",
"artifacts": ["IMPL_PLAN.md"], "timestamp": "2025-01-24T14:30:25Z"
}
]
}
Status Values: running → waiting → completed | failed
running → waiting → [hook callback] → waiting → [hook callback] → completed
↓ ↑
failed ←────────────────────────────────────────────────────────────┘
workflow 操作通过 Skill() 调用对应的 Skill。
// Skill 调用方式
Skill({ skill: 'workflow-lite-plan', args: '"task description"' });
Skill({ skill: 'workflow-execute', args: '--resume-session="WFS-xxx"' });
Skill({ skill: 'brainstorm', args: '"exploration topic"' });
Skill({ skill: 'spec-generator', args: '"product specification"' });
// 命名空间命令调用方式
Skill({ skill: 'workflow:brainstorm-with-file', args: '"topic"' });
Skill({ skill: 'workflow:roadmap-with-file', args: '"requirement"' });
Skill({ skill: 'issue:discover', args: '' });
IMPORTANT: The ccw cli command executes prompts through external tools. The format is:
ccw cli -p "PROMPT_CONTENT" --tool <tool> --mode <mode>
Parameters:
-p "PROMPT_CONTENT": The prompt content to execute (required)--tool <tool>: CLI tool to use (e.g., claude, gemini, qwen)--mode <mode>: Execution mode (analysis or write)Note: -y is a command parameter inside the prompt, NOT a ccw cli parameter.
The prompt content MUST start with the workflow command, followed by task context:
/workflow:<command> -y <parameters>
Task: <description>
<optional_context>
CRITICAL: Commands execute one-by-one. After launching CLI in background:
break)| Skill | 包含操作 |
|---|---|
workflow-lite-plan | lite-plan (Skill handoff to lite-execute) |
workflow-lite-execute | lite-execute (multi-mode execution engine) |
workflow-plan | plan, plan-verify, replan |
workflow-execute | execute |
workflow-multi-cli-plan | multi-cli-plan (includes execution phase internally) |
workflow-test-fix | test-fix-gen, test-cycle-execute |
workflow-tdd-plan | tdd-plan, tdd-verify |
review-cycle | review-session-cycle, review-module-cycle, review-cycle-fix |
brainstorm | auto-parallel, artifacts, role-analysis, synthesis |
spec-generator | product-brief → PRD → architecture → epics |
team-planex | planner + executor wave pipeline |
With-File Workflows: workflow:brainstorm-with-file, workflow:debug-with-file, workflow:analyze-with-file, workflow:collaborative-plan-with-file, workflow:roadmap-with-file Cycle Workflows: workflow:integration-test-cycle, workflow:refactor-cycle Execution: workflow:unified-execute-with-file Design: workflow:ui-design:* Session Management: workflow:session:start, workflow:session:resume, workflow:session:complete, workflow:session:list, workflow:session:sync Utility: workflow:clean, workflow:spec:setup, workflow:status Spec Management: workflow:spec:setup, workflow:spec:add Issue Workflow: issue:discover, issue:discover-by-prompt, issue:plan, issue:queue, issue:execute, issue:convert-to-plan, issue:from-brainstorm, issue:new
| Command | Purpose | Output | Follow-up |
|---|---|---|---|
| test-gen | 广泛测试示例生成并进行测试 | test-tasks (IMPL-001, IMPL-002) | Skill(workflow-execute) |
| test-fix-gen | 针对特定问题生成测试并在测试中修正 | test-tasks | Skill(workflow-test-fix) → test-cycle-execute |
| test-cycle-execute | 执行测试周期(迭代测试和修复) | test-passed | N/A (终点) |
Note: 【 】 marks Minimum Execution Units (最小执行单元) - these commands must execute together.
| Task Type | Pipeline | Minimum Units |
|---|---|---|
| feature (simple) | 需求 →【lite-plan】→ 代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Quick Implementation + Test Validation |
| feature (complex) | 需求 →【plan → plan-verify】→ validate → execute → 代码 → review → fix | Full Planning + Code Review + Testing |
| bugfix | Bug报告 → lite-plan (--bugfix) → 修复代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Bug Fix + Test Validation |
| tdd | 需求 → tdd-plan → TDD任务 → execute → 代码 → tdd-verify | TDD Planning + Execution |
| test-fix | 失败测试 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Test Validation |
| test-gen | 代码/会话 →【test-gen → execute】→ 测试通过 | Test Generation + Execution |
| review | 代码 →【review-* → review-cycle-fix】→ 修复代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Code Review + Testing |
| brainstorm | 探索主题 → brainstorm → 分析 →【plan → plan-verify】→ execute → test | Exploration + Planning + Execution |
| multi-cli | 需求 → multi-cli-plan → 对比分析 → 代码 → test | Multi-Perspective + Testing |
| spec-driven | 需求 →【spec-generator → plan → execute】→ 代码 →【test-fix-gen → test-cycle-execute】→ 测试通过 | Spec-Driven + Testing |
| issue-batch | 代码库 →【discover → plan → queue → execute】→ 完成 issues | Issue Workflow |
| issue-transition | 需求 →【lite-plan → convert-to-plan → queue → execute】→ 完成 issues | Rapid-to-Issue |
| analyze-file | 分析主题 →【analyze-with-file → lite-plan】→ 代码 | Analyze to Plan |
| greenfield | 需求 →【brainstorm-with-file → plan → execute】→ 代码 → test | Greenfield (0→1) |
| brainstorm-file | 主题 →【brainstorm-with-file → plan → execute】→ 代码 → test | Brainstorm to Plan |
| brainstorm-to-issue | brainstorm.md →【from-brainstorm → queue → execute】→ 完成 issues | Brainstorm to Issue |
| debug-file | Bug报告 → debug-with-file → understanding.md (自包含) | Debug With File |
| collaborative-plan | 需求 →【collaborative-plan-with-file → unified-execute-with-file】→ 代码 | Collaborative Plan |
| roadmap | 需求 →【roadmap-with-file → team-planex】→ 代码 | Roadmap Plan |
| integration-test | 需求/模块 → integration-test-cycle → 测试通过 (自包含) | Integration Test Cycle |
| refactor | 代码库 → refactor-cycle → 重构后代码 (自包含) | Refactor Cycle |
| team-planex | 需求 → team-planex → 代码 (自包含) | Team Plan+Execute |
| bugfix-hotfix | Bug报告(紧急) → lite-plan (--hotfix) → 修复代码 | Hotfix (skip tests) |
| exploration | 探索主题 → brainstorm →【plan → execute】→ 代码 → test | Exploration + Planning |
| quick-task | 需求 →【lite-plan】→ 代码 → test | Quick Implementation |
| ui-design | UI需求 → ui-design:explore → plan → execute → 代码 | UI Design |
| documentation | 文档需求 → lite-plan → 文档 | Documentation |
Refer to the Skill 映射 section above for available Skills and Commands.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
38 commands in this plugin
/ccwMain workflow orchestrator - analyze intent, select workflow, execute command chain in main process/issue:convert-to-planconvert-to-planConvert planning artifacts (lite-plan, workflow session, markdown) to issue solutions/issue:issue:discoverissue:discoverDiscover potential issues from multiple perspectives (bug, UX, test, quality, security, performance, maintainability, best-practices) using CLI explore. Supports Exa external research for security and best-practices perspectives./issue:issue:discover-by-promptissue:discover-by-promptDiscover issues from user prompt with Gemini-planned iterative multi-agent exploration. Uses ACE semantic search for context gathering and supports cross-module comparison (e.g., frontend vs backend API contracts)./issue:executeexecuteExecute queue with DAG-based parallel orchestration (one commit per solution)/issue:from-brainstormfrom-brainstormConvert brainstorm session ideas into issue with executable solution for parallel-dev-cyclenpx claudepluginhub nx1-org/platformnex-abilities --plugin ccw-workflow2 plugins ship this exact command · first indexed Nov 17, 2026