@dzhechkov/p-replicator 1.0.1 → 1.1.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.
- package/README.md +25 -3
- package/package.json +6 -3
- package/src/commands/doctor.js +2 -2
- package/src/commands/list.js +1 -1
- package/templates/.claude/rules/replicate-pipeline.md +13 -1
- package/templates/.claude/rules/skill-interface-protocol.md +148 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +116 -63
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/01-detect-parse.md +329 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/02-analyze-map.md +449 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +630 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +537 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/05-generate-p2p3.md +512 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +710 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/07-harvest-feedback.md +286 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/08-skill-composition.md +378 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/09-cross-project-learning.md +461 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/README.md +83 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/maturity-integration.md +198 -0
- package/templates/.claude/skills/pipeline-forge/references/self-extracted-patterns.md +260 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Module: Harvest Feedback
|
|
2
|
+
|
|
3
|
+
Feedback loop between knowledge extraction (/harvest) and toolkit generation.
|
|
4
|
+
After a project completes and /harvest extracts reusable knowledge, this module
|
|
5
|
+
analyzes the harvested artifacts and improves the toolkit generator's templates,
|
|
6
|
+
defaults, and rules for future projects.
|
|
7
|
+
|
|
8
|
+
## Input
|
|
9
|
+
|
|
10
|
+
| Source | Location | Description |
|
|
11
|
+
|--------|----------|-------------|
|
|
12
|
+
| Harvest reports | `docs/harvest-report-*.md` | Completed harvest session outputs |
|
|
13
|
+
| Extracted artifacts catalog | `.claude/toolkit-manifest.json` or CLAUDE.md toolkit section | Registry of all harvested artifacts with maturity levels |
|
|
14
|
+
| Current toolkit templates | `.claude/skills/cc-toolkit-generator-enhanced/references/templates/` | Templates used by the generator |
|
|
15
|
+
| Maturity model | `view() knowledge-extractor/references/maturity-model.md` | Artifact lifecycle definitions |
|
|
16
|
+
| Generator SKILL.md | `view() cc-toolkit-generator-enhanced/SKILL.md` | Current generation rules and recommendations |
|
|
17
|
+
|
|
18
|
+
## Process
|
|
19
|
+
|
|
20
|
+
### Step 1: Scan for Completed Harvest Reports
|
|
21
|
+
|
|
22
|
+
Locate all harvest reports in the project:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
SCAN docs/harvest-report-*.md
|
|
26
|
+
SCAN docs/harvest-history/
|
|
27
|
+
SCAN .claude/toolkit-manifest.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For each report, extract:
|
|
31
|
+
- **Artifact list** with categories, maturity levels, and source files
|
|
32
|
+
- **Skipped items** with reasons (these reveal template gaps)
|
|
33
|
+
- **Recommendations** section (these are explicit improvement hints)
|
|
34
|
+
- **Maturity promotions** that occurred (these validate artifact quality)
|
|
35
|
+
|
|
36
|
+
If no harvest reports found, exit with:
|
|
37
|
+
```
|
|
38
|
+
No harvest reports found. Run /harvest first, then re-run this module.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2: Match Harvested Patterns Against Generator Templates
|
|
42
|
+
|
|
43
|
+
For each harvested artifact, determine which toolkit generator template or default it relates to:
|
|
44
|
+
|
|
45
|
+
| Artifact Category | Generator Template Mapping |
|
|
46
|
+
|-------------------|---------------------------|
|
|
47
|
+
| Skills | `references/templates/feature-lifecycle.md`, skill copy protocol |
|
|
48
|
+
| Commands | `references/templates/start-command.md`, `automation-commands.md` |
|
|
49
|
+
| Hooks | `settings.json` generation, hook templates |
|
|
50
|
+
| Rules | `security.md`, `coding-style.md`, `git-workflow.md` generation |
|
|
51
|
+
| Templates | `references/templates/` directory, scaffold generation |
|
|
52
|
+
| Patterns | `references/enhanced-recommendations.md`, scoring system |
|
|
53
|
+
| Snippets | `coding-standards/` skill generation |
|
|
54
|
+
|
|
55
|
+
**Matching Algorithm:**
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
FOR each harvested_artifact IN harvest_report:
|
|
59
|
+
1. IDENTIFY target_template = map_category_to_template(artifact.category)
|
|
60
|
+
2. COMPARE artifact.content WITH target_template.defaults
|
|
61
|
+
3. IF artifact adds new capability NOT in template:
|
|
62
|
+
→ CLASSIFY as "NEW_DEFAULT"
|
|
63
|
+
4. IF artifact improves existing template section:
|
|
64
|
+
→ CLASSIFY as "TEMPLATE_UPGRADE"
|
|
65
|
+
5. IF artifact reveals a missing rule or constraint:
|
|
66
|
+
→ CLASSIFY as "NEW_RULE"
|
|
67
|
+
6. IF artifact is a pattern that should be in recommendations:
|
|
68
|
+
→ CLASSIFY as "RECOMMENDATION_UPDATE"
|
|
69
|
+
7. RECORD match with confidence score (0-100)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Step 3: Identify Improvements
|
|
73
|
+
|
|
74
|
+
For each match, generate an improvement proposal:
|
|
75
|
+
|
|
76
|
+
```markdown
|
|
77
|
+
## Improvement Proposal
|
|
78
|
+
|
|
79
|
+
### ID: {{IMPROVEMENT_ID}}
|
|
80
|
+
### Type: NEW_DEFAULT | TEMPLATE_UPGRADE | NEW_RULE | RECOMMENDATION_UPDATE
|
|
81
|
+
### Source Artifact: {{ARTIFACT_NAME}} ({{MATURITY_LEVEL}})
|
|
82
|
+
### Target Template: {{TEMPLATE_PATH}}
|
|
83
|
+
|
|
84
|
+
### Current State
|
|
85
|
+
[What the template currently does]
|
|
86
|
+
|
|
87
|
+
### Proposed Change
|
|
88
|
+
[What the template should do after applying this improvement]
|
|
89
|
+
|
|
90
|
+
### Rationale
|
|
91
|
+
[Why this improvement matters — based on harvest evidence]
|
|
92
|
+
|
|
93
|
+
### Impact Score: {{SCORE}}/10
|
|
94
|
+
### Risk Level: LOW | MEDIUM | HIGH
|
|
95
|
+
|
|
96
|
+
### Auto-Apply Eligible: YES | NO
|
|
97
|
+
[YES only if: Risk=LOW AND Impact>=7 AND source artifact maturity >= Beta]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Improvement Types:**
|
|
101
|
+
|
|
102
|
+
| Type | Example | Typical Risk |
|
|
103
|
+
|------|---------|-------------|
|
|
104
|
+
| NEW_DEFAULT | Harvested a retry pattern used in 3+ projects → add to P0 defaults | LOW |
|
|
105
|
+
| TEMPLATE_UPGRADE | Harvested a better /start command structure → update template | MEDIUM |
|
|
106
|
+
| NEW_RULE | Harvested a "don't do X" rule → add to generated rules | LOW |
|
|
107
|
+
| RECOMMENDATION_UPDATE | Harvested pattern scores higher than existing recommendation → update scoring | LOW |
|
|
108
|
+
|
|
109
|
+
### Step 4: Score Improvements by Impact
|
|
110
|
+
|
|
111
|
+
Each improvement is scored on two axes:
|
|
112
|
+
|
|
113
|
+
**Impact Score (1-10):** How many future projects benefit?
|
|
114
|
+
|
|
115
|
+
| Score | Meaning |
|
|
116
|
+
|-------|---------|
|
|
117
|
+
| 1-3 | Niche — helps specific tech stacks or domains only |
|
|
118
|
+
| 4-6 | Moderate — helps a category of projects (e.g., all API projects) |
|
|
119
|
+
| 7-8 | Broad — helps most projects regardless of stack |
|
|
120
|
+
| 9-10 | Universal — fundamental improvement to the generation process |
|
|
121
|
+
|
|
122
|
+
**Risk Score (LOW / MEDIUM / HIGH):**
|
|
123
|
+
|
|
124
|
+
| Risk | Definition |
|
|
125
|
+
|------|-----------|
|
|
126
|
+
| LOW | Additive change, no existing behavior modified, easy to revert |
|
|
127
|
+
| MEDIUM | Modifies existing template, might change output for some projects |
|
|
128
|
+
| HIGH | Changes core generation logic, affects all future projects |
|
|
129
|
+
|
|
130
|
+
**Auto-Apply Eligibility Matrix:**
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Auto-apply = (Risk == LOW) AND (Impact >= 7) AND (Source Maturity >= Beta)
|
|
134
|
+
|
|
135
|
+
| Risk \ Impact | 1-6 | 7-8 | 9-10 |
|
|
136
|
+
|---------------|-----|-----|------|
|
|
137
|
+
| LOW | Report | Auto (if Beta+) | Auto (if Beta+) |
|
|
138
|
+
| MEDIUM | Report | Report + Recommend | Report + Recommend |
|
|
139
|
+
| HIGH | Report | Report + Warning | Report + Warning |
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Step 5: Generate Upgrade Recommendations or Auto-Apply
|
|
143
|
+
|
|
144
|
+
**For auto-eligible improvements (LOW risk, high impact, Beta+ source):**
|
|
145
|
+
|
|
146
|
+
1. Apply the change to the target template
|
|
147
|
+
2. Record the change in a changelog entry
|
|
148
|
+
3. Mark the source artifact as "feedback-applied" in the manifest
|
|
149
|
+
|
|
150
|
+
**For non-auto-eligible improvements:**
|
|
151
|
+
|
|
152
|
+
1. Generate a recommendation report with full context
|
|
153
|
+
2. Include before/after comparison
|
|
154
|
+
3. Include rollback instructions
|
|
155
|
+
4. Present to user for approval
|
|
156
|
+
|
|
157
|
+
**Maturity Promotions:**
|
|
158
|
+
|
|
159
|
+
When a harvested artifact has been used as a template improvement AND the resulting
|
|
160
|
+
generated toolkits work well in subsequent projects, promote the source artifact:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
IF artifact.maturity == Alpha AND artifact.used_in_projects >= 2:
|
|
164
|
+
PROMOTE to Beta
|
|
165
|
+
IF artifact.maturity == Beta AND artifact.used_in_projects >= 3:
|
|
166
|
+
PROMOTE to Stable
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Record promotions in the harvest feedback report.
|
|
170
|
+
|
|
171
|
+
## Output
|
|
172
|
+
|
|
173
|
+
### 1. Template Improvement Proposals
|
|
174
|
+
|
|
175
|
+
```markdown
|
|
176
|
+
# Harvest Feedback Report: {{PROJECT_NAME}}
|
|
177
|
+
Date: {{DATE}}
|
|
178
|
+
Source: {{HARVEST_REPORT_PATH}}
|
|
179
|
+
|
|
180
|
+
## Summary
|
|
181
|
+
| Metric | Value |
|
|
182
|
+
|--------|-------|
|
|
183
|
+
| Harvest reports scanned | {{N}} |
|
|
184
|
+
| Artifacts analyzed | {{M}} |
|
|
185
|
+
| Improvements identified | {{K}} |
|
|
186
|
+
| Auto-applied | {{A}} |
|
|
187
|
+
| Pending approval | {{P}} |
|
|
188
|
+
| Maturity promotions | {{R}} |
|
|
189
|
+
|
|
190
|
+
## Auto-Applied Upgrades
|
|
191
|
+
|
|
192
|
+
| # | Improvement | Type | Target Template | Impact | Source Artifact |
|
|
193
|
+
|---|-------------|------|-----------------|--------|-----------------|
|
|
194
|
+
| 1 | {{NAME}} | {{TYPE}} | {{TEMPLATE}} | {{SCORE}}/10 | {{ARTIFACT}} ({{MATURITY}}) |
|
|
195
|
+
|
|
196
|
+
## Pending Approval
|
|
197
|
+
|
|
198
|
+
| # | Improvement | Type | Target Template | Impact | Risk | Source Artifact |
|
|
199
|
+
|---|-------------|------|-----------------|--------|------|-----------------|
|
|
200
|
+
| 1 | {{NAME}} | {{TYPE}} | {{TEMPLATE}} | {{SCORE}}/10 | {{RISK}} | {{ARTIFACT}} ({{MATURITY}}) |
|
|
201
|
+
|
|
202
|
+
## Maturity Promotions
|
|
203
|
+
|
|
204
|
+
| Artifact | From | To | Reason |
|
|
205
|
+
|----------|------|----|--------|
|
|
206
|
+
| {{NAME}} | {{OLD_LEVEL}} | {{NEW_LEVEL}} | {{REASON}} |
|
|
207
|
+
|
|
208
|
+
## Skipped (No Match or Low Impact)
|
|
209
|
+
|
|
210
|
+
| Artifact | Reason |
|
|
211
|
+
|----------|--------|
|
|
212
|
+
| {{NAME}} | {{REASON}} |
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 2. Updated Templates (if auto-applied)
|
|
216
|
+
|
|
217
|
+
Modified template files with changelog entries appended:
|
|
218
|
+
|
|
219
|
+
```markdown
|
|
220
|
+
<!-- Harvest Feedback: {{DATE}} -->
|
|
221
|
+
<!-- Source: {{ARTIFACT_NAME}} from {{PROJECT_NAME}} -->
|
|
222
|
+
<!-- Change: {{DESCRIPTION}} -->
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 3. Updated Manifest
|
|
226
|
+
|
|
227
|
+
Updated `.claude/toolkit-manifest.json` with:
|
|
228
|
+
- `feedback_applied: true` on source artifacts
|
|
229
|
+
- Updated maturity levels for promoted artifacts
|
|
230
|
+
- `last_feedback_scan` timestamp
|
|
231
|
+
|
|
232
|
+
## Quality Gate
|
|
233
|
+
|
|
234
|
+
| Check | Threshold | Blocking? |
|
|
235
|
+
|-------|-----------|-----------|
|
|
236
|
+
| No breaking changes to existing templates | 0 breaking changes | YES |
|
|
237
|
+
| All auto-applied improvements scored >= 7/10 impact | Minimum 7 | YES |
|
|
238
|
+
| All auto-applied source artifacts >= Beta maturity | Minimum Beta | YES |
|
|
239
|
+
| Improvement proposals have before/after comparison | Must exist | YES |
|
|
240
|
+
| No duplicate improvements (already applied) | 0 duplicates | YES |
|
|
241
|
+
| Rollback instructions for non-trivial changes | Must exist for MEDIUM+ risk | YES |
|
|
242
|
+
| Maturity promotions follow promotion criteria | All criteria met | YES |
|
|
243
|
+
|
|
244
|
+
**Validation Command:**
|
|
245
|
+
```
|
|
246
|
+
FOR each auto_applied_change:
|
|
247
|
+
VERIFY original_template still passes Master Validation Checklist
|
|
248
|
+
VERIFY change is additive (no removed functionality)
|
|
249
|
+
VERIFY change has changelog entry
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Dependencies
|
|
253
|
+
|
|
254
|
+
| Dependency | Purpose | Fallback |
|
|
255
|
+
|------------|---------|----------|
|
|
256
|
+
| `view() knowledge-extractor/SKILL.md` | Understand harvest report format and artifact categories | Parse reports heuristically from markdown structure |
|
|
257
|
+
| `view() knowledge-extractor/references/maturity-model.md` | Maturity level definitions and promotion criteria | Use inline maturity table (Alpha/Beta/Stable/Proven) |
|
|
258
|
+
| `view() cc-toolkit-generator-enhanced/SKILL.md` | Current template structure and generation rules | Scan `references/templates/` directory directly |
|
|
259
|
+
|
|
260
|
+
## Reusability
|
|
261
|
+
|
|
262
|
+
This module implements the **Harvest-Improve-Generate** feedback loop pattern, which is
|
|
263
|
+
universal for any AI-assisted development pipeline:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
[Project Execution] → [Knowledge Extraction] → [Template Improvement] → [Better Generation]
|
|
267
|
+
↑ |
|
|
268
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Reuse scenarios:**
|
|
272
|
+
- Any toolkit that generates from templates can use this feedback loop
|
|
273
|
+
- CI/CD template generators (improve pipeline templates from production incidents)
|
|
274
|
+
- Documentation generators (improve doc templates from user feedback)
|
|
275
|
+
- Code scaffolders (improve scaffolds from real-world project structures)
|
|
276
|
+
- AI prompt libraries (improve prompts from output quality assessments)
|
|
277
|
+
|
|
278
|
+
**To adapt for a different pipeline:**
|
|
279
|
+
1. Replace the "Generator Template Mapping" table with your pipeline's template structure
|
|
280
|
+
2. Replace the "Matching Algorithm" with your category-to-template mapping
|
|
281
|
+
3. Keep the scoring system, auto-apply matrix, and quality gate unchanged
|
|
282
|
+
4. Keep the maturity promotion logic unchanged (it references the universal maturity model)
|
|
283
|
+
|
|
284
|
+
**Key design decision:** This module never modifies templates destructively. All changes
|
|
285
|
+
are additive (new defaults, new rules, updated recommendations). Breaking changes require
|
|
286
|
+
explicit user approval and are never auto-applied.
|
package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/08-skill-composition.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# Module: Skill Composition
|
|
2
|
+
|
|
3
|
+
Centralized logic for copying skills into generated projects, resolving dependencies,
|
|
4
|
+
rewriting view() paths, verifying skill integrity, and producing a skill manifest.
|
|
5
|
+
This module is used by the toolkit generator whenever skills need to be bundled into
|
|
6
|
+
a target project.
|
|
7
|
+
|
|
8
|
+
## Input
|
|
9
|
+
|
|
10
|
+
| Parameter | Type | Description | Required |
|
|
11
|
+
|-----------|------|-------------|----------|
|
|
12
|
+
| `required_skills` | List[string] | Skill names that the target project needs (e.g., `["explore", "sparc-prd-mini", "goap-research-ed25519"]`) | YES |
|
|
13
|
+
| `target_project_path` | Path | Absolute path to the target project root | YES |
|
|
14
|
+
| `skill_source_registry` | Path | Path to the skill source directory (default: `.claude/skills/` in template repo) | YES |
|
|
15
|
+
| `path_rewrite_rules` | Map | Custom path rewriting overrides (optional, uses defaults if not provided) | NO |
|
|
16
|
+
| `verify_integrity` | Boolean | Whether to run integrity checks on copied skills (default: `true`) | NO |
|
|
17
|
+
|
|
18
|
+
## Process
|
|
19
|
+
|
|
20
|
+
### Step 1: Build Dependency Graph
|
|
21
|
+
|
|
22
|
+
For each skill in `required_skills`, scan its `SKILL.md` for dependencies:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
FOR each skill_name IN required_skills:
|
|
26
|
+
1. READ {{skill_source_registry}}/{{skill_name}}/SKILL.md
|
|
27
|
+
2. EXTRACT dependency declarations:
|
|
28
|
+
- view() references to other skills
|
|
29
|
+
- "Dependencies" or "External Dependencies" sections
|
|
30
|
+
- Fallback declarations (optional dependencies)
|
|
31
|
+
3. CLASSIFY each dependency:
|
|
32
|
+
- REQUIRED: skill will not function without it
|
|
33
|
+
- OPTIONAL: skill has a fallback if missing
|
|
34
|
+
4. ADD to dependency graph as node with edges
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Dependency Detection Patterns:**
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
# Pattern 1: view() references in SKILL.md
|
|
41
|
+
view() knowledge-extractor/references/maturity-model.md
|
|
42
|
+
→ dependency on skill: knowledge-extractor
|
|
43
|
+
|
|
44
|
+
# Pattern 2: Explicit dependency table
|
|
45
|
+
| Skill | When Used | Purpose |
|
|
46
|
+
|-------|-----------|---------|
|
|
47
|
+
| explore | Phase 1 | Clarify scope |
|
|
48
|
+
→ dependency on skill: explore
|
|
49
|
+
|
|
50
|
+
# Pattern 3: Module cross-references
|
|
51
|
+
Read module: modules/01-agent-review.md
|
|
52
|
+
→ internal reference (not a cross-skill dependency)
|
|
53
|
+
|
|
54
|
+
# Pattern 4: Fallback declarations
|
|
55
|
+
- `explore` unavailable → built-in 3 clarification questions
|
|
56
|
+
→ OPTIONAL dependency on skill: explore
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Step 2: Resolve Transitive Dependencies
|
|
60
|
+
|
|
61
|
+
Expand the dependency graph to include all transitive dependencies:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
FUNCTION resolve_transitive(skill_name, visited=set()):
|
|
65
|
+
IF skill_name IN visited:
|
|
66
|
+
RETURN # Circular dependency detected
|
|
67
|
+
visited.add(skill_name)
|
|
68
|
+
|
|
69
|
+
FOR each dep IN dependencies_of(skill_name):
|
|
70
|
+
IF dep NOT IN required_skills:
|
|
71
|
+
required_skills.append(dep)
|
|
72
|
+
resolve_transitive(dep, visited)
|
|
73
|
+
|
|
74
|
+
FOR each skill_name IN required_skills (copy):
|
|
75
|
+
resolve_transitive(skill_name)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Output: Resolved Skills List**
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
## Resolved Skills
|
|
82
|
+
|
|
83
|
+
### Explicitly Required
|
|
84
|
+
| Skill | Requested By |
|
|
85
|
+
|-------|-------------|
|
|
86
|
+
| sparc-prd-mini | toolkit generator P0 |
|
|
87
|
+
| explore | toolkit generator P0 |
|
|
88
|
+
|
|
89
|
+
### Transitive Dependencies
|
|
90
|
+
| Skill | Required By | Dependency Type |
|
|
91
|
+
|-------|------------|-----------------|
|
|
92
|
+
| goap-research-ed25519 | sparc-prd-mini | OPTIONAL |
|
|
93
|
+
| problem-solver-enhanced | sparc-prd-mini | OPTIONAL |
|
|
94
|
+
|
|
95
|
+
### Total: {{N}} skills to copy
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Step 3: Detect Circular Dependencies
|
|
99
|
+
|
|
100
|
+
Before copying, verify no circular dependency chains exist:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
FUNCTION detect_cycles(graph):
|
|
104
|
+
FOR each node IN graph:
|
|
105
|
+
IF depth_first_search(node) finds back_edge:
|
|
106
|
+
REPORT circular dependency: {{node}} → ... → {{node}}
|
|
107
|
+
FAIL with error
|
|
108
|
+
|
|
109
|
+
# Example cycle (would be caught):
|
|
110
|
+
# skill-A → skill-B → skill-C → skill-A
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If a cycle is detected, report the full chain and halt. Circular dependencies
|
|
114
|
+
indicate a design problem that must be resolved before copying.
|
|
115
|
+
|
|
116
|
+
### Step 4: Copy Skill Directories
|
|
117
|
+
|
|
118
|
+
Copy each skill directory from source to target with integrity verification:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
FOR each skill_name IN resolved_skills_list:
|
|
122
|
+
source = {{skill_source_registry}}/{{skill_name}}/
|
|
123
|
+
target = {{target_project_path}}/.claude/skills/{{skill_name}}/
|
|
124
|
+
|
|
125
|
+
1. VERIFY source directory exists
|
|
126
|
+
2. VERIFY SKILL.md exists in source (minimum required file)
|
|
127
|
+
3. COPY entire directory tree: source → target
|
|
128
|
+
4. VERIFY all files copied (compare file counts)
|
|
129
|
+
5. VERIFY SKILL.md readable in target
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Required Files per Skill:**
|
|
133
|
+
|
|
134
|
+
| File | Required? | Purpose |
|
|
135
|
+
|------|-----------|---------|
|
|
136
|
+
| `SKILL.md` | YES | Skill definition and orchestration |
|
|
137
|
+
| `references/` | NO | Supporting documentation |
|
|
138
|
+
| `templates/` | NO | Output templates |
|
|
139
|
+
| `modules/` | NO | Modular sub-processes |
|
|
140
|
+
| `examples/` | NO | Usage examples |
|
|
141
|
+
|
|
142
|
+
**Copy Protocol:**
|
|
143
|
+
- Preserve directory structure exactly
|
|
144
|
+
- Preserve file permissions
|
|
145
|
+
- Do NOT modify file contents during copy (path rewriting is a separate step)
|
|
146
|
+
- Skip `.git`, `node_modules`, `__pycache__`, and other build artifacts
|
|
147
|
+
|
|
148
|
+
### Step 5: Rewrite view() Paths
|
|
149
|
+
|
|
150
|
+
After copying, rewrite all path references in the copied skills to match the target
|
|
151
|
+
project structure:
|
|
152
|
+
|
|
153
|
+
**Default Path Rewriting Rules:**
|
|
154
|
+
|
|
155
|
+
| Source Pattern | Target Pattern | Context |
|
|
156
|
+
|----------------|----------------|---------|
|
|
157
|
+
| `/mnt/skills/user/{{SKILL_NAME}}/` | `.claude/skills/{{SKILL_NAME}}/` | claude.ai skill paths to Claude Code local paths |
|
|
158
|
+
| `/mnt/user-data/uploads/` | `docs/` | claude.ai uploads directory to project docs |
|
|
159
|
+
| `/output/` | `docs/` or project root | claude.ai output directory to project output |
|
|
160
|
+
| `view() {{SKILL_NAME}}/` | `view() .claude/skills/{{SKILL_NAME}}/` | Relative skill references |
|
|
161
|
+
|
|
162
|
+
**Rewrite Algorithm:**
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
FOR each copied_file IN target_skill_directory:
|
|
166
|
+
IF file is markdown (.md) or text:
|
|
167
|
+
content = READ(copied_file)
|
|
168
|
+
|
|
169
|
+
# Rule 1: Absolute claude.ai skill paths
|
|
170
|
+
content = REPLACE_ALL(
|
|
171
|
+
/\/mnt\/skills\/user\/([a-zA-Z0-9_-]+)\//g,
|
|
172
|
+
'.claude/skills/$1/'
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
# Rule 2: Upload directory references
|
|
176
|
+
content = REPLACE_ALL(
|
|
177
|
+
/\/mnt\/user-data\/uploads\//g,
|
|
178
|
+
'docs/'
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# Rule 3: Output directory references
|
|
182
|
+
content = REPLACE_ALL(
|
|
183
|
+
/\/output\//g,
|
|
184
|
+
'docs/'
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Rule 4: Skill name aliases (known mappings)
|
|
188
|
+
content = REPLACE_ALL(
|
|
189
|
+
'goap-research/',
|
|
190
|
+
'goap-research-ed25519/'
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
# Rule 5: Custom rewrite rules (from input parameter)
|
|
194
|
+
FOR each rule IN path_rewrite_rules:
|
|
195
|
+
content = REPLACE_ALL(rule.pattern, rule.replacement)
|
|
196
|
+
|
|
197
|
+
WRITE(copied_file, content)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Path Rewriting Examples:**
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
# Before (claude.ai format):
|
|
204
|
+
Read `/mnt/skills/user/explore/SKILL.md` for clarification protocol.
|
|
205
|
+
Scan `/mnt/user-data/uploads/` for documents.
|
|
206
|
+
Write output to `/output/validation-report.md`.
|
|
207
|
+
|
|
208
|
+
# After (Claude Code local format):
|
|
209
|
+
Read `.claude/skills/explore/SKILL.md` for clarification protocol.
|
|
210
|
+
Scan `docs/` for documents.
|
|
211
|
+
Write output to `docs/validation-report.md`.
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Step 6: Generate Skill Manifest
|
|
215
|
+
|
|
216
|
+
Create a `skills.json` manifest in the target project:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"generated": "{{DATE}}",
|
|
221
|
+
"generator": "cc-toolkit-generator-enhanced",
|
|
222
|
+
"generator_version": "{{VERSION}}",
|
|
223
|
+
"skill_count": {{N}},
|
|
224
|
+
"skills": [
|
|
225
|
+
{
|
|
226
|
+
"name": "{{SKILL_NAME}}",
|
|
227
|
+
"path": ".claude/skills/{{SKILL_NAME}}/",
|
|
228
|
+
"source": "{{SKILL_SOURCE_REGISTRY}}",
|
|
229
|
+
"copied_at": "{{DATE}}",
|
|
230
|
+
"files": ["SKILL.md", "references/", "templates/"],
|
|
231
|
+
"dependencies": {
|
|
232
|
+
"required": ["{{DEP_1}}", "{{DEP_2}}"],
|
|
233
|
+
"optional": ["{{DEP_3}}"]
|
|
234
|
+
},
|
|
235
|
+
"paths_rewritten": {{COUNT}},
|
|
236
|
+
"integrity": "PASS"
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"dependency_graph": {
|
|
240
|
+
"{{SKILL_A}}": ["{{SKILL_B}}", "{{SKILL_C}}"],
|
|
241
|
+
"{{SKILL_B}}": [],
|
|
242
|
+
"{{SKILL_C}}": ["{{SKILL_B}}"]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Manifest location:** `{{target_project_path}}/.claude/skills/skills.json`
|
|
248
|
+
|
|
249
|
+
### Step 7: Produce Health Check Report
|
|
250
|
+
|
|
251
|
+
Run a health check to verify the composed skill set is functional:
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
## Skill Health Check
|
|
255
|
+
|
|
256
|
+
Date: {{DATE}}
|
|
257
|
+
Target: {{TARGET_PROJECT_PATH}}
|
|
258
|
+
|
|
259
|
+
### Dependency Resolution
|
|
260
|
+
| Check | Status |
|
|
261
|
+
|-------|--------|
|
|
262
|
+
| All required dependencies present | PASS / FAIL |
|
|
263
|
+
| No circular dependencies | PASS / FAIL |
|
|
264
|
+
| All optional dependencies noted | PASS / FAIL |
|
|
265
|
+
|
|
266
|
+
### File Integrity
|
|
267
|
+
| Skill | SKILL.md | References | Templates | Modules | Status |
|
|
268
|
+
|-------|----------|------------|-----------|---------|--------|
|
|
269
|
+
| {{NAME}} | PRESENT | {{N}} files | {{M}} files | {{K}} files | PASS |
|
|
270
|
+
|
|
271
|
+
### Path Rewriting
|
|
272
|
+
| Skill | Rewrites Applied | Unresolved Paths | Status |
|
|
273
|
+
|-------|-----------------|------------------|--------|
|
|
274
|
+
| {{NAME}} | {{N}} | {{M}} | PASS / WARN |
|
|
275
|
+
|
|
276
|
+
### Cross-Skill References
|
|
277
|
+
| Source Skill | References | Target Skill | Resolvable | Status |
|
|
278
|
+
|-------------|------------|--------------|------------|--------|
|
|
279
|
+
| {{A}} | view() | {{B}} | YES / NO | PASS / FAIL |
|
|
280
|
+
|
|
281
|
+
### Overall: {{PASS / FAIL}}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Unresolved Path Detection:**
|
|
285
|
+
|
|
286
|
+
After rewriting, scan all copied files for remaining `/mnt/` references
|
|
287
|
+
or other patterns that suggest an incomplete rewrite:
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
GREP -r '/mnt/' {{target_skill_directory}}
|
|
291
|
+
GREP -r 'view() [a-z]' {{target_skill_directory}} # relative view() without .claude/
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Any matches are warnings (not blocking, but reported).
|
|
295
|
+
|
|
296
|
+
## Output
|
|
297
|
+
|
|
298
|
+
| Artifact | Location | Description |
|
|
299
|
+
|----------|----------|-------------|
|
|
300
|
+
| Copied skill directories | `{{TARGET}}/.claude/skills/{{NAME}}/` | Complete skill trees with rewritten paths |
|
|
301
|
+
| Skill manifest | `{{TARGET}}/.claude/skills/skills.json` | Machine-readable dependency and integrity data |
|
|
302
|
+
| Health check report | Inline in generation output | Human-readable verification summary |
|
|
303
|
+
| Resolved dependency list | Part of manifest | Full transitive dependency tree |
|
|
304
|
+
|
|
305
|
+
## Quality Gate
|
|
306
|
+
|
|
307
|
+
| Check | Threshold | Blocking? |
|
|
308
|
+
|-------|-----------|-----------|
|
|
309
|
+
| Zero circular dependencies | 0 cycles | YES |
|
|
310
|
+
| All view() paths resolve to existing files | 100% resolution | YES |
|
|
311
|
+
| All required SKILL.md files present | 100% present | YES |
|
|
312
|
+
| No remaining `/mnt/` paths after rewrite | 0 remaining | YES (warning if non-zero) |
|
|
313
|
+
| skills.json is valid JSON | Parseable | YES |
|
|
314
|
+
| Every skill has at least SKILL.md | Minimum 1 file | YES |
|
|
315
|
+
| All required dependencies included in copy list | 100% included | YES |
|
|
316
|
+
| Optional dependencies documented (even if absent) | All noted | NO (warning) |
|
|
317
|
+
| File count matches source (no missing files) | Source count == target count | YES |
|
|
318
|
+
|
|
319
|
+
**Quick Validation Command:**
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
# Verify all skills have SKILL.md
|
|
323
|
+
FOR each dir IN {{TARGET}}/.claude/skills/*/
|
|
324
|
+
ASSERT exists(dir/SKILL.md)
|
|
325
|
+
|
|
326
|
+
# Verify no stale paths
|
|
327
|
+
GREP -r '/mnt/skills/user/' {{TARGET}}/.claude/skills/ → expect 0 matches
|
|
328
|
+
GREP -r '/mnt/user-data/' {{TARGET}}/.claude/skills/ → expect 0 matches
|
|
329
|
+
|
|
330
|
+
# Verify manifest
|
|
331
|
+
JSON_VALIDATE {{TARGET}}/.claude/skills/skills.json
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Dependencies
|
|
335
|
+
|
|
336
|
+
This module has **no external skill dependencies**. It operates purely on the
|
|
337
|
+
filesystem and the skill source registry.
|
|
338
|
+
|
|
339
|
+
| Dependency | Type | Purpose |
|
|
340
|
+
|------------|------|---------|
|
|
341
|
+
| Filesystem access | System | Read source skills, write to target |
|
|
342
|
+
| Skill source registry | Input | Directory containing source skill definitions |
|
|
343
|
+
| JSON serialization | System | Generate skills.json manifest |
|
|
344
|
+
|
|
345
|
+
## Reusability
|
|
346
|
+
|
|
347
|
+
This is a **critical infrastructure module** that should be extracted and reused by
|
|
348
|
+
any system that copies, composes, or distributes Claude Code skills.
|
|
349
|
+
|
|
350
|
+
**Reuse scenarios:**
|
|
351
|
+
|
|
352
|
+
| Scenario | How This Module Helps |
|
|
353
|
+
|----------|----------------------|
|
|
354
|
+
| Plugin installers (install.sh) | Use Steps 1-5 for safe skill installation |
|
|
355
|
+
| Template repositories | Use Steps 4-6 for skill bundling during fork/clone |
|
|
356
|
+
| Skill marketplace / registry | Use Steps 1-3 for dependency resolution |
|
|
357
|
+
| CI/CD skill validation | Use Step 7 for automated skill health checks |
|
|
358
|
+
| Cross-project skill sharing | Use Steps 4-5 for portable skill transfer |
|
|
359
|
+
|
|
360
|
+
**Extraction as standalone utility:**
|
|
361
|
+
|
|
362
|
+
This module can be extracted into a standalone skill or CLI tool:
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
skill-composer/
|
|
366
|
+
├── SKILL.md # This module's logic as a skill
|
|
367
|
+
├── references/
|
|
368
|
+
│ └── path-rules.md # Default path rewriting rules
|
|
369
|
+
└── templates/
|
|
370
|
+
└── skills.json # Manifest template
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Key design decisions:**
|
|
374
|
+
- Path rewriting is rule-based (regex), not heuristic, ensuring deterministic behavior
|
|
375
|
+
- Integrity verification happens AFTER copy, not during, for simplicity
|
|
376
|
+
- The manifest is JSON (machine-readable) for downstream tooling integration
|
|
377
|
+
- Health check is a separate step so it can be run independently of copying
|
|
378
|
+
- Circular dependency detection happens BEFORE copying to fail fast
|