claude-code-workflow 7.2.29 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json +2 -2
  2. package/.ccw/workflows/cli-templates/schemas/task-schema.json +14 -7
  3. package/.claude/agents/action-planning-agent.md +7 -4
  4. package/.claude/agents/cli-explore-agent.md +77 -63
  5. package/.claude/agents/cli-lite-planning-agent.md +11 -10
  6. package/.claude/agents/issue-plan-agent.md +421 -426
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/commands/workflow-skill.md +130 -0
  9. package/.claude/skills/ccw-chain/SKILL.md +92 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +31 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +58 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-issue.json +44 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +71 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-main.json +65 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-standard.json +51 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-team.json +15 -0
  17. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +47 -0
  18. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  19. package/.claude/skills/chain-loader/SKILL.md +78 -0
  20. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  21. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  22. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  23. package/.claude/skills/chain-loader/specs/chain-schema.md +126 -0
  24. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  25. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  26. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  27. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  28. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  29. package/.claude/skills/workflow-plan/SKILL.md +1 -0
  30. package/.claude/skills/workflow-plan/phases/01-session-discovery.md +19 -2
  31. package/.claude/skills/workflow-plan/phases/02-context-gathering.md +2 -2
  32. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  33. package/.claude/skills/workflow-plan/phases/04-task-generation.md +9 -1
  34. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  35. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  36. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  37. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  38. package/.codex/skills/analyze-with-file/SKILL.md +383 -134
  39. package/.codex/skills/brainstorm/SKILL.md +3 -3
  40. package/.codex/skills/brainstorm-with-file/SKILL.md +208 -88
  41. package/.codex/skills/clean/SKILL.md +1 -1
  42. package/.codex/skills/csv-wave-pipeline/SKILL.md +2 -2
  43. package/.codex/skills/investigate/orchestrator.md +24 -0
  44. package/.codex/skills/issue-discover/SKILL.md +374 -361
  45. package/.codex/skills/issue-discover/phases/01-issue-new.md +1 -1
  46. package/.codex/skills/issue-discover/phases/02-discover.md +2 -2
  47. package/.codex/skills/issue-discover/phases/03-discover-by-prompt.md +1 -1
  48. package/.codex/skills/issue-discover/phases/04-quick-execute.md +2 -2
  49. package/.codex/skills/parallel-dev-cycle/SKILL.md +44 -37
  50. package/.codex/skills/project-documentation-workflow/SKILL.md +1 -1
  51. package/.codex/skills/review-cycle/SKILL.md +31 -12
  52. package/.codex/skills/roadmap-with-file/SKILL.md +141 -133
  53. package/.codex/skills/security-audit/orchestrator.md +29 -0
  54. package/.codex/skills/session-sync/SKILL.md +1 -1
  55. package/.codex/skills/ship/orchestrator.md +24 -0
  56. package/.codex/skills/spec-add/SKILL.md +5 -5
  57. package/.codex/skills/spec-generator/SKILL.md +33 -2
  58. package/.codex/skills/spec-generator/phases/01-5-requirement-clarification.md +3 -3
  59. package/.codex/skills/spec-generator/phases/01-discovery.md +1 -1
  60. package/.codex/skills/spec-generator/phases/02-product-brief.md +1 -1
  61. package/.codex/skills/spec-generator/phases/03-requirements.md +1 -1
  62. package/.codex/skills/spec-generator/phases/04-architecture.md +1 -1
  63. package/.codex/skills/spec-generator/phases/05-epics-stories.md +1 -1
  64. package/.codex/skills/spec-generator/phases/06-readiness-check.md +1 -1
  65. package/.codex/skills/spec-generator/phases/07-issue-export.md +1 -1
  66. package/.codex/skills/spec-setup/SKILL.md +669 -669
  67. package/.codex/skills/team-arch-opt/specs/team-config.json +1 -1
  68. package/.codex/skills/team-brainstorm/SKILL.md +259 -259
  69. package/.codex/skills/team-coordinate/SKILL.md +359 -359
  70. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +1 -1
  71. package/.codex/skills/team-designer/SKILL.md +27 -1
  72. package/.codex/skills/team-designer/phases/01-requirements-analysis.md +2 -2
  73. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  74. package/.codex/skills/team-designer/phases/04-validation.md +1 -1
  75. package/.codex/skills/team-executor/SKILL.md +218 -218
  76. package/.codex/skills/team-frontend/SKILL.md +227 -227
  77. package/.codex/skills/team-frontend-debug/SKILL.md +278 -278
  78. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/analyze.md +2 -2
  79. package/.codex/skills/team-interactive-craft/SKILL.md +220 -220
  80. package/.codex/skills/team-interactive-craft/roles/coordinator/role.md +209 -209
  81. package/.codex/skills/team-issue/SKILL.md +269 -269
  82. package/.codex/skills/team-issue/roles/coordinator/role.md +1 -1
  83. package/.codex/skills/team-lifecycle-v4/SKILL.md +305 -305
  84. package/.codex/skills/team-motion-design/SKILL.md +222 -222
  85. package/.codex/skills/team-motion-design/roles/coordinator/role.md +210 -210
  86. package/.codex/skills/team-perf-opt/SKILL.md +258 -258
  87. package/.codex/skills/team-perf-opt/specs/team-config.json +1 -1
  88. package/.codex/skills/team-planex/SKILL.md +216 -216
  89. package/.codex/skills/team-quality-assurance/SKILL.md +229 -229
  90. package/.codex/skills/team-review/SKILL.md +227 -227
  91. package/.codex/skills/team-roadmap-dev/SKILL.md +238 -238
  92. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/roadmap-discuss.md +5 -5
  93. package/.codex/skills/team-tech-debt/SKILL.md +206 -206
  94. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
  95. package/.codex/skills/team-testing/SKILL.md +237 -237
  96. package/.codex/skills/team-ui-polish/SKILL.md +218 -218
  97. package/.codex/skills/team-ui-polish/roles/coordinator/role.md +213 -213
  98. package/.codex/skills/team-uidesign/SKILL.md +219 -219
  99. package/.codex/skills/team-uidesign/roles/coordinator/role.md +2 -2
  100. package/.codex/skills/team-ultra-analyze/SKILL.md +260 -260
  101. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +1 -1
  102. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +1 -1
  103. package/.codex/skills/team-ux-improve/SKILL.md +227 -227
  104. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +1 -1
  105. package/.codex/skills/team-ux-improve/specs/team-config.json +1 -1
  106. package/.codex/skills/team-visual-a11y/SKILL.md +319 -319
  107. package/.codex/skills/team-visual-a11y/roles/coordinator/role.md +213 -213
  108. package/.codex/skills/workflow-execute/SKILL.md +5 -5
  109. package/.codex/skills/workflow-lite-planex/SKILL.md +3 -3
  110. package/.codex/skills/workflow-plan/SKILL.md +3 -3
  111. package/.codex/skills/workflow-tdd-plan/SKILL.md +4 -4
  112. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +403 -402
  113. package/README.md +14 -0
  114. package/ccw/dist/cli.d.ts.map +1 -1
  115. package/ccw/dist/cli.js +16 -0
  116. package/ccw/dist/cli.js.map +1 -1
  117. package/ccw/dist/commands/chain-loader.d.ts +2 -0
  118. package/ccw/dist/commands/chain-loader.d.ts.map +1 -0
  119. package/ccw/dist/commands/chain-loader.js +11 -0
  120. package/ccw/dist/commands/chain-loader.js.map +1 -0
  121. package/ccw/dist/commands/install.d.ts.map +1 -1
  122. package/ccw/dist/commands/install.js +52 -1
  123. package/ccw/dist/commands/install.js.map +1 -1
  124. package/ccw/dist/commands/launcher.d.ts +2 -0
  125. package/ccw/dist/commands/launcher.d.ts.map +1 -0
  126. package/ccw/dist/commands/launcher.js +434 -0
  127. package/ccw/dist/commands/launcher.js.map +1 -0
  128. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  129. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  130. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  131. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  132. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  133. package/ccw/dist/tools/chain-loader.js +1054 -0
  134. package/ccw/dist/tools/chain-loader.js.map +1 -0
  135. package/ccw/dist/tools/index.d.ts.map +1 -1
  136. package/ccw/dist/tools/index.js +2 -0
  137. package/ccw/dist/tools/index.js.map +1 -1
  138. package/ccw/dist/tools/json-builder.js +20 -0
  139. package/ccw/dist/tools/json-builder.js.map +1 -1
  140. package/ccw/dist/tools/skill-context-loader.d.ts.map +1 -1
  141. package/ccw/dist/tools/skill-context-loader.js +12 -26
  142. package/ccw/dist/tools/skill-context-loader.js.map +1 -1
  143. package/ccw/dist/types/chain-types.d.ts +112 -0
  144. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  145. package/ccw/dist/types/chain-types.js +5 -0
  146. package/ccw/dist/types/chain-types.js.map +1 -0
  147. package/ccw/dist/utils/chain-visualizer.d.ts +13 -0
  148. package/ccw/dist/utils/chain-visualizer.d.ts.map +1 -0
  149. package/ccw/dist/utils/chain-visualizer.js +164 -0
  150. package/ccw/dist/utils/chain-visualizer.js.map +1 -0
  151. package/ccw/scripts/prepublish-clean.mjs +0 -1
  152. package/package.json +1 -3
  153. package/.claude/commands/cli/cli-init.md +0 -441
  154. package/.claude/commands/cli/codex-review.md +0 -361
  155. package/.claude/commands/flow-create.md +0 -663
  156. package/.claude/skills/team-edict.zip +0 -0
  157. package/ccw-litellm/README.md +0 -180
  158. package/ccw-litellm/pyproject.toml +0 -35
  159. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  160. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  161. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  162. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  163. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  164. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  165. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  166. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  167. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  168. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  169. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -0,0 +1,47 @@
1
+ {
2
+ "chain_id": "ccw-with-file",
3
+ "name": "CCW With-File Workflows",
4
+ "description": "With-File workflow routing: documented exploration with auto-chain to downstream skills",
5
+ "version": "2.2",
6
+ "entry": "D1",
7
+ "entries": [
8
+ { "name": "default", "node": "D1", "description": "Select flow via decision node" },
9
+ { "name": "analyze", "node": "S_AP1", "description": "Direct: Analyze → Plan flow" },
10
+ { "name": "debug", "node": "S_DB1", "description": "Direct: Debug flow (standalone)" },
11
+ { "name": "collab-plan", "node": "S_CP1", "description": "Direct: Collaborative Plan → Execute" },
12
+ { "name": "roadmap", "node": "S_RM1", "description": "Direct: Roadmap → Team flow" },
13
+ { "name": "investigate", "node": "S_INV1", "description": "Direct: Systematic investigation with Iron Law gate" }
14
+ ],
15
+ "triggers": {
16
+ "task_types": ["analyze-file", "debug-file", "collaborative-plan", "roadmap"],
17
+ "keywords": ["analyze.*document|collaborative analysis", "hypothesis.*debug|systematic debug|investigate", "collaborative.*plan|multi.*agent.*plan", "roadmap"],
18
+ "scope": "With-File: documented exploration with auto-chain to downstream skills"
19
+ },
20
+ "nodes": {
21
+ "D1": {
22
+ "type": "decision",
23
+ "name": "Select With-File Flow",
24
+ "prompt": "Based on the detected task_type, select the specific With-File workflow:\n1. Analyze → Plan — collaborative analysis auto-chaining to lite-plan\n2. Debug (standalone) — hypothesis-driven debugging, self-contained\n3. Collaborative Plan → Execute — multi-agent planning with unified execution\n4. Roadmap → Team — strategic requirement roadmap with team-planex execution\n\nDetection keywords:\n- analyze-file: collaborative analysis, explore concept\n- debug-file: hypothesis debug, systematic debug\n- collaborative-plan: multi-agent plan, Plan Note\n- roadmap: roadmap (explicit only)",
25
+ "choices": [
26
+ { "label": "Analyze → Plan", "description": "analyze-with-file → lite-plan", "next": "S_AP1" },
27
+ { "label": "Debug", "description": "debug-with-file (standalone)", "next": "S_DB1" },
28
+ { "label": "Collaborative Plan", "description": "collaborative-plan → unified-execute", "next": "S_CP1" },
29
+ { "label": "Roadmap → Team", "description": "roadmap-with-file → team-planex", "next": "S_RM1" },
30
+ { "label": "Investigate", "description": "Systematic investigation with Iron Law gate", "next": "S_INV1" }
31
+ ],
32
+ "default": "S_AP1"
33
+ },
34
+ "S_AP1": { "type": "step", "name": "Analyze: analyze-with-file", "content_ref": "@commands/workflow/analyze-with-file.md", "next": "S_AP2" },
35
+ "S_AP2": { "type": "step", "name": "Analyze: workflow-lite-plan", "content_ref": "@skills/workflow-lite-plan/SKILL.md", "next": null },
36
+
37
+ "S_DB1": { "type": "step", "name": "Debug: debug-with-file", "content_ref": "@commands/workflow/debug-with-file.md", "next": null },
38
+
39
+ "S_CP1": { "type": "step", "name": "Collab: collaborative-plan-with-file", "content_ref": "@commands/workflow/collaborative-plan-with-file.md", "next": "S_CP2" },
40
+ "S_CP2": { "type": "step", "name": "Collab: unified-execute-with-file", "content_ref": "@commands/workflow/unified-execute-with-file.md", "next": null },
41
+
42
+ "S_RM1": { "type": "step", "name": "Roadmap: roadmap-with-file", "content_ref": "@commands/workflow/roadmap-with-file.md", "next": "S_RM2" },
43
+ "S_RM2": { "type": "step", "name": "Roadmap: team-planex", "content_ref": "@skills/team-planex/SKILL.md", "next": null },
44
+
45
+ "S_INV1": { "type": "delegate", "name": "Investigate: ccw-investigate", "chain": "ccw-investigate", "pass_variables": ["goal", "auto_yes"], "receive_variables": ["root_cause", "confidence"], "next": null }
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ # Auto Mode Specification
2
+
3
+ When user passes `-y` or `--yes` in arguments, the entire CCW chain enters auto mode.
4
+
5
+ ## Detection
6
+
7
+ ```javascript
8
+ const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS)
9
+ ```
10
+
11
+ ## Behavior Changes
12
+
13
+ | Phase | Normal Mode | Auto Mode |
14
+ |-------|-------------|-----------|
15
+ | Phase 1 (Analyze) | Full analysis | Same |
16
+ | Phase 1.5 (Clarify) | Ask if clarity < 2 | **Skip** — infer from available info |
17
+ | Phase 3 (Confirm) | Show pipeline, ask confirm | **Skip** — execute immediately |
18
+ | Phase 5 (Execute) | Error → ask retry/skip/abort | **Skip** failed step, continue |
19
+ | Skill Args | As-is | **Inject** `-y` to all downstream Skills |
20
+
21
+ ## Propagation Mechanism
22
+
23
+ The `-y` flag is propagated to every Skill in the command chain via `assembleCommand`:
24
+
25
+ ```javascript
26
+ function assembleCommand(step, previousResult) {
27
+ let args = step.args || '';
28
+ if (!args && previousResult?.session_id) {
29
+ args = `--session="${previousResult.session_id}"`;
30
+ }
31
+ // Propagate -y to downstream Skills
32
+ if (autoYes && !args.includes('-y') && !args.includes('--yes')) {
33
+ args = args ? `${args} -y` : '-y';
34
+ }
35
+ return { skill: step.cmd, args };
36
+ }
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ```bash
42
+ # Auto mode — skip all confirmations
43
+ /ccw -y "Add user authentication"
44
+
45
+ # Auto mode — urgent hotfix, skip everything
46
+ /ccw --yes "Fix memory leak in WebSocket handler"
47
+ ```
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: chain-loader
3
+ description: Meta-skill for generating chain-based skills with progressive step loading and LLM-driven decision routing. Converts linear phase skills into chain graph skills. Triggers on "create chain", "chain skill", "add chain", "generate chain".
4
+ allowed-tools: Agent, AskUserQuestion, Read, Bash, Glob, Grep, Write
5
+ ---
6
+
7
+ # Chain Skill Generator
8
+
9
+ Generate chain graph JSON for skills, enabling progressive content delivery and LLM-driven decision routing via the `chain_loader` tool.
10
+
11
+ ## Architecture
12
+
13
+ ```
14
+ User Request (target skill + chain purpose)
15
+ |
16
+ Phase 1: Analyze target skill (existing phases/ or new requirements)
17
+ |
18
+ Phase 2: Design node graph (step/decision/delegate nodes + routing)
19
+ |
20
+ Phase 3: Generate chain JSON + validate with chain_loader
21
+ |
22
+ Output: .claude/skills/{skill}/chains/{chain}.json
23
+ ```
24
+
25
+ ## Key Rules
26
+
27
+ 1. **Spec-first** — Read `specs/chain-schema.md` and `specs/design-patterns.md` before any generation
28
+ 2. **content_ref over inline** — Use `@phases/` file references; `content_inline` only for <200 char
29
+ 3. **Validate before commit** — Never write chain JSON without graph connectivity check
30
+ 4. **Preserve existing content** — When adding chains to existing skills, never modify existing phase files
31
+ 5. **12-node limit** — If a chain exceeds 12 nodes, split into main + sub-chains
32
+
33
+ ## Exemplar
34
+
35
+ `ccw-chain` is the canonical example of this meta-skill's output:
36
+ - 8 chains, 79 total nodes, cross-chain routing via `->chain-name`
37
+ - phases/ contains actual command/skill documents (not orchestration code)
38
+ - Location: `.claude/skills/ccw-chain/`
39
+
40
+ Study its structure before generating new chains: `Read(".claude/skills/ccw-chain/SKILL.md")`
41
+
42
+ ## Execution Flow
43
+
44
+ ```
45
+ Pre-Phase: Read specs/chain-schema.md + specs/design-patterns.md
46
+
47
+ Phase 1: Analyze Target Skill
48
+ Ref: phases/01-analyze-skill.md
49
+ Input: user request, target skill name
50
+ Output: skill analysis (workflow steps, decision points, content files)
51
+
52
+ Phase 2: Design Node Graph
53
+ Ref: phases/02-design-graph.md
54
+ Input: skill analysis
55
+ Output: validated node graph (in-memory)
56
+
57
+ Phase 3: Generate & Validate
58
+ Ref: phases/03-generate-validate.md
59
+ Input: validated node graph
60
+ Output: chain JSON files, validation report
61
+ ```
62
+
63
+ | Phase | Document | Purpose |
64
+ |-------|----------|---------|
65
+ | 1 | phases/01-analyze-skill.md | Understand target skill workflow and content |
66
+ | 2 | phases/02-design-graph.md | Design nodes, routing, validate connectivity |
67
+ | 3 | phases/03-generate-validate.md | Write JSON, test with chain_loader |
68
+
69
+ ## Output Structure
70
+
71
+ ```
72
+ .claude/skills/{skill}/
73
+ ├── chains/
74
+ │ ├── {chain-name}.json # Main chain
75
+ │ └── {sub-chain}.json # Optional sub-chains
76
+ ├── phases/ # Content files (existing or generated)
77
+ └── SKILL.md # Existing or updated entry
78
+ ```
@@ -0,0 +1,53 @@
1
+ # Phase 1: Analyze Target Skill
2
+
3
+ Understand the target skill's workflow to identify nodes, decision points, and content files.
4
+
5
+ ## Step 1.1: Identify Target
6
+
7
+ Determine if adding chains to an existing skill or creating new:
8
+
9
+ **Existing skill**: Read its SKILL.md and list its phases/ directory
10
+ ```bash
11
+ # Find the skill
12
+ ls .claude/skills/{skill-name}/SKILL.md
13
+ ls .claude/skills/{skill-name}/phases/
14
+ ```
15
+
16
+ **New skill**: Collect requirements from user — what workflow steps, what branches, what content.
17
+
18
+ ## Step 1.2: Map Workflow Steps
19
+
20
+ For existing skills, read each phase file and identify:
21
+
22
+ 1. **Sequential steps** — each phase becomes a StepNode with `content_ref: "@phases/{file}"`
23
+ 2. **Decision points** — look for conditional language ("if...", "based on...", "choose...") that implies branching
24
+ 3. **Sub-workflows** — sections that reference other skills or could be extracted as separate chains
25
+
26
+ For new skills, work with the user to define:
27
+ - What are the execution steps?
28
+ - Where does the LLM need to make a routing decision?
29
+ - What content should each step load?
30
+
31
+ ## Step 1.3: Inventory Content Files
32
+
33
+ List all files that chain nodes will reference:
34
+
35
+ | Type | Source | content_ref Format |
36
+ |------|--------|--------------------|
37
+ | Phase files | `phases/01-xxx.md` | `@phases/01-xxx.md` |
38
+ | Skill subdirs | `phases/workflow-plan/SKILL.md` | `@skills/workflow-plan/SKILL.md` |
39
+ | Commands | `.claude/commands/workflow/xxx.md` | Copy to phases/ first, then `@phases/xxx.md` |
40
+ | Inline content | Short instructions (<200 chars) | Use `content_inline` instead |
41
+
42
+ **Key lesson from ccw-chain**: phases/ should contain **actual command/skill documents** that the LLM executes, not orchestration pseudocode.
43
+
44
+ ## Output
45
+
46
+ - Skill name and directory path
47
+ - List of workflow steps with their content file mappings
48
+ - Identified decision points with branch options
49
+ - List of content files that need to be created or copied
50
+
51
+ ## Next Phase
52
+
53
+ Proceed to [Phase 2: Design Node Graph](02-design-graph.md).
@@ -0,0 +1,73 @@
1
+ # Phase 2: Design Node Graph
2
+
3
+ Transform skill analysis into a validated directed graph of chain nodes.
4
+
5
+ ## Step 2.1: Choose Chain Pattern
6
+
7
+ Based on the workflow analysis from Phase 1, select a pattern from `specs/design-patterns.md`:
8
+
9
+ | Workflow Shape | Pattern | Example |
10
+ |----------------|---------|---------|
11
+ | Pure sequential | Linear Chain | `S1 → S2 → S3 → null` |
12
+ | Quality gate / retry | Decision Gate | `S1 → D1 --[pass]--> S2 --[fail]--> S1` |
13
+ | Normal vs escalation | Escalation Branch | `D1 --[simple]--> S2 --[complex]--> ->deep` |
14
+ | Reusable sub-workflow | Delegate | `S1 → DEL1 [->verify] → S2` |
15
+ | Multi-flow routing | Decision Router | `D1 --[A]--> S_A1 --[B]--> S_B1` (ccw-chain pattern) |
16
+
17
+ ## Step 2.2: Define Nodes
18
+
19
+ For each workflow step, create a node definition:
20
+
21
+ **StepNode** — loads content for LLM execution:
22
+ - `content_ref: "@phases/{file}"` for existing files
23
+ - `content_inline: "..."` for short instructions only (<200 chars)
24
+ - `next: "{node_id}"` or `null` for terminal
25
+
26
+ **DecisionNode** — LLM chooses a path:
27
+ - `prompt`: describe what the LLM should assess
28
+ - `choices[]`: each with `label`, `description`, `next`
29
+ - `default`: fallback node ID
30
+
31
+ **DelegateNode** — route to sub-chain:
32
+ - `chain`: sub-chain filename (without .json)
33
+ - `next`: return node after sub-chain completes
34
+
35
+ **Node ID conventions**:
36
+ - Steps: `S1`, `S2`, `S3` (sequential) or `S_{prefix}{n}` for multi-flow (e.g., `S_R1`, `S_B1`)
37
+ - Decisions: `D1`, `D2`
38
+ - Delegates: `DEL1`, `DEL2`
39
+
40
+ ## Step 2.3: Design Routing
41
+
42
+ For multi-flow chains (like ccw-chain's category chains), use the Decision Router pattern:
43
+
44
+ ```
45
+ D1 (Select Flow)
46
+ ├── choice 1 → S_A1 → S_A2 → null
47
+ ├── choice 2 → S_B1 → S_B2 → S_B3 → null
48
+ └── choice 3 → S_C1 → null
49
+ ```
50
+
51
+ For cross-chain routing, use `"next": "->chain-name"` to jump to another chain's entry node.
52
+
53
+ ## Step 2.4: Validate Graph
54
+
55
+ Before proceeding to generation, verify:
56
+
57
+ 1. **Entry exists** — `entry` points to a node in `nodes`
58
+ 2. **All `next` references resolve** — every node ID in `next`, `choices[].next`, `default` either exists in `nodes`, is `null`, or starts with `->` (cross-chain)
59
+ 3. **No orphan nodes** — BFS from entry reaches every node in `nodes`
60
+ 4. **Content files exist** — every `content_ref` path resolves to a real file
61
+ 5. **Decision completeness** — every DecisionNode has non-empty `choices` and a `default`
62
+
63
+ If validation fails, fix the graph before proceeding. Do NOT generate invalid chains.
64
+
65
+ ## Output
66
+
67
+ - Validated node graph (nodes map ready for JSON serialization)
68
+ - Sub-chain definitions if any
69
+ - List of content files that need creation
70
+
71
+ ## Next Phase
72
+
73
+ Proceed to [Phase 3: Generate & Validate](03-generate-validate.md).
@@ -0,0 +1,75 @@
1
+ # Phase 3: Generate & Validate
2
+
3
+ Write chain JSON files and validate with the chain_loader tool.
4
+
5
+ ## Step 3.1: Create Directory
6
+
7
+ ```bash
8
+ mkdir -p ".claude/skills/${skillName}/chains"
9
+ ```
10
+
11
+ ## Step 3.2: Write Chain JSON
12
+
13
+ Write the main chain file using the validated graph from Phase 2:
14
+
15
+ ```json
16
+ {
17
+ "chain_id": "{chain-id}",
18
+ "name": "{Human-Readable Name}",
19
+ "description": "{What this chain does}",
20
+ "version": "1.0",
21
+ "entry": "{first-node-id}",
22
+ "nodes": { ... }
23
+ }
24
+ ```
25
+
26
+ Write to: `.claude/skills/{skill}/chains/{chain-id}.json`
27
+
28
+ If there are sub-chains, write each as a separate JSON file in the same `chains/` directory.
29
+
30
+ ## Step 3.3: Create Missing Content Files
31
+
32
+ If any step nodes need new content files:
33
+ 1. Write the content to `phases/{filename}.md`
34
+ 2. Ensure the `content_ref` in the chain JSON matches: `@phases/{filename}.md`
35
+
36
+ For content files copied from commands or other skills, preserve the full document — do not summarize.
37
+
38
+ ## Step 3.4: Validate Structure
39
+
40
+ Check the generated JSON:
41
+
42
+ 1. **Required fields**: `chain_id`, `name`, `description`, `version`, `entry`, `nodes`
43
+ 2. **Entry exists**: `entry` points to a key in `nodes`
44
+ 3. **Node completeness**: every node has `type` and `name`
45
+ 4. **Step nodes**: have `content_ref` or `content_inline`
46
+ 5. **Decision nodes**: have non-empty `choices[]` and `default`
47
+ 6. **Delegate nodes**: have `chain` field
48
+ 7. **All `next` references**: resolve to existing nodes, `null`, or `->chain-name`
49
+ 8. **No orphans**: BFS from entry reaches every node
50
+ 9. **Content refs exist**: every `@phases/...` file is on disk
51
+
52
+ ## Step 3.5: Integration Test
53
+
54
+ Test with the chain_loader tool from the **project root** (not from the skill directory):
55
+
56
+ ```bash
57
+ # List — should show the new chain(s)
58
+ ccw tool exec chain_loader '{"cmd":"list","skill":"{skill-name}"}'
59
+
60
+ # Start — should return entry node content
61
+ ccw tool exec chain_loader '{"cmd":"start","skill":"{skill-name}","chain":"{chain-id}"}'
62
+ ```
63
+
64
+ **Known gotcha**: `chain_loader list` auto-detects skill from cwd. Run from project root with explicit `skill` param to avoid empty results.
65
+
66
+ ## Step 3.6: Report Results
67
+
68
+ Output summary:
69
+ - Chains generated (count and names)
70
+ - Total nodes, by type (step/decision/delegate)
71
+ - Validation status (PASS/FAIL)
72
+ - Any warnings (orphan nodes, missing content)
73
+
74
+ If FAIL: fix errors before marking complete.
75
+ If PASS: the chain is ready for use.
@@ -0,0 +1,126 @@
1
+ # Chain JSON Schema & State Machine
2
+
3
+ ## Chain JSON Structure
4
+
5
+ Files live at `.claude/skills/{skill}/chains/{chain-name}.json`.
6
+
7
+ ### Required Fields
8
+
9
+ | Field | Type | Description |
10
+ |-------|------|-------------|
11
+ | `chain_id` | string | Unique ID matching filename (without .json) |
12
+ | `name` | string | Human-readable name |
13
+ | `description` | string | What this chain does |
14
+ | `version` | string | Semantic version |
15
+ | `entry` | string? | Node ID of single entry point (backward compat) |
16
+ | `entries` | array? | Multiple named entry points (preferred over `entry`) |
17
+ | `triggers` | object? | Self-describing trigger conditions |
18
+ | `nodes` | object | Map of node ID to node definition |
19
+
20
+ ### Entries (multiple entry points)
21
+
22
+ ```json
23
+ "entries": [
24
+ { "name": "default", "node": "D1", "description": "Select flow via decision" },
25
+ { "name": "bugfix", "node": "S_B1", "description": "Direct: Bugfix flow" }
26
+ ]
27
+ ```
28
+ - First entry is the default when no `entry_name` or `node` specified in `start`
29
+ - Resolution priority: explicit `node` > `entry_name` lookup > `entries[0]` > `entry`
30
+
31
+ ### Triggers (self-describing)
32
+
33
+ ```json
34
+ "triggers": {
35
+ "task_types": ["bugfix", "bugfix-hotfix", "quick-task"],
36
+ "keywords": ["fix|bug|error", "urgent|production"],
37
+ "scope": "Level 2: rapid, bugfix, hotfix, docs"
38
+ }
39
+ ```
40
+ - `task_types`: array of task_type values this chain handles
41
+ - `keywords`: array of regex patterns for intent matching
42
+ - `scope`: human-readable description of when to use this chain
43
+
44
+ ### StepNode
45
+
46
+ ```json
47
+ {
48
+ "type": "step",
49
+ "name": "Phase Name",
50
+ "content_ref": "@phases/01-xxx.md",
51
+ "next": "S2"
52
+ }
53
+ ```
54
+ - `content_ref` (`@`-prefixed path) or `content_inline` (direct text) — at least one required
55
+ - `content_ref` resolved relative to skill directory: `resolve(skillPath, refPath.replace('@',''))`
56
+ - `next: null` = chain termination
57
+
58
+ ### DecisionNode
59
+
60
+ ```json
61
+ {
62
+ "type": "decision",
63
+ "name": "Select Flow",
64
+ "prompt": "Based on analysis, choose...",
65
+ "choices": [
66
+ { "label": "Option A", "description": "...", "next": "S_A1" },
67
+ { "label": "Option B", "description": "...", "next": "S_B1" }
68
+ ],
69
+ "default": "S_A1"
70
+ }
71
+ ```
72
+ - `choices` — non-empty array, selected by **1-based index**
73
+ - `choice.next` can be node ID or `"->chain-name"` for cross-chain routing
74
+ - `default` — fallback if no valid choice provided
75
+
76
+ ### DelegateNode
77
+
78
+ ```json
79
+ {
80
+ "type": "delegate",
81
+ "name": "Run Sub-workflow",
82
+ "chain": "sub-chain-name",
83
+ "next": "S5"
84
+ }
85
+ ```
86
+ - `chain` — filename (without .json) of another chain in same skill's `chains/` dir
87
+ - `next` — return node after sub-chain completes; `null` if no return
88
+
89
+ ### Cross-Chain Routing
90
+
91
+ - `"->chain-name"` in any `next` field jumps to that chain's entry node
92
+ - DelegateNode pushes current chain onto stack; sub-chain completion pops back to `next`
93
+
94
+ ---
95
+
96
+ ## Node State Machine
97
+
98
+ ### Lifecycle
99
+
100
+ ```
101
+ pending → active → completed
102
+ ```
103
+
104
+ ### Rules
105
+
106
+ 1. `start` — creates session, entry node becomes `active`
107
+ 2. `next` on `active` node — returns current content (idempotent, no state change)
108
+ 3. `next` on `completed` node — auto-advances to next node
109
+ 4. `done` — forces `active -> completed`, advances to next node
110
+ 5. Decision `done` requires `choice` (1-based index)
111
+ 6. Delegate `done` — pushes chain onto `chain_stack`, switches to sub-chain entry
112
+ 7. Sub-chain termination (`next: null`) — pops `chain_stack`, returns to parent's `return_node`
113
+ 8. All chains exhausted (empty stack + `next: null`) — session `completed`
114
+
115
+ ### chain_loader Commands
116
+
117
+ | cmd | Params | Description |
118
+ |-----|--------|-------------|
119
+ | `list` | `skill?` | List chains with triggers/entries |
120
+ | `inspect` | `chain`, `skill?` | Show chain node graph and entries |
121
+ | `start` | `chain`, `skill?`, `node?`, `entry_name?` | Create session from entry, named entry, or any node |
122
+ | `next` | `session_id` | Read current node (idempotent if active) |
123
+ | `done` | `session_id`, `choice?` | Complete current node, advance |
124
+ | `status` | `session_id` | Query session state |
125
+ | `content` | `session_id` | Get all loaded content |
126
+ | `complete` | `session_id` | Mark session completed |
@@ -0,0 +1,99 @@
1
+ # Chain Design Patterns
2
+
3
+ Common patterns and anti-patterns for chain graph design.
4
+
5
+ ## Patterns
6
+
7
+ ### 1. Linear Chain (Simplest)
8
+
9
+ ```
10
+ S1 → S2 → S3 → null
11
+ ```
12
+
13
+ Use when: Pure sequential workflow, no branching needed. Equivalent to numbered phases but with session tracking.
14
+
15
+ ### 2. Decision Gate
16
+
17
+ ```
18
+ S1 → S2 → D1 --[pass]--> S3 → null
19
+ --[fail]--> S2 (loop back)
20
+ ```
21
+
22
+ Use when: Quality gate after analysis, confidence check, retry loop.
23
+
24
+ ### 3. Escalation Branch
25
+
26
+ ```
27
+ S1 → S2 → D1 --[simple]--> S3 → null
28
+ --[complex]--> →deep-analysis (cross-chain)
29
+ ```
30
+
31
+ Use when: Normal path vs. escalation to separate workflow.
32
+
33
+ ### 4. Delegate Sub-Chain
34
+
35
+ ```
36
+ S1 → S2 → DEL1 [→verification] → S3 → null
37
+ ```
38
+
39
+ Use when: Reusable sub-workflow that multiple chains can call.
40
+
41
+ ### 5. Multi-Path Merge
42
+
43
+ ```
44
+ S1 → D1 --[A]--> S2A → S3
45
+ --[B]--> S2B → S3
46
+ ```
47
+
48
+ Use when: Different approaches converge to same final step.
49
+
50
+ ### 6. Decision Router (Multi-Flow)
51
+
52
+ ```
53
+ D1 --[flow A]--> S_A1 → S_A2 → null
54
+ --[flow B]--> S_B1 → S_B2 → S_B3 → null
55
+ --[flow C]--> S_C1 → null
56
+ ```
57
+
58
+ Use when: Single entry point dispatches to multiple independent pipelines. Each flow has its own step sequence. This is the primary pattern used in ccw-chain's category chains (ccw-lightweight, ccw-standard, ccw-exploration, etc.).
59
+
60
+ ## Anti-Patterns
61
+
62
+ ### 1. Too Many Decisions
63
+
64
+ Bad: `D1 → D2 → D3 → D4` (decision after decision)
65
+
66
+ Fix: Combine into one decision with more choices, or add a step between decisions.
67
+
68
+ ### 2. Orphan Nodes
69
+
70
+ Bad: Node exists in `nodes` but unreachable from `entry`.
71
+
72
+ Fix: Remove it or connect it to the graph.
73
+
74
+ ### 3. Missing Default
75
+
76
+ Bad: Decision node without `default` field.
77
+
78
+ Fix: Always set `default` to a safe fallback node.
79
+
80
+ ### 4. Deep Delegation
81
+
82
+ Bad: Chain A delegates to B which delegates to C which delegates to D.
83
+
84
+ Fix: Keep delegation to max 2 levels. Flatten if possible.
85
+
86
+ ### 5. Inline Novel Content
87
+
88
+ Bad: `content_inline` with 500+ words of unique instruction.
89
+
90
+ Fix: Extract to a `phases/*.md` file and use `content_ref`.
91
+
92
+ ## Chain Sizing Guide
93
+
94
+ | Complexity | Nodes | Decisions | Sub-chains |
95
+ |-----------|-------|-----------|------------|
96
+ | Simple | 3-5 | 0-1 | 0 |
97
+ | Standard | 5-8 | 1-2 | 0-1 |
98
+ | Complex | 8-12 | 2-3 | 1-2 |
99
+ | Large | 12+ | Consider splitting into multiple chains |
@@ -0,0 +1,63 @@
1
+ # Chain JSON Template
2
+
3
+ ## Minimal Linear Chain
4
+
5
+ ```json
6
+ {
7
+ "chain_id": "my-workflow",
8
+ "name": "My Workflow",
9
+ "description": "Sequential 3-step workflow",
10
+ "version": "1.0",
11
+ "entry": "S1",
12
+ "nodes": {
13
+ "S1": { "type": "step", "name": "Step 1", "content_ref": "@phases/01-step.md", "next": "S2" },
14
+ "S2": { "type": "step", "name": "Step 2", "content_ref": "@phases/02-step.md", "next": "S3" },
15
+ "S3": { "type": "step", "name": "Step 3", "content_ref": "@phases/03-step.md", "next": null }
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Decision Router (from ccw-chain/ccw-lightweight)
21
+
22
+ ```json
23
+ {
24
+ "chain_id": "ccw-lightweight",
25
+ "name": "CCW Lightweight Workflows",
26
+ "description": "Level 2: rapid, bugfix, hotfix, docs-only",
27
+ "version": "2.0",
28
+ "entry": "D1",
29
+ "nodes": {
30
+ "D1": {
31
+ "type": "decision",
32
+ "name": "Select Lightweight Flow",
33
+ "prompt": "Based on the detected task_type, select the flow:\n1. Rapid\n2. Bugfix\n3. Hotfix\n4. Docs",
34
+ "choices": [
35
+ { "label": "Rapid", "description": "lite-plan + test-fix", "next": "S_R1" },
36
+ { "label": "Bugfix", "description": "lite-plan(--bugfix) + test-fix", "next": "S_B1" },
37
+ { "label": "Hotfix", "description": "lite-plan(--hotfix)", "next": "S_H1" },
38
+ { "label": "Docs", "description": "lite-plan(--docs)", "next": "S_D1" }
39
+ ],
40
+ "default": "S_R1"
41
+ },
42
+ "S_R1": { "type": "step", "name": "Rapid: workflow-lite-plan", "content_ref": "@phases/workflow-lite-plan.md", "next": "S_R2" },
43
+ "S_R2": { "type": "step", "name": "Rapid: workflow-test-fix", "content_ref": "@skills/workflow-test-fix/SKILL.md", "next": null },
44
+ "S_B1": { "type": "step", "name": "Bugfix: workflow-lite-plan", "content_ref": "@phases/workflow-lite-plan.md", "next": "S_B2" },
45
+ "S_B2": { "type": "step", "name": "Bugfix: workflow-test-fix", "content_ref": "@skills/workflow-test-fix/SKILL.md", "next": null },
46
+ "S_H1": { "type": "step", "name": "Hotfix: workflow-lite-plan", "content_ref": "@phases/workflow-lite-plan.md", "next": null },
47
+ "S_D1": { "type": "step", "name": "Docs: workflow-lite-plan", "content_ref": "@phases/workflow-lite-plan.md", "next": null }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Cross-Chain Routing (from ccw-chain/ccw-main)
53
+
54
+ Decision choice with `"next": "->ccw-lightweight"` jumps to another chain's entry node.
55
+
56
+ ## Node ID Conventions
57
+
58
+ | Prefix | Type | Example |
59
+ |--------|------|---------|
60
+ | `S{n}` | Sequential step | S1, S2, S3 |
61
+ | `S_{prefix}{n}` | Flow-scoped step | S_R1, S_B1, S_CP2 |
62
+ | `D{n}` | Decision | D1, D2 |
63
+ | `DEL{n}` | Delegate | DEL1 |