@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,342 @@
1
+ # Artifact Categories Reference
2
+
3
+ Detailed criteria for classifying extracted knowledge into 7 toolkit categories.
4
+
5
+ ---
6
+
7
+ ## Category 1: Skills
8
+
9
+ **Directory:** `skills/[name]/SKILL.md`
10
+
11
+ **What belongs:**
12
+ - New techniques or improved approaches to common tasks
13
+ - Multi-step workflows that can be reused across projects
14
+ - AI-assisted capabilities (Claude Code skill definitions)
15
+
16
+ **Criteria:**
17
+ - Involves a multi-step process (not a single function)
18
+ - Has clear input → transformation → output
19
+ - Can be described with trigger patterns
20
+ - Benefits from documentation (when to use, anti-patterns)
21
+
22
+ **Structure:** Follow `pipeline-forge` skill anatomy
23
+ ```
24
+ skills/[name]/
25
+ ├── SKILL.md
26
+ ├── references/ (optional)
27
+ └── templates/ (optional)
28
+ ```
29
+
30
+ **Examples:**
31
+ - Better database migration technique
32
+ - API integration pattern with retry + circuit breaker
33
+ - Testing strategy for event-driven systems
34
+
35
+ **NOT a skill:** A single utility function (→ snippet), a config file (→ template)
36
+
37
+ ---
38
+
39
+ ## Category 2: Commands
40
+
41
+ **Directory:** `commands/[name].md`
42
+
43
+ **What belongs:**
44
+ - Slash commands for Claude Code
45
+ - CLI utilities that automate common dev tasks
46
+ - Build/deploy/test shortcuts
47
+
48
+ **Criteria:**
49
+ - Invoked explicitly by the user (not automatic)
50
+ - Has clear arguments and expected output
51
+ - Saves significant time on repetitive tasks
52
+ - Works across different projects (not project-specific)
53
+
54
+ **Structure:** Claude Code command format
55
+ ```markdown
56
+ ---
57
+ description: What the command does. $ARGUMENTS: what it expects.
58
+ ---
59
+
60
+ # /command-name $ARGUMENTS
61
+
62
+ ## Steps
63
+ 1. [step]
64
+ 2. [step]
65
+ ```
66
+
67
+ **Examples:**
68
+ - `/api-endpoint` generates CRUD for a resource
69
+ - `/db-migrate` runs migration with safety checks
70
+ - `/perf-check` profiles and reports performance
71
+
72
+ **NOT a command:** An automation trigger (→ hook), a file structure (→ template)
73
+
74
+ ---
75
+
76
+ ## Category 3: Hooks
77
+
78
+ **Directory:** `.claude/settings.json` or `.claude/hooks/`
79
+
80
+ **What belongs:**
81
+ - Pre-commit validation hooks
82
+ - Post-task automation (auto-format, auto-test)
83
+ - CI pipeline triggers
84
+ - Git hooks for quality gates
85
+ - Claude Code hooks (PreToolUse, PostToolUse, Stop)
86
+
87
+ **Criteria:**
88
+ - Triggered automatically (not manually invoked)
89
+ - Attached to a specific event (commit, merge, task completion)
90
+ - Enforces a quality standard or automates a chore
91
+ - Low overhead (runs fast, doesn't block workflow)
92
+
93
+ **Structure:**
94
+ ```json
95
+ {
96
+ "hooks": {
97
+ "EventName": [{
98
+ "matcher": "ToolName",
99
+ "command": "echo 'hook output'"
100
+ }]
101
+ }
102
+ }
103
+ ```
104
+
105
+ **Examples:**
106
+ - Auto-validate OpenAPI schema on save
107
+ - Run linter on pre-commit
108
+ - Remind about harvest on release tag
109
+ - Auto-commit insights on Stop
110
+
111
+ **NOT a hook:** A manual command (→ command), a constraint (→ rule)
112
+
113
+ ---
114
+
115
+ ## Category 4: Rules
116
+
117
+ **Directory:** `rules/[name].md`
118
+
119
+ **What belongs:**
120
+ - Constraints and limitations discovered empirically
121
+ - "Don't do X because Y" lessons
122
+ - Framework/language quirks worth remembering
123
+ - Security constraints
124
+ - Performance constraints
125
+ - AI (Claude Code) limitations and workarounds
126
+
127
+ **Criteria:**
128
+ - States a constraint, not a how-to
129
+ - Has a clear "because" (reason, not just assertion)
130
+ - Applies beyond the source project
131
+ - Saves future debugging time
132
+
133
+ **Structure:**
134
+ ```markdown
135
+ # Rule: [Short Name]
136
+
137
+ ## Rule
138
+ [Don't do X because Y]
139
+
140
+ ## Why
141
+ [Technical explanation]
142
+
143
+ ## Example (what goes wrong)
144
+ [Code or scenario]
145
+
146
+ ## Correct Approach
147
+ [What to do instead]
148
+
149
+ ## Scope
150
+ Universal | Language: [lang] | Framework: [fw]
151
+
152
+ ## Expiry
153
+ Permanent | Check after [condition]
154
+ ```
155
+
156
+ **Examples:**
157
+ - "Don't use nested generics >3 levels — Claude Code loses context"
158
+ - "Always use parameterized queries — never string concat for SQL"
159
+ - "Redis SCAN is O(N) — don't use for large keyspaces in hot path"
160
+
161
+ **NOT a rule:** A code pattern (→ pattern), an automation (→ hook)
162
+
163
+ ---
164
+
165
+ ## Category 5: Templates
166
+
167
+ **Directory:** `templates/[name]/` or standalone files
168
+
169
+ **What belongs:**
170
+ - Reusable file structures (Dockerfile, CI config, etc.)
171
+ - Project scaffold templates
172
+ - Configuration file templates
173
+ - Document templates (ADR, RFC, etc.)
174
+
175
+ **Criteria:**
176
+ - Has `{{PLACEHOLDERS}}` for project-specific values
177
+ - Works by filling in parameters, not rewriting
178
+ - Structure is more valuable than content
179
+ - Tested with at least one real project
180
+
181
+ **Structure:**
182
+ ```markdown
183
+ # Template: [Name]
184
+
185
+ ## Parameters
186
+ | Placeholder | Description | Default | Required |
187
+ |------------|-------------|---------|----------|
188
+ | {{NAME}} | [desc] | [default] | YES/NO |
189
+
190
+ ## Template Content
191
+ [the actual template with placeholders]
192
+
193
+ ## Usage
194
+ [how to use this template]
195
+ ```
196
+
197
+ **Examples:**
198
+ - Dockerfile for Node.js + PostgreSQL
199
+ - GitHub Actions CI/CD pipeline
200
+ - ADR (Architecture Decision Record) template
201
+ - docker-compose.yml for dev environment
202
+
203
+ **NOT a template:** Code logic (→ snippet/pattern), a process (→ skill)
204
+
205
+ ---
206
+
207
+ ## Category 6: Patterns
208
+
209
+ **Directory:** `patterns/[name].md` or `docs/patterns/`
210
+
211
+ **What belongs:**
212
+ - Architectural approaches documented as knowledge
213
+ - Design patterns adapted to specific contexts
214
+ - Integration patterns between systems
215
+ - Error handling strategies
216
+ - Data access patterns
217
+
218
+ **Criteria:**
219
+ - Describes an APPROACH, not specific code
220
+ - Has multiple valid implementations
221
+ - Includes trade-offs and when-to-use/when-not
222
+ - More than just a code snippet — includes reasoning
223
+
224
+ **Structure:**
225
+ ```markdown
226
+ # Pattern: [Name]
227
+
228
+ ## Intent
229
+ [What problem this pattern solves]
230
+
231
+ ## When to Use
232
+ [Conditions]
233
+
234
+ ## When NOT to Use
235
+ [Anti-conditions]
236
+
237
+ ## Structure
238
+ [Diagram or pseudocode]
239
+
240
+ ## Implementation Variants
241
+ ### Variant A: [context]
242
+ [implementation]
243
+
244
+ ### Variant B: [context]
245
+ [implementation]
246
+
247
+ ## Trade-offs
248
+ | Pro | Con |
249
+ |-----|-----|
250
+ | [+] | [-] |
251
+
252
+ ## Related Patterns
253
+ [links to complementary or alternative patterns]
254
+ ```
255
+
256
+ **Examples:**
257
+ - Rate limiting (in-memory vs. Redis-backed)
258
+ - Circuit breaker with fallback
259
+ - Event sourcing + CQRS
260
+ - Repository pattern with caching
261
+
262
+ **NOT a pattern:** Specific code (<50 lines → snippet), a constraint (→ rule)
263
+
264
+ ---
265
+
266
+ ## Category 7: Snippets
267
+
268
+ **Directory:** `snippets/[language]/[name].[ext]` or inline in docs
269
+
270
+ **What belongs:**
271
+ - Small, self-contained code fragments (<50 lines)
272
+ - Utility functions that solve common problems
273
+ - One-liners or short helpers
274
+ - Type definitions / interfaces that are universal
275
+
276
+ **Criteria:**
277
+ - Self-contained (works without project context)
278
+ - Under 50 lines of code
279
+ - Solves a common problem
280
+ - No domain-specific dependencies
281
+ - Can be copy-pasted and used immediately
282
+
283
+ **Structure:**
284
+ ```markdown
285
+ # Snippet: [Name]
286
+
287
+ **Language:** [lang]
288
+ **Lines:** [N]
289
+ **Dependencies:** None | [list]
290
+
291
+ ## Code
292
+ \`\`\`[lang]
293
+ [code]
294
+ \`\`\`
295
+
296
+ ## Usage
297
+ [how and when to use]
298
+ ```
299
+
300
+ **Examples:**
301
+ - Universal retry with exponential backoff
302
+ - Safe JSON parse with default
303
+ - Debounce/throttle function
304
+ - Type-safe environment variable reader
305
+
306
+ **NOT a snippet:** >50 lines (→ pattern), a process (→ skill), a config (→ template)
307
+
308
+ ---
309
+
310
+ ## Decision Flowchart
311
+
312
+ ```
313
+ Start with a finding
314
+
315
+ ├── Is it a multi-step process/workflow?
316
+ │ ├── YES → Skill or Command
317
+ │ │ ├── User-invoked? → Command
318
+ │ │ └── AI-assisted workflow? → Skill
319
+ │ └── NO ↓
320
+
321
+ ├── Is it triggered automatically?
322
+ │ ├── YES → Hook
323
+ │ └── NO ↓
324
+
325
+ ├── Is it a constraint / "don't do X"?
326
+ │ ├── YES → Rule
327
+ │ └── NO ↓
328
+
329
+ ├── Is it a file/config structure?
330
+ │ ├── YES → Template
331
+ │ └── NO ↓
332
+
333
+ ├── Is it <50 lines of executable code?
334
+ │ ├── YES → Snippet
335
+ │ └── NO ↓
336
+
337
+ ├── Is it an architectural approach?
338
+ │ ├── YES → Pattern
339
+ │ └── NO → Reconsider extraction
340
+
341
+ └── END
342
+ ```
@@ -0,0 +1,247 @@
1
+ # Decontextualization Guide
2
+
3
+ How to transform project-specific artifacts into universal, reusable toolkit entries.
4
+
5
+ ---
6
+
7
+ ## Core Principle
8
+
9
+ > **Decontextualization is NOT renaming variables. It's extracting the PRINCIPLE
10
+ > and providing an implementation that works in any context.**
11
+
12
+ The goal is to separate the **universal insight** from the **project-specific implementation**.
13
+
14
+ ---
15
+
16
+ ## The Decontextualization Checklist
17
+
18
+ For every artifact, verify each item before it enters the toolkit:
19
+
20
+ ### 1. Names & References
21
+ - [ ] No company/product names → replaced with `{{PROJECT_NAME}}` or generic
22
+ - [ ] No team member names → removed or replaced with roles
23
+ - [ ] No project-specific variable names → use descriptive generic names
24
+ - [ ] No internal URLs → removed or parameterized
25
+ - [ ] No specific database/table names → generic schema references
26
+
27
+ ### 2. Paths & Configuration
28
+ - [ ] No absolute paths → relative or `{{PROJECT_ROOT}}`
29
+ - [ ] No hardcoded ports → `{{PORT}}` or env variable
30
+ - [ ] No hardcoded API keys → `{{API_KEY}}` with note about secure storage
31
+ - [ ] No environment-specific configs → parameterized with defaults
32
+ - [ ] Config values documented in parameter table
33
+
34
+ ### 3. Dependencies
35
+ - [ ] External dependencies listed explicitly
36
+ - [ ] Version constraints documented
37
+ - [ ] Alternative libraries mentioned (if applicable)
38
+ - [ ] No implicit dependencies (things that "just work" because of project setup)
39
+
40
+ ### 4. Context
41
+ - [ ] Works without the original project's other modules
42
+ - [ ] Import/require statements are generic or documented
43
+ - [ ] No circular dependencies with project code
44
+ - [ ] Can be copy-pasted into new project and work (with documented setup)
45
+
46
+ ---
47
+
48
+ ## Decontextualization Techniques
49
+
50
+ ### Technique 1: Extract Interface
51
+
52
+ **Before:**
53
+ ```typescript
54
+ // Tightly coupled to UserService
55
+ function rateLimitMiddleware(userService: UserService) {
56
+ return (req: Request) => {
57
+ const user = userService.getUser(req.userId);
58
+ if (user.requestCount > user.plan.limit) {
59
+ throw new RateLimitError();
60
+ }
61
+ };
62
+ }
63
+ ```
64
+
65
+ **After:**
66
+ ```typescript
67
+ // Generic — works with any identity provider
68
+ interface RateLimitSubject {
69
+ id: string;
70
+ currentCount: number;
71
+ limit: number;
72
+ }
73
+
74
+ interface RateLimitProvider {
75
+ getSubject(requestId: string): Promise<RateLimitSubject>;
76
+ increment(subjectId: string): Promise<void>;
77
+ }
78
+
79
+ function rateLimitMiddleware(provider: RateLimitProvider) {
80
+ return async (req: Request) => {
81
+ const subject = await provider.getSubject(req.headers['x-subject-id']);
82
+ if (subject.currentCount >= subject.limit) {
83
+ throw new RateLimitError(subject.id, subject.limit);
84
+ }
85
+ await provider.increment(subject.id);
86
+ };
87
+ }
88
+ ```
89
+
90
+ **What changed:** Replaced concrete `UserService` with generic `RateLimitProvider` interface.
91
+
92
+ ### Technique 2: Parameterize
93
+
94
+ **Before:**
95
+ ```yaml
96
+ # docker-compose.yml for the e-commerce project
97
+ services:
98
+ api:
99
+ build: ./backend
100
+ ports:
101
+ - "3000:3000"
102
+ environment:
103
+ DATABASE_URL: postgres://ecommerce:secret@db:5432/ecommerce_dev
104
+ db:
105
+ image: postgres:15
106
+ environment:
107
+ POSTGRES_DB: ecommerce_dev
108
+ POSTGRES_PASSWORD: secret
109
+ ```
110
+
111
+ **After:**
112
+ ```yaml
113
+ # Template: Node.js + PostgreSQL Docker Compose
114
+ # Parameters: {{SERVICE_NAME}}, {{PORT}}, {{DB_NAME}}, {{DB_PASSWORD}}
115
+ services:
116
+ {{SERVICE_NAME}}:
117
+ build: ./backend
118
+ ports:
119
+ - "${PORT:-3000}:${PORT:-3000}"
120
+ environment:
121
+ DATABASE_URL: postgres://${DB_USER:-app}:${DB_PASSWORD}@db:5432/${DB_NAME}
122
+ db:
123
+ image: postgres:${POSTGRES_VERSION:-15}
124
+ environment:
125
+ POSTGRES_DB: ${DB_NAME}
126
+ POSTGRES_PASSWORD: ${DB_PASSWORD}
127
+ ```
128
+
129
+ **What changed:** All project-specific values → environment variables with defaults.
130
+
131
+ ### Technique 3: Document the Principle
132
+
133
+ **Before (code comment in project):**
134
+ ```
135
+ // HACK: Don't use Promise.all for Stripe API calls — it triggers rate limit
136
+ ```
137
+
138
+ **After (toolkit rule):**
139
+ ```markdown
140
+ # Rule: Sequential External API Calls for Rate-Limited Services
141
+
142
+ ## Rule
143
+ When calling rate-limited external APIs (Stripe, Twilio, etc.),
144
+ use sequential execution instead of Promise.all/parallel.
145
+
146
+ ## Why
147
+ Rate-limited APIs count requests per time window. Parallel requests
148
+ arrive simultaneously and exceed the limit, causing failures that
149
+ are hard to debug (they appear intermittent).
150
+
151
+ ## Example (what goes wrong)
152
+ \`\`\`typescript
153
+ // ❌ BAD — triggers rate limit
154
+ const results = await Promise.all(
155
+ items.map(item => stripeApi.createCharge(item))
156
+ );
157
+ // Error: Rate limit exceeded (429) — but only sometimes!
158
+ \`\`\`
159
+
160
+ ## Correct Approach
161
+ \`\`\`typescript
162
+ // ✅ GOOD — respects rate limits
163
+ const results = [];
164
+ for (const item of items) {
165
+ results.push(await externalApi.call(item));
166
+ // Optional: add small delay for strict rate limits
167
+ }
168
+ \`\`\`
169
+
170
+ ## Scope
171
+ Universal — applies to any rate-limited external API
172
+
173
+ ## Variants
174
+ - With retry + backoff for transient failures
175
+ - With queue for high-volume scenarios
176
+ - With batch endpoint if API supports it
177
+ ```
178
+
179
+ **What changed:** Specific Stripe hack → universal rule about rate-limited APIs.
180
+
181
+ ### Technique 4: Provide Variants
182
+
183
+ When the original implementation is language/framework-specific,
184
+ provide multiple variants:
185
+
186
+ ```markdown
187
+ # Pattern: Retry with Exponential Backoff
188
+
189
+ ## Variant A: TypeScript (Node.js)
190
+ \`\`\`typescript
191
+ async function retry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
192
+ for (let i = 0; i < maxRetries; i++) {
193
+ try { return await fn(); }
194
+ catch (e) {
195
+ if (i === maxRetries - 1) throw e;
196
+ await sleep(Math.pow(2, i) * 1000);
197
+ }
198
+ }
199
+ throw new Error('unreachable');
200
+ }
201
+ \`\`\`
202
+
203
+ ## Variant B: Python
204
+ \`\`\`python
205
+ async def retry(fn, max_retries=3):
206
+ for i in range(max_retries):
207
+ try: return await fn()
208
+ except Exception as e:
209
+ if i == max_retries - 1: raise
210
+ await asyncio.sleep(2 ** i)
211
+ \`\`\`
212
+
213
+ ## Variant C: Rust
214
+ \`\`\`rust
215
+ async fn retry<F, T, E>(f: F, max_retries: u32) -> Result<T, E>
216
+ where F: Fn() -> Pin<Box<dyn Future<Output = Result<T, E>>>> {
217
+ // ...
218
+ }
219
+ \`\`\`
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Red Flags (Incomplete Decontextualization)
225
+
226
+ | Red Flag | Problem | Fix |
227
+ |----------|---------|-----|
228
+ | `import { UserModel } from '../models'` | Project-specific import | Use interface/generic |
229
+ | `const API_URL = 'https://api.mycompany.com'` | Hardcoded URL | Use env variable |
230
+ | `// Works because we use Express 4.x` | Implicit dependency | Document explicitly |
231
+ | Function name `handleStripeWebhook` | Too specific | Rename to `handleWebhook` |
232
+ | `config.ecommerceSettings.taxRate` | Domain-specific config | Extract to parameters |
233
+ | Only works with PostgreSQL | Missing variants | Add alternative DB support |
234
+
235
+ ---
236
+
237
+ ## Decontextualization by Category
238
+
239
+ | Category | Key Focus |
240
+ |----------|-----------|
241
+ | **Skills** | Remove domain context, keep methodology |
242
+ | **Commands** | Parameterize paths and args, document tool deps |
243
+ | **Hooks** | Make trigger event configurable |
244
+ | **Rules** | State universal principle, not project symptom |
245
+ | **Templates** | Replace ALL hardcoded values with `{{PLACEHOLDERS}}` |
246
+ | **Patterns** | Describe the APPROACH with multiple implementations |
247
+ | **Snippets** | Ensure standalone execution, document dependencies |