@qball-inc/the-bulwark 1.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 (175) hide show
  1. package/.claude-plugin/plugin.json +43 -0
  2. package/agents/bulwark-fix-validator.md +633 -0
  3. package/agents/bulwark-implementer.md +391 -0
  4. package/agents/bulwark-issue-analyzer.md +308 -0
  5. package/agents/bulwark-standards-reviewer.md +221 -0
  6. package/agents/plan-creation-architect.md +323 -0
  7. package/agents/plan-creation-eng-lead.md +352 -0
  8. package/agents/plan-creation-po.md +300 -0
  9. package/agents/plan-creation-qa-critic.md +334 -0
  10. package/agents/product-ideation-competitive-analyzer.md +298 -0
  11. package/agents/product-ideation-idea-validator.md +268 -0
  12. package/agents/product-ideation-market-researcher.md +292 -0
  13. package/agents/product-ideation-pattern-documenter.md +308 -0
  14. package/agents/product-ideation-segment-analyzer.md +303 -0
  15. package/agents/product-ideation-strategist.md +259 -0
  16. package/agents/statusline-setup.md +97 -0
  17. package/hooks/hooks.json +59 -0
  18. package/package.json +45 -0
  19. package/scripts/hooks/cleanup-stale.sh +13 -0
  20. package/scripts/hooks/enforce-quality.sh +166 -0
  21. package/scripts/hooks/implementer-quality.sh +256 -0
  22. package/scripts/hooks/inject-protocol.sh +52 -0
  23. package/scripts/hooks/suggest-pipeline.sh +175 -0
  24. package/scripts/hooks/track-pipeline-start.sh +37 -0
  25. package/scripts/hooks/track-pipeline-stop.sh +52 -0
  26. package/scripts/init-rules.sh +35 -0
  27. package/scripts/init.sh +151 -0
  28. package/skills/anthropic-validator/SKILL.md +607 -0
  29. package/skills/anthropic-validator/references/agents-checklist.md +131 -0
  30. package/skills/anthropic-validator/references/commands-checklist.md +102 -0
  31. package/skills/anthropic-validator/references/hooks-checklist.md +151 -0
  32. package/skills/anthropic-validator/references/mcp-checklist.md +136 -0
  33. package/skills/anthropic-validator/references/plugins-checklist.md +148 -0
  34. package/skills/anthropic-validator/references/skills-checklist.md +85 -0
  35. package/skills/assertion-patterns/SKILL.md +296 -0
  36. package/skills/bug-magnet-data/SKILL.md +284 -0
  37. package/skills/bug-magnet-data/context/cli-args.md +91 -0
  38. package/skills/bug-magnet-data/context/db-query.md +104 -0
  39. package/skills/bug-magnet-data/context/file-contents.md +103 -0
  40. package/skills/bug-magnet-data/context/http-body.md +91 -0
  41. package/skills/bug-magnet-data/context/process-spawn.md +123 -0
  42. package/skills/bug-magnet-data/data/booleans/boundaries.yaml +143 -0
  43. package/skills/bug-magnet-data/data/collections/arrays.yaml +114 -0
  44. package/skills/bug-magnet-data/data/collections/objects.yaml +123 -0
  45. package/skills/bug-magnet-data/data/concurrency/race-conditions.yaml +118 -0
  46. package/skills/bug-magnet-data/data/concurrency/state-machines.yaml +115 -0
  47. package/skills/bug-magnet-data/data/dates/boundaries.yaml +137 -0
  48. package/skills/bug-magnet-data/data/dates/invalid.yaml +132 -0
  49. package/skills/bug-magnet-data/data/dates/timezone.yaml +118 -0
  50. package/skills/bug-magnet-data/data/encoding/charset.yaml +79 -0
  51. package/skills/bug-magnet-data/data/encoding/normalization.yaml +105 -0
  52. package/skills/bug-magnet-data/data/formats/email.yaml +154 -0
  53. package/skills/bug-magnet-data/data/formats/json.yaml +187 -0
  54. package/skills/bug-magnet-data/data/formats/url.yaml +165 -0
  55. package/skills/bug-magnet-data/data/language-specific/javascript.yaml +182 -0
  56. package/skills/bug-magnet-data/data/language-specific/python.yaml +174 -0
  57. package/skills/bug-magnet-data/data/language-specific/rust.yaml +148 -0
  58. package/skills/bug-magnet-data/data/numbers/boundaries.yaml +161 -0
  59. package/skills/bug-magnet-data/data/numbers/precision.yaml +89 -0
  60. package/skills/bug-magnet-data/data/numbers/special.yaml +69 -0
  61. package/skills/bug-magnet-data/data/strings/boundaries.yaml +109 -0
  62. package/skills/bug-magnet-data/data/strings/injection.yaml +208 -0
  63. package/skills/bug-magnet-data/data/strings/special-chars.yaml +190 -0
  64. package/skills/bug-magnet-data/data/strings/unicode.yaml +139 -0
  65. package/skills/bug-magnet-data/references/external-lists.md +115 -0
  66. package/skills/bulwark-brainstorm/SKILL.md +563 -0
  67. package/skills/bulwark-brainstorm/references/at-teammate-prompts.md +60 -0
  68. package/skills/bulwark-brainstorm/references/role-critical-analyst.md +78 -0
  69. package/skills/bulwark-brainstorm/references/role-development-lead.md +66 -0
  70. package/skills/bulwark-brainstorm/references/role-product-delivery-lead.md +79 -0
  71. package/skills/bulwark-brainstorm/references/role-product-manager.md +62 -0
  72. package/skills/bulwark-brainstorm/references/role-project-sme.md +59 -0
  73. package/skills/bulwark-brainstorm/references/role-technical-architect.md +66 -0
  74. package/skills/bulwark-research/SKILL.md +298 -0
  75. package/skills/bulwark-research/references/viewpoint-contrarian.md +63 -0
  76. package/skills/bulwark-research/references/viewpoint-direct-investigation.md +62 -0
  77. package/skills/bulwark-research/references/viewpoint-first-principles.md +65 -0
  78. package/skills/bulwark-research/references/viewpoint-practitioner.md +62 -0
  79. package/skills/bulwark-research/references/viewpoint-prior-art.md +66 -0
  80. package/skills/bulwark-scaffold/SKILL.md +330 -0
  81. package/skills/bulwark-statusline/SKILL.md +161 -0
  82. package/skills/bulwark-statusline/scripts/statusline.sh +144 -0
  83. package/skills/bulwark-verify/SKILL.md +519 -0
  84. package/skills/code-review/SKILL.md +428 -0
  85. package/skills/code-review/examples/anti-patterns/linting.ts +181 -0
  86. package/skills/code-review/examples/anti-patterns/security.ts +91 -0
  87. package/skills/code-review/examples/anti-patterns/standards.ts +195 -0
  88. package/skills/code-review/examples/anti-patterns/type-safety.ts +108 -0
  89. package/skills/code-review/examples/recommended/linting.ts +195 -0
  90. package/skills/code-review/examples/recommended/security.ts +154 -0
  91. package/skills/code-review/examples/recommended/standards.ts +231 -0
  92. package/skills/code-review/examples/recommended/type-safety.ts +181 -0
  93. package/skills/code-review/frameworks/angular.md +218 -0
  94. package/skills/code-review/frameworks/django.md +235 -0
  95. package/skills/code-review/frameworks/express.md +207 -0
  96. package/skills/code-review/frameworks/flask.md +298 -0
  97. package/skills/code-review/frameworks/generic.md +146 -0
  98. package/skills/code-review/frameworks/react.md +152 -0
  99. package/skills/code-review/frameworks/vue.md +244 -0
  100. package/skills/code-review/references/linting-patterns.md +221 -0
  101. package/skills/code-review/references/security-patterns.md +125 -0
  102. package/skills/code-review/references/standards-patterns.md +246 -0
  103. package/skills/code-review/references/type-safety-patterns.md +130 -0
  104. package/skills/component-patterns/SKILL.md +131 -0
  105. package/skills/component-patterns/references/pattern-cli-command.md +118 -0
  106. package/skills/component-patterns/references/pattern-database.md +166 -0
  107. package/skills/component-patterns/references/pattern-external-api.md +139 -0
  108. package/skills/component-patterns/references/pattern-file-parser.md +168 -0
  109. package/skills/component-patterns/references/pattern-http-server.md +162 -0
  110. package/skills/component-patterns/references/pattern-process-spawner.md +133 -0
  111. package/skills/continuous-feedback/SKILL.md +327 -0
  112. package/skills/continuous-feedback/references/collect-instructions.md +81 -0
  113. package/skills/continuous-feedback/references/specialize-code-review.md +82 -0
  114. package/skills/continuous-feedback/references/specialize-general.md +98 -0
  115. package/skills/continuous-feedback/references/specialize-test-audit.md +81 -0
  116. package/skills/create-skill/SKILL.md +359 -0
  117. package/skills/create-skill/references/agent-conventions.md +194 -0
  118. package/skills/create-skill/references/agent-template.md +195 -0
  119. package/skills/create-skill/references/content-guidance.md +291 -0
  120. package/skills/create-skill/references/decision-framework.md +124 -0
  121. package/skills/create-skill/references/template-pipeline.md +217 -0
  122. package/skills/create-skill/references/template-reference-heavy.md +111 -0
  123. package/skills/create-skill/references/template-research.md +210 -0
  124. package/skills/create-skill/references/template-script-driven.md +172 -0
  125. package/skills/create-skill/references/template-simple.md +80 -0
  126. package/skills/create-subagent/SKILL.md +353 -0
  127. package/skills/create-subagent/references/agent-conventions.md +268 -0
  128. package/skills/create-subagent/references/content-guidance.md +232 -0
  129. package/skills/create-subagent/references/decision-framework.md +134 -0
  130. package/skills/create-subagent/references/template-single-agent.md +192 -0
  131. package/skills/fix-bug/SKILL.md +241 -0
  132. package/skills/governance-protocol/SKILL.md +116 -0
  133. package/skills/init/SKILL.md +341 -0
  134. package/skills/issue-debugging/SKILL.md +385 -0
  135. package/skills/issue-debugging/references/anti-patterns.md +245 -0
  136. package/skills/issue-debugging/references/debug-report-schema.md +227 -0
  137. package/skills/mock-detection/SKILL.md +511 -0
  138. package/skills/mock-detection/references/false-positive-prevention.md +402 -0
  139. package/skills/mock-detection/references/stub-patterns.md +236 -0
  140. package/skills/pipeline-templates/SKILL.md +215 -0
  141. package/skills/pipeline-templates/references/code-change-workflow.md +277 -0
  142. package/skills/pipeline-templates/references/code-review.md +336 -0
  143. package/skills/pipeline-templates/references/fix-validation.md +421 -0
  144. package/skills/pipeline-templates/references/new-feature.md +335 -0
  145. package/skills/pipeline-templates/references/research-brainstorm.md +161 -0
  146. package/skills/pipeline-templates/references/research-planning.md +257 -0
  147. package/skills/pipeline-templates/references/test-audit.md +389 -0
  148. package/skills/pipeline-templates/references/test-execution-fix.md +238 -0
  149. package/skills/plan-creation/SKILL.md +497 -0
  150. package/skills/product-ideation/SKILL.md +372 -0
  151. package/skills/product-ideation/references/analysis-frameworks.md +161 -0
  152. package/skills/session-handoff/SKILL.md +139 -0
  153. package/skills/session-handoff/references/examples.md +223 -0
  154. package/skills/setup-lsp/SKILL.md +312 -0
  155. package/skills/setup-lsp/references/server-registry.md +85 -0
  156. package/skills/setup-lsp/references/troubleshooting.md +135 -0
  157. package/skills/subagent-output-templating/SKILL.md +415 -0
  158. package/skills/subagent-output-templating/references/examples.md +440 -0
  159. package/skills/subagent-prompting/SKILL.md +364 -0
  160. package/skills/subagent-prompting/references/examples.md +342 -0
  161. package/skills/test-audit/SKILL.md +531 -0
  162. package/skills/test-audit/references/known-limitations.md +41 -0
  163. package/skills/test-audit/references/priority-classification.md +30 -0
  164. package/skills/test-audit/references/prompts/deep-mode-detection.md +83 -0
  165. package/skills/test-audit/references/prompts/synthesis.md +57 -0
  166. package/skills/test-audit/references/rewrite-instructions.md +46 -0
  167. package/skills/test-audit/references/schemas/audit-output.yaml +100 -0
  168. package/skills/test-audit/references/schemas/diagnostic-output.yaml +49 -0
  169. package/skills/test-audit/scripts/data-flow-analyzer.ts +509 -0
  170. package/skills/test-audit/scripts/integration-mock-detector.ts +462 -0
  171. package/skills/test-audit/scripts/package.json +20 -0
  172. package/skills/test-audit/scripts/skip-detector.ts +211 -0
  173. package/skills/test-audit/scripts/verification-counter.ts +295 -0
  174. package/skills/test-classification/SKILL.md +310 -0
  175. package/skills/test-fixture-creation/SKILL.md +295 -0
@@ -0,0 +1,124 @@
1
+ # Decision Framework
2
+
3
+ Interview questions and classification logic for the create-skill pipeline. The orchestrator uses this at Stage 0 (Pre-Flight) and Stage 1 (Classify).
4
+
5
+ ---
6
+
7
+ ## Stage 0: Adaptive Interview
8
+
9
+ ### Core Questions (Always Ask)
10
+
11
+ Present all 5 questions to the user via AskUserQuestion. These determine the skill type, context mode, and supporting file needs.
12
+
13
+ | # | Question | What It Reveals |
14
+ |---|----------|-----------------|
15
+ | Q1 | What does this skill do? Give 2-3 concrete examples of how someone would invoke it. | Scope, trigger patterns, invocation style |
16
+ | Q2 | Does it need conversation history, or can it run in complete isolation? | Context mode (inline vs fork) |
17
+ | Q3 | Does it orchestrate multiple distinct operations or analyses? | Sub-agent pattern (none, sequential, parallel) |
18
+ | Q4 | How much domain-specific reference content does it need? (None / Some / Extensive) | Supporting file structure (vanilla vs references/) |
19
+ | Q5 | Does it produce structured output that must match a specific format? | Templates directory need |
20
+
21
+ ### Follow-Up Questions (Conditional)
22
+
23
+ Ask follow-ups when Q1-Q5 answers indicate complexity. Trigger conditions:
24
+
25
+ | Trigger | Follow-Up Questions |
26
+ |---------|-------------------|
27
+ | Q3 = "yes, multiple operations" | Q6: Do the operations depend on each other's output? (sequential vs parallel) |
28
+ | Q3 = "yes, multiple operations" | Q7: Do workers need to communicate with each other directly? (Task tool vs Agent Teams) |
29
+ | Q3 = "yes" AND Q2 = "isolation" | Q8: What error handling is needed between stages? (retry, fallback, abort) |
30
+ | Q4 = "extensive" | Q9: Is the reference content static (loaded once) or dynamic (computed per run)? |
31
+ | Q5 = "yes, structured" | Q10: Is the output format YAML, Markdown with sections, or something else? |
32
+
33
+ ### Interview Behavior
34
+
35
+ - Present Q1-Q5 in a single AskUserQuestion call (not one-at-a-time)
36
+ - If answers are ambiguous, ask 1-2 clarifying follow-ups (do not over-interview)
37
+ - If the user provides a `--doc` requirements document, extract Q1-Q5 answers from it and present for confirmation instead of asking fresh
38
+ - Total interview: 1-2 AskUserQuestion rounds maximum
39
+
40
+ ---
41
+
42
+ ## Stage 1: Three-Decision Classification
43
+
44
+ After the interview, make three independent decisions. Each decision is self-contained — they don't depend on each other.
45
+
46
+ ### Decision A: Context Mode
47
+
48
+ Determines whether the skill runs inline (access to conversation) or forked (isolated context).
49
+
50
+ ```
51
+ Q2 = "needs conversation history" → inline (no fork)
52
+ Q2 = "can run in isolation"
53
+ AND Q3 = "multiple operations" → context: fork
54
+ Q2 = "can run in isolation"
55
+ AND Q3 = "no" → inline (no fork)
56
+ NOTE: Warn if user requests fork for a simple guideline/knowledge skill.
57
+ Fork adds overhead with no benefit for inline knowledge.
58
+ ```
59
+
60
+ **Default**: inline (no fork). Fork is rare — only 2 of 21 Bulwark skills use it.
61
+
62
+ ### Decision B: Sub-Agent Pattern
63
+
64
+ Determines how the skill orchestrates work.
65
+
66
+ ```
67
+ Q3 = "no, single operation" → no sub-agents
68
+ Q3 = "yes" AND Q6 = "dependent" → sequential Task tool sub-agents
69
+ Q3 = "yes" AND Q6 = "independent" → parallel Task tool sub-agents
70
+ Q3 = "yes" AND Q7 = "direct comms" → Agent Teams (experimental)
71
+ NOTE: Include env var gating (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)
72
+ and experimental warning in generated skill.
73
+ ```
74
+
75
+ **Default**: no sub-agents. Only add orchestration when the skill genuinely needs multiple distinct passes.
76
+
77
+ ### Decision C: Supporting Files
78
+
79
+ Determines the file structure beyond SKILL.md.
80
+
81
+ ```
82
+ Q4 = "none" AND Q5 = "no" → vanilla SKILL.md only
83
+ Q4 = "some" or "extensive" → add references/ directory
84
+ Q5 = "yes, structured output" → add templates/ directory
85
+ Q3 = "yes" AND needs scripts → add scripts/ directory
86
+ NOTE: scripts/ is for deterministic code execution (AST analysis,
87
+ data transforms). Not needed for LLM-only workflows.
88
+ ```
89
+
90
+ ### Decision → Template Mapping
91
+
92
+ | Classification | Template | File Structure |
93
+ |----------------|----------|----------------|
94
+ | No sub-agents, no references, no templates | `template-simple.md` | `SKILL.md` only |
95
+ | References needed, no sub-agents | `template-reference-heavy.md` | `SKILL.md` + `references/` |
96
+ | Sequential or parallel sub-agents | `template-pipeline.md` | `SKILL.md` + `references/` + `templates/` |
97
+ | Deterministic scripts required | `template-script-driven.md` | `SKILL.md` + `scripts/` + `references/` |
98
+ | Multi-agent research/brainstorm | `template-research.md` | `SKILL.md` + `references/` + `templates/` |
99
+
100
+ ### Classification Output
101
+
102
+ After classification, present the three decisions to the user for confirmation before proceeding to Stage 2:
103
+
104
+ ```
105
+ Classification:
106
+ - Context: {inline/fork} — {one-line reason}
107
+ - Sub-agents: {none/sequential/parallel/Agent Teams} — {one-line reason}
108
+ - Supporting files: {list} — {one-line reason}
109
+ - Template: {template name}
110
+
111
+ Proceed with generation? [Yes / Adjust]
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Edge Cases
117
+
118
+ | Scenario | Resolution |
119
+ |----------|------------|
120
+ | User requests fork for simple knowledge skill | Warn: "Fork adds overhead with no benefit for inline knowledge skills. Recommend inline." Allow override. |
121
+ | User requests Agent Teams | Include experimental warning + env var check. Note: Agent Teams requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`. |
122
+ | Skill type doesn't clearly map to one template | Pick the closest match, note the mismatch in post-generation summary. |
123
+ | User provides conflicting Q2/Q3 answers | Ask one clarifying question to resolve. |
124
+ | Very large skill (>500 lines estimated) | Warn about token budget. Suggest splitting into multiple skills. |
@@ -0,0 +1,217 @@
1
+ # Template: Pipeline Skill
2
+
3
+ Use this template when the skill orchestrates multiple distinct operations using sub-agents. Typical for review pipelines, audit workflows, and multi-stage analysis.
4
+
5
+ **When to use**: Decision B = sequential or parallel Task tool sub-agents.
6
+
7
+ ---
8
+
9
+ ## File Structure
10
+
11
+ Pipeline skills generate both an orchestrating skill AND dedicated sub-agent files:
12
+
13
+ ```
14
+ skills/{skill-name}/
15
+ ├── SKILL.md (orchestrating skill)
16
+ ├── references/
17
+ │ ├── {stage-specific-reference-1}.md
18
+ │ └── {stage-specific-reference-N}.md
19
+ └── templates/
20
+ ├── {output-template}.md
21
+ └── diagnostic-output.yaml
22
+
23
+ .claude/agents/
24
+ ├── {skill-name}-{stage1-name}.md (sub-agent for stage 1)
25
+ ├── {skill-name}-{stage2-name}.md (sub-agent for stage 2)
26
+ └── {skill-name}-{stageN-name}.md (sub-agent for stage N)
27
+ ```
28
+
29
+ **Why dedicated sub-agent files**: Sub-agents defined in `.claude/agents/*.md` have deterministic behavior locked into their system prompts — consistent across invocations. Inline sub-agent definitions in skill references produce variable behavior because the orchestrator interprets the reference content differently per run.
30
+
31
+ **Naming convention**: Sub-agent files are prefixed with the skill name to avoid collisions (e.g., `code-review-security-reviewer.md`, `code-review-type-safety-reviewer.md`).
32
+
33
+ ## Generated SKILL.md Structure
34
+
35
+ ```markdown
36
+ ---
37
+ name: {skill-name}
38
+ description: {single-line, trigger-specific, "Use when..." framing}
39
+ user-invocable: true
40
+ skills:
41
+ - subagent-prompting
42
+ ---
43
+
44
+ # {Skill Title}
45
+
46
+ {One-paragraph summary describing the pipeline and its purpose.}
47
+
48
+ ---
49
+
50
+ ## When to Use This Skill
51
+
52
+ {Trigger pattern table + DO NOT use for section.}
53
+
54
+ ---
55
+
56
+ ## Dependencies
57
+
58
+ | Category | Files | Requirement | When to Load |
59
+ |----------|-------|-------------|--------------|
60
+ | **Stage references** | `references/{name}.md` | **REQUIRED** | Load before spawning stage agent |
61
+ | **Output templates** | `templates/{name}.md` | **REQUIRED** | Include in sub-agent prompt |
62
+ | **Diagnostics** | `templates/diagnostic-output.yaml` | **REQUIRED** | Write at pipeline completion |
63
+ | **Prompting** | `subagent-prompting` skill | **REQUIRED** | Load before spawning any sub-agent |
64
+ | **Sub-agents** | `.claude/agents/{skill-name}-{stage}.md` | **REQUIRED** | Invoked via Task tool per stage |
65
+
66
+ ---
67
+
68
+ ## Usage
69
+
70
+ ```
71
+ /{skill-name} {arguments} [flags]
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Pre-Flight Gate (BLOCKING)
77
+
78
+ **STOP. Before ANY work, you MUST acknowledge what this skill requires.**
79
+
80
+ This skill uses a **multi-stage pipeline with dedicated sub-agents**. You are the orchestrator, NOT the executor.
81
+
82
+ ### What You MUST Do
83
+
84
+ 1. Load all required dependencies
85
+ 2. Execute stages in order (or parallel where specified)
86
+ 3. Spawn dedicated sub-agents for each stage via Task tool — do NOT perform their work yourself
87
+ 4. Write intermediate stage outputs to `$PROJECT_DIR/logs/`
88
+ 5. Write final deliverables (synthesis, reports) to `$PROJECT_DIR/artifacts/`
89
+ 6. Write diagnostic YAML to `$PROJECT_DIR/logs/diagnostics/`
90
+
91
+ ### What You MUST NOT Do
92
+
93
+ - Do NOT skip stages
94
+ - Do NOT perform sub-agent work yourself
95
+ - Do NOT return to user until all log files are written
96
+ - Do NOT spawn sub-agents with run_in_background: true (SA5)
97
+
98
+ ---
99
+
100
+ ## Pipeline
101
+
102
+ ```fsharp
103
+ // {skill-name} pipeline
104
+ Stage0_PreFlight(args)
105
+ |> Stage1_{Name}(input) // {skill-name}-{stage1} sub-agent — {purpose}
106
+ |> Stage2_{Name}(stage1_output) // {skill-name}-{stage2} sub-agent — {purpose}
107
+ |> Stage3_{Name}(stage2_output) // {skill-name}-{stage3} sub-agent — {purpose}
108
+ |> Diagnostics(all_outputs)
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Stage Definitions
114
+
115
+ ### Stage 0: Pre-Flight (Orchestrator)
116
+
117
+ ```
118
+ Stage 0: Pre-Flight
119
+ ├── Parse arguments
120
+ ├── Load dependencies
121
+ ├── Validate inputs exist
122
+ └── Token budget check
123
+ ```
124
+
125
+ ### Stage 1: {Name} (Dedicated sub-agent)
126
+
127
+ ```
128
+ Construct prompt using 4-part template:
129
+ ├── GOAL: {what this stage achieves}
130
+ ├── CONSTRAINTS: {boundaries}
131
+ ├── CONTEXT: {input data, reference files to read}
132
+ └── OUTPUT: Write to $PROJECT_DIR/logs/{skill-name}/{stage1-name}-{timestamp}.{ext}
133
+
134
+ Spawn: Task(subagent_type="{skill-name}-{stage1-name}", prompt=...)
135
+ Read output from $PROJECT_DIR/logs/{skill-name}/
136
+ ```
137
+
138
+ ### Stage 2: {Name} (Dedicated sub-agent)
139
+
140
+ {Same structure as Stage 1, reading Stage 1 output as input.}
141
+
142
+ ### Stage N: Diagnostics (REQUIRED)
143
+
144
+ Write to `$PROJECT_DIR/logs/diagnostics/{skill-name}-{YYYYMMDD-HHMMSS}.yaml`
145
+
146
+ ---
147
+
148
+ ## Error Handling
149
+
150
+ | Scenario | Action |
151
+ |----------|--------|
152
+ | Sub-agent returns empty output | Re-spawn once. If still empty, STOP with error. |
153
+ | Stage fails validation | {retry/abort/skip with warning} |
154
+ | Token budget exceeded | Stop, present partial output with explanation. |
155
+
156
+ ---
157
+
158
+ ## Completion Checklist
159
+
160
+ - [ ] All stages executed
161
+ - [ ] Intermediate stage outputs written to `$PROJECT_DIR/logs/{skill-name}/`
162
+ - [ ] Final deliverables written to `$PROJECT_DIR/artifacts/{skill-name}/{slug}/`
163
+ - [ ] Diagnostic YAML written to `$PROJECT_DIR/logs/diagnostics/`
164
+ - [ ] Results presented to user
165
+ ```
166
+
167
+ ## Generated Sub-Agent Structure
168
+
169
+ Each pipeline stage gets a dedicated agent file at `.claude/agents/{skill-name}-{stage-name}.md`. Use the `references/agent-template.md` structure and follow `references/agent-conventions.md` conventions.
170
+
171
+ Key requirements for generated sub-agents:
172
+
173
+ - **System-prompt register**: The agent body defines WHO the agent IS, not step-by-step instructions
174
+ - **Identity reflects stage role**: "You are a security reviewer" not "You are Stage 2"
175
+ - **Single-purpose**: Each sub-agent does one thing well
176
+ - **SA2 compliant**: All intermediate output goes to `$PROJECT_DIR/logs/`, deliverables to `$PROJECT_DIR/artifacts/`
177
+ - **Permissions Setup section**: Documents required tool permissions
178
+ - **150-250 lines each**: Keep sub-agents focused
179
+
180
+ ### Sub-Agent Naming
181
+
182
+ ```
183
+ {skill-name}-{stage-role}.md
184
+ ```
185
+
186
+ Examples:
187
+ - `code-review-security-reviewer.md`
188
+ - `code-review-type-safety-reviewer.md`
189
+ - `test-audit-classifier.md`
190
+ - `test-audit-deep-analyzer.md`
191
+
192
+ ### Sub-Agent Model Selection
193
+
194
+ | Stage Purpose | Model | Rationale |
195
+ |---------------|-------|-----------|
196
+ | Quick lookups, classification | haiku | Fast, low-cost |
197
+ | Analysis, review, research | sonnet | Balanced capability |
198
+ | Implementation, architecture | opus | Highest quality |
199
+
200
+ Default to **Sonnet** for most pipeline stages.
201
+
202
+ ## Guidance for Generator
203
+
204
+ - Generate BOTH the orchestrating SKILL.md AND the sub-agent `.md` files
205
+ - The orchestrating skill references sub-agents by `Task(subagent_type="{name}")`, not inline definitions
206
+ - Every sub-agent stage needs a 4-part prompt (GOAL/CONSTRAINTS/CONTEXT/OUTPUT) in the orchestrating skill
207
+ - Include the `subagent-prompting` skill in the orchestrating skill's frontmatter `skills:` dependency
208
+ - Use the Pre-Flight Gate pattern — without it, Claude skips sub-agent spawning (DEF-P4-005)
209
+ - Model selection per stage: Haiku for lookups, Sonnet for analysis, Opus for writing
210
+ - Each stage writes to `$PROJECT_DIR/logs/{skill-name}/` — the next stage reads from there (SA2/SA4 compliance)
211
+ - Final deliverables (synthesis, reports) go to `$PROJECT_DIR/artifacts/{skill-name}/{slug}/` — NOT to `logs/`
212
+ - **IMPORTANT**: `$PROJECT_DIR` is the project root (where `.claude/` lives). All paths MUST use this prefix. Do NOT write to the skill directory, CWD, or `.claude/skills/`.
213
+ - Include F# pipeline notation for visual workflow documentation
214
+ - Orchestrating skill is typically 200-400 lines
215
+ - Each sub-agent is typically 150-250 lines
216
+ - Read `references/agent-template.md` for the sub-agent file structure
217
+ - Read `references/agent-conventions.md` for system-prompt register and frontmatter conventions
@@ -0,0 +1,111 @@
1
+ # Template: Reference-Heavy Skill
2
+
3
+ Use this template when the skill needs domain-specific reference content that would bloat SKILL.md if inlined. Typical for data-driven skills, pattern libraries, and knowledge bases.
4
+
5
+ **When to use**: Decision C = references needed, no sub-agents.
6
+
7
+ ---
8
+
9
+ ## File Structure
10
+
11
+ ```
12
+ skills/{skill-name}/
13
+ ├── SKILL.md
14
+ └── references/
15
+ ├── {domain-1}.md
16
+ ├── {domain-2}.md
17
+ └── {domain-N}.md
18
+ ```
19
+
20
+ ## Generated SKILL.md Structure
21
+
22
+ ```markdown
23
+ ---
24
+ name: {skill-name}
25
+ description: {single-line, trigger-specific, "Use when..." framing}
26
+ user-invocable: {true/false}
27
+ ---
28
+
29
+ # {Skill Title}
30
+
31
+ {One-paragraph summary.}
32
+
33
+ ---
34
+
35
+ ## When to Use This Skill
36
+
37
+ {Trigger pattern table + DO NOT use for section.}
38
+
39
+ ---
40
+
41
+ ## Dependencies
42
+
43
+ | Category | Files | Requirement | When to Load |
44
+ |----------|-------|-------------|--------------|
45
+ | **{Category 1}** | `references/{domain-1}.md` | **REQUIRED** | {loading condition} |
46
+ | **{Category 2}** | `references/{domain-2}.md` | **REQUIRED** | {loading condition} |
47
+
48
+ **Fallback behavior:**
49
+ - If a reference file is missing: {what to do — note in log, continue with available data, or stop}
50
+
51
+ ---
52
+
53
+ ## Usage
54
+
55
+ {Invocation syntax, arguments, flags.}
56
+
57
+ ---
58
+
59
+ ## Workflow
60
+
61
+ {Step-by-step instructions referencing the loaded reference files.}
62
+
63
+ ### Step 1: Load References
64
+
65
+ Read the applicable reference files from the Dependencies table.
66
+
67
+ ### Step 2: {Core Operation}
68
+
69
+ {Apply the reference data to the user's request.}
70
+
71
+ ### Step 3: {Output}
72
+
73
+ {Present results to the user.}
74
+
75
+ ---
76
+
77
+ ## Completion Checklist
78
+
79
+ - [ ] All required reference files loaded
80
+ - [ ] {Domain-specific outcome achieved}
81
+ - [ ] {Output matches expected format}
82
+ ```
83
+
84
+ ## Generated Reference File Structure
85
+
86
+ Each reference file in `references/` should follow this pattern:
87
+
88
+ ```markdown
89
+ # {Domain Name}
90
+
91
+ {Brief description of what this reference contains and when to use it.}
92
+
93
+ ---
94
+
95
+ ## {Section 1}
96
+
97
+ {Content organized by how it will be consumed — tables for lookup,
98
+ lists for iteration, prose for context.}
99
+
100
+ ## {Section 2}
101
+
102
+ {Additional content sections as needed.}
103
+ ```
104
+
105
+ ## Guidance for Generator
106
+
107
+ - Reference files should be 50-150 lines each — enough to be useful, not so much they consume token budget
108
+ - The SKILL.md should NOT duplicate reference content — it should instruct WHEN and HOW to load it
109
+ - Reference files are the domain knowledge; SKILL.md is the workflow
110
+ - Name reference files by domain concept, not by step number (e.g., `security-patterns.md` not `step-2-data.md`)
111
+ - Include a Dependencies table in SKILL.md — this is how consumers know what to load
@@ -0,0 +1,210 @@
1
+ # Template: Research / Multi-Agent Skill
2
+
3
+ Use this template when the skill spawns multiple agents for parallel or sequential analysis on a topic. Typical for research workflows, brainstorming, and multi-perspective analysis.
4
+
5
+ **When to use**: Decision B = parallel or sequential multi-agent, AND the skill's purpose is research, exploration, or multi-viewpoint analysis.
6
+
7
+ ---
8
+
9
+ ## File Structure
10
+
11
+ ```
12
+ skills/{skill-name}/
13
+ ├── SKILL.md
14
+ ├── references/
15
+ │ ├── {viewpoint-or-role-1}.md
16
+ │ ├── {viewpoint-or-role-2}.md
17
+ │ └── {viewpoint-or-role-N}.md
18
+ └── templates/
19
+ ├── {agent-output-template}.md
20
+ ├── {synthesis-output-template}.md
21
+ └── diagnostic-output.yaml
22
+ ```
23
+
24
+ ## Generated SKILL.md Structure
25
+
26
+ ```markdown
27
+ ---
28
+ name: {skill-name}
29
+ description: {single-line, trigger-specific, "Use when..." framing}
30
+ user-invocable: true
31
+ argument-hint: "<topic, filepath, or directory>"
32
+ skills:
33
+ - subagent-prompting
34
+ ---
35
+
36
+ # {Skill Title}
37
+
38
+ {One-paragraph summary: what the skill researches/analyzes, how many agents, parallel vs sequential, what the output is.}
39
+
40
+ ---
41
+
42
+ ## When to Use This Skill
43
+
44
+ {Trigger pattern table + DO NOT use for section.}
45
+
46
+ ---
47
+
48
+ ## Dependencies
49
+
50
+ | Category | Files | Requirement | When to Load |
51
+ |----------|-------|-------------|--------------|
52
+ | **Viewpoint/Role definitions** | `references/{name}.md` | **REQUIRED** | Load all before spawning agents |
53
+ | **Agent output template** | `templates/{name}.md` | **REQUIRED** | Include in every agent prompt |
54
+ | **Synthesis template** | `templates/{name}.md` | **REQUIRED** | Use when writing synthesis |
55
+ | **Diagnostics** | `templates/diagnostic-output.yaml` | **REQUIRED** | Write at completion |
56
+ | **Prompting** | `subagent-prompting` skill | **REQUIRED** | Load for 4-part prompt template |
57
+
58
+ ---
59
+
60
+ ## Usage
61
+
62
+ ```
63
+ /{skill-name} <topic> [flags]
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Pre-Flight Gate (BLOCKING)
69
+
70
+ **STOP. This skill spawns multiple sub-agents. You are the orchestrator.**
71
+
72
+ ### What You MUST Do
73
+
74
+ 1. Conduct an iterative interview (AskUserQuestion) to clarify the research topic
75
+ 2. Load all viewpoint/role reference files
76
+ 3. Spawn agents per the pipeline (parallel or sequential as defined)
77
+ 4. Write synthesis from agent outputs
78
+ 5. Write diagnostic YAML
79
+
80
+ ### What You MUST NOT Do
81
+
82
+ - Do NOT analyze the topic yourself — spawn agents
83
+ - Do NOT skip the interview — topic clarity determines agent quality
84
+ - Do NOT skip synthesis — raw agent output is not the deliverable
85
+
86
+ ---
87
+
88
+ ## Pipeline
89
+
90
+ ```fsharp
91
+ // {skill-name} pipeline — {parallel/sequential}
92
+ Interview(topic)
93
+ |> LoadViewpoints(references/)
94
+ |> SpawnAgents([Agent1, Agent2, ..., AgentN]) // {parallel/sequential}
95
+ |> Synthesize(all_agent_outputs)
96
+ |> Present(synthesis)
97
+ |> Diagnostics()
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Stage Definitions
103
+
104
+ ### Stage 0: Interview (Orchestrator)
105
+
106
+ ```
107
+ Stage 0: Interview
108
+ ├── AskUserQuestion: Clarify topic scope and focus areas
109
+ │ ├── Round 1: 2-3 scoping questions
110
+ │ └── Round 2 (if needed): 1-2 follow-ups for ambiguous answers
111
+ ├── Load all viewpoint/role references from references/
112
+ ├── Load output templates from templates/
113
+ └── Token budget check
114
+ ```
115
+
116
+ ### Stage 1: Agent Spawning ({Parallel/Sequential})
117
+
118
+ For each viewpoint/role:
119
+
120
+ ```
121
+ Construct prompt using 4-part template:
122
+ ├── GOAL: Analyze {topic} from the {viewpoint/role} perspective
123
+ ├── CONSTRAINTS: Focus on {viewpoint-specific scope}, read-only analysis
124
+ ├── CONTEXT: Topic description, relevant files/codebase areas,
125
+ │ viewpoint definition from references/{name}.md
126
+ └── OUTPUT: Write to $PROJECT_DIR/logs/{skill-name}/{agent-name}.md
127
+ using templates/{agent-output-template}.md format
128
+
129
+ Spawn: Task(subagent_type="general-purpose", model="{model}", prompt=...)
130
+ ```
131
+
132
+ **IMPORTANT — output paths**: `$PROJECT_DIR` is the project root directory (where `.claude/` lives). All paths MUST be project-root-relative using this prefix. Do NOT write to the skill directory or CWD.
133
+
134
+ **Parallel**: Spawn all agents without waiting for each other.
135
+ **Sequential**: Each agent reads previous agent's output before running.
136
+
137
+ ### Stage 2: Synthesis (Orchestrator)
138
+
139
+ ```
140
+ Stage 2: Synthesis
141
+ ├── Read all agent outputs from $PROJECT_DIR/logs/{skill-name}/
142
+ ├── Identify convergent findings (multiple agents agree)
143
+ ├── Identify divergent findings (agents disagree — flag for user)
144
+ ├── Write synthesis to $PROJECT_DIR/artifacts/{skill-name}/{topic-slug}/synthesis.md
145
+ │ using templates/{synthesis-output-template}.md format
146
+ └── Present key findings to user
147
+ ```
148
+
149
+ **Note**: Synthesis is a deliverable — it goes to `artifacts/`, not `logs/`. Agent intermediate output stays in `logs/`.
150
+
151
+ ### Stage 3: Diagnostics (REQUIRED)
152
+
153
+ Write to `$PROJECT_DIR/logs/diagnostics/{skill-name}-{YYYYMMDD-HHMMSS}.yaml`
154
+
155
+ ---
156
+
157
+ ## Error Handling
158
+
159
+ | Scenario | Action |
160
+ |----------|--------|
161
+ | Agent returns empty output | Re-spawn once. If still empty, note in synthesis and continue with remaining agents. |
162
+ | Agent produces off-topic analysis | Note in synthesis. Do not re-spawn — off-topic output often reveals unexpected angles. |
163
+ | Token budget exceeded mid-pipeline | Complete current agent, skip remaining, synthesize from available outputs. |
164
+
165
+ ---
166
+
167
+ ## Completion Checklist
168
+
169
+ - [ ] Interview conducted (1-2 rounds)
170
+ - [ ] All agents spawned and completed
171
+ - [ ] All agent outputs in `$PROJECT_DIR/logs/{skill-name}/`
172
+ - [ ] Synthesis written to `$PROJECT_DIR/artifacts/{skill-name}/{topic-slug}/synthesis.md`
173
+ - [ ] Diagnostic YAML written
174
+ - [ ] Key findings presented to user
175
+ ```
176
+
177
+ ## Generated Viewpoint/Role File Structure
178
+
179
+ Each file in `references/` defines one agent's perspective:
180
+
181
+ ```markdown
182
+ # {Viewpoint/Role Name}
183
+
184
+ ## Identity
185
+
186
+ You are a {role description}. Your analytical focus is {scope}.
187
+
188
+ ## Analytical Lens
189
+
190
+ When analyzing a topic, you prioritize:
191
+ 1. {Priority 1}
192
+ 2. {Priority 2}
193
+ 3. {Priority 3}
194
+
195
+ ## Output Expectations
196
+
197
+ - {What findings from this viewpoint typically look like}
198
+ - {Level of specificity expected}
199
+ - {How this viewpoint differs from others in the pipeline}
200
+ ```
201
+
202
+ ## Guidance for Generator
203
+
204
+ - Research/brainstorm skills are the most token-intensive — warn about budget
205
+ - Parallel agents save time but cost more tokens; sequential agents build on each other
206
+ - The synthesis is the deliverable — agent outputs are intermediate artifacts
207
+ - Model selection: Sonnet for research/analysis, Opus for brainstorming/creative
208
+ - 3-5 agents is the sweet spot — fewer lacks diversity, more exceeds token budgets
209
+ - Include `argument-hint` in frontmatter for better UX in the `/` menu
210
+ - Viewpoint/role reference files should be 40-80 lines each