@dzhechkov/p-replicator 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 (92) hide show
  1. package/README.md +314 -0
  2. package/bin/cli.js +4 -0
  3. package/package.json +62 -0
  4. package/src/cli.js +160 -0
  5. package/src/commands/doctor.js +151 -0
  6. package/src/commands/init.js +155 -0
  7. package/src/commands/list.js +133 -0
  8. package/src/commands/remove.js +111 -0
  9. package/src/commands/update.js +102 -0
  10. package/src/utils.js +280 -0
  11. package/templates/.claude/agents/doc-validator.md +92 -0
  12. package/templates/.claude/agents/harvest-coordinator.md +91 -0
  13. package/templates/.claude/agents/product-discoverer.md +57 -0
  14. package/templates/.claude/agents/replicate-coordinator.md +98 -0
  15. package/templates/.claude/commands/harvest.md +106 -0
  16. package/templates/.claude/commands/replicate.md +389 -0
  17. package/templates/.claude/rules/replicate-pipeline.md +92 -0
  18. package/templates/.claude/skills/brutal-honesty-review/README.md +218 -0
  19. package/templates/.claude/skills/brutal-honesty-review/SKILL.md +225 -0
  20. package/templates/.claude/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
  21. package/templates/.claude/skills/brutal-honesty-review/resources/review-template.md +102 -0
  22. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
  23. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
  24. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +374 -0
  25. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/claude-md-strategy.md +178 -0
  26. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/enhanced-recommendations.md +416 -0
  27. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/extended-mapping.md +370 -0
  28. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/automation-commands.md +733 -0
  29. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-agents.md +416 -0
  30. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-hooks-commands.md +524 -0
  31. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-skills.md +350 -0
  32. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/enhanced-claude-md.md +235 -0
  33. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle-ent.md +400 -0
  34. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle.md +325 -0
  35. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-suggestions.md +423 -0
  36. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/insights-system.md +349 -0
  37. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/mcp.md +274 -0
  38. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/start-command.md +283 -0
  39. package/templates/.claude/skills/explore/SKILL.md +215 -0
  40. package/templates/.claude/skills/explore/references/questioning-techniques.md +151 -0
  41. package/templates/.claude/skills/explore/references/task-brief-templates.md +355 -0
  42. package/templates/.claude/skills/goap-research-ed25519/SKILL.md +415 -0
  43. package/templates/.claude/skills/goap-research-ed25519/references/ed25519-verification.md +658 -0
  44. package/templates/.claude/skills/goap-research-ed25519/references/research-actions.md +544 -0
  45. package/templates/.claude/skills/goap-research-ed25519/references/source-evaluation.md +560 -0
  46. package/templates/.claude/skills/goap-research-ed25519/scripts/ed25519_verifier.py +662 -0
  47. package/templates/.claude/skills/goap-research-ed25519/scripts/goap_planner.py +720 -0
  48. package/templates/.claude/skills/knowledge-extractor/SKILL.md +412 -0
  49. package/templates/.claude/skills/knowledge-extractor/examples/rate-limiting-extraction.md +259 -0
  50. package/templates/.claude/skills/knowledge-extractor/modules/01-agent-review.md +192 -0
  51. package/templates/.claude/skills/knowledge-extractor/modules/02-classify.md +122 -0
  52. package/templates/.claude/skills/knowledge-extractor/modules/03-decontextualize.md +156 -0
  53. package/templates/.claude/skills/knowledge-extractor/modules/04-integrate.md +178 -0
  54. package/templates/.claude/skills/knowledge-extractor/references/artifact-categories.md +342 -0
  55. package/templates/.claude/skills/knowledge-extractor/references/decontextualization-guide.md +247 -0
  56. package/templates/.claude/skills/knowledge-extractor/references/maturity-model.md +153 -0
  57. package/templates/.claude/skills/knowledge-extractor/templates/artifact-card.md +60 -0
  58. package/templates/.claude/skills/knowledge-extractor/templates/harvest-report.md +70 -0
  59. package/templates/.claude/skills/knowledge-extractor/templates/toolkit-harvest.md +38 -0
  60. package/templates/.claude/skills/pipeline-forge/SKILL.md +523 -0
  61. package/templates/.claude/skills/pipeline-forge/examples/replicate-analysis.md +291 -0
  62. package/templates/.claude/skills/pipeline-forge/references/patterns-catalog.md +408 -0
  63. package/templates/.claude/skills/pipeline-forge/references/quality-gates.md +268 -0
  64. package/templates/.claude/skills/pipeline-forge/references/skill-anatomy.md +292 -0
  65. package/templates/.claude/skills/pipeline-forge/templates/agent-template.md +60 -0
  66. package/templates/.claude/skills/pipeline-forge/templates/command-template.md +80 -0
  67. package/templates/.claude/skills/pipeline-forge/templates/pipeline-template.md +137 -0
  68. package/templates/.claude/skills/pipeline-forge/templates/skill-template.md +132 -0
  69. package/templates/.claude/skills/problem-solver-enhanced/SKILL.md +562 -0
  70. package/templates/.claude/skills/requirements-validator/SKILL.md +121 -0
  71. package/templates/.claude/skills/requirements-validator/assets/templates/bdd-feature-template.feature +69 -0
  72. package/templates/.claude/skills/requirements-validator/references/bdd-patterns.md +184 -0
  73. package/templates/.claude/skills/requirements-validator/references/invest-criteria.md +121 -0
  74. package/templates/.claude/skills/requirements-validator/references/scoring-system.md +134 -0
  75. package/templates/.claude/skills/requirements-validator/references/smart-criteria.md +130 -0
  76. package/templates/.claude/skills/reverse-engineering-unicorn/SKILL.md +194 -0
  77. package/templates/.claude/skills/reverse-engineering-unicorn/examples/noom-cjm-example.md +100 -0
  78. package/templates/.claude/skills/reverse-engineering-unicorn/examples/noom-module1-example.md +88 -0
  79. package/templates/.claude/skills/reverse-engineering-unicorn/modules/01-intelligence.md +328 -0
  80. package/templates/.claude/skills/reverse-engineering-unicorn/modules/02-product-customers.md +221 -0
  81. package/templates/.claude/skills/reverse-engineering-unicorn/modules/025-cjm-prototype.md +206 -0
  82. package/templates/.claude/skills/reverse-engineering-unicorn/modules/03-market-competition.md +402 -0
  83. package/templates/.claude/skills/reverse-engineering-unicorn/modules/04-business-finance.md +287 -0
  84. package/templates/.claude/skills/reverse-engineering-unicorn/modules/05-growth-engine.md +290 -0
  85. package/templates/.claude/skills/reverse-engineering-unicorn/modules/06-playbook-synthesis.md +286 -0
  86. package/templates/.claude/skills/reverse-engineering-unicorn/references/blue-ocean-canvas.md +39 -0
  87. package/templates/.claude/skills/reverse-engineering-unicorn/references/industry-benchmarks.md +67 -0
  88. package/templates/.claude/skills/reverse-engineering-unicorn/references/jtbd-canvas.md +48 -0
  89. package/templates/.claude/skills/sparc-prd-mini/SKILL.md +955 -0
  90. package/templates/.claude/skills/sparc-prd-mini/references/sparc-methodology.md +360 -0
  91. package/templates/.claude/skills/sparc-prd-mini/templates/CLAUDE.md +91 -0
  92. package/templates/.claude/skills/sparc-prd-mini/templates/prd.md +336 -0
@@ -0,0 +1,291 @@
1
+ # Reference Implementation: PU Unicorn Replicate
2
+
3
+ Analysis of the PU Unicorn Replicate methodology as a reference implementation
4
+ of all 7 Pipeline Forge patterns. Use this as a model for designing your own pipelines.
5
+
6
+ ---
7
+
8
+ ## System Overview
9
+
10
+ **Purpose:** Transform a product idea into a fully equipped Claude Code project, ready for
11
+ AI-assisted development (Vibe Coding).
12
+
13
+ **Pipeline:** Idea → Documentation → Validation → Toolkit → Scaffold
14
+
15
+ **Stats:**
16
+ - 8 composable skills
17
+ - 5 pipeline phases (1 optional)
18
+ - 3 specialized agents
19
+ - 5 parallel validation sub-agents (swarm)
20
+ - 11 SPARC documentation files generated
21
+ - ~30 Claude Code instruments generated (commands, agents, rules, skills, hooks)
22
+
23
+ ---
24
+
25
+ ## Pattern Application Map
26
+
27
+ | Pattern | How PU Unicorn Replicate Uses It |
28
+ |---------|----------------------------------|
29
+ | 1. Composable Skills | 8 skills with SKILL.md entry, references/, templates/, modules/ |
30
+ | 2. Pipeline Orchestration | 5-phase `/replicate` pipeline with checkpoints and git commits |
31
+ | 3. Swarm of Agents | 5 parallel validators in Phase 2 (doc-validator) |
32
+ | 4. Skill Composition | sparc-prd-mini loads explore, goap-research, problem-solver via view() |
33
+ | 5. Quality Gates | INVEST/SMART scoring, 0-100 scale, BLOCKED <50, 3 iteration max |
34
+ | 6. Doc-Driven Dev | 11 SPARC docs as single source, validated before toolkit generation |
35
+ | 7. Toolkit Generation | Docs → commands, agents, rules, skills, hooks; P0/P1/P2 tiers |
36
+
37
+ ---
38
+
39
+ ## Skill Inventory
40
+
41
+ ### Leaf Skills (no dependencies)
42
+
43
+ | Skill | Lines | Purpose | Used By |
44
+ |-------|-------|---------|---------|
45
+ | `explore` | ~220 | Socratic task clarification | sparc-prd-mini, reverse-engineering-unicorn |
46
+ | `problem-solver-enhanced` | ~560 | 9-module problem solving + TRIZ | sparc-prd-mini |
47
+ | `requirements-validator` | ~125 | INVEST/SMART validation + BDD | doc-validator agent |
48
+ | `brutal-honesty-review` | ~225 | Unvarnished technical criticism | /feature command |
49
+
50
+ ### Composite Skills (depend on others via view())
51
+
52
+ | Skill | Lines | Dependencies | Used By |
53
+ |-------|-------|-------------|---------|
54
+ | `goap-research-ed25519` | ~415 | None (standalone) | sparc-prd-mini, reverse-engineering-unicorn |
55
+ | `sparc-prd-mini` | ~955 | explore, goap-research, problem-solver | /replicate Phase 1 |
56
+ | `reverse-engineering-unicorn` | ~195 + 7 modules | explore, goap-research, problem-solver, brutal-honesty | /replicate Phase 0 |
57
+ | `cc-toolkit-generator-enhanced` | ~375 + 11 templates | Reads docs, no skill deps | /replicate Phase 3 |
58
+
59
+ ### Dependency Graph
60
+
61
+ ```
62
+ /replicate (command)
63
+ ├── reverse-engineering-unicorn (Phase 0)
64
+ │ ├── explore
65
+ │ ├── goap-research-ed25519
66
+ │ ├── problem-solver-enhanced
67
+ │ └── brutal-honesty-review
68
+ ├── sparc-prd-mini (Phase 1)
69
+ │ ├── explore
70
+ │ ├── goap-research-ed25519
71
+ │ └── problem-solver-enhanced
72
+ ├── requirements-validator (Phase 2, via doc-validator agent)
73
+ ├── cc-toolkit-generator-enhanced (Phase 3)
74
+ └── (Phase 4: no skills, just scaffold)
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Pipeline: /replicate
80
+
81
+ ### Phase Flow
82
+
83
+ ```
84
+ INPUT: Product idea or company name
85
+
86
+ PHASE 0: PRODUCT DISCOVERY (optional)
87
+ Skill: reverse-engineering-unicorn (QUICK mode)
88
+ Modules: M2 (Product), M3 (Market), M4 (Business), M5 (Growth)
89
+ Output: Product Discovery Brief
90
+ Gate: activate if SaaS/startup, skip if internal tool
91
+ ⏸️ CHECKPOINT 0
92
+ git commit: (none — brief is in-memory context)
93
+
94
+ PHASE 1: PLANNING
95
+ Skill: sparc-prd-mini (MANUAL mode)
96
+ Internal phases: Explore → Research → Solve → Spec → Pseudo → Arch → Refine → Complete
97
+ Output: 11 SPARC documents in docs/
98
+ Constraints: Distributed Monolith, Docker, VPS, MCP
99
+ ⏸️ CHECKPOINT 1
100
+ git commit: "docs: SPARC documentation for [project-name]"
101
+
102
+ PHASE 2: VALIDATION
103
+ Agent: doc-validator (swarm of 5 parallel validators)
104
+ Criteria: INVEST ≥50, SMART ≥50, avg ≥70
105
+ Max iterations: 3
106
+ Output: docs/validation-report.md, docs/test-scenarios.md
107
+ ⏸️ CHECKPOINT 2
108
+ git commit: "docs: validation report and BDD scenarios"
109
+
110
+ PHASE 3: TOOLKIT GENERATION
111
+ Skill: cc-toolkit-generator-enhanced
112
+ Input: validated docs from docs/
113
+ Output: CLAUDE.md, commands, agents, rules, skills, hooks
114
+ Tiers: P0 (mandatory), P1 (recommended), P2 (optional)
115
+ ⏸️ CHECKPOINT 3
116
+ git commit: "feat: Claude Code toolkit for [project-name]"
117
+
118
+ PHASE 4: FINALIZE
119
+ Output: docker-compose.yml, Dockerfile, .gitignore
120
+ git commit: "chore: initial project setup from SPARC documentation"
121
+ Final summary with project structure and next steps
122
+ ```
123
+
124
+ ### Context Flow
125
+
126
+ | From | To | What Passes |
127
+ |------|----|-------------|
128
+ | Phase 0 | Phase 1 | Product Discovery Brief (JTBD, competitors, Blue Ocean) |
129
+ | Phase 1 | Phase 2 | 11 SPARC documents in docs/ |
130
+ | Phase 2 | Phase 3 | Validated docs + validation-report.md + test-scenarios.md |
131
+ | Phase 3 | Phase 4 | Complete toolkit (commands, agents, rules, skills) |
132
+
133
+ ### Quality Gate (Phase 2)
134
+
135
+ ```
136
+ Swarm: 5 parallel validators via Task tool
137
+ ├── validator-stories → INVEST on user stories
138
+ ├── validator-acceptance → SMART on acceptance criteria
139
+ ├── validator-architecture → Target constraints compliance
140
+ ├── validator-pseudocode → Story coverage, implementability
141
+ └── validator-coherence → Cross-document consistency
142
+
143
+ Scoring: 0-100 per validator
144
+ Aggregate: weighted average
145
+ Blocking: score <50 = BLOCKED
146
+ Iterations: max 3
147
+
148
+ Verdicts:
149
+ 🟢 READY: all ≥50, avg ≥70, no contradictions → Phase 3
150
+ 🟡 CAVEATS: warnings, no blocked, limitations noted → Phase 3 with notes
151
+ 🔴 NEEDS WORK: blocked items exist → return to Phase 1
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Skill Composition Example
157
+
158
+ ### How sparc-prd-mini composes 3 external skills
159
+
160
+ ```
161
+ sparc-prd-mini/SKILL.md declares:
162
+
163
+ | Phase | Skill | Action |
164
+ |-------|-------|--------|
165
+ | Phase 0: Explore | explore | view(".claude/skills/explore/SKILL.md") |
166
+ | Phase 1: Research | goap-research-ed25519 | view(".claude/skills/goap-research-ed25519/SKILL.md") |
167
+ | Phase 2: Solve | problem-solver-enhanced | view(".claude/skills/problem-solver-enhanced/SKILL.md") |
168
+
169
+ Fallbacks:
170
+ - explore unavailable → built-in 3-5 Socratic questions
171
+ - goap-research unavailable → direct web_search
172
+ - problem-solver unavailable → First Principles + SCQA only
173
+
174
+ Pre-filled context acceptance:
175
+ - Product Brief provided? → skip Phase 0
176
+ - Research Findings provided? → skip Phase 1
177
+ - Solution Strategy provided? → skip Phase 2
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Toolkit Generation Example (Phase 3)
183
+
184
+ ### What cc-toolkit-generator-enhanced produces from SPARC docs
185
+
186
+ **P0 (Mandatory) — always generated:**
187
+ ```
188
+ CLAUDE.md ← PRD + Architecture + Final_Summary
189
+ .claude/commands/start.md ← Architecture + Pseudocode
190
+ .claude/commands/feature.md ← feature-lifecycle template
191
+ .claude/commands/myinsights.md ← insights-system template
192
+ .claude/rules/git-workflow.md ← semantic commits
193
+ .claude/rules/security.md ← Specification NFRs
194
+ .claude/rules/coding-style.md ← Architecture tech stack
195
+ .claude/rules/insights-capture.md ← insights-system template
196
+ .claude/rules/feature-lifecycle.md ← feature-lifecycle template
197
+ .claude/settings.json ← hooks (insights, roadmap, plans)
198
+ 6 lifecycle skills (copied) ← explore, goap, solver, validator, brutal, sparc-prd
199
+ ```
200
+
201
+ **P1 (Recommended) — if docs provide context:**
202
+ ```
203
+ .claude/agents/planner.md ← Pseudocode + PRD
204
+ .claude/agents/code-reviewer.md ← Refinement + Specification
205
+ .claude/agents/architect.md ← Architecture + Solution_Strategy
206
+ .claude/skills/project-context/ ← Research_Findings
207
+ .claude/skills/coding-standards/ ← Architecture tech stack
208
+ .claude/commands/plan.md ← PRD + Pseudocode
209
+ .claude/commands/test.md ← Refinement
210
+ .claude/commands/deploy.md ← Completion
211
+ .claude/commands/next.md ← feature suggestions
212
+ .claude/commands/go.md ← smart pipeline
213
+ .claude/commands/run.md ← autonomous loop
214
+ .claude/commands/docs.md ← bilingual docs
215
+ .claude/rules/testing.md ← Refinement test strategy
216
+ feature-roadmap.json ← PRD features
217
+ ```
218
+
219
+ **P1 Conditional — if detected:**
220
+ ```
221
+ IF has_external_apis:
222
+ .claude/rules/secrets-management.md
223
+ .claude/skills/security-patterns/
224
+
225
+ IF has_ddd_docs:
226
+ .claude/commands/feature-ent.md
227
+ .claude/rules/feature-lifecycle-ent.md
228
+ .claude/skills/idea2prd-manual/
229
+ .claude/skills/goap-research-ed25519/ (copy)
230
+ ```
231
+
232
+ ---
233
+
234
+ ## Plugin Architecture
235
+
236
+ ### install.sh flow
237
+
238
+ ```
239
+ 1. Pre-flight: check git, warn if not git repo
240
+ 2. Clone: git clone --depth 1 to temp dir
241
+ 3. Detect conflicts: check .claude/{skills,commands,agents,rules}/*
242
+ 4. If conflicts: prompt user (y/N)
243
+ 5. Install:
244
+ - mkdir -p .claude/{skills,commands,agents,rules}
245
+ - cp -r skills/ (8 skills)
246
+ - cp -r commands/ (1 command)
247
+ - cp -r agents/ (3 agents)
248
+ - cp -r rules/ (1 rule)
249
+ 6. Write manifest: .claude/.replicate-plugin-manifest
250
+ 7. Summary: counts + next steps
251
+ ```
252
+
253
+ ### uninstall.sh flow
254
+
255
+ ```
256
+ 1. Read manifest
257
+ 2. Show what will be removed
258
+ 3. Prompt user
259
+ 4. Remove files listed in manifest
260
+ 5. Remove manifest
261
+ 6. Clean empty dirs
262
+ 7. Summary (preserves project-specific files)
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Key Design Decisions
268
+
269
+ | Decision | Rationale |
270
+ |----------|-----------|
271
+ | Skills use view() not inline | Single source of truth, auto-propagation of updates |
272
+ | Phase 2 never skipped | Quality gate ensures toolkit is built on validated docs |
273
+ | MANUAL mode for sparc-prd-mini | User controls each sub-phase of documentation |
274
+ | Swarm of 5 validators | Independent checks parallelized for speed |
275
+ | P0/P1/P2 tiers | Not everything is mandatory; reduces noise for simple projects |
276
+ | Path mapping tables | Portability between claude.ai and Claude Code environments |
277
+ | Manifest for uninstall | Clean removal without affecting project files |
278
+ | Architecture constraints injected | All projects follow same infrastructure pattern |
279
+
280
+ ---
281
+
282
+ ## Lessons for New Pipelines
283
+
284
+ 1. **Start with the dependency graph** — identify leaf skills first, then composites
285
+ 2. **Quality gates are non-negotiable** — never skip validation between major phases
286
+ 3. **Swarm where independent** — 5 validators run faster in parallel than sequentially
287
+ 4. **Context budget matters** — keep CLAUDE.md under 6k tokens, total under 30k
288
+ 5. **Fallbacks for everything** — skills should work even if dependencies are missing
289
+ 6. **Git at phase boundaries** — semantic commits enable rollback to any phase
290
+ 7. **Checkpoints for user control** — automated does not mean uncontrolled
291
+ 8. **Plugin architecture** — install.sh + manifest = clean install/uninstall
@@ -0,0 +1,408 @@
1
+ # Patterns Catalog
2
+
3
+ 7 architectural patterns extracted from the PU Unicorn Replicate methodology.
4
+ Each pattern is described with: intent, structure, when to use, implementation, and examples.
5
+
6
+ ---
7
+
8
+ ## Pattern 1: Composable Skill Architecture
9
+
10
+ ### Intent
11
+ Create self-contained, reusable AI skill modules that can be mixed, matched, and composed
12
+ into larger workflows without tight coupling.
13
+
14
+ ### Structure
15
+ ```
16
+ skill-name/
17
+ ├── SKILL.md # Entry point — complete skill definition
18
+ │ ├── Frontmatter # name, description, triggers
19
+ │ ├── Architecture # Directory layout, dependencies
20
+ │ ├── When to Use # Trigger patterns
21
+ │ ├── Operating Modes # AUTO/MANUAL/etc.
22
+ │ ├── Workflow # Phase-by-phase execution
23
+ │ ├── Output Format # Structured output templates
24
+ │ ├── Anti-Patterns # What NOT to do
25
+ │ └── Quality Standards # Completeness checklist
26
+ ├── references/ # Supporting knowledge (read-only context)
27
+ │ ├── methodology.md
28
+ │ └── criteria.md
29
+ ├── templates/ # Output templates with placeholders
30
+ │ ├── output.md
31
+ │ └── report.md
32
+ ├── modules/ # Sub-phases (for complex skills)
33
+ │ ├── 01-phase-one.md
34
+ │ └── 02-phase-two.md
35
+ ├── examples/ # Few-shot examples
36
+ │ └── example-output.md
37
+ └── scripts/ # Executable helpers (optional)
38
+ └── helper.sh
39
+ ```
40
+
41
+ ### Key Principles
42
+ 1. **SKILL.md is the entry point** — always read it first
43
+ 2. **Self-contained** — skill works with just its own directory
44
+ 3. **Explicit interfaces** — input format, output format, triggers documented
45
+ 4. **Fallback strategy** — what happens if optional dependencies are unavailable
46
+ 5. **Frontmatter** — standardized metadata (name, description, triggers)
47
+
48
+ ### When to Use
49
+ - You have a capability that needs to be reusable across contexts
50
+ - The capability has clear inputs, outputs, and triggers
51
+ - Multiple workflows need the same functionality
52
+
53
+ ### Implementation
54
+
55
+ **Frontmatter format:**
56
+ ```yaml
57
+ ---
58
+ name: skill-name
59
+ description: >
60
+ One-paragraph description of what the skill does.
61
+ Trigger patterns listed. Use cases described.
62
+ ---
63
+ ```
64
+
65
+ **Minimum viable SKILL.md sections:**
66
+ 1. Name and purpose (1 sentence)
67
+ 2. When to Use (trigger patterns)
68
+ 3. Input format
69
+ 4. Output format
70
+ 5. Execution steps
71
+ 6. Anti-patterns
72
+
73
+ ### Examples from PU Unicorn Replicate
74
+
75
+ | Skill | Size | References | Templates | Modules |
76
+ |-------|------|-----------|-----------|---------|
77
+ | `explore` | ~220 lines | 2 | 0 | 0 |
78
+ | `problem-solver-enhanced` | ~560 lines | 0 | 0 | 0 |
79
+ | `requirements-validator` | ~125 lines | 4 | 0 | 0 |
80
+ | `reverse-engineering-unicorn` | ~200 lines | 3 | 0 | 7 |
81
+ | `cc-toolkit-generator-enhanced` | ~375 lines | 3 + 11 templates | 0 | 0 |
82
+
83
+ **Rule of thumb:** If SKILL.md exceeds 400 lines, consider splitting into modules/.
84
+
85
+ ---
86
+
87
+ ## Pattern 2: Multi-Phase Pipeline Orchestration
88
+
89
+ ### Intent
90
+ Execute a sequence of phases in strict order, passing context between them,
91
+ with checkpoints for user control and git commits at boundaries.
92
+
93
+ ### Structure
94
+ ```
95
+ INPUT
96
+
97
+ PHASE 1: [Name] ─── Skill A ──→ Artifact 1
98
+ ⏸️ CHECKPOINT 1
99
+ git commit: "[type]: [phase-1-message]"
100
+
101
+ PHASE 2: [Name] ─── Skill B ──→ Artifact 2
102
+ (receives: Artifact 1 as context)
103
+ ⏸️ CHECKPOINT 2
104
+ git commit: "[type]: [phase-2-message]"
105
+
106
+ PHASE N: [Name] ─── Skill N ──→ Final Output
107
+ ⏸️ FINAL CHECKPOINT
108
+ git commit: "[type]: [final-message]"
109
+ ```
110
+
111
+ ### Key Principles
112
+ 1. **Strict ordering** — phases execute sequentially (unless swarm is used within a phase)
113
+ 2. **Context passing** — each phase receives output of previous phases
114
+ 3. **Quality gates** — between phases, validate output before proceeding
115
+ 4. **Checkpoints** — user confirms before moving to next phase
116
+ 5. **Git discipline** — semantic commits at phase boundaries
117
+ 6. **Resumability** — pipeline can restart from any checkpoint
118
+
119
+ ### Checkpoint Format
120
+ ```
121
+ ═══════════════════════════════════════════════════════════════
122
+ ✅ PHASE [N]: [PHASE NAME]
123
+ [Summary of what was accomplished]
124
+ ⏸️ "ок" — next | [other commands]
125
+ ═══════════════════════════════════════════════════════════════
126
+ ```
127
+
128
+ ### Context Passing Strategies
129
+
130
+ | Strategy | When | Example |
131
+ |----------|------|---------|
132
+ | **File-based** | Large context | Write to `docs/`, read in next phase |
133
+ | **Variable-based** | Small context | Pass as pre-filled context parameter |
134
+ | **Implicit** | Convention | Next phase scans known directory |
135
+
136
+ ### Git Commit Convention
137
+
138
+ | Phase Type | Commit Prefix |
139
+ |-----------|---------------|
140
+ | Documentation | `docs:` |
141
+ | Validation | `docs:` |
142
+ | Code generation | `feat:` |
143
+ | Configuration | `chore:` |
144
+ | Bug fixes | `fix:` |
145
+
146
+ ### When to Use
147
+ - Process has natural sequential stages
148
+ - Each stage transforms work product
149
+ - User oversight needed between stages
150
+ - Audit trail (git) is important
151
+
152
+ ### Examples from PU Unicorn Replicate
153
+
154
+ **`/replicate` pipeline (5 phases):**
155
+ ```
156
+ Phase 0: Product Discovery → Product Discovery Brief
157
+ Phase 1: Planning → 11 SPARC documents
158
+ Phase 2: Validation → Validation report + BDD scenarios
159
+ Phase 3: Toolkit → Commands + agents + rules + skills
160
+ Phase 4: Finalize → Scaffolds + final commit
161
+ ```
162
+
163
+ **`sparc-prd-mini` internal pipeline (8 phases):**
164
+ ```
165
+ Phase 0: Explore → Product Brief
166
+ Phase 1: Research → Research_Findings.md
167
+ Phase 2: Solve → Solution_Strategy.md
168
+ Phase 3: Specify → Specification.md + PRD.md
169
+ Phase 4: Pseudocode → Pseudocode.md
170
+ Phase 5: Architect → Architecture.md
171
+ Phase 6: Refine → Refinement.md
172
+ Phase 7: Complete → Completion.md + CLAUDE.md
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Pattern 3: Swarm of Agents
178
+
179
+ ### Intent
180
+ Parallelize independent tasks by spawning multiple specialized agents
181
+ that work simultaneously, then aggregate their results.
182
+
183
+ ### Structure
184
+ ```
185
+ ORCHESTRATOR
186
+ ↓ (Task tool)
187
+ ┌───────────────────────┐
188
+ │ Agent A Agent B │ ← Independent (no cross-deps)
189
+ │ Agent C Agent D │
190
+ │ Agent E │ ← May depend on A,B output
191
+ └───────────────────────┘
192
+
193
+ AGGREGATOR
194
+
195
+ UNIFIED RESULT
196
+ ```
197
+
198
+ ### Key Principles
199
+ 1. **Independence** — swarm agents must not depend on each other (or explicitly declare dependencies)
200
+ 2. **Clear scope** — each agent has a defined scope and criteria
201
+ 3. **Parallel execution** — use Task tool to launch agents concurrently
202
+ 4. **Aggregation** — orchestrator merges results, resolves conflicts
203
+ 5. **Iterative** — if aggregate fails quality gate, re-run with fixes (max N iterations)
204
+
205
+ ### Swarm Design Template
206
+ ```markdown
207
+ | Agent | Scope | Criteria | Independence | Output |
208
+ |-------|-------|----------|-------------|--------|
209
+ | agent-A | [what it checks] | [pass/fail criteria] | Full | [output format] |
210
+ | agent-B | [what it checks] | [pass/fail criteria] | Full | [output format] |
211
+ | agent-C | [what it checks] | [pass/fail criteria] | Reads A,B | [output format] |
212
+ ```
213
+
214
+ ### When to Use
215
+ - Multiple independent analyses of the same input
216
+ - Validation from different perspectives
217
+ - Research across independent topics
218
+ - Generation of independent artifacts
219
+
220
+ ### Anti-Patterns
221
+ ❌ Swarm agents that depend on each other's output (use pipeline instead)
222
+ ❌ More than 7 agents in a single swarm (diminishing returns)
223
+ ❌ No aggregation step (results just dumped without synthesis)
224
+ ❌ No conflict resolution strategy
225
+
226
+ ### Examples from PU Unicorn Replicate
227
+
228
+ **Phase 2 Validation Swarm (5 agents):**
229
+ ```
230
+ validator-stories → INVEST criteria on user stories
231
+ validator-acceptance → SMART criteria on acceptance criteria
232
+ validator-architecture → Target constraints compliance
233
+ validator-pseudocode → Story coverage, implementability
234
+ validator-coherence → Cross-document consistency (reads all above)
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Pattern 4: Skill Composition via view()
240
+
241
+ ### Intent
242
+ Enable loose coupling between skills by loading external skills at runtime
243
+ via `view()` instead of copying their content. Single source of truth.
244
+
245
+ ### Structure
246
+ ```
247
+ orchestrator-skill/SKILL.md
248
+ ├── "view explore skill" → reads .claude/skills/explore/SKILL.md
249
+ ├── "view research skill" → reads .claude/skills/goap-research-ed25519/SKILL.md
250
+ └── "view solver skill" → reads .claude/skills/problem-solver-enhanced/SKILL.md
251
+ ```
252
+
253
+ ### Key Principles
254
+ 1. **Single Source of Truth** — skill logic lives in ONE place
255
+ 2. **Runtime loading** — read skill content when needed, not before
256
+ 3. **Fallback strategy** — if skill unavailable, use simplified built-in
257
+ 4. **Path mapping** — support multiple environments (claude.ai vs Claude Code)
258
+ 5. **No duplication** — never copy skill content into another skill
259
+
260
+ ### Path Mapping Table
261
+ ```markdown
262
+ | Source Environment | Path Pattern | Mapped Path |
263
+ |-------------------|-------------|-------------|
264
+ | claude.ai | `/mnt/skills/user/[name]/` | `.claude/skills/[name]/` |
265
+ | claude.ai | `/mnt/user-data/uploads/` | `docs/` |
266
+ | claude.ai | `/output/` | `docs/` or project root |
267
+ ```
268
+
269
+ ### Fallback Strategy Template
270
+ ```markdown
271
+ **Fallbacks (if skill unavailable):**
272
+ - `explore` unavailable → built-in 3-5 Socratic questions
273
+ - `goap-research` unavailable → direct web_search
274
+ - `problem-solver` unavailable → First Principles + SCQA only
275
+ ```
276
+
277
+ ### When to Use
278
+ - Multiple skills need the same capability
279
+ - Skill updates should propagate automatically
280
+ - Skills need to work in different environments
281
+ - You want to avoid code duplication
282
+
283
+ ### Anti-Patterns
284
+ ❌ Copying skill content into another skill's SKILL.md
285
+ ❌ Hardcoding paths without mapping table
286
+ ❌ No fallback when dependency is unavailable
287
+ ❌ Circular dependencies between skills
288
+
289
+ ---
290
+
291
+ ## Pattern 5: Quality Gates
292
+
293
+ See `quality-gates.md` for detailed reference.
294
+
295
+ ---
296
+
297
+ ## Pattern 6: Documentation-Driven Development
298
+
299
+ ### Intent
300
+ Use validated documentation as the single source of truth for all downstream
301
+ code generation, toolkit creation, and implementation decisions.
302
+
303
+ ### Structure
304
+ ```
305
+ IDEA → DOCUMENTATION → VALIDATION → IMPLEMENTATION
306
+ (11 docs) (score ≥70) (reads docs, not memory)
307
+ ```
308
+
309
+ ### Key Principles
310
+ 1. **Docs before code** — never implement without validated documentation
311
+ 2. **Anti-hallucination** — implementation reads actual docs, not AI memory
312
+ 3. **Validation gate** — docs must pass quality gate before toolkit generation
313
+ 4. **Traceability** — every implementation decision traces to a document
314
+ 5. **Completeness** — documentation covers all aspects (requirements, architecture, testing, deployment)
315
+
316
+ ### Document Set (SPARC Methodology)
317
+
318
+ | Document | Purpose | Maps To |
319
+ |----------|---------|---------|
320
+ | PRD.md | Product requirements | Overview, features, commands |
321
+ | Solution_Strategy.md | Problem analysis | Context, architect agent |
322
+ | Specification.md | Detailed requirements | Coding standards, security rules |
323
+ | Pseudocode.md | Algorithms, data flow | Planner agent, implementation refs |
324
+ | Architecture.md | System design | Tech stack, project structure |
325
+ | Refinement.md | Edge cases, testing | Code reviewer, test strategy |
326
+ | Completion.md | Deployment, CI/CD | Deploy command, hooks |
327
+ | Research_Findings.md | Market & tech research | Domain knowledge skill |
328
+ | Final_Summary.md | Executive summary | Quick reference |
329
+
330
+ ### When to Use
331
+ - Building anything beyond a simple script
332
+ - Multiple people/agents will implement from the same spec
333
+ - Quality and consistency matter
334
+ - You need an audit trail of design decisions
335
+
336
+ ### Anti-Patterns
337
+ ❌ Generating code from memory without reading docs
338
+ ❌ Skipping validation (building toolkit from unvalidated docs)
339
+ ❌ Partial documentation (only PRD, no architecture)
340
+ ❌ Documentation that doesn't match implementation
341
+
342
+ ---
343
+
344
+ ## Pattern 7: Toolkit Generation
345
+
346
+ ### Intent
347
+ Transform validated documentation into a complete set of AI development instruments
348
+ (commands, agents, rules, skills, hooks) that encode domain knowledge.
349
+
350
+ ### Structure
351
+ ```
352
+ VALIDATED DOCS ──→ DETECT ──→ MAP ──→ GENERATE ──→ VALIDATE
353
+ (scan) (score) (templates) (checklist)
354
+ ```
355
+
356
+ ### Key Principles
357
+ 1. **Detection-based** — scan docs to determine what to generate
358
+ 2. **Conditional generation** — some instruments only if conditions met
359
+ 3. **Priority tiers** — P0 (mandatory), P1 (recommended), P2-P3 (optional)
360
+ 4. **Template-based** — use templates with placeholder substitution
361
+ 5. **In-place generation** — write directly into project, no archives
362
+ 6. **Master validation** — checklist to verify completeness
363
+
364
+ ### Priority Tiers
365
+
366
+ | Tier | When | Examples |
367
+ |------|------|---------|
368
+ | **P0 (Mandatory)** | Always | CLAUDE.md, /start, /feature, security rule, git-workflow |
369
+ | **P1 (Recommended)** | When docs provide enough context | planner agent, /plan, /test, /deploy |
370
+ | **P1 Conditional** | When specific docs detected | DDD → /feature-ent, APIs → secrets-management |
371
+ | **P2 (Optional)** | Nice to have | tdd-guide agent, review command |
372
+ | **P3 (Infrastructure)** | External integrations | .mcp.json, Docker MCP |
373
+
374
+ ### Document-to-Instrument Mapping
375
+
376
+ ```
377
+ EXTRACT [Document]: [field] → [instrument] [section]
378
+ ```
379
+
380
+ Example:
381
+ ```
382
+ EXTRACT PRD.md: name → title, problem → context, requirements → features
383
+ EXTRACT Architecture: structure → /start P1, packages → /start P2, stack → CLAUDE.md
384
+ EXTRACT Pseudocode: functions → planner templates, algorithms → /start P2 refs
385
+ ```
386
+
387
+ ### Context Budget
388
+ Keep total generated content within limits:
389
+
390
+ | Component | Target | Max |
391
+ |-----------|--------|-----|
392
+ | CLAUDE.md | 4k tokens | 6k |
393
+ | Commands (combined) | 5k | 8k |
394
+ | Rules (combined) | 3k | 5k |
395
+ | Agents + Skills | 4k | 6k |
396
+ | **Total** | ~18k | ~30k |
397
+
398
+ ### When to Use
399
+ - You have validated documentation and need development instruments
400
+ - You want to encode domain knowledge into reusable Claude Code artifacts
401
+ - You need consistency across all generated instruments
402
+
403
+ ### Anti-Patterns
404
+ ❌ Generating toolkit from unvalidated documentation
405
+ ❌ No priority tiers (everything is "mandatory")
406
+ ❌ Exceeding context budget (bloated CLAUDE.md)
407
+ ❌ Hardcoded content instead of reading from docs
408
+ ❌ No master validation checklist