cfsa-antigravity 2.0.0 → 2.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.
Files changed (99) hide show
  1. package/README.md +14 -0
  2. package/package.json +1 -1
  3. package/template/.agent/instructions/commands.md +8 -32
  4. package/template/.agent/instructions/patterns.md +3 -3
  5. package/template/.agent/instructions/tech-stack.md +71 -23
  6. package/template/.agent/instructions/workflow.md +12 -1
  7. package/template/.agent/rules/completion-checklist.md +6 -0
  8. package/template/.agent/rules/security-first.md +3 -3
  9. package/template/.agent/rules/vertical-slices.md +1 -1
  10. package/template/.agent/skill-library/MANIFEST.md +6 -0
  11. package/template/.agent/skill-library/stack/devops/git-advanced/SKILL.md +972 -0
  12. package/template/.agent/skill-library/stack/devops/git-workflow/SKILL.md +420 -0
  13. package/template/.agent/skills/api-versioning/SKILL.md +44 -298
  14. package/template/.agent/skills/api-versioning/references/typescript.md +157 -0
  15. package/template/.agent/skills/architecture-mapping/SKILL.md +7 -7
  16. package/template/.agent/skills/bootstrap-agents/SKILL.md +151 -152
  17. package/template/.agent/skills/clean-code/SKILL.md +64 -118
  18. package/template/.agent/skills/clean-code/references/typescript.md +126 -0
  19. package/template/.agent/skills/database-schema-design/SKILL.md +93 -317
  20. package/template/.agent/skills/database-schema-design/references/relational.md +228 -0
  21. package/template/.agent/skills/error-handling-patterns/SKILL.md +62 -557
  22. package/template/.agent/skills/error-handling-patterns/references/go.md +162 -0
  23. package/template/.agent/skills/error-handling-patterns/references/python.md +262 -0
  24. package/template/.agent/skills/error-handling-patterns/references/rust.md +112 -0
  25. package/template/.agent/skills/error-handling-patterns/references/typescript.md +178 -0
  26. package/template/.agent/skills/idea-extraction/SKILL.md +119 -12
  27. package/template/.agent/skills/logging-best-practices/SKILL.md +108 -767
  28. package/template/.agent/skills/logging-best-practices/references/go.md +49 -0
  29. package/template/.agent/skills/logging-best-practices/references/python.md +52 -0
  30. package/template/.agent/skills/logging-best-practices/references/typescript.md +215 -0
  31. package/template/.agent/skills/migration-management/SKILL.md +127 -311
  32. package/template/.agent/skills/migration-management/references/relational.md +214 -0
  33. package/template/.agent/skills/parallel-feature-development/SKILL.md +34 -43
  34. package/template/.agent/skills/pipeline-rubrics/references/be-rubric.md +1 -1
  35. package/template/.agent/skills/pipeline-rubrics/references/ia-rubric.md +1 -1
  36. package/template/.agent/skills/prd-templates/SKILL.md +20 -3
  37. package/template/.agent/skills/prd-templates/references/be-spec-template.md +2 -2
  38. package/template/.agent/skills/prd-templates/references/decomposition-templates.md +2 -2
  39. package/template/.agent/skills/prd-templates/references/fe-spec-template.md +1 -1
  40. package/template/.agent/skills/prd-templates/references/ideation-domain-template.md +8 -2
  41. package/template/.agent/skills/prd-templates/references/ideation-index-template.md +25 -1
  42. package/template/.agent/skills/prd-templates/references/operational-templates.md +1 -1
  43. package/template/.agent/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -21
  44. package/template/.agent/skills/prd-templates/references/skill-loading-protocol.md +32 -0
  45. package/template/.agent/skills/prd-templates/references/slice-completion-gates.md +21 -0
  46. package/template/.agent/skills/prd-templates/references/spec-coverage-sweep.md +3 -3
  47. package/template/.agent/skills/prd-templates/references/tdd-testing-policy.md +39 -0
  48. package/template/.agent/skills/prd-templates/references/vision-template.md +1 -1
  49. package/template/.agent/skills/regex-patterns/SKILL.md +122 -540
  50. package/template/.agent/skills/regex-patterns/references/go.md +44 -0
  51. package/template/.agent/skills/regex-patterns/references/javascript.md +63 -0
  52. package/template/.agent/skills/regex-patterns/references/python.md +77 -0
  53. package/template/.agent/skills/regex-patterns/references/rust.md +43 -0
  54. package/template/.agent/skills/session-continuity/SKILL.md +11 -9
  55. package/template/.agent/skills/session-continuity/protocols/02-progress-generation.md +2 -2
  56. package/template/.agent/skills/session-continuity/protocols/04-pattern-extraction.md +1 -1
  57. package/template/.agent/skills/session-continuity/protocols/05-session-close.md +1 -1
  58. package/template/.agent/skills/session-continuity/protocols/09-parallel-claim.md +1 -1
  59. package/template/.agent/skills/session-continuity/protocols/10-placeholder-verification-gate.md +57 -78
  60. package/template/.agent/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
  61. package/template/.agent/skills/tdd-workflow/SKILL.md +94 -317
  62. package/template/.agent/skills/tdd-workflow/references/typescript.md +231 -0
  63. package/template/.agent/skills/testing-strategist/SKILL.md +74 -687
  64. package/template/.agent/skills/testing-strategist/references/typescript.md +328 -0
  65. package/template/.agent/skills/workflow-automation/SKILL.md +62 -154
  66. package/template/.agent/skills/workflow-automation/references/inngest.md +88 -0
  67. package/template/.agent/skills/workflow-automation/references/temporal.md +64 -0
  68. package/template/.agent/workflows/bootstrap-agents-fill.md +85 -143
  69. package/template/.agent/workflows/bootstrap-agents-provision.md +90 -107
  70. package/template/.agent/workflows/create-prd-architecture.md +16 -14
  71. package/template/.agent/workflows/create-prd-compile.md +11 -12
  72. package/template/.agent/workflows/create-prd-design-system.md +1 -1
  73. package/template/.agent/workflows/create-prd-security.md +9 -11
  74. package/template/.agent/workflows/create-prd-stack.md +10 -4
  75. package/template/.agent/workflows/create-prd.md +5 -6
  76. package/template/.agent/workflows/decompose-architecture-structure.md +3 -5
  77. package/template/.agent/workflows/decompose-architecture-validate.md +18 -1
  78. package/template/.agent/workflows/evolve-contract.md +11 -11
  79. package/template/.agent/workflows/ideate-discover.md +10 -6
  80. package/template/.agent/workflows/ideate-extract.md +61 -4
  81. package/template/.agent/workflows/ideate-validate.md +3 -3
  82. package/template/.agent/workflows/ideate.md +2 -2
  83. package/template/.agent/workflows/implement-slice-setup.md +25 -23
  84. package/template/.agent/workflows/implement-slice-tdd.md +51 -92
  85. package/template/.agent/workflows/implement-slice.md +4 -4
  86. package/template/.agent/workflows/plan-phase-preflight.md +6 -2
  87. package/template/.agent/workflows/plan-phase-write.md +6 -8
  88. package/template/.agent/workflows/resolve-ambiguity.md +1 -1
  89. package/template/.agent/workflows/update-architecture-map.md +22 -5
  90. package/template/.agent/workflows/validate-phase.md +26 -29
  91. package/template/.agent/workflows/verify-infrastructure.md +10 -10
  92. package/template/.agent/workflows/write-architecture-spec-design.md +17 -12
  93. package/template/.agent/workflows/write-be-spec-classify.md +25 -21
  94. package/template/.agent/workflows/write-be-spec.md +1 -1
  95. package/template/.agent/workflows/write-fe-spec-classify.md +6 -12
  96. package/template/.agent/workflows/write-fe-spec-write.md +1 -1
  97. package/template/AGENTS.md +1 -1
  98. package/template/GEMINI.md +3 -3
  99. package/template/docs/kit-architecture.md +34 -8
@@ -1,102 +1,90 @@
1
1
  ---
2
2
  name: bootstrap-agents
3
- description: "Utility — fill {{PLACEHOLDER}} values and provision skills from the library. Called by pipeline commands when tech stack info changes."
4
- version: 2.0.0
3
+ description: "Utility — fill the surface stack map in tech-stack.md and provision skills using intelligent resolution. Called by pipeline commands when tech stack info changes."
4
+ version: 3.0.0
5
5
  ---
6
6
 
7
7
  # Bootstrap Agents
8
8
 
9
- **This is a utility command, not an entry point.** It gets called by other pipeline commands (like `/create-prd`, `/iterate-plan`, `/write-be-spec`, `/write-fe-spec`, `/add-feature`, `/implement-slice`) whenever they make tech stack decisions or introduce new dependencies.
9
+ **This is a utility command, not an entry point.** It gets called by other pipeline commands (like `/create-prd`, `/write-be-spec`, `/write-fe-spec`, `/implement-slice`) whenever they make tech stack decisions or introduce new dependencies.
10
10
 
11
11
  Bootstrap does two things:
12
- 1. **Fill `{{PLACEHOLDER}}` values** in kit instruction templates
13
- 2. **Provision skills** from `skill-library/` based on stack and surface triggers
12
+ 1. **Fill the surface stack map** in `.agent/instructions/tech-stack.md` with stack decisions
13
+ 2. **Provision skills** from `skill-library/` using the 4-tier resolution chain
14
14
 
15
- **Input**: Template values (package manager, framework, database, etc.) + optional stack/surface triggers
16
- **Output**: Filled templates + newly installed skills in `.claude/skills/`
15
+ **Input**: Surface-keyed stack values + optional global values
16
+ **Output**: Filled map cells + newly installed skills in `.agent/skills/`
17
17
 
18
18
  ---
19
19
 
20
- ## 1. Receive template values
20
+ ## 1. Receive values
21
21
 
22
- The calling command provides these values (all optional — fill only what's provided, leave others as `{{PLACEHOLDER}}`):
22
+ The calling command provides values in two categories:
23
23
 
24
- ### Command & Tool Values
24
+ ### Surface-Keyed Values (fill the Per-Surface Skills table)
25
25
 
26
- | Key | Example |
27
- |-----|---------|
28
- | `PACKAGE_MANAGER` | pnpm |
29
- | `DEV_COMMAND` | pnpm dev |
30
- | `TEST_COMMAND` | pnpm test |
31
- | `TEST_WATCH_COMMAND` | pnpm test:watch |
32
- | `TEST_COVERAGE_COMMAND` | pnpm test:coverage |
33
- | `LINT_COMMAND` | pnpm lint |
34
- | `LINT_FIX_COMMAND` | pnpm lint:fix |
35
- | `FORMAT_COMMAND` | pnpm format |
36
- | `TYPE_CHECK_COMMAND` | pnpm type-check |
37
- | `BUILD_COMMAND` | pnpm build |
38
- | `PREVIEW_COMMAND` | pnpm preview |
39
- | `VALIDATION_COMMAND` | pnpm test && pnpm lint && pnpm type-check && pnpm build |
40
-
41
- ### Project Identity
26
+ Each value is tagged with a surface. Format: `SURFACE=<surface> KEY=<value>`
27
+
28
+ Example invocation from `/create-prd-stack`:
29
+ ```
30
+ SURFACE=shared LANGUAGES=typescript BE_FRAMEWORKS=hono DATABASES=supabase,surrealdb ORMS=drizzle
31
+ SURFACE=web LANGUAGES=typescript FE_FRAMEWORKS=astro FE_DESIGN=tailwind,vanilla-css STATE_MGMT=nanostores DATABASES=supabase,surrealdb UNIT_TESTS=vitest E2E_TESTS=playwright
32
+ SURFACE=desktop LANGUAGES=typescript,rust FE_FRAMEWORKS=— BE_FRAMEWORKS=tauri DATABASES=supabase,surrealdb,pglite,surrealdb-embedded UNIT_TESTS=vitest,cargo-test
33
+ ```
34
+
35
+ Per-surface column keys:
36
+
37
+ | Column Key | Map Column | Example |
38
+ |-----------|------------|---------|
39
+ | `LANGUAGES` | Languages | typescript, rust |
40
+ | `BE_FRAMEWORKS` | BE Frameworks | hono, tauri |
41
+ | `FE_FRAMEWORKS` | FE Frameworks | astro, react-native |
42
+ | `FE_DESIGN` | FE Design | tailwind, vanilla-css |
43
+ | `ORMS` | ORMs | drizzle |
44
+ | `STATE_MGMT` | State Mgmt | nanostores, zustand |
45
+ | `DATABASES` | Databases | supabase, surrealdb, pglite |
46
+ | `UNIT_TESTS` | Unit Tests | vitest, cargo-test |
47
+ | `E2E_TESTS` | E2E Tests | playwright, detox |
48
+ | `TEST_CMD` | Test Cmd | npm test |
49
+ | `VALIDATION_CMD` | Validation Cmd | npm run validate |
50
+ | `LINT_CMD` | Lint Cmd | npm run lint |
51
+ | `BUILD_CMD` | Build Cmd | npm run build |
52
+ | `DEV_CMD` | Dev Cmd | npm run dev |
53
+ | `PACKAGE_MGR` | Package Mgr | npm |
54
+
55
+ ### Cross-Cutting Values (fill the Cross-Cutting Skills table)
56
+
57
+ These are project-wide, not per-surface:
58
+
59
+ | Key | Map Category | Example |
60
+ |-----|-------------|---------|
61
+ | `AUTH` | Auth | clerk, supabase-auth |
62
+ | `CI_CD` | CI/CD | github-actions |
63
+ | `HOSTING` | Hosting | vercel, tauri-updater |
64
+ | `SECURITY` | Security | owasp-web, desktop-sandboxing |
65
+ | `API_DESIGN` | API Design | api-design-principles |
66
+ | `ACCESSIBILITY` | Accessibility | accessibility |
67
+ | `CONTRACT_LIBRARY` | Contract Library | zod |
68
+
69
+ ### Global Values (fill Global Settings in tech-stack.md + root configs)
42
70
 
43
71
  | Key | Example |
44
72
  |-----|---------|
45
- | `PROJECT_NAME` | My Project |
73
+ | `PROJECT_NAME` | RepairYour.Tech |
46
74
  | `DESCRIPTION` | One-line description |
47
- | `TECH_STACK_SUMMARY` | Astro + React + SurrealDB + Firebase Auth |
75
+ | `TECH_STACK_SUMMARY` | Supabase + SurrealDB + Astro + Tauri |
76
+ | `SURFACES` | web, desktop, mobile |
77
+ | `ARCHITECTURE_DOC` | docs/plans/2026-03-13-architecture-design.md |
48
78
 
49
- ### Architecture & Structure
79
+ ### Structural Values (fill instruction templates — unchanged from v2)
50
80
 
51
81
  | Key | Example |
52
82
  |-----|---------|
53
83
  | `FRAMEWORK_PATTERNS` | Framework-specific patterns block |
54
84
  | `PROJECT_STRUCTURE` | Directory layout block |
55
85
  | `ARCHITECTURE_TABLE` | Concern/Location/Runtime table rows |
56
- | `ARCHITECTURE_DOC` | docs/plans/2026-02-10-architecture-design.md |
57
- | `CONTRACTS_DIR` | src/contracts/ |
58
- | `BUILD_OUTPUT_DIR` | dist/ |
59
-
60
- ### Stack Values (trigger skill provisioning)
61
86
 
62
- | Key | Example |
63
- |-----|---------|
64
- | `DATABASE` | SurrealDB (self-hosted) |
65
- | `FRONTEND_FRAMEWORK` | Astro + React Islands |
66
- | `BACKEND_FRAMEWORK` | Hono |
67
- | `API_LAYER` | tRPC |
68
- | `BACKEND_RUNTIME` | Cloudflare Workers |
69
- | `ORM` | Drizzle |
70
- | `CSS_FRAMEWORK` | Tailwind CSS v4 |
71
- | `UI_LIBRARY` | shadcn/ui |
72
- | `AUTH_PROVIDER` | Firebase Auth |
73
- | `PAYMENTS` | Stripe |
74
- | `AI_SDK` | Vercel AI SDK |
75
- | `STATE_MANAGEMENT` | TanStack Query |
76
- | `E2E_TESTING` | Playwright |
77
- | `UNIT_TESTING` | Vitest |
78
- | `HOSTING` | Cloudflare Pages + Workers |
79
- | `CDN_ASSETS` | Cloudflare R2 |
80
- | `MONITORING` | Sentry |
81
- | `ANALYTICS` | Google Analytics |
82
- | `EMAIL` | Resend |
83
- | `QUEUE` | Inngest |
84
- | `REALTIME` | Socket.io |
85
- | `SEARCH` | Meilisearch |
86
- | `CMS` | Payload CMS |
87
- | `STORAGE` | AWS S3 |
88
- | `CI_CD` | GitHub Actions |
89
- | `MOBILE_FRAMEWORK` | Expo |
90
- | `LANGUAGE` | TypeScript |
91
- | `3D_FRAMEWORK` | Three.js / R3F |
92
- | `DESKTOP_FRAMEWORK` | Tauri |
93
- | `GAME_ENGINE` | Godot |
94
- | `SECURITY` | OWASP |
95
- | `TEST_RUNNER` | Vitest |
96
- | `LINTER` | ESLint |
97
- | `TYPE_CHECKER` | TypeScript (tsc) |
98
-
99
- ### Infrastructure Values
87
+ ### Infrastructure Values (fill instruction templates — unchanged from v2)
100
88
 
101
89
  | Key | Example |
102
90
  |-----|---------|
@@ -106,65 +94,69 @@ The calling command provides these values (all optional — fill only what's pro
106
94
  | `SECRET_MANAGEMENT` | wrangler secret |
107
95
  | `DEPLOY_COMMAND` | wrangler deploy |
108
96
 
109
- ### Surface Types
97
+ If any values are missing, leave those cells empty — they'll be filled on a future invocation.
110
98
 
111
- | Key | Example |
112
- |-----|---------|
113
- | `SURFACES` | web, api |
99
+ ---
114
100
 
115
- If any values are missing, leave those `{{PLACEHOLDER}}`s in place — they'll be filled on a future invocation.
101
+ ## 2. Fill the surface stack map
116
102
 
117
- ---
103
+ Open `.agent/instructions/tech-stack.md` and update:
118
104
 
119
- ## 2. Fill project skill templates
105
+ ### 2a. Per-Surface Skills table
120
106
 
121
- ### `.claude/skills/project-commands/SKILL.md`
122
- Replace: `{{PACKAGE_MANAGER}}`, `{{DEV_COMMAND}}`, `{{TEST_COMMAND}}`, `{{TEST_WATCH_COMMAND}}`, `{{TEST_COVERAGE_COMMAND}}`, `{{LINT_COMMAND}}`, `{{LINT_FIX_COMMAND}}`, `{{FORMAT_COMMAND}}`, `{{TYPE_CHECK_COMMAND}}`, `{{BUILD_COMMAND}}`, `{{PREVIEW_COMMAND}}`, `{{VALIDATION_COMMAND}}`
107
+ For each `SURFACE=<name>` received:
108
+ 1. If a row for `<name>` exists update the cells for the provided column keys only (don't overwrite cells that already have values unless explicitly re-provided)
109
+ 2. If no row exists → add a new row with the provided values, `—` for unprovided columns
123
110
 
124
- ### `.claude/skills/project-workflow/SKILL.md`
125
- Replace: `{{VALIDATION_COMMAND}}`
111
+ ### 2b. Cross-Cutting Skills table
126
112
 
127
- ### `.claude/skills/project-patterns/SKILL.md`
128
- Replace: `{{FRAMEWORK_PATTERNS}}` if provided
113
+ For each cross-cutting key received, update the corresponding category row. If the value is additive (e.g., adding a second database), **append** to the comma-separated list rather than overwriting. If the value is already present, skip (idempotent).
129
114
 
130
- ### `.claude/skills/project-structure/SKILL.md`
131
- Replace: `{{PROJECT_STRUCTURE}}`, `{{ARCHITECTURE_TABLE}}` if provided
115
+ ### 2c. Global Settings
132
116
 
133
- ### `.claude/skills/project-tech-stack/SKILL.md`
134
- Replace: `{{TECH_STACK_SUMMARY}}`, `{{FRONTEND_FRAMEWORK}}`, `{{BACKEND_RUNTIME}}`, `{{DATABASE}}`, `{{AUTH_PROVIDER}}`, `{{HOSTING}}`, `{{CDN_ASSETS}}`, `{{CICD}}`, `{{MONITORING}}`, `{{PACKAGE_MANAGER}}`, `{{TEST_RUNNER}}`, `{{LINTER}}`, `{{TYPE_CHECKER}}`, `{{INSTALLED_SKILLS}}`
117
+ Fill the Global Settings table with any provided global values.
135
118
 
136
119
  ---
137
120
 
138
- ## 3. Fill default operational skill templates
121
+ ## 3. Fill root agent config files
139
122
 
140
- Scan all `.claude/skills/*/SKILL.md` files for `{{PLACEHOLDER}}` values and fill any that match the provided template values:
123
+ Replace in **both** `AGENTS.md` and `GEMINI.md`:
124
+ - `{{PROJECT_NAME}}`
125
+ - `{{DESCRIPTION}}`
126
+ - `{{TECH_STACK_SUMMARY}}`
127
+ - `{{VALIDATION_COMMAND}}` — use the **primary surface's** validation command from the map (first non-shared row, or shared if only shared exists)
128
+ - `{{ARCHITECTURE_DOC}}`
129
+ - `{{CONTRACT_LIBRARY}}`
130
+ - `{{INSTALLED_SKILLS}}` (if provided; otherwise leave for step 8)
141
131
 
142
- - `{{VALIDATION_COMMAND}}` — in `fix-bug`, `main-workflow`, `deploy`, `refactor`
143
- - `{{PACKAGE_MANAGER}}` — in `refactor`, `security-audit`
144
- - `{{TEST_COVERAGE_COMMAND}}` — in `refactor`
145
- - `{{BUILD_COMMAND}}` — in `deploy`
146
- - `{{DEPLOY_COMMAND}}` — in `deploy`
147
- - `{{BUILD_OUTPUT_DIR}}` — in `deploy`
148
- - `{{SSH_HOST}}` — in `setup-session`
149
- - `{{DB_PORT}}` — in `setup-session`
150
- - `{{CREDENTIAL_TOOL}}` — in `setup-session`
132
+ > **Note**: Both files serve as root agent config. Both must be kept in sync any value filled in one must be filled in the other.
151
133
 
152
134
  ---
153
135
 
154
- ## 4. Fill rule templates
136
+ ## 4. Fill instruction templates
137
+
138
+ ### `.agent/instructions/commands.md`
139
+ Write per-surface command sections. For each surface in the map, create a section with its commands (Test Cmd, Validation Cmd, Lint Cmd, Build Cmd, Dev Cmd, Package Mgr).
140
+
141
+ ### `.agent/instructions/workflow.md`
142
+ Fill `{{VALIDATION_COMMAND}}` with the primary surface's validation command.
143
+
144
+ ### `.agent/instructions/patterns.md`
145
+ Replace `{{FRAMEWORK_PATTERNS}}` if provided.
155
146
 
156
- ### `.claude/rules/contract-first.md`
157
- Replace: `{{VALIDATION_COMMAND}}`, `{{TEST_RUNNER}}`
147
+ ### `.agent/instructions/structure.md`
148
+ Replace `{{PROJECT_STRUCTURE}}`, `{{ARCHITECTURE_TABLE}}` if provided.
158
149
 
159
150
  ---
160
151
 
161
- ## 5. Fill CLAUDE.md
152
+ ## 5. Fill operational skill and rule templates
162
153
 
163
- Replace in `CLAUDE.md` at project root:
164
- - `{{PROJECT_NAME}}`
165
- - `{{DESCRIPTION}}`
166
- - `{{TECH_STACK_SUMMARY}}`
167
- - `{{VALIDATION_COMMAND}}`
154
+ Scan `.agent/skills/*/SKILL.md` and `.agent/rules/*.md` for `{{PLACEHOLDER}}` values and fill any that match the provided values. Currently applicable:
155
+
156
+ - `{{VALIDATION_COMMAND}}` — in `fix-bug`, `main-workflow`, `deploy`, `refactor`
157
+ - `{{PACKAGE_MANAGER}}` — in `refactor`, `security-audit`
158
+ - `{{CONTRACT_LIBRARY}}` — in `tdd-contract-first.md`
159
+ - Other command/infra placeholders as documented in v2
168
160
 
169
161
  ---
170
162
 
@@ -172,62 +164,67 @@ Replace in `CLAUDE.md` at project root:
172
164
 
173
165
  Read `skill-library/MANIFEST.md` to load the trigger tables.
174
166
 
175
- If `skill-library/MANIFEST.md` does not exist (e.g., user deleted it or is using a minimal kit), skip steps 7-8 and go to step 9.
167
+ If `skill-library/MANIFEST.md` does not exist, skip steps 7-8 and go to step 9.
176
168
 
177
169
  ---
178
170
 
179
- ## 7. Provision skills from library
171
+ ## 7. Provision skills 4-Tier Resolution Chain
172
+
173
+ For each skill name referenced in ANY cell of the surface stack map, resolve it using this chain:
174
+
175
+ ### Tier 1: Exact Match
176
+ Check `.agent/skill-library/{name}/` (or `.agent/skills/{name}/` if already installed).
177
+ - **Found in library** AND not yet installed → copy to `.agent/skills/{name}/`, fill any `{{PLACEHOLDER}}`s in the copied SKILL.md
178
+ - **Already installed** → skip (idempotent)
179
+ - **Not found** → proceed to Tier 2
180
180
 
181
- For each stack key provided in the template values, check the **Stack Triggers** table in the manifest:
181
+ ### Tier 2: Partial Match + Adequacy Check
182
+ Search `.agent/skill-library/` and `.agent/skills/` for skills whose name contains the base term. E.g., for `surrealdb-embedded`, check if `surrealdb` exists.
182
183
 
183
- 1. Match the provided value against the manifest's `Value Pattern` (case-insensitive)
184
- 2. If a match is found AND the skill is NOT already in `.claude/skills/[installed-as]/`:
185
- - Copy the entire directory from `skill-library/[library-path]/``.claude/skills/[installed-as]/`
186
- - Fill any `{{PLACEHOLDER}}`s in the newly-copied `SKILL.md` with current template values
187
- 3. If the skill already exists in `.claude/skills/`, skip it (idempotent)
184
+ - **Partial match found** → Read its `SKILL.md`. Assess: does it cover the needed variant? Check for keywords related to the specific need (e.g., "embedded", "WASM", "Rust-native" for `surrealdb-embedded`).
185
+ - **Adequate** the existing skill covers the variant use it. Note in the report: `"{name}" resolved by existing "{partial}" skill (covers {variant})`.
186
+ - **Falls short** — the skill doesn't address the specific variant proceed to Tier 3
187
+ - **No partial match** proceed to Tier 3
188
188
 
189
- For each surface type provided in `SURFACES`, check the **Surface Triggers** table:
189
+ ### Tier 3: External Discovery
190
+ Read `.agent/skills/find-skills/SKILL.md` and invoke its discovery methodology to search for the skill externally.
190
191
 
191
- 1. Match the surface type against the manifest's `Surface Type` column
192
- 2. Copy matching skills that don't already exist, same as above
192
+ - **Found** install fill map cell with resolved name
193
+ - **Not found** proceed to Tier 4
193
194
 
194
- ### Matching rules
195
+ ### Tier 4: Human Escalation
196
+ Mark the map cell with `⚠️ {name} [not found]`. Include in the report:
195
197
 
196
- | Manifest Pattern | Matches |
197
- |-----------------|---------|
198
- | `*surrealdb*` | "SurrealDB", "surrealdb (self-hosted)", "SurrealDB Cloud" |
199
- | `*cloudflare*` | "Cloudflare Workers", "Cloudflare Pages + Workers" |
200
- | `*tailwind*` | "Tailwind CSS v4", "Tailwind CSS" |
201
- | `*vercel*` OR `*ai-sdk*` | "Vercel AI SDK", "AI SDK" |
202
- | `*three*` OR `*r3f*` | "Three.js", "React Three Fiber", "R3F" |
198
+ > "Skill `{name}` was not found in the skill library, via partial match, or externally. Options:
199
+ > 1. Create it with `/skill-creator`
200
+ > 2. Provide an alternative skill name
201
+ > 3. Mark as not needed (change cell to `—`)"
203
202
 
204
- Pattern matching is glob-style with `*` as wildcard, case-insensitive.
203
+ ### Resolution reporting
204
+ After resolving all skills, report:
205
+ - Which skills were installed (Tier 1)
206
+ - Which skills were resolved by adequacy check (Tier 2) — include justification
207
+ - Which skills were discovered externally (Tier 3)
208
+ - Which skills need human attention (Tier 4) — include the `⚠️` cells
205
209
 
206
210
  ---
207
211
 
208
212
  ## 8. Update installed skills list
209
213
 
210
- After provisioning, build a markdown list of all installed skills (both defaults and library-provisioned) and update `{{INSTALLED_SKILLS}}` in `project-tech-stack`:
214
+ After provisioning, build a markdown list of all installed skills and update `{{INSTALLED_SKILLS}}` in `tech-stack.md`:
211
215
 
212
216
  ```markdown
213
217
  ### Default Skills
214
218
  - fix-bug — TDD bug fix workflow
215
219
  - refactor — Safe refactoring with test verification
216
- - add-feature — Add feature to existing architecture
217
- - deploy — Full deployment pipeline
218
- - pr-review Structured PR review
219
- - security-auditSecurity review across all layers
220
- - main-workflow — General development workflow
221
- - iterate-plan — Tech stack gap analysis
222
- - setup-session Session initialization
223
- - using-git-worktreesIsolated workspace management
224
- - github-workflow-automation — GitHub CI/CD patterns
225
- - audit-context-building — Deep code analysis
226
- - context7-auto-research — Auto documentation lookup
227
- - self-improving-agent — Learning from experiences
228
-
229
- ### Stack Skills
230
- - [skill-name] — [description] (installed for [STACK_KEY]=[value])
220
+ - ...
221
+
222
+ ### Stack Skills (Per-Surface)
223
+ - [skill-name][description] (surface: [surface], column: [column])
224
+ - ...
225
+
226
+ ### Stack Skills (Cross-Cutting)
227
+ - [skill-name][description] (category: [category])
231
228
  - ...
232
229
 
233
230
  ### Surface Skills
@@ -241,10 +238,11 @@ After provisioning, build a markdown list of all installed skills (both defaults
241
238
 
242
239
  Present the results to the calling command (not directly to the user — the calling command handles user communication):
243
240
 
244
- - Which `{{PLACEHOLDER}}`s were filled (and their values)
245
- - Which `{{PLACEHOLDER}}`s remain unfilled
246
- - Which skills were provisioned from the library (if any)
241
+ - Which map cells were filled (and their values)
242
+ - Which map cells remain empty
243
+ - Skill resolution report (from step 7)
247
244
  - Which skills were already installed and skipped
245
+ - Any `⚠️` cells requiring user attention
248
246
  - Any errors (missing files, missing library paths)
249
247
 
250
248
  ---
@@ -253,7 +251,8 @@ Present the results to the calling command (not directly to the user — the cal
253
251
 
254
252
  Bootstrap is safe to call multiple times:
255
253
 
256
- - **Already-filled placeholders**: If a `{{PLACEHOLDER}}` has already been replaced with a value, it is NOT re-filled unless the calling command explicitly provides a new value for that key
257
- - **Already-installed skills**: Skills that already exist in `.claude/skills/` are not re-copied from the library
258
- - **New values**: New stack/surface values trigger new skill installations without affecting existing ones
259
- - **Partial invocation**: Bootstrap can be called with just one or two new values — it only fills what's provided
254
+ - **Already-filled map cells**: Cells with values are NOT overwritten unless the calling command explicitly re-provides a value for that surface + column
255
+ - **Already-installed skills**: Skills that already exist in `.agent/skills/` are not re-copied from the library
256
+ - **New surface rows**: New surfaces trigger new row creation without affecting existing rows
257
+ - **Appending values**: Cross-cutting skills and accumulated columns append to existing comma-separated lists without duplicating
258
+ - **Partial invocation**: Bootstrap can be called with just one surface or one key — it only fills what's provided
@@ -2,9 +2,6 @@
2
2
  name: clean-code
3
3
  description: "Applies battle-tested clean code principles to writing, reviewing, and refactoring code. Covers naming, functions, comments, error handling, class design, and the critical difference between clever code and clear code."
4
4
  version: 2.0.0
5
- source: self
6
- date_added: "2026-02-27"
7
- date_rewritten: "2026-03-14"
8
5
  ---
9
6
 
10
7
  # Clean Code
@@ -18,6 +15,17 @@ Code is read 10x more than it's written. Every naming choice, every function bou
18
15
  - Refactoring existing code
19
16
  - When code "works but feels wrong"
20
17
 
18
+ ## Stack-Specific References
19
+
20
+ The principles below are language-agnostic. For idiomatic patterns and syntax, read the reference matching your surface's Languages column:
21
+
22
+ | Language | Reference |
23
+ |----------|-----------|
24
+ | TypeScript / JavaScript | `references/typescript.md` |
25
+ | Python | `references/python.md` |
26
+ | Go | `references/go.md` |
27
+ | Rust | `references/rust.md` |
28
+
21
29
  ## Core Principles
22
30
 
23
31
  ### 1. Names Are Documentation
@@ -36,7 +44,7 @@ Names should reveal intent. If a name requires a comment to explain it, the name
36
44
  | `Utils` | `StringFormatter` | Util for what? |
37
45
 
38
46
  **Rules:**
39
- - Classes → nouns (`UserRepository`, `PaymentGateway`)
47
+ - Classes/types → nouns (`UserRepository`, `PaymentGateway`)
40
48
  - Functions → verbs (`calculateTotal`, `sendNotification`)
41
49
  - Booleans → questions (`isActive`, `hasPermission`, `canEdit`)
42
50
  - Constants → screaming snake with context (`MAX_RETRY_ATTEMPTS`, not `MAX`)
@@ -48,46 +56,16 @@ A function that does one thing well is easy to name, test, and reuse. A function
48
56
 
49
57
  **The test:** Can you describe the function without using "and"? If not, split it.
50
58
 
51
- ```typescript
52
- // Does three things
53
- function processOrder(order: Order): void {
54
- // Validate
55
- if (!order.items.length) throw new Error("Empty order");
56
- if (!order.customer) throw new Error("No customer");
57
-
58
- // Calculate
59
- let total = 0;
60
- for (const item of order.items) {
61
- total += item.price * item.quantity;
62
- if (item.taxable) total += item.price * 0.08;
63
- }
64
-
65
- // Save
66
- db.orders.insert({ ...order, total, status: "pending" });
67
- emailService.send(order.customer.email, "Order confirmed");
68
- }
69
-
70
- // ✅ Each function does one thing
71
- function validateOrder(order: Order): void {
72
- if (!order.items.length) throw new InvalidOrderError("Empty order");
73
- if (!order.customer) throw new InvalidOrderError("No customer");
74
- }
75
-
76
- function calculateOrderTotal(items: OrderItem[]): number {
77
- return items.reduce((total, item) => {
78
- const subtotal = item.price * item.quantity;
79
- const tax = item.taxable ? item.price * TAX_RATE : 0;
80
- return total + subtotal + tax;
81
- }, 0);
82
- }
83
-
84
- function submitOrder(order: Order): OrderConfirmation {
85
- validateOrder(order);
86
- const total = calculateOrderTotal(order.items);
87
- const saved = db.orders.insert({ ...order, total, status: "pending" });
88
- emailService.send(order.customer.email, "Order confirmed");
89
- return { orderId: saved.id, total };
90
- }
59
+ ```
60
+ processOrder(order)
61
+ validates order
62
+ calculates total with tax
63
+ saves to database
64
+ sends confirmation email
65
+
66
+ validateOrder(order) → throws if invalid
67
+ calculateOrderTotal(items) returns numeric total
68
+ submitOrder(order) → orchestrates the above
91
69
  ```
92
70
 
93
71
  **Function size limits:**
@@ -100,111 +78,79 @@ function submitOrder(order: Order): OrderConfirmation {
100
78
 
101
79
  - **0-2 parameters**: ideal
102
80
  - **3 parameters**: acceptable with named/destructured args
103
- - **4+ parameters**: use an options object
81
+ - **4+ parameters**: use an options object/struct/dataclass
104
82
  - **Boolean parameters**: almost always a code smell — split into two functions
105
83
 
106
- ```typescript
107
- // Boolean flag parameter
108
- function createUser(name: string, isAdmin: boolean): User { ... }
109
-
110
- // Two clear functions
111
- function createUser(name: string): User { ... }
112
- function createAdmin(name: string): User { ... }
113
-
114
- // ❌ Too many positional args
115
- function sendEmail(to: string, from: string, subject: string, body: string, cc?: string): void { ... }
116
-
117
- // ✅ Options object
118
- interface SendEmailOptions {
119
- to: string;
120
- from: string;
121
- subject: string;
122
- body: string;
123
- cc?: string;
124
- }
125
- function sendEmail(options: SendEmailOptions): void { ... }
84
+ ```
85
+ createUser(name, isAdmin)
86
+ createUser(name) / createAdmin(name)
87
+
88
+ sendEmail(to, from, subject, body, cc)
89
+ sendEmail(options) options is a structured type
126
90
  ```
127
91
 
128
92
  ### 4. Comments: Why, Not What
129
93
 
130
94
  Good code doesn't need comments to explain WHAT it does. Comments should explain WHY — the non-obvious reasoning, business rules, or constraints.
131
95
 
132
- ```typescript
133
- // Comment explains what (redundant)
134
- // Increment counter by one
135
- counter += 1;
96
+ ```
97
+ // Increment counter by one
98
+ counter += 1
136
99
 
137
- // Comment explains obvious logic
138
- // Check if user is admin
139
- if (user.role === "admin") { ... }
100
+ // Check if user is admin
101
+ if user.role == "admin"
140
102
 
141
- // Comment explains WHY
142
- // Stripe requires amount in cents, not dollars
143
- const amountInCents = Math.round(price * 100);
103
+ // Stripe requires amount in cents, not dollars
104
+ amountInCents = round(price * 100)
144
105
 
145
- // Comment explains business rule
146
- // FDA regulation 21 CFR Part 11 requires audit trail for all changes
147
- await auditLog.record(changeEvent);
106
+ // FDA regulation 21 CFR Part 11 requires audit trail
107
+ auditLog.record(changeEvent)
148
108
 
149
- // Comment warns about non-obvious consequence
150
- // WARNING: This query locks the orders table — avoid running during peak hours
151
- await db.execute(batchUpdateQuery);
109
+ // WARNING: This query locks the orders table — avoid during peak hours
110
+ db.execute(batchUpdateQuery)
152
111
  ```
153
112
 
154
113
  **Delete these comments immediately:**
155
114
  - `// TODO: fix this later` — fix it now or create a tracked issue
156
115
  - `// This is a hack` — then don't commit the hack
157
116
  - `// I don't know why this works` — figure it out before shipping
158
- - Commented-out code — delete it; git has your history
117
+ - Commented-out code — delete it; version control has your history
159
118
 
160
119
  ### 5. Error Handling
161
120
 
162
121
  Errors are not edge cases — they're expected behavior. Handle them explicitly.
163
122
 
164
- ```typescript
165
- // Swallowing errors
166
- try {
167
- await saveOrder(order);
168
- } catch (e) {
169
- console.log("error"); // What error? What happens to the order?
170
- }
171
-
172
- // ❌ Generic catch-all
173
- try {
174
- await processPayment(order);
175
- } catch (e) {
176
- throw new Error("Something went wrong"); // Useless to the caller
177
- }
178
-
179
- // Specific, actionable error handling
180
- try {
181
- await processPayment(order);
182
- } catch (error) {
183
- if (error instanceof InsufficientFundsError) {
184
- return { success: false, code: "INSUFFICIENT_FUNDS", retry: false };
185
- }
186
- if (error instanceof PaymentGatewayError) {
187
- logger.error("Payment gateway failure", { orderId: order.id, error });
188
- return { success: false, code: "GATEWAY_ERROR", retry: true };
189
- }
190
- throw error; // Unknown errors bubble up
191
- }
123
+ ```
124
+ try { save(order) } catch { log("error") }
125
+ What error? What happens to the order?
126
+
127
+ ❌ try { processPayment(order) } catch { throw Error("Something went wrong") }
128
+ Useless to the caller
129
+
130
+ ✅ try {
131
+ processPayment(order)
132
+ } catch InsufficientFundsError:
133
+ return { success: false, code: "INSUFFICIENT_FUNDS", retry: false }
134
+ catch PaymentGatewayError:
135
+ logger.error("Payment gateway failure", { orderId: order.id })
136
+ return { success: false, code: "GATEWAY_ERROR", retry: true }
137
+ catch unknown:
138
+ rethrow → Unknown errors bubble up
192
139
  ```
193
140
 
194
141
  ### 6. Don't Repeat Yourself (DRY) — But Don't Over-Abstract
195
142
 
196
143
  **DRY violation** — same logic copy-pasted in 3+ places:
197
- ```typescript
198
- // If you change the tax rate, you need to find and update all copies
199
- const tax1 = price1 * 0.08;
200
- const tax2 = price2 * 0.08;
201
- const tax3 = price3 * 0.08;
144
+ ```
145
+ tax1 = price1 * 0.08
146
+ tax2 = price2 * 0.08
147
+ tax3 = price3 * 0.08
148
+ Extract: calculateTax(price)
202
149
  ```
203
150
 
204
151
  **Over-abstraction** — premature DRY that couples unrelated things:
205
- ```typescript
206
- // ❌ "Universal" handler that handles everything poorly
207
- function handleEntity(type: "user" | "order" | "product", action: "create" | "update" | "delete", data: unknown) { ... }
152
+ ```
153
+ handleEntity(type, action, data) → "universal" handler for everything
208
154
  ```
209
155
 
210
156
  **Rule of Three**: Duplicate once is acceptable. Duplicate twice means extract.