@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,192 @@
1
+ # Phase 1: Agent Review
2
+
3
+ AI-assisted project scanning using a swarm of 5 parallel extraction agents.
4
+
5
+ ## Goal
6
+
7
+ Find all extractable knowledge in the project — patterns, commands, rules, templates,
8
+ snippets, skills, and hooks that could be reused in other projects.
9
+
10
+ ## Input
11
+
12
+ - Project codebase (current working directory)
13
+ - `TOOLKIT_HARVEST.md` markers (if exists in project root)
14
+ - User context about what was valuable (if provided)
15
+
16
+ ## Swarm of Extraction Agents
17
+
18
+ Launch 5 parallel agents via Task tool. Each agent independently scans the codebase
19
+ from its perspective.
20
+
21
+ ### Agent: extractor-patterns
22
+
23
+ **Scope:** Architecture and code patterns
24
+
25
+ **Scan for:**
26
+ - Middleware implementations (rate limiting, auth, logging, caching)
27
+ - Error handling patterns (retries, circuit breakers, fallbacks)
28
+ - Data access patterns (repository, DAO, query builders)
29
+ - Communication patterns (pub/sub, event sourcing, CQRS)
30
+ - Configuration patterns (env loading, feature flags, multi-env)
31
+ - Testing patterns (fixtures, factories, custom matchers)
32
+
33
+ **How to scan:**
34
+ 1. Look at directory structure for architectural patterns
35
+ 2. Scan for abstract/generic implementations (not domain-specific)
36
+ 3. Check for reusable middleware or interceptors
37
+ 4. Look for utility modules that solve common problems
38
+ 5. Check `TOOLKIT_HARVEST.md` → Patterns section
39
+
40
+ **Output per finding:**
41
+ ```markdown
42
+ - **Name:** [Pattern Name]
43
+ - **File:** [path/to/file.ext:line]
44
+ - **Description:** [1 sentence]
45
+ - **Reusability:** HIGH | MEDIUM | LOW
46
+ - **Why reusable:** [reason]
47
+ ```
48
+
49
+ ### Agent: extractor-commands
50
+
51
+ **Scope:** Scripts, CLI utilities, slash commands
52
+
53
+ **Scan for:**
54
+ - Shell scripts in `scripts/`, `bin/`, `tools/`
55
+ - Package.json scripts / Makefile targets / Taskfile tasks
56
+ - Database migration commands
57
+ - Code generation utilities
58
+ - Dev environment setup scripts
59
+ - CI/CD pipeline steps that could be local commands
60
+ - Existing `.claude/commands/` that are generalizable
61
+
62
+ **How to scan:**
63
+ 1. List all executable scripts
64
+ 2. Check package.json / Makefile / Taskfile for useful targets
65
+ 3. Check `.claude/commands/` for project-specific commands worth generalizing
66
+ 4. Check `TOOLKIT_HARVEST.md` → Commands section
67
+
68
+ **Output per finding:**
69
+ ```markdown
70
+ - **Name:** [Command Name]
71
+ - **File:** [path]
72
+ - **What it does:** [1 sentence]
73
+ - **Generalizability:** HIGH | MEDIUM | LOW
74
+ - **Dependencies:** [external tools needed]
75
+ ```
76
+
77
+ ### Agent: extractor-rules
78
+
79
+ **Scope:** Constraints, workarounds, lessons learned
80
+
81
+ **Scan for:**
82
+ - Comments with `TODO`, `HACK`, `WORKAROUND`, `NOTE`, `FIXME`
83
+ - Known issues documented in README or docs
84
+ - Edge cases in tests (especially ones that were hard to find)
85
+ - Library-specific quirks discovered during development
86
+ - Performance constraints discovered empirically
87
+ - Security constraints that weren't obvious
88
+ - Claude Code limitations (things that don't work well with AI)
89
+
90
+ **How to scan:**
91
+ 1. Grep for `TODO|HACK|WORKAROUND|NOTE|FIXME|XXX|BUG`
92
+ 2. Check README/docs for "gotchas" or "known issues"
93
+ 3. Look at test names for edge case descriptions
94
+ 4. Check git commit messages for "fix:" — these often encode lessons
95
+ 5. Check `TOOLKIT_HARVEST.md` → Lessons/Rules section
96
+
97
+ **Output per finding:**
98
+ ```markdown
99
+ - **Rule:** [Don't do X because Y]
100
+ - **Source:** [file:line or commit:hash]
101
+ - **Type:** Constraint | Workaround | Lesson | Limitation
102
+ - **Scope:** Universal | Language-specific | Framework-specific
103
+ - **Expiry:** Permanent | Check in [timeframe]
104
+ ```
105
+
106
+ ### Agent: extractor-templates
107
+
108
+ **Scope:** File structures, configs, project scaffolds
109
+
110
+ **Scan for:**
111
+ - Dockerfile / docker-compose.yml patterns
112
+ - CI/CD configuration (.github/workflows, .gitlab-ci.yml)
113
+ - Linter/formatter configs (.eslintrc, .prettierrc, rustfmt.toml)
114
+ - Project structure conventions
115
+ - Testing configuration
116
+ - Monitoring/logging setup
117
+ - Environment configuration templates
118
+
119
+ **How to scan:**
120
+ 1. List all config/dot files
121
+ 2. Identify which configs are project-specific vs. generalizable
122
+ 3. Check for well-structured Dockerfiles worth reusing
123
+ 4. Check CI/CD configs for reusable job definitions
124
+ 5. Check `TOOLKIT_HARVEST.md` → Templates section
125
+
126
+ **Output per finding:**
127
+ ```markdown
128
+ - **Name:** [Template Name]
129
+ - **File:** [path]
130
+ - **What it templates:** [1 sentence]
131
+ - **Parameterizable:** YES (what params) | NO (why)
132
+ - **Tech stack:** [language/framework]
133
+ ```
134
+
135
+ ### Agent: extractor-snippets
136
+
137
+ **Scope:** Small, ready-to-use code fragments
138
+
139
+ **Scan for:**
140
+ - Utility functions in `utils/`, `helpers/`, `lib/`, `common/`
141
+ - One-liners that solve common problems
142
+ - Type definitions / interfaces that are universal
143
+ - Error handler implementations
144
+ - Validation functions
145
+ - Date/time helpers
146
+ - String manipulation utilities
147
+ - HTTP client wrappers
148
+
149
+ **How to scan:**
150
+ 1. Scan utility directories
151
+ 2. Look for small (<50 lines) functions with no domain dependencies
152
+ 3. Check for functions used across multiple modules (sign of universality)
153
+ 4. Check `TOOLKIT_HARVEST.md` → Snippets section
154
+
155
+ **Output per finding:**
156
+ ```markdown
157
+ - **Name:** [Snippet Name]
158
+ - **File:** [path:line]
159
+ - **Language:** [lang]
160
+ - **Lines:** [count]
161
+ - **Dependencies:** None | [list]
162
+ - **What it does:** [1 sentence]
163
+ ```
164
+
165
+ ## Merging Strategy
166
+
167
+ After all 5 agents complete:
168
+
169
+ 1. **Deduplicate** — same finding reported by multiple agents → keep richest description
170
+ 2. **Cross-reference** — if a pattern is also a template, note both categories
171
+ 3. **Sort by confidence** — HIGH reusability first
172
+ 4. **Count** — total findings, per-category breakdown
173
+ 5. **Include TOOLKIT_HARVEST.md markers** — merge manual markers with auto-discovered
174
+
175
+ ## Output: Raw Findings List
176
+
177
+ ```markdown
178
+ ## Raw Findings
179
+
180
+ ### Summary
181
+ - Total candidates: [N]
182
+ - From agents: [M] (unique after dedup)
183
+ - From TOOLKIT_HARVEST.md markers: [K]
184
+ - By category: Skills [X], Commands [Y], Patterns [Z], Rules [A], Templates [B], Snippets [C], Hooks [D]
185
+
186
+ ### Findings Table
187
+
188
+ | # | Finding | Source | Category | Reusability | Agent |
189
+ |---|---------|--------|----------|-------------|-------|
190
+ | 1 | [name] | [file:line] | [category] | HIGH | extractor-patterns |
191
+ | 2 | [name] | [file:line] | [category] | MEDIUM | extractor-commands |
192
+ ```
@@ -0,0 +1,122 @@
1
+ # Phase 2: Classify
2
+
3
+ Map raw findings to the 7 artifact categories and filter out non-extractables.
4
+
5
+ ## Goal
6
+
7
+ Transform the Raw Findings List into a curated Classified Artifact List.
8
+ Every finding must either be assigned a category or explicitly excluded with reason.
9
+
10
+ ## 7 Artifact Categories
11
+
12
+ | # | Category | Directory | What Belongs | Example |
13
+ |---|----------|-----------|-------------|---------|
14
+ | 1 | **Skills** | `skills/` | New or improved SKILL.md techniques | Better API integration technique |
15
+ | 2 | **Commands** | `commands/` | Slash commands for Claude Code | `/api-endpoint` generates CRUD |
16
+ | 3 | **Hooks** | `hooks/` | Pre-commit, post-task, CI automation | Auto-validate OpenAPI schema |
17
+ | 4 | **Rules** | `rules/` | Constraints, limitations, "don't do X" | "Nested generics >3 levels break AI" |
18
+ | 5 | **Templates** | `templates/` | Reusable file/project structures | Dockerfile for Node+Postgres |
19
+ | 6 | **Patterns** | `patterns/` | Architectural approaches as docs | Event sourcing + CQRS |
20
+ | 7 | **Snippets** | `snippets/` | Small ready code fragments (<50 lines) | Universal retry with backoff |
21
+
22
+ See `references/artifact-categories.md` for detailed criteria per category.
23
+
24
+ ## Classification Process
25
+
26
+ For each finding from Phase 1:
27
+
28
+ ### Step 1: Apply Exclusion Filter
29
+
30
+ **Exclude if ANY of these are true:**
31
+
32
+ | Exclusion Criteria | Reason |
33
+ |-------------------|--------|
34
+ | Domain-specific (business logic) | Won't generalize |
35
+ | Used exactly once, unvalidated | Not proven enough |
36
+ | Library bugfix workaround | Will expire with next lib version |
37
+ | Contains secrets/credentials | Security risk |
38
+ | Hardcoded business rules | Not transferable |
39
+ | Extremely framework-specific | Too narrow scope |
40
+
41
+ **Exception:** Library workarounds CAN be extracted as temporary rules
42
+ with a review date: `## Expiry: Check after [library] v[next]`
43
+
44
+ ### Step 2: Determine Primary Category
45
+
46
+ Use this decision tree:
47
+
48
+ ```
49
+ Is it executable logic (<50 lines)?
50
+ → YES: Snippet
51
+ → NO: Continue
52
+
53
+ Is it a complete workflow/process?
54
+ → YES: Is it a Claude Code slash command?
55
+ → YES: Command
56
+ → NO: Skill
57
+ → NO: Continue
58
+
59
+ Is it an automation trigger?
60
+ → YES: Hook
61
+ → NO: Continue
62
+
63
+ Is it a constraint or lesson?
64
+ → YES: Rule
65
+ → NO: Continue
66
+
67
+ Is it a file structure or config?
68
+ → YES: Template
69
+ → NO: Continue
70
+
71
+ Is it an architectural approach?
72
+ → YES: Pattern
73
+ → NO: Reconsider — may not be extractable
74
+ ```
75
+
76
+ ### Step 3: Assess Cross-Category
77
+
78
+ Some artifacts span categories. Mark secondary categories:
79
+
80
+ | Primary | Common Secondary |
81
+ |---------|-----------------|
82
+ | Pattern | Template (implementation scaffold) |
83
+ | Snippet | Pattern (if part of larger pattern) |
84
+ | Command | Hook (if automatable) |
85
+ | Rule | Snippet (code that enforces the rule) |
86
+ | Skill | Command (entry point for the skill) |
87
+
88
+ ### Step 4: Confidence Rating
89
+
90
+ | Rating | Meaning | Criteria |
91
+ |--------|---------|----------|
92
+ | **HIGH** | Definitely extract | Universal, proven, well-tested |
93
+ | **MEDIUM** | Likely extract | Needs some generalization |
94
+ | **LOW** | Maybe extract | Needs significant rework, questionable reusability |
95
+
96
+ ## Output: Classified Artifact List
97
+
98
+ ```markdown
99
+ ## Classified Artifacts
100
+
101
+ ### ✅ Extract ([N] artifacts)
102
+
103
+ | # | Artifact | Primary | Secondary | Confidence | Notes |
104
+ |---|----------|---------|-----------|------------|-------|
105
+ | 1 | Retry with backoff | Pattern | Snippet | HIGH | Universal HTTP retry |
106
+ | 2 | /db-migrate | Command | - | MEDIUM | Needs param extraction |
107
+ | 3 | Error boundary pattern | Pattern | Template | HIGH | Works with any framework |
108
+
109
+ ### ❌ Skip ([M] items)
110
+
111
+ | # | Finding | Reason |
112
+ |---|---------|--------|
113
+ | 4 | Auth middleware | Domain-specific (user model tied) |
114
+ | 5 | Stripe webhook handler | Too platform-specific |
115
+ | 6 | Temp fix for lib bug #123 | Will expire, library-specific |
116
+
117
+ ### ⚠️ Uncertain ([K] items)
118
+
119
+ | # | Finding | Question | Decision Needed |
120
+ |---|---------|----------|-----------------|
121
+ | 7 | Custom ORM wrapper | Generalizable or too specific? | User input |
122
+ ```
@@ -0,0 +1,156 @@
1
+ # Phase 3: Decontextualize
2
+
3
+ Transform project-specific artifacts into reusable, documented toolkit entries.
4
+
5
+ ## Goal
6
+
7
+ Each classified artifact must be generalized so it works in ANY project,
8
+ not just the one it was extracted from. This is the critical step that separates
9
+ "copying code" from "building a toolkit."
10
+
11
+ ## The 3-Step Decontextualization
12
+
13
+ ### Step 1: Remove Project Specifics
14
+
15
+ **Find and replace:**
16
+
17
+ | Project-Specific | Generalized Replacement |
18
+ |-----------------|----------------------|
19
+ | Concrete service names (`auth-service`) | `{{SERVICE_NAME}}` or generic (`service`) |
20
+ | Specific paths (`src/auth/errors.rs`) | Pattern description ("error handling module") |
21
+ | Hardcoded configs (`port: 3000`) | Parameters (`port: {{PORT}}`) |
22
+ | Specific DB names/tables | Generic schema references |
23
+ | API endpoint paths (`/api/v1/users`) | `{{API_PREFIX}}/{{RESOURCE}}` |
24
+ | Company/product names | `{{PROJECT_NAME}}` |
25
+ | Specific env variables | Documented parameter list |
26
+ | Concrete user models | Interface/trait with required methods |
27
+
28
+ **Example transformation:**
29
+
30
+ Before (project-specific):
31
+ ```rust
32
+ // auth-service/src/middleware/rate_limit.rs
33
+ pub fn rate_limit(config: &AuthConfig) -> RateLimiter {
34
+ RateLimiter::new(config.max_requests, config.window_secs)
35
+ }
36
+ ```
37
+
38
+ After (decontextualized):
39
+ ```rust
40
+ // Pattern: Rate Limiting Middleware
41
+ // Works with any HTTP service
42
+ pub fn rate_limit<C: RateLimitConfig>(config: &C) -> RateLimiter {
43
+ RateLimiter::new(config.max_requests(), config.window_duration())
44
+ }
45
+
46
+ // Required trait for configuration
47
+ pub trait RateLimitConfig {
48
+ fn max_requests(&self) -> u32;
49
+ fn window_duration(&self) -> Duration;
50
+ }
51
+ ```
52
+
53
+ ### Step 2: Document Usage
54
+
55
+ Every artifact gets documentation following `templates/artifact-card.md`:
56
+
57
+ **Required sections:**
58
+ 1. **Title** — descriptive name
59
+ 2. **When to Use** — conditions where this artifact applies
60
+ 3. **When NOT to Use** — explicit anti-patterns
61
+ 4. **Prerequisites** — what must exist before using this
62
+ 5. **Implementation** — the generalized code/pattern/template
63
+ 6. **Variants** — alternative implementations for different contexts
64
+ 7. **Source** — provenance (project, date, version)
65
+
66
+ **Optional sections:**
67
+ - **Gotchas** — things that can go wrong
68
+ - **Related Artifacts** — links to complementary artifacts
69
+ - **Performance Notes** — benchmarks, trade-offs
70
+
71
+ ### Step 3: Version & Provenance
72
+
73
+ Every artifact must have a maturity block:
74
+
75
+ ```markdown
76
+ ## Maturity: 🔴 Alpha
77
+ ## Used in: [source-project]
78
+ ## Extracted: [DATE]
79
+ ## Last updated: [DATE]
80
+ ## Changelog:
81
+ - v1: Initial extraction from [source-project]
82
+ ```
83
+
84
+ See `references/maturity-model.md` for maturity progression rules.
85
+
86
+ ## Quality Gate
87
+
88
+ Apply to each artifact before it can proceed to Phase 4:
89
+
90
+ | # | Check | Threshold | Blocking? |
91
+ |---|-------|-----------|-----------|
92
+ | 1 | No project-specific names | 0 remaining | YES |
93
+ | 2 | No hardcoded paths | 0 remaining | YES |
94
+ | 3 | "When to Use" section | Must exist | YES |
95
+ | 4 | "When NOT to Use" section | Must exist | YES |
96
+ | 5 | Prerequisites documented | Must exist | YES |
97
+ | 6 | At least 1 usage variant | Recommended | NO |
98
+ | 7 | Code compiles standalone | Must pass (code) | YES |
99
+ | 8 | Maturity level assigned | Must exist | YES |
100
+ | 9 | Source project recorded | Must exist | YES |
101
+
102
+ **If `brutal-honesty-review` skill available:**
103
+
104
+ Apply Bach-mode BS detection:
105
+ - "Is this ACTUALLY reusable, or are we fooling ourselves?"
106
+ - "Would this work if transplanted to a completely different project?"
107
+ - "Is the generalization genuine or superficial (just renamed variables)?"
108
+
109
+ ## Decontextualization Patterns by Category
110
+
111
+ ### For Patterns
112
+ - Replace concrete types with generics/traits/interfaces
113
+ - Extract configuration into parameters
114
+ - Document the PRINCIPLE, not just the implementation
115
+ - Provide at least 2 language/framework variants if possible
116
+
117
+ ### For Commands
118
+ - Replace project paths with `$PROJECT_ROOT` or auto-detection
119
+ - Make tool dependencies explicit (what must be installed)
120
+ - Add argument parsing for project-specific values
121
+ - Document required environment variables
122
+
123
+ ### For Rules
124
+ - State the UNIVERSAL principle, not the project symptom
125
+ - Include example of what goes wrong (without project specifics)
126
+ - Specify scope: universal vs. language-specific vs. framework-specific
127
+ - Add expiry date for library-specific workarounds
128
+
129
+ ### For Templates
130
+ - Replace all hardcoded values with `{{PLACEHOLDERS}}`
131
+ - Document every placeholder with type and default value
132
+ - Include comments explaining WHY each section exists
133
+ - Test that template works with example values
134
+
135
+ ### For Snippets
136
+ - Remove all import/require statements that are project-specific
137
+ - Document required dependencies
138
+ - Add type signatures / function documentation
139
+ - Ensure the snippet is self-contained (<50 lines)
140
+
141
+ ### For Skills
142
+ - Follow `pipeline-forge` skill anatomy (view `.claude/skills/pipeline-forge/references/skill-anatomy.md`)
143
+ - Include SKILL.md with frontmatter
144
+ - Add trigger patterns
145
+ - Document input/output formats
146
+
147
+ ### For Hooks
148
+ - Make the triggering event configurable
149
+ - Document which tool/framework the hook targets
150
+ - Include installation instructions
151
+ - Add enable/disable mechanism
152
+
153
+ ## Output
154
+
155
+ Each artifact is now a complete, documented, generalized entry ready for toolkit integration.
156
+ The output is a set of files (one per artifact) following the `templates/artifact-card.md` format.
@@ -0,0 +1,178 @@
1
+ # Phase 4: Integrate
2
+
3
+ Write generalized artifacts to the toolkit and update the index.
4
+
5
+ ## Goal
6
+
7
+ Place each artifact in its correct toolkit location, handle version conflicts,
8
+ and produce a comprehensive Harvest Report.
9
+
10
+ ## Integration Process
11
+
12
+ ### Step 1: Determine Target Location
13
+
14
+ Each artifact category has a default target:
15
+
16
+ | Category | Default Target | Alternative |
17
+ |----------|---------------|-------------|
18
+ | Skills | `.claude/skills/[name]/SKILL.md` | External toolkit repo |
19
+ | Commands | `.claude/commands/[name].md` | External toolkit repo |
20
+ | Hooks | `.claude/settings.json` or `.claude/hooks/` | git hooks |
21
+ | Rules | `.claude/rules/[name].md` | CLAUDE.md inline |
22
+ | Templates | `templates/[name]/` or `.claude/templates/` | Standalone repo |
23
+ | Patterns | `docs/patterns/[name].md` or `patterns/` | Knowledge base |
24
+ | Snippets | `snippets/[lang]/[name].[ext]` or inline in docs | Gist/snippet manager |
25
+
26
+ **Target selection:**
27
+ - If integrating into current project → `.claude/` or project root
28
+ - If integrating into external toolkit → specify toolkit path
29
+ - If creating new repo → use pipeline-forge to scaffold
30
+
31
+ ### Step 2: Handle Existing Artifacts
32
+
33
+ When an artifact with the same name already exists:
34
+
35
+ | Scenario | Action |
36
+ |----------|--------|
37
+ | New artifact | Write directly |
38
+ | Same name, different version | Merge: update version, add new variants |
39
+ | Same name, same content | Skip (already extracted) |
40
+ | Conflict (different approach) | Show both, ask user which to keep |
41
+
42
+ **Version merge process:**
43
+ 1. Read existing artifact
44
+ 2. Compare with new extraction
45
+ 3. If new adds value → increment version, add to changelog
46
+ 4. If new is different approach → present as variant
47
+ 5. Update maturity level if warranted
48
+
49
+ ### Step 3: Write Artifacts
50
+
51
+ For each artifact:
52
+
53
+ 1. Create file at target location
54
+ 2. Ensure directory exists
55
+ 3. Write using `templates/artifact-card.md` format
56
+ 4. Verify file was written successfully
57
+
58
+ **Skills (special handling):**
59
+ If artifact is a Skill, use pipeline-forge's skill anatomy:
60
+ ```
61
+ .claude/skills/[skill-name]/
62
+ ├── SKILL.md
63
+ ├── references/ (if needed)
64
+ └── templates/ (if needed)
65
+ ```
66
+
67
+ ### Step 4: Update Toolkit Index
68
+
69
+ After all artifacts are written, update the toolkit index.
70
+
71
+ **If CLAUDE.md is the index:**
72
+ Add/update the toolkit section:
73
+
74
+ ```markdown
75
+ ## Toolkit Artifacts
76
+
77
+ ### Skills
78
+ | Skill | Maturity | Description | Source |
79
+ |-------|----------|-------------|--------|
80
+ | [name] | 🔴/🟡/🟢 | [desc] | [project], [date] |
81
+
82
+ ### Patterns
83
+ | Pattern | Maturity | Description | Source |
84
+ |---------|----------|-------------|--------|
85
+ | [name] | 🔴/🟡/🟢 | [desc] | [project], [date] |
86
+
87
+ [... for each category with artifacts]
88
+
89
+ Last harvest: [DATE]
90
+ Total artifacts: [N]
91
+ ```
92
+
93
+ **If standalone manifest:**
94
+ Write to `.claude/toolkit-manifest.json`:
95
+ ```json
96
+ {
97
+ "last_harvest": "2026-03-01",
98
+ "artifacts": [
99
+ {
100
+ "name": "retry-with-backoff",
101
+ "category": "pattern",
102
+ "maturity": "alpha",
103
+ "path": "docs/patterns/retry-with-backoff.md",
104
+ "source_project": "api-gateway",
105
+ "extracted": "2026-03-01",
106
+ "version": 1
107
+ }
108
+ ]
109
+ }
110
+ ```
111
+
112
+ ### Step 5: Generate Harvest Report
113
+
114
+ Produce a summary report using `templates/harvest-report.md`:
115
+
116
+ ```markdown
117
+ # Harvest Report: [Project Name]
118
+ Date: [DATE]
119
+
120
+ ## Summary
121
+ | Metric | Value |
122
+ |--------|-------|
123
+ | Files scanned | [N] |
124
+ | Candidates found | [M] |
125
+ | Artifacts extracted | [K] |
126
+ | Artifacts skipped | [J] |
127
+ | New artifacts | [X] |
128
+ | Updated artifacts | [Y] |
129
+
130
+ ## Extracted Artifacts
131
+
132
+ | # | Name | Category | Maturity | Location |
133
+ |---|------|----------|----------|----------|
134
+ | 1 | [name] | [cat] | 🔴 | [path] |
135
+
136
+ ## Skipped Items (with reasons)
137
+
138
+ | # | Name | Reason |
139
+ |---|------|--------|
140
+ | 1 | [name] | [reason] |
141
+
142
+ ## Toolkit Status
143
+
144
+ Total artifacts in toolkit: [N]
145
+ - 🔴 Alpha: [X]
146
+ - 🟡 Beta: [Y]
147
+ - 🟢 Stable: [Z]
148
+
149
+ ## Recommendations
150
+
151
+ - [Artifact X] → Consider promoting to 🟡 Beta after use in next project
152
+ - [Pattern Y] → Needs variant for [framework Z]
153
+ - Run next harvest after: [project/sprint/milestone]
154
+ ```
155
+
156
+ ### Step 6: Clean Up
157
+
158
+ 1. Mark extracted items as done in `TOOLKIT_HARVEST.md` (check the checkboxes)
159
+ 2. Optionally archive `TOOLKIT_HARVEST.md` to `docs/harvest-history/`
160
+ 3. Git commit: `chore: harvest [N] artifacts from [project-name]`
161
+
162
+ ## Git Commit Convention
163
+
164
+ ```
165
+ chore: harvest [N] artifacts from [project-name]
166
+
167
+ Extracted:
168
+ - [category]: [artifact-name] (v[N])
169
+ - [category]: [artifact-name] (new)
170
+ ```
171
+
172
+ ## Output
173
+
174
+ - Written artifact files at their target locations
175
+ - Updated toolkit index
176
+ - Harvest Report at `docs/harvest-report-[date].md`
177
+ - Checked off `TOOLKIT_HARVEST.md` items
178
+ - Git commit with harvest summary