@cleocode/skills 2.0.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 (171) hide show
  1. package/dispatch-config.json +404 -0
  2. package/index.d.ts +178 -0
  3. package/index.js +405 -0
  4. package/package.json +14 -0
  5. package/profiles/core.json +7 -0
  6. package/profiles/full.json +10 -0
  7. package/profiles/minimal.json +7 -0
  8. package/profiles/recommended.json +7 -0
  9. package/provider-skills-map.json +97 -0
  10. package/skills/_shared/cleo-style-guide.md +84 -0
  11. package/skills/_shared/manifest-operations.md +810 -0
  12. package/skills/_shared/placeholders.json +433 -0
  13. package/skills/_shared/skill-chaining-patterns.md +237 -0
  14. package/skills/_shared/subagent-protocol-base.md +223 -0
  15. package/skills/_shared/task-system-integration.md +232 -0
  16. package/skills/_shared/testing-framework-config.md +110 -0
  17. package/skills/ct-cleo/SKILL.md +490 -0
  18. package/skills/ct-cleo/references/anti-patterns.md +19 -0
  19. package/skills/ct-cleo/references/loom-lifecycle.md +136 -0
  20. package/skills/ct-cleo/references/orchestrator-constraints.md +55 -0
  21. package/skills/ct-cleo/references/session-protocol.md +162 -0
  22. package/skills/ct-codebase-mapper/SKILL.md +82 -0
  23. package/skills/ct-contribution/SKILL.md +521 -0
  24. package/skills/ct-contribution/templates/contribution-init.json +21 -0
  25. package/skills/ct-dev-workflow/SKILL.md +423 -0
  26. package/skills/ct-docs-lookup/SKILL.md +66 -0
  27. package/skills/ct-docs-review/SKILL.md +175 -0
  28. package/skills/ct-docs-write/SKILL.md +108 -0
  29. package/skills/ct-documentor/SKILL.md +231 -0
  30. package/skills/ct-epic-architect/SKILL.md +305 -0
  31. package/skills/ct-epic-architect/references/bug-epic-example.md +172 -0
  32. package/skills/ct-epic-architect/references/commands.md +201 -0
  33. package/skills/ct-epic-architect/references/feature-epic-example.md +210 -0
  34. package/skills/ct-epic-architect/references/migration-epic-example.md +244 -0
  35. package/skills/ct-epic-architect/references/output-format.md +92 -0
  36. package/skills/ct-epic-architect/references/patterns.md +284 -0
  37. package/skills/ct-epic-architect/references/refactor-epic-example.md +412 -0
  38. package/skills/ct-epic-architect/references/research-epic-example.md +226 -0
  39. package/skills/ct-epic-architect/references/shell-escaping.md +86 -0
  40. package/skills/ct-epic-architect/references/skill-aware-execution.md +195 -0
  41. package/skills/ct-grade/SKILL.md +230 -0
  42. package/skills/ct-grade/agents/analysis-reporter.md +203 -0
  43. package/skills/ct-grade/agents/blind-comparator.md +157 -0
  44. package/skills/ct-grade/agents/scenario-runner.md +134 -0
  45. package/skills/ct-grade/eval-viewer/__pycache__/generate_grade_review.cpython-314.pyc +0 -0
  46. package/skills/ct-grade/eval-viewer/generate_grade_review.py +1138 -0
  47. package/skills/ct-grade/eval-viewer/generate_grade_viewer.py +544 -0
  48. package/skills/ct-grade/eval-viewer/generate_review.py +283 -0
  49. package/skills/ct-grade/eval-viewer/grade-review.html +1574 -0
  50. package/skills/ct-grade/eval-viewer/viewer.html +219 -0
  51. package/skills/ct-grade/evals/evals.json +94 -0
  52. package/skills/ct-grade/references/ab-test-methodology.md +150 -0
  53. package/skills/ct-grade/references/domains.md +137 -0
  54. package/skills/ct-grade/references/grade-spec.md +236 -0
  55. package/skills/ct-grade/references/scenario-playbook.md +234 -0
  56. package/skills/ct-grade/references/token-tracking.md +120 -0
  57. package/skills/ct-grade/scripts/__pycache__/audit_analyzer.cpython-314.pyc +0 -0
  58. package/skills/ct-grade/scripts/__pycache__/run_ab_test.cpython-314.pyc +0 -0
  59. package/skills/ct-grade/scripts/__pycache__/run_all.cpython-314.pyc +0 -0
  60. package/skills/ct-grade/scripts/__pycache__/token_tracker.cpython-314.pyc +0 -0
  61. package/skills/ct-grade/scripts/audit_analyzer.py +279 -0
  62. package/skills/ct-grade/scripts/generate_report.py +283 -0
  63. package/skills/ct-grade/scripts/run_ab_test.py +504 -0
  64. package/skills/ct-grade/scripts/run_all.py +287 -0
  65. package/skills/ct-grade/scripts/setup_run.py +183 -0
  66. package/skills/ct-grade/scripts/token_tracker.py +630 -0
  67. package/skills/ct-grade-v2-1/SKILL.md +237 -0
  68. package/skills/ct-grade-v2-1/agents/analysis-reporter.md +203 -0
  69. package/skills/ct-grade-v2-1/agents/blind-comparator.md +157 -0
  70. package/skills/ct-grade-v2-1/agents/scenario-runner.md +179 -0
  71. package/skills/ct-grade-v2-1/evals/evals.json +74 -0
  72. package/skills/ct-grade-v2-1/grade-viewer/__pycache__/build_op_stats.cpython-314.pyc +0 -0
  73. package/skills/ct-grade-v2-1/grade-viewer/__pycache__/generate_grade_review.cpython-314.pyc +0 -0
  74. package/skills/ct-grade-v2-1/grade-viewer/build_op_stats.py +174 -0
  75. package/skills/ct-grade-v2-1/grade-viewer/eval-analysis.json +41 -0
  76. package/skills/ct-grade-v2-1/grade-viewer/eval-report.md +34 -0
  77. package/skills/ct-grade-v2-1/grade-viewer/generate_grade_review.py +1023 -0
  78. package/skills/ct-grade-v2-1/grade-viewer/generate_grade_viewer.py +548 -0
  79. package/skills/ct-grade-v2-1/grade-viewer/grade-review-eval.html +613 -0
  80. package/skills/ct-grade-v2-1/grade-viewer/grade-review.html +1532 -0
  81. package/skills/ct-grade-v2-1/grade-viewer/viewer.html +620 -0
  82. package/skills/ct-grade-v2-1/manifest-entry.json +31 -0
  83. package/skills/ct-grade-v2-1/references/ab-testing.md +233 -0
  84. package/skills/ct-grade-v2-1/references/domains-ssot.md +156 -0
  85. package/skills/ct-grade-v2-1/references/grade-spec-v2.md +167 -0
  86. package/skills/ct-grade-v2-1/references/playbook-v2.md +393 -0
  87. package/skills/ct-grade-v2-1/references/token-tracking.md +202 -0
  88. package/skills/ct-grade-v2-1/scripts/generate_report.py +419 -0
  89. package/skills/ct-grade-v2-1/scripts/run_ab_test.py +493 -0
  90. package/skills/ct-grade-v2-1/scripts/run_scenario.py +396 -0
  91. package/skills/ct-grade-v2-1/scripts/setup_run.py +207 -0
  92. package/skills/ct-grade-v2-1/scripts/token_tracker.py +175 -0
  93. package/skills/ct-memory/SKILL.md +84 -0
  94. package/skills/ct-orchestrator/INSTALL.md +61 -0
  95. package/skills/ct-orchestrator/README.md +69 -0
  96. package/skills/ct-orchestrator/SKILL.md +380 -0
  97. package/skills/ct-orchestrator/manifest-entry.json +19 -0
  98. package/skills/ct-orchestrator/orchestrator-prompt.txt +17 -0
  99. package/skills/ct-orchestrator/references/SUBAGENT-PROTOCOL-BLOCK.md +66 -0
  100. package/skills/ct-orchestrator/references/autonomous-operation.md +167 -0
  101. package/skills/ct-orchestrator/references/lifecycle-gates.md +98 -0
  102. package/skills/ct-orchestrator/references/orchestrator-compliance.md +271 -0
  103. package/skills/ct-orchestrator/references/orchestrator-handoffs.md +85 -0
  104. package/skills/ct-orchestrator/references/orchestrator-patterns.md +164 -0
  105. package/skills/ct-orchestrator/references/orchestrator-recovery.md +113 -0
  106. package/skills/ct-orchestrator/references/orchestrator-spawning.md +271 -0
  107. package/skills/ct-orchestrator/references/orchestrator-tokens.md +180 -0
  108. package/skills/ct-research-agent/SKILL.md +226 -0
  109. package/skills/ct-skill-creator/.cleo/.context-state.json +13 -0
  110. package/skills/ct-skill-creator/.cleo/logs/cleo.2026-03-07.1.log +24 -0
  111. package/skills/ct-skill-creator/.cleo/tasks.db +0 -0
  112. package/skills/ct-skill-creator/SKILL.md +356 -0
  113. package/skills/ct-skill-creator/agents/analyzer.md +276 -0
  114. package/skills/ct-skill-creator/agents/comparator.md +204 -0
  115. package/skills/ct-skill-creator/agents/grader.md +225 -0
  116. package/skills/ct-skill-creator/assets/eval_review.html +146 -0
  117. package/skills/ct-skill-creator/eval-viewer/__pycache__/generate_review.cpython-314.pyc +0 -0
  118. package/skills/ct-skill-creator/eval-viewer/generate_review.py +471 -0
  119. package/skills/ct-skill-creator/eval-viewer/viewer.html +1325 -0
  120. package/skills/ct-skill-creator/manifest-entry.json +17 -0
  121. package/skills/ct-skill-creator/references/dynamic-context.md +228 -0
  122. package/skills/ct-skill-creator/references/frontmatter.md +83 -0
  123. package/skills/ct-skill-creator/references/invocation-control.md +165 -0
  124. package/skills/ct-skill-creator/references/output-patterns.md +86 -0
  125. package/skills/ct-skill-creator/references/provider-deployment.md +175 -0
  126. package/skills/ct-skill-creator/references/schemas.md +430 -0
  127. package/skills/ct-skill-creator/references/workflows.md +28 -0
  128. package/skills/ct-skill-creator/scripts/__init__.py +1 -0
  129. package/skills/ct-skill-creator/scripts/__pycache__/__init__.cpython-314.pyc +0 -0
  130. package/skills/ct-skill-creator/scripts/__pycache__/aggregate_benchmark.cpython-314.pyc +0 -0
  131. package/skills/ct-skill-creator/scripts/__pycache__/generate_report.cpython-314.pyc +0 -0
  132. package/skills/ct-skill-creator/scripts/__pycache__/improve_description.cpython-314.pyc +0 -0
  133. package/skills/ct-skill-creator/scripts/__pycache__/init_skill.cpython-314.pyc +0 -0
  134. package/skills/ct-skill-creator/scripts/__pycache__/quick_validate.cpython-314.pyc +0 -0
  135. package/skills/ct-skill-creator/scripts/__pycache__/run_eval.cpython-314.pyc +0 -0
  136. package/skills/ct-skill-creator/scripts/__pycache__/run_loop.cpython-314.pyc +0 -0
  137. package/skills/ct-skill-creator/scripts/__pycache__/utils.cpython-314.pyc +0 -0
  138. package/skills/ct-skill-creator/scripts/aggregate_benchmark.py +401 -0
  139. package/skills/ct-skill-creator/scripts/generate_report.py +326 -0
  140. package/skills/ct-skill-creator/scripts/improve_description.py +247 -0
  141. package/skills/ct-skill-creator/scripts/init_skill.py +306 -0
  142. package/skills/ct-skill-creator/scripts/package_skill.py +110 -0
  143. package/skills/ct-skill-creator/scripts/quick_validate.py +97 -0
  144. package/skills/ct-skill-creator/scripts/run_eval.py +310 -0
  145. package/skills/ct-skill-creator/scripts/run_loop.py +328 -0
  146. package/skills/ct-skill-creator/scripts/utils.py +47 -0
  147. package/skills/ct-skill-validator/SKILL.md +178 -0
  148. package/skills/ct-skill-validator/agents/ecosystem-checker.md +151 -0
  149. package/skills/ct-skill-validator/assets/valid-skill-example.md +13 -0
  150. package/skills/ct-skill-validator/evals/eval_set.json +14 -0
  151. package/skills/ct-skill-validator/evals/evals.json +52 -0
  152. package/skills/ct-skill-validator/manifest-entry.json +20 -0
  153. package/skills/ct-skill-validator/references/cleo-ecosystem-rules.md +163 -0
  154. package/skills/ct-skill-validator/references/validation-rules.md +168 -0
  155. package/skills/ct-skill-validator/scripts/__init__.py +0 -0
  156. package/skills/ct-skill-validator/scripts/__pycache__/audit_body.cpython-314.pyc +0 -0
  157. package/skills/ct-skill-validator/scripts/__pycache__/check_ecosystem.cpython-314.pyc +0 -0
  158. package/skills/ct-skill-validator/scripts/__pycache__/generate_validation_report.cpython-314.pyc +0 -0
  159. package/skills/ct-skill-validator/scripts/__pycache__/validate.cpython-314.pyc +0 -0
  160. package/skills/ct-skill-validator/scripts/audit_body.py +242 -0
  161. package/skills/ct-skill-validator/scripts/check_ecosystem.py +169 -0
  162. package/skills/ct-skill-validator/scripts/check_manifest.py +172 -0
  163. package/skills/ct-skill-validator/scripts/generate_validation_report.py +442 -0
  164. package/skills/ct-skill-validator/scripts/validate.py +422 -0
  165. package/skills/ct-spec-writer/SKILL.md +189 -0
  166. package/skills/ct-stickynote/README.md +14 -0
  167. package/skills/ct-stickynote/SKILL.md +46 -0
  168. package/skills/ct-task-executor/SKILL.md +296 -0
  169. package/skills/ct-validator/SKILL.md +216 -0
  170. package/skills/manifest.json +469 -0
  171. package/skills.json +281 -0
@@ -0,0 +1,98 @@
1
+ # Lifecycle Gate Enforcement
2
+
3
+ > Referenced from: @skills/ct-orchestrator/SKILL.md
4
+ > Load when: Need details on RCASD-IVTR+C gate checks, enforcement modes, handling gate failures, or emergency bypass
5
+
6
+ ## Overview
7
+
8
+ Before spawning ANY implementation task, the system automatically checks RCASD-IVTR+C prerequisites. This ensures the Research → Consensus → Specification → Decomposition pipeline is followed.
9
+
10
+ ## Decision Tree
11
+
12
+ ```
13
+ Before spawn:
14
+
15
+ ├─ Is task under an epic (has parentId)?
16
+ │ ├─ NO → Skip gate check, proceed
17
+ │ └─ YES → Continue to gate check
18
+
19
+ ├─ What is enforcement mode?
20
+ │ ├─ off → Skip gate check, proceed
21
+ │ ├─ advisory → Check gates, warn on failure, proceed
22
+ │ └─ strict (default) → Check gates, BLOCK on failure
23
+
24
+ ├─ Map protocol to RCASD-IVTR+C stage:
25
+ │ ├─ research → research stage
26
+ │ ├─ consensus → consensus stage
27
+ │ ├─ specification → specification stage
28
+ │ ├─ decomposition → decomposition stage
29
+ │ ├─ implementation/contribution → implementation stage
30
+ │ └─ release → release stage
31
+
32
+ ├─ Check prerequisites for target stage:
33
+ │ ├─ All prior stages completed/skipped → GATE PASSES → Proceed with spawn
34
+ │ └─ Missing prerequisite stages → GATE FAILS
35
+
36
+ └─ On GATE FAILURE (strict mode):
37
+ ├─ Exit code: 75 (EXIT_LIFECYCLE_GATE_FAILED)
38
+ ├─ Error includes: missing stages, fix commands
39
+ └─ Action: Complete prerequisite stages first
40
+ ```
41
+
42
+ ## Enforcement Modes
43
+
44
+ | Mode | Behavior | When to Use |
45
+ |------|----------|-------------|
46
+ | **strict** (default) | Blocks spawn if prerequisites missing | Production, regulated work |
47
+ | **advisory** | Warns but allows spawn | Rapid prototyping, debugging |
48
+ | **off** | Disables all gate checks | Legacy compatibility, emergencies |
49
+
50
+ ## Setting Enforcement Mode
51
+
52
+ ```bash
53
+ # Check current mode
54
+ jq '.lifecycleEnforcement.mode' .cleo/config.json
55
+
56
+ # Set to advisory (temporary)
57
+ jq '.lifecycleEnforcement.mode = "advisory"' .cleo/config.json > tmp && mv tmp .cleo/config.json
58
+
59
+ # Set back to strict
60
+ jq '.lifecycleEnforcement.mode = "strict"' .cleo/config.json > tmp && mv tmp .cleo/config.json
61
+ ```
62
+
63
+ ## Handling Gate Failures
64
+
65
+ When a gate fails in strict mode:
66
+
67
+ 1. **Check what's missing**: Error JSON shows `missingPrerequisites`
68
+ 2. **Complete prerequisites**: Spawn subagents for missing stages
69
+ 3. **Record completion**: System auto-records via manifest entries
70
+ 4. **Retry spawn**: Original task should now pass gate
71
+
72
+ **Example failure response:**
73
+ ```json
74
+ {
75
+ "error": {
76
+ "code": "E_LIFECYCLE_GATE_FAILED",
77
+ "message": "SPAWN BLOCKED: Lifecycle prerequisites not met for implementation stage",
78
+ "context": {
79
+ "targetStage": "implementation",
80
+ "missingPrerequisites": "research consensus"
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## Emergency Bypass
87
+
88
+ **Only for emergencies** — set mode to advisory or off:
89
+
90
+ ```bash
91
+ # Temporary bypass for single session
92
+ export LIFECYCLE_ENFORCEMENT_MODE=off
93
+
94
+ # Or update config
95
+ jq '.lifecycleEnforcement.mode = "off"' .cleo/config.json > tmp && mv tmp .cleo/config.json
96
+ ```
97
+
98
+ **Remember to restore strict mode after emergency.**
@@ -0,0 +1,271 @@
1
+ # Orchestrator: Protocol Compliance
2
+
3
+ > Referenced from: @skills/ct-orchestrator/SKILL.md
4
+ > Load when: Need details on protocol enforcement, validation requirements, compliance verification, retry protocols, or anti-patterns
5
+
6
+ ## Protocol Enforcement Requirements
7
+
8
+ ### MUST Inject Protocol Block
9
+
10
+ Every Task tool spawn **MUST** include the protocol block. Verification:
11
+
12
+ ```bash
13
+ # Before spawning, verify protocol injection
14
+ echo "$prompt" | grep -q "SUBAGENT PROTOCOL" || echo "ERROR: Missing protocol block!"
15
+ ```
16
+
17
+ ### MUST Validate Return Messages
18
+
19
+ Only accept these return message formats from subagents:
20
+
21
+ | Status | Valid Return Message |
22
+ |--------|---------------------|
23
+ | Complete | "Research complete. See MANIFEST.jsonl for summary." |
24
+ | Partial | "Research partial. See MANIFEST.jsonl for details." |
25
+ | Blocked | "Research blocked. See MANIFEST.jsonl for blocker details." |
26
+
27
+ Any other return format indicates protocol violation.
28
+
29
+ ### MUST Verify Manifest Entry
30
+
31
+ After EACH subagent spawn completes, verify manifest entry exists:
32
+
33
+ ```bash
34
+ # 1. Get expected research ID
35
+ research_id="${topic_slug}-${date}" # e.g., "auth-research-2026-01-21"
36
+
37
+ # 2. Verify manifest entry exists
38
+ cleo research show "$research_id"
39
+ # OR
40
+ jq -s '.[] | select(.id == "'$research_id'")' "{{MANIFEST_PATH}}"
41
+
42
+ # 3. Block on missing manifest - DO NOT spawn next agent until confirmed
43
+ if ! cleo research show "$research_id" &>/dev/null; then
44
+ echo "ERROR: Manifest entry missing for $research_id"
45
+ echo "ACTION: Re-spawn with clearer protocol instructions"
46
+ exit 1
47
+ fi
48
+ ```
49
+
50
+ ### MUST Verify Research Link
51
+
52
+ After subagent completion, verify research is linked to task:
53
+
54
+ ```bash
55
+ # 1. Check task for linked research
56
+ linked=$(cleo show "$task_id" | jq -r '.task.linkedResearch // empty')
57
+
58
+ # 2. If missing, orchestrator MUST link
59
+ if [[ -z "$linked" ]]; then
60
+ echo "WARN: Research not linked to task $task_id - orchestrator linking..."
61
+ cleo research link "$task_id" "$research_id"
62
+ fi
63
+
64
+ # 3. Verify link succeeded
65
+ if ! cleo show "$task_id" | jq -e '.task.linkedResearch' &>/dev/null; then
66
+ echo "ERROR: Failed to link research $research_id to task $task_id"
67
+ echo "ACTION: Manual intervention required"
68
+ fi
69
+ ```
70
+
71
+ **Note**: Subagents SHOULD link research during execution. Orchestrator verification ensures no orphaned research artifacts.
72
+
73
+ ### Enforcement Sequence
74
+
75
+ ```
76
+ 1. Generate spawn prompt -> orchestrator_spawn_for_task() or cleo orchestrator spawn
77
+ 2. VERIFY protocol block -> Check prompt contains "SUBAGENT PROTOCOL"
78
+ 3. Spawn subagent -> Task tool with validated prompt
79
+ 4. Receive return message -> VALIDATE against allowed formats
80
+ 5. Verify manifest entry -> cleo research show <id> BEFORE proceeding
81
+ 5.5. Verify handoff pattern -> Manifest key_findings used, NOT TaskOutput
82
+ 5.6. Extract handoff context -> key_findings + file path for next spawn
83
+ 6. Verify research link -> cleo show <task> | check linkedResearch
84
+ 7. Link if missing -> cleo research link <task> <research-id>
85
+ 8. Continue or escalate -> Only spawn next if manifest AND link confirmed
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Anti-Patterns (Protocol Violations)
91
+
92
+ | Violation | Detection | Recovery |
93
+ |-----------|-----------|----------|
94
+ | Missing protocol block | `grep -q "SUBAGENT PROTOCOL"` fails | Re-inject via `cleo research inject` |
95
+ | Invalid return message | Not in allowed format list | Mark as violation, re-spawn |
96
+ | No manifest entry | `cleo research show` returns error | Re-spawn with explicit manifest requirement |
97
+ | No research link | `jq '.task.linkedResearch'` empty | Orchestrator links via `cleo research link` |
98
+ | Spawning before verification | Multiple agents, missing entries | Stop, verify all, then resume |
99
+ | Using TaskOutput for results | TOOL-001 violation | Read manifest key_findings only |
100
+
101
+ ---
102
+
103
+ ## Step 7.5: Handoff Validation
104
+
105
+ After each subagent returns, orchestrator MUST validate handoff compliance:
106
+
107
+ ```bash
108
+ # 1. Verify manifest entry (already in Step 5)
109
+ manifest_entry=$(cleo research show "$research_id" --json)
110
+
111
+ # 2. Extract handoff context (NOT TaskOutput)
112
+ key_findings=$(echo "$manifest_entry" | jq -r '.key_findings[]')
113
+ output_file=$(echo "$manifest_entry" | jq -r '.file')
114
+
115
+ # 3. Build next spawn prompt with handoff
116
+ next_prompt="## Context from Previous Agent
117
+ Key Findings:
118
+ $key_findings
119
+
120
+ Reference file (if details needed): $output_file
121
+
122
+ ## Your Task
123
+ ..."
124
+
125
+ # 4. CRITICAL: Do NOT call TaskOutput
126
+ # TaskOutput violates TOOL-001 and breaks handoff chain
127
+ ```
128
+
129
+ ### Handoff Validation Checks
130
+
131
+ | Check | Constraint | Action if Failed |
132
+ |-------|------------|------------------|
133
+ | key_findings extracted | HNDOFF-001 | Re-query manifest |
134
+ | file path included | HNDOFF-003 | Add to prompt |
135
+ | TaskOutput NOT called | TOOL-001 | Block, re-spawn |
136
+
137
+ ---
138
+
139
+ ## Step 7: Compliance Verification
140
+
141
+ After each subagent returns, orchestrator **MUST** verify compliance:
142
+
143
+ ```bash
144
+ source lib/compliance-check.sh
145
+
146
+ # 1. Score compliance (checks manifest entry, research link, return format)
147
+ metrics=$(score_subagent_compliance "$task_id" "$agent_id" "$response")
148
+
149
+ # 2. Extract pass rate
150
+ compliance_pass_rate=$(echo "$metrics" | jq -r '.compliance.compliance_pass_rate')
151
+
152
+ # 3. Log violation if not 100% pass
153
+ if [[ "$compliance_pass_rate" != "1.0" ]]; then
154
+ log_violation "$epic_id" "$(jq -n \
155
+ --arg task "$task_id" \
156
+ --arg agent "$agent_id" \
157
+ --arg rate "$compliance_pass_rate" \
158
+ '{summary: "Subagent compliance failure", task_id: $task, agent_id: $agent, severity: "medium"}'
159
+ )"
160
+ fi
161
+
162
+ # 4. Append metrics to COMPLIANCE.jsonl (automatic via score_subagent_compliance)
163
+ log_compliance_metrics "$metrics"
164
+ ```
165
+
166
+ **Compliance Checks Performed:**
167
+ | Check | Rule | Severity if Failed |
168
+ |-------|------|-------------------|
169
+ | Manifest entry exists | OUT-002 | high |
170
+ | Research link present | Task linkage | medium |
171
+ | Return format valid | OUT-003 | low |
172
+ | Handoff via manifest | HNDOFF-001 | high |
173
+ | No TaskOutput usage | TOOL-001 | critical |
174
+
175
+ ---
176
+
177
+ ## Epic Completion: Compliance Report
178
+
179
+ Before marking an epic complete, orchestrator **MUST** generate compliance summary:
180
+
181
+ ```bash
182
+ source lib/metrics-aggregation.sh
183
+
184
+ # 1. Get project compliance summary
185
+ summary=$(get_project_compliance_summary)
186
+
187
+ # 2. Extract key metrics
188
+ total_tasks=$(echo "$summary" | jq -r '.result.totalEntries')
189
+ pass_rate=$(echo "$summary" | jq -r '.result.averagePassRate')
190
+ violations=$(echo "$summary" | jq -r '.result.totalViolations')
191
+
192
+ # 3. Check for critical breaches
193
+ critical_count=$(echo "$summary" | jq -r '.result.bySeverity.critical // 0')
194
+ high_count=$(echo "$summary" | jq -r '.result.bySeverity.high // 0')
195
+
196
+ # 4. Block auto-complete if critical breaches exist
197
+ if [[ "$critical_count" -gt 0 || "$high_count" -gt 0 ]]; then
198
+ echo "ERROR: Cannot auto-complete epic - critical/high violations exist"
199
+ echo "Critical: $critical_count, High: $high_count"
200
+ echo "ACTION: Resolve violations before completing epic"
201
+ exit 1
202
+ fi
203
+
204
+ # 5. Report compliance summary
205
+ echo "=== Epic Compliance Report ==="
206
+ echo "Total Tasks: $total_tasks"
207
+ echo "Pass Rate: $(awk "BEGIN {printf \"%.1f\", $pass_rate * 100}")%"
208
+ echo "Violations: $violations"
209
+ ```
210
+
211
+ **Auto-Complete Criteria:**
212
+ - `critical_breach_rate == 0` (no critical violations)
213
+ - `high_breach_rate == 0` (no high-severity violations)
214
+ - All subagent manifest entries validated
215
+
216
+ ---
217
+
218
+ ## Subagent Retry Protocol
219
+
220
+ When a subagent fails compliance checks, orchestrator **MUST** follow retry protocol:
221
+
222
+ ```bash
223
+ # Retry thresholds
224
+ MAX_RETRIES=2
225
+ COMPLIANCE_THRESHOLD="0.80"
226
+
227
+ # Check if retry needed
228
+ if (( $(echo "$compliance_pass_rate < $COMPLIANCE_THRESHOLD" | bc -l) )); then
229
+ echo "WARN: Compliance pass rate below 80% ($compliance_pass_rate)"
230
+
231
+ # Log violation
232
+ log_violation "$epic_id" "$(jq -n \
233
+ --arg task "$task_id" \
234
+ --arg agent "$agent_id" \
235
+ --arg rate "$compliance_pass_rate" \
236
+ '{summary: "Subagent retry triggered", task_id: $task, agent_id: $agent, severity: "medium"}'
237
+ )"
238
+
239
+ # Re-spawn with stricter prompt (add explicit checklist)
240
+ stricter_prompt="$original_prompt
241
+
242
+ ## COMPLIANCE CHECKLIST (VERIFY BEFORE RETURNING)
243
+ - [ ] Output file exists at {{OUTPUT_DIR}}/{{DATE}}_{{TOPIC_SLUG}}.md
244
+ - [ ] MANIFEST.jsonl entry appended with all required fields
245
+ - [ ] Return message is EXACTLY: 'Research complete. See MANIFEST.jsonl for summary.'
246
+ - [ ] Task linked via: {{TASK_LINK_CMD}} {{TASK_ID}} <research-id>
247
+ - [ ] Task completed via: {{TASK_COMPLETE_CMD}} {{TASK_ID}}
248
+ "
249
+
250
+ # Track retry count (stored in session context)
251
+ retry_count=$((retry_count + 1))
252
+
253
+ if [[ $retry_count -gt $MAX_RETRIES ]]; then
254
+ echo "ERROR: Max retries ($MAX_RETRIES) exceeded for task $task_id"
255
+ echo "ACTION: Escalate to human review"
256
+ # Mark task as blocked
257
+ cleo update "$task_id" --status blocked --blocked-by "Compliance failure after $MAX_RETRIES retries"
258
+ exit 1
259
+ fi
260
+
261
+ # Re-spawn with stricter prompt
262
+ # ... Task tool invocation with $stricter_prompt ...
263
+ fi
264
+ ```
265
+
266
+ **Retry Rules:**
267
+ | Condition | Action |
268
+ |-----------|--------|
269
+ | `compliance_pass_rate < 80%` | Log violation, re-spawn with explicit checklist |
270
+ | `retry_count > 2` | Escalate to human, mark task blocked |
271
+ | `critical` severity | Immediate escalation, no retry |
@@ -0,0 +1,85 @@
1
+ # Handoff Chain Protocol
2
+
3
+ > Referenced from: @skills/ct-orchestrator/SKILL.md
4
+ > Load when: Need details on manifest-mediated handoffs, handoff constraints, prompt templates, or anti-patterns
5
+
6
+ ## Overview
7
+
8
+ Orchestrator coordinates work through **manifest-mediated handoffs**. Content flows between subagents via files, not through orchestrator context.
9
+
10
+ ## Architecture
11
+
12
+ ```
13
+ Orchestrator (Tier 0)
14
+
15
+ ├─ Spawns Agent A with task instructions
16
+ │ └─ A completes → writes output file + manifest entry
17
+
18
+ ├─ Reads MANIFEST.jsonl → extracts key_findings (3-7 items)
19
+ │ └─ Does NOT read full output file
20
+ │ └─ Does NOT use TaskOutput tool
21
+
22
+ ├─ Spawns Agent B with handoff context
23
+ │ └─ Prompt includes: "Previous agent found: [key_findings]"
24
+ │ └─ Prompt includes: "If details needed, read [file path from manifest]"
25
+ │ └─ B reads full file directly if needed
26
+
27
+ └─ Continue chain...
28
+ ```
29
+
30
+ ## Handoff Constraints (RFC 2119)
31
+
32
+ | ID | Rule | Enforcement |
33
+ |----|------|-------------|
34
+ | HNDOFF-001 | Orchestrator MUST read only manifest `key_findings` | Not full output files |
35
+ | HNDOFF-002 | Orchestrator MUST include `key_findings` in next spawn prompt | Context continuity |
36
+ | HNDOFF-003 | Orchestrator MUST include file path for detailed reference | Subagent can read if needed |
37
+ | HNDOFF-004 | Subagents MAY read previous agent output files directly | Full context when needed |
38
+ | HNDOFF-005 | Orchestrator MUST NOT process or analyze subagent content | Delegation enforcement |
39
+
40
+ ## Handoff Prompt Template
41
+
42
+ When spawning Agent B after Agent A completes:
43
+
44
+ ```markdown
45
+ ## Context from Previous Agent
46
+
47
+ **Previous Task**: {A's task ID} - {A's title}
48
+ **Key Findings**:
49
+ {bullet list from manifest key_findings}
50
+
51
+ **Reference**: If you need detailed information, read: {file path from manifest}
52
+
53
+ ## Your Task
54
+ {B's instructions}
55
+ ```
56
+
57
+ ## Example Handoff
58
+
59
+ ```bash
60
+ # 1. Agent A completes, manifest shows:
61
+ # {"key_findings": ["OAuth2 recommended", "JWT for sessions", "30-day token expiry"]}
62
+
63
+ # 2. Orchestrator reads manifest summary
64
+ cleo research show A-research-id
65
+
66
+ # 3. Orchestrator spawns Agent B with context:
67
+ # "Previous research found: OAuth2 recommended, JWT for sessions, 30-day token expiry.
68
+ # If you need details, read: claudedocs/agent-outputs/2026-01-31_A-research.md
69
+ # Your task: Implement the authentication module based on these findings."
70
+ ```
71
+
72
+ ## Anti-Pattern: Direct Content Flow
73
+
74
+ **WRONG** (content through orchestrator):
75
+ ```
76
+ A completes → Orchestrator reads TaskOutput →
77
+ Orchestrator analyzes content → Spawns B
78
+ ```
79
+
80
+ **CORRECT** (manifest-mediated):
81
+ ```
82
+ A completes → Orchestrator reads manifest key_findings →
83
+ Orchestrator spawns B with key_findings + file reference →
84
+ B reads file directly if needed
85
+ ```
@@ -0,0 +1,164 @@
1
+ # Common HITL Patterns
2
+
3
+ > Referenced from: @skills/ct-orchestrator/SKILL.md
4
+ > Load when: Need executable workflow patterns for specific orchestrator scenarios
5
+
6
+ Executable workflows for typical orchestrator scenarios.
7
+
8
+ ## Pattern: Starting Fresh Epic
9
+
10
+ ```bash
11
+ # 1. HITL creates epic
12
+ cleo add "Implement auth system" --type epic --size large --phase core
13
+
14
+ # 2. Start orchestrator session
15
+ cleo session start --scope epic:T1575 --auto-start
16
+
17
+ # 3. Spawn planning subagent (decomposition protocol)
18
+ cleo orchestrator spawn T1575 # Auto-detects epic → uses decomposition protocol
19
+
20
+ # 4. Wait for decomposition completion
21
+ cleo research show <research-id>
22
+
23
+ # 5. Continue with wave-0 tasks
24
+ cleo orchestrator next --epic T1575
25
+ ```
26
+
27
+ ## Pattern: Resuming Interrupted Work
28
+
29
+ ```bash
30
+ # 1. Check state on conversation start
31
+ cleo orchestrator start --epic T1575
32
+ # Shows: session active, current T1586, next task T1589
33
+
34
+ # 2. Check for incomplete subagent work
35
+ cleo research pending
36
+ # Shows: needs_followup: ["T1586"]
37
+
38
+ # 3. Resume focused task or spawn followup
39
+ cleo show T1586 --brief
40
+ cleo orchestrator spawn T1586 # Re-spawn if needed
41
+ ```
42
+
43
+ ## Pattern: Handling Manifest Followups
44
+
45
+ ```bash
46
+ # 1. Query manifest for pending items
47
+ cleo research pending
48
+ # Returns: { "T1586": ["Add error handling", "Write tests"] }
49
+
50
+ # 2. Create child tasks for followups
51
+ cleo add "Add error handling to auth" --parent T1586 --depends T1586
52
+ cleo add "Write auth tests" --parent T1586 --depends T1586
53
+
54
+ # 3. Spawn for new tasks
55
+ cleo orchestrator next --epic T1575
56
+ cleo orchestrator spawn T1590
57
+ ```
58
+
59
+ ## Pattern: Parallel Execution
60
+
61
+ ```bash
62
+ # 1. Analyze dependency waves
63
+ cleo orchestrator analyze T1575
64
+ # Shows: Wave 0: T1578, T1580, T1582 (no deps)
65
+
66
+ # 2. Verify parallel safety
67
+ cleo orchestrator ready --epic T1575
68
+ # Returns: ["T1578", "T1580", "T1582"]
69
+
70
+ # 3. Spawn multiple subagents (different sessions)
71
+ # Session A spawns T1578
72
+ # Session B spawns T1580
73
+ # Session C spawns T1582
74
+
75
+ # 4. Monitor completion via manifest
76
+ cleo research list --status complete --limit 10
77
+ ```
78
+
79
+ ## Pattern: Phase-Aware Orchestration
80
+
81
+ ```bash
82
+ # 1. Check current phase
83
+ cleo phase show
84
+ # Returns: "core"
85
+
86
+ # 2. Get tasks in current phase
87
+ cleo orchestrator ready --epic T1575 --phase core
88
+
89
+ # 3. Spawn within phase context
90
+ cleo orchestrator spawn T1586
91
+
92
+ # 4. When phase complete, advance
93
+ cleo phases stats
94
+ cleo phase advance # Move to testing phase
95
+ ```
96
+
97
+ ## Pattern: Quality Gates Workflow
98
+
99
+ ```bash
100
+ # 1. Subagent completes implementation
101
+ # Returns: "Implementation complete. See MANIFEST.jsonl for summary."
102
+
103
+ # 2. Orchestrator verifies output
104
+ cleo research show <research-id>
105
+ cleo show T1586
106
+
107
+ # 3. Spawn validation subagent
108
+ cleo orchestrator spawn T1590 # Validation task
109
+
110
+ # 4. Set verification gates
111
+ cleo verify T1586 --gate testsPassed
112
+ cleo verify T1586 --gate qaPassed
113
+ cleo verify T1586 --all
114
+
115
+ # 5. Parent epic auto-completes when all children verified
116
+ ```
117
+
118
+ ## Pattern: Release Workflow
119
+
120
+ **Release tasks use the `release` protocol** via `cleo release` commands.
121
+
122
+ ```bash
123
+ # 1. Verify all epic tasks complete
124
+ cleo list --parent T1575 --status pending # Should be empty
125
+
126
+ # 2. Run pre-release validation
127
+ ./tests/run-all-tests.sh
128
+ cleo validate
129
+
130
+ # 3. Create and ship release
131
+ cleo release create v0.85.0 --tasks T001,T002,T003
132
+ cleo release ship v0.85.0 --bump-version --create-tag --push
133
+
134
+ # Preview without changes:
135
+ cleo release ship v0.85.0 --bump-version --dry-run
136
+ ```
137
+
138
+ **IMPORTANT**: `dev/release-version.sh` is **DEPRECATED** (since v0.78.0).
139
+ Always use `cleo release create` → `cleo release ship`.
140
+
141
+ See `src/protocols/release.md` for the full release protocol specification.
142
+
143
+ ## Full RCASD-IVTR+C Lifecycle
144
+
145
+ ```bash
146
+ # RCASD-IVTR+C PIPELINE (setup phase)
147
+ cleo orchestrator spawn T100 # research protocol
148
+ cleo orchestrator spawn T101 # consensus protocol
149
+ cleo orchestrator spawn T102 # specification protocol
150
+ cleo orchestrator spawn T103 # decomposition protocol
151
+
152
+ # EXECUTION (core phase)
153
+ cleo orchestrator spawn T104 # implementation protocol
154
+ cleo orchestrator spawn T105 # implementation protocol
155
+ # ...more implementation tasks...
156
+
157
+ # CONTRIBUTION (tracked automatically)
158
+ # contribution protocol auto-triggers for shared resources
159
+
160
+ # RELEASE (polish phase)
161
+ cleo release create v0.74.0 --tasks T104,T105
162
+ cleo release ship v0.74.0 --bump-version --create-tag --push
163
+ cleo session end --note "Feature X released v0.74.0"
164
+ ```