cclaw-cli 0.48.35 → 0.51.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 (181) hide show
  1. package/README.md +54 -82
  2. package/dist/artifact-linter.d.ts +4 -0
  3. package/dist/artifact-linter.js +24 -3
  4. package/dist/cli.d.ts +1 -19
  5. package/dist/cli.js +49 -495
  6. package/dist/constants.d.ts +2 -13
  7. package/dist/constants.js +1 -46
  8. package/dist/content/closeout-guidance.d.ts +14 -0
  9. package/dist/content/closeout-guidance.js +42 -0
  10. package/dist/content/core-agents.js +51 -9
  11. package/dist/content/decision-protocol.d.ts +12 -0
  12. package/dist/content/decision-protocol.js +20 -0
  13. package/dist/content/diff-command.d.ts +1 -2
  14. package/dist/content/diff-command.js +8 -94
  15. package/dist/content/examples.d.ts +4 -10
  16. package/dist/content/examples.js +10 -20
  17. package/dist/content/hook-events.js +2 -2
  18. package/dist/content/hook-inline-snippets.d.ts +5 -2
  19. package/dist/content/hook-inline-snippets.js +33 -1
  20. package/dist/content/hook-manifest.d.ts +3 -4
  21. package/dist/content/hook-manifest.js +11 -12
  22. package/dist/content/hooks.js +2 -0
  23. package/dist/content/ideate-command.d.ts +2 -0
  24. package/dist/content/ideate-command.js +31 -25
  25. package/dist/content/iron-laws.d.ts +5 -5
  26. package/dist/content/iron-laws.js +5 -5
  27. package/dist/content/learnings.d.ts +3 -4
  28. package/dist/content/learnings.js +24 -50
  29. package/dist/content/meta-skill.js +31 -24
  30. package/dist/content/next-command.js +38 -38
  31. package/dist/content/node-hooks.js +17 -343
  32. package/dist/content/opencode-plugin.js +2 -100
  33. package/dist/content/research-playbooks.js +14 -14
  34. package/dist/content/review-loop.d.ts +2 -0
  35. package/dist/content/review-loop.js +8 -0
  36. package/dist/content/session-hooks.js +14 -46
  37. package/dist/content/skills.d.ts +0 -5
  38. package/dist/content/skills.js +53 -128
  39. package/dist/content/stage-common-guidance.d.ts +0 -1
  40. package/dist/content/stage-common-guidance.js +15 -14
  41. package/dist/content/stage-schema.d.ts +26 -1
  42. package/dist/content/stage-schema.js +121 -40
  43. package/dist/content/stages/_lint-metadata/index.js +9 -15
  44. package/dist/content/stages/brainstorm.js +22 -43
  45. package/dist/content/stages/design.js +37 -57
  46. package/dist/content/stages/plan.js +22 -13
  47. package/dist/content/stages/review.js +24 -27
  48. package/dist/content/stages/scope.js +34 -46
  49. package/dist/content/stages/ship.js +7 -4
  50. package/dist/content/stages/spec.js +20 -9
  51. package/dist/content/stages/tdd.js +64 -44
  52. package/dist/content/start-command.js +10 -12
  53. package/dist/content/status-command.d.ts +2 -7
  54. package/dist/content/status-command.js +19 -146
  55. package/dist/content/subagents.d.ts +0 -5
  56. package/dist/content/subagents.js +47 -28
  57. package/dist/content/templates.d.ts +1 -1
  58. package/dist/content/templates.js +126 -135
  59. package/dist/content/track-render-context.d.ts +17 -0
  60. package/dist/content/track-render-context.js +44 -0
  61. package/dist/content/tree-command.d.ts +1 -2
  62. package/dist/content/tree-command.js +4 -87
  63. package/dist/content/utility-skills.d.ts +2 -29
  64. package/dist/content/utility-skills.js +2 -1533
  65. package/dist/content/view-command.js +29 -11
  66. package/dist/delegation.d.ts +1 -1
  67. package/dist/delegation.js +5 -15
  68. package/dist/doctor-registry.js +20 -21
  69. package/dist/doctor.js +88 -408
  70. package/dist/flow-state.d.ts +3 -0
  71. package/dist/flow-state.js +2 -0
  72. package/dist/harness-adapters.d.ts +1 -1
  73. package/dist/harness-adapters.js +48 -57
  74. package/dist/install.js +128 -520
  75. package/dist/internal/advance-stage.js +3 -9
  76. package/dist/internal/compound-readiness.d.ts +1 -1
  77. package/dist/internal/compound-readiness.js +1 -1
  78. package/dist/internal/tdd-loop-status.d.ts +1 -1
  79. package/dist/internal/tdd-loop-status.js +1 -1
  80. package/dist/knowledge-store.d.ts +16 -10
  81. package/dist/knowledge-store.js +51 -15
  82. package/dist/policy.js +16 -109
  83. package/dist/run-archive.d.ts +4 -6
  84. package/dist/run-archive.js +15 -20
  85. package/dist/run-persistence.d.ts +2 -2
  86. package/dist/run-persistence.js +3 -9
  87. package/package.json +1 -2
  88. package/dist/content/archive-command.d.ts +0 -2
  89. package/dist/content/archive-command.js +0 -124
  90. package/dist/content/compound-command.d.ts +0 -5
  91. package/dist/content/compound-command.js +0 -193
  92. package/dist/content/contexts.d.ts +0 -9
  93. package/dist/content/contexts.js +0 -65
  94. package/dist/content/contracts.d.ts +0 -2
  95. package/dist/content/contracts.js +0 -51
  96. package/dist/content/doctor-references.d.ts +0 -2
  97. package/dist/content/doctor-references.js +0 -150
  98. package/dist/content/eval-scaffold.d.ts +0 -15
  99. package/dist/content/eval-scaffold.js +0 -370
  100. package/dist/content/feature-command.d.ts +0 -2
  101. package/dist/content/feature-command.js +0 -123
  102. package/dist/content/flow-map.d.ts +0 -23
  103. package/dist/content/flow-map.js +0 -134
  104. package/dist/content/harness-doc.d.ts +0 -2
  105. package/dist/content/harness-doc.js +0 -202
  106. package/dist/content/harness-playbooks.d.ts +0 -24
  107. package/dist/content/harness-playbooks.js +0 -393
  108. package/dist/content/harness-tool-refs.d.ts +0 -20
  109. package/dist/content/harness-tool-refs.js +0 -268
  110. package/dist/content/ops-command.d.ts +0 -2
  111. package/dist/content/ops-command.js +0 -71
  112. package/dist/content/protocols.d.ts +0 -7
  113. package/dist/content/protocols.js +0 -215
  114. package/dist/content/retro-command.d.ts +0 -2
  115. package/dist/content/retro-command.js +0 -165
  116. package/dist/content/rewind-command.d.ts +0 -2
  117. package/dist/content/rewind-command.js +0 -106
  118. package/dist/content/tdd-log-command.d.ts +0 -2
  119. package/dist/content/tdd-log-command.js +0 -85
  120. package/dist/eval/agents/single-shot.d.ts +0 -27
  121. package/dist/eval/agents/single-shot.js +0 -79
  122. package/dist/eval/agents/with-tools.d.ts +0 -44
  123. package/dist/eval/agents/with-tools.js +0 -261
  124. package/dist/eval/agents/workflow.d.ts +0 -31
  125. package/dist/eval/agents/workflow.js +0 -155
  126. package/dist/eval/baseline.d.ts +0 -38
  127. package/dist/eval/baseline.js +0 -282
  128. package/dist/eval/config-loader.d.ts +0 -14
  129. package/dist/eval/config-loader.js +0 -395
  130. package/dist/eval/corpus.d.ts +0 -30
  131. package/dist/eval/corpus.js +0 -330
  132. package/dist/eval/cost-guard.d.ts +0 -102
  133. package/dist/eval/cost-guard.js +0 -190
  134. package/dist/eval/diff.d.ts +0 -64
  135. package/dist/eval/diff.js +0 -323
  136. package/dist/eval/llm-client.d.ts +0 -176
  137. package/dist/eval/llm-client.js +0 -267
  138. package/dist/eval/mode.d.ts +0 -28
  139. package/dist/eval/mode.js +0 -61
  140. package/dist/eval/progress.d.ts +0 -83
  141. package/dist/eval/progress.js +0 -59
  142. package/dist/eval/report.d.ts +0 -11
  143. package/dist/eval/report.js +0 -181
  144. package/dist/eval/rubric-loader.d.ts +0 -20
  145. package/dist/eval/rubric-loader.js +0 -143
  146. package/dist/eval/runner.d.ts +0 -81
  147. package/dist/eval/runner.js +0 -746
  148. package/dist/eval/runs.d.ts +0 -41
  149. package/dist/eval/runs.js +0 -114
  150. package/dist/eval/sandbox.d.ts +0 -38
  151. package/dist/eval/sandbox.js +0 -137
  152. package/dist/eval/tools/glob.d.ts +0 -2
  153. package/dist/eval/tools/glob.js +0 -163
  154. package/dist/eval/tools/grep.d.ts +0 -2
  155. package/dist/eval/tools/grep.js +0 -152
  156. package/dist/eval/tools/index.d.ts +0 -7
  157. package/dist/eval/tools/index.js +0 -35
  158. package/dist/eval/tools/read.d.ts +0 -2
  159. package/dist/eval/tools/read.js +0 -122
  160. package/dist/eval/tools/types.d.ts +0 -49
  161. package/dist/eval/tools/types.js +0 -41
  162. package/dist/eval/tools/write.d.ts +0 -2
  163. package/dist/eval/tools/write.js +0 -92
  164. package/dist/eval/types.d.ts +0 -561
  165. package/dist/eval/types.js +0 -47
  166. package/dist/eval/verifiers/judge.d.ts +0 -40
  167. package/dist/eval/verifiers/judge.js +0 -256
  168. package/dist/eval/verifiers/rules.d.ts +0 -24
  169. package/dist/eval/verifiers/rules.js +0 -218
  170. package/dist/eval/verifiers/structural.d.ts +0 -14
  171. package/dist/eval/verifiers/structural.js +0 -171
  172. package/dist/eval/verifiers/traceability.d.ts +0 -23
  173. package/dist/eval/verifiers/traceability.js +0 -84
  174. package/dist/eval/verifiers/workflow-consistency.d.ts +0 -21
  175. package/dist/eval/verifiers/workflow-consistency.js +0 -225
  176. package/dist/eval/workflow-corpus.d.ts +0 -7
  177. package/dist/eval/workflow-corpus.js +0 -207
  178. package/dist/feature-system.d.ts +0 -42
  179. package/dist/feature-system.js +0 -432
  180. package/dist/internal/knowledge-digest.d.ts +0 -7
  181. package/dist/internal/knowledge-digest.js +0 -93
@@ -1,1493 +1,7 @@
1
1
  /**
2
- * Utility skills that complement the 8 flow stages.
3
- * These are contextual lenses, not flow stages.
4
- * Each skill: ~120-180 lines, under the 500-line progressive disclosure guideline.
2
+ * Opt-in language rule packs for stage hooks and the meta-skill router.
3
+ * These are generated under `.cclaw/rules/lang`, not as default skills.
5
4
  */
6
- export function securityReviewSkill() {
7
- return `---
8
- name: security
9
- description: "Security hardening review. Use when reviewing code for vulnerabilities, adding auth, handling secrets, or before shipping to production."
10
- ---
11
-
12
- # Security Review
13
-
14
- ## Quick Start
15
-
16
- > 1. Run the checklist below against the code under review.
17
- > 2. For each finding: severity (Critical/Important/Suggestion), file:line, fix.
18
- > 3. Critical findings block merge. Important findings need a named owner + deadline.
19
-
20
- ## HARD-GATE
21
-
22
- Do not approve code with known Critical security issues. No exceptions.
23
-
24
- ## When to Use
25
-
26
- - Before shipping any user-facing feature
27
- - When adding authentication, authorization, or secrets handling
28
- - When handling user input, file uploads, or external API data
29
- - During the review stage (entered via \`/cc-next\`) as a specialist lens
30
- - When the security-reviewer agent persona is activated
31
-
32
- ## Checklist
33
-
34
- ### Input Validation
35
- 1. All user inputs validated (type, length, format) before processing
36
- 2. No raw SQL — parameterized queries or ORM only
37
- 3. No \`eval()\`, \`new Function()\`, or dynamic code execution from user input
38
- 4. File uploads: validated type, size limit, stored outside webroot, no executable permissions
39
-
40
- ### Authentication & Authorization
41
- 5. Passwords hashed with bcrypt/scrypt/argon2 (never MD5/SHA1 alone)
42
- 6. Session tokens: cryptographically random, HttpOnly, Secure, SameSite
43
- 7. Auth checks on every protected route (not just the frontend)
44
- 8. Rate limiting on login, signup, password reset endpoints
45
- 9. No secret keys in source code or client bundles; server-side secrets must come from env vars or a secrets manager
46
-
47
- ### Data Protection
48
- 10. Sensitive data encrypted at rest and in transit (TLS 1.2+)
49
- 11. PII minimized — collect only what's needed, with retention policy
50
- 12. Error messages do not leak stack traces, DB schema, or internal paths
51
- 13. Logs scrubbed of tokens, passwords, PII
52
-
53
- ### Dependency & Infrastructure
54
- 14. No critical CVEs in direct dependencies (\`npm audit\`, \`pip audit\`, etc.)
55
- 15. Docker images: non-root user, minimal base, no unnecessary packages
56
- 16. CORS configured to allow only expected origins
57
- 17. CSP headers set; no \`unsafe-inline\` unless justified and documented
58
-
59
- ## Severity Classification
60
-
61
- | Severity | Definition | Action |
62
- |----------|-----------|--------|
63
- | Critical | Exploitable vulnerability (injection, auth bypass, secret exposure) | Block merge. Fix immediately. |
64
- | Important | Weakness that could become exploitable (missing rate limit, weak validation) | Named owner + fix deadline before ship. |
65
- | Suggestion | Defense-in-depth improvement (additional header, stricter CSP) | Track in backlog. |
66
-
67
- ## Output Format
68
-
69
- For each finding:
70
- \`\`\`
71
- - **Severity:** Critical | Important | Suggestion
72
- - **Category:** Input Validation | Auth | Data Protection | Dependencies
73
- - **File:line:** path/to/file.ts:42
74
- - **Description:** What's wrong and why it matters
75
- - **Fix:** Specific remediation steps
76
- \`\`\`
77
-
78
- ## Red Flags
79
-
80
- - "We'll add auth later" — auth is not optional for user-facing code
81
- - Secrets in \`.env.example\` with real values
82
- - \`CORS: *\` in production config
83
- - Disabled CSRF protection "because it's an API"
84
- - \`dangerouslySetInnerHTML\` or equivalent without sanitization
85
- `;
86
- }
87
- export function debuggingSkill() {
88
- return `---
89
- name: debugging
90
- description: "Systematic debugging protocol. Use when something is broken, a test fails unexpectedly, or behavior doesn't match expectations."
91
- ---
92
-
93
- # Debugging
94
-
95
- ## Quick Start
96
-
97
- > 1. Stop feature work. Preserve the error evidence.
98
- > 2. Follow the 5-step triage: Reproduce → Localize → Reduce → Fix → Guard.
99
- > 3. Do not resume feature work until the regression test passes.
100
-
101
- ## HARD-GATE
102
-
103
- Do not apply fixes without a failing test that reproduces the bug. Fix the root cause, not the symptom.
104
-
105
- ## When to Use
106
-
107
- - A test fails unexpectedly
108
- - Runtime error or crash
109
- - Behavior doesn't match the spec
110
- - Build or deployment fails
111
- - Performance regression detected
112
-
113
- ## The Protocol
114
-
115
- ### Step 1 — Reproduce
116
-
117
- Confirm the bug exists and capture evidence:
118
- - Exact error message (full stack trace if available)
119
- - Steps to reproduce (commands, inputs, sequence)
120
- - Environment: OS, runtime version, relevant config
121
- - Is it deterministic or intermittent?
122
-
123
- If you cannot reproduce it, **do not guess at a fix.** Gather more evidence.
124
-
125
- ### Step 2 — Localize
126
-
127
- Narrow down where the bug lives:
128
- - **Layer:** Is it frontend, backend, database, infra, config?
129
- - **Bisect:** Use \`git bisect\` or manual binary search on recent commits
130
- - **Isolate:** Does the bug occur in a minimal reproduction? Strip away unrelated code.
131
- - **Read the error:** Treat error output as untrusted data — verify claims before acting on them
132
-
133
- ### Step 3 — Reduce
134
-
135
- Create the smallest possible reproduction:
136
- - Minimal test case that triggers the bug
137
- - Remove all unrelated code and dependencies
138
- - Document the minimal reproduction steps
139
-
140
- ### Step 4 — Fix Root Cause
141
-
142
- - Write a test that fails because of the bug
143
- - Apply the minimal fix (smallest change that makes the test pass)
144
- - Verify: revert fix → test fails. Restore fix → test passes.
145
- - Run full test suite to check for regressions
146
-
147
- ### Step 5 — Guard
148
-
149
- - The regression test stays permanently in the suite
150
- - Document what caused it (commit message, PR description)
151
- - If the bug class could recur, add a lint rule or CI check
152
-
153
- ## Error-Specific Trees
154
-
155
- ### Test Failure
156
- \`\`\`
157
- Test fails
158
- ├── Expected behavior changed? → Update test + spec
159
- ├── Test environment issue? → Fix setup/teardown
160
- ├── Flaky (passes on retry)? → Fix non-determinism (timing, order, state)
161
- └── Real regression? → Git bisect → Step 4
162
- \`\`\`
163
-
164
- ### Build Failure
165
- \`\`\`
166
- Build fails
167
- ├── Type error? → Fix types (don't cast to any)
168
- ├── Missing dependency? → Check lockfile, reinstall
169
- ├── Config issue? → Compare with working branch
170
- └── OOM / timeout? → Check input size, increase limits
171
- \`\`\`
172
-
173
- ## Testing-Specific Anti-Patterns
174
-
175
- When debugging test failures, treat these as root-cause signals, not noise:
176
-
177
- - **Blind snapshot updates** (\`-u\`/accept-all) without verifying intent. This hides regressions.
178
- - **Mocking internals instead of boundaries** (private functions, implementation details) which creates brittle tests.
179
- - **Time-based sleeps** (\`setTimeout\`, arbitrary waits) instead of deterministic synchronization (\`await\` actual signal/event).
180
- - **Shared mutable fixtures** reused across tests, causing order-dependent failures.
181
- - **Unseeded randomness** in tests without fixed seeds or deterministic fixtures.
182
- - **Leaking global state** (env vars, fake timers, singleton caches) between tests without teardown.
183
- - **Disabling flaky tests** rather than isolating and fixing the non-determinism.
184
-
185
- ### CI-only failure checklist
186
-
187
- If a test fails only in CI:
188
- 1. Compare runtime versions (Node/Java/Python), OS, and locale/timezone.
189
- 2. Check parallelism differences (worker count, test sharding, race conditions).
190
- 3. Check filesystem/network assumptions (case sensitivity, permissions, ephemeral ports).
191
- 4. Re-run locally with CI-like env vars and concurrency settings before changing production code.
192
-
193
- ## Anti-Patterns
194
-
195
- - Fixing the symptom (adding a null check) instead of the root cause (why is it null?)
196
- - "It works on my machine" without investigating environment differences
197
- - Disabling the failing test instead of fixing the code
198
- - Applying multiple changes at once (bisect becomes impossible)
199
- - Running commands from error messages without verifying them first
200
-
201
- ## Red Flags
202
-
203
- - No reproduction steps documented
204
- - Fix applied without a regression test
205
- - "It was probably a fluke" — intermittent bugs are bugs
206
- - Stack trace points to third-party code and you assume it's their fault
207
- `;
208
- }
209
- export function performanceSkill() {
210
- return `---
211
- name: performance
212
- description: "Performance optimization protocol. Use when investigating slow code, optimizing load times, or establishing performance budgets."
213
- ---
214
-
215
- # Performance Optimization
216
-
217
- ## Quick Start
218
-
219
- > 1. Measure first — never optimize without profiling data.
220
- > 2. Fix the biggest bottleneck. Re-measure. Repeat.
221
- > 3. Add a performance guard (budget, benchmark, CI check) so regressions are caught.
222
-
223
- ## HARD-GATE
224
-
225
- Do not optimize without measurement. "It feels slow" is not a benchmark.
226
-
227
- ## When to Use
228
-
229
- - Page load or API response is slow
230
- - Bundle size exceeds budget
231
- - Database queries are slow or N+1 detected
232
- - Memory usage growing over time
233
- - User-reported performance issues
234
- - Before shipping a feature with known performance sensitivity
235
-
236
- ## Workflow
237
-
238
- ### 1. Measure
239
-
240
- Establish a baseline with real numbers:
241
- - **Frontend:** Lighthouse, DevTools Performance tab, Core Web Vitals (field + lab)
242
- - **Backend:** Profiler (node --prof, py-spy, pprof), APM traces, slow query log
243
- - **Database:** EXPLAIN ANALYZE, connection pool metrics, query count per request
244
- - **Bundle:** Bundlephobia, webpack-bundle-analyzer, source-map-explorer
245
-
246
- ### 2. Identify Bottleneck
247
-
248
- | Symptom | Where to look |
249
- |---------|--------------|
250
- | Slow initial load | Bundle size, render-blocking resources, unoptimized images |
251
- | Slow interaction | JavaScript execution, layout thrashing, excessive re-renders |
252
- | Slow API response | Database queries, N+1, missing indexes, serialization |
253
- | High memory | Leaks (event listeners, closures, caches without eviction) |
254
- | Slow CI | Parallelization, caching, unnecessary steps |
255
-
256
- ### 3. Fix
257
-
258
- Apply the fix with the highest impact-to-effort ratio:
259
- - One change at a time (so you can measure the delta)
260
- - Prefer removing code over adding caching layers
261
- - Prefer lazy loading over eager optimization
262
-
263
- ### 4. Verify
264
-
265
- Re-run the same measurement from Step 1:
266
- - Did the metric improve?
267
- - Did anything else regress?
268
- - Is the improvement statistically significant (not just noise)?
269
-
270
- ### 5. Guard
271
-
272
- Prevent regressions:
273
- - Bundle size budget in CI (fail if exceeded)
274
- - Performance benchmark in test suite
275
- - Slow query alerting
276
- - Core Web Vitals monitoring (CrUX, RUM)
277
-
278
- ## Core Web Vitals Reference
279
-
280
- | Metric | Good | Needs Improvement | Poor |
281
- |--------|------|-------------------|------|
282
- | LCP (Largest Contentful Paint) | ≤ 2.5s | ≤ 4.0s | > 4.0s |
283
- | INP (Interaction to Next Paint) | ≤ 200ms | ≤ 500ms | > 500ms |
284
- | CLS (Cumulative Layout Shift) | ≤ 0.1 | ≤ 0.25 | > 0.25 |
285
-
286
- ## Common Anti-Patterns
287
-
288
- - Premature optimization without profiling
289
- - N+1 queries (fetch list, then fetch related 1-by-1)
290
- - Unbounded \`SELECT *\` without pagination
291
- - Missing database indexes on filtered/joined columns
292
- - Loading entire libraries for one function (use tree-shaking or targeted import)
293
- - Synchronous file I/O in request handlers
294
- - No \`Cache-Control\` headers on static assets
295
- `;
296
- }
297
- export function ciCdSkill() {
298
- return `---
299
- name: ci-cd
300
- description: "CI/CD pipeline guidance. Use when setting up, debugging, or optimizing continuous integration and deployment."
301
- ---
302
-
303
- # CI/CD & Automation
304
-
305
- ## Quick Start
306
-
307
- > 1. Every push runs: lint → types → test → build.
308
- > 2. No skipping steps. A green pipeline is the only merge gate.
309
- > 3. Secrets in CI vault only — never in source code or logs.
310
-
311
- ## HARD-GATE
312
-
313
- Do not merge without a green CI pipeline. Do not skip quality gates.
314
-
315
- ## When to Use
316
-
317
- - Setting up CI for a new project
318
- - CI is failing and needs debugging
319
- - Optimizing slow CI pipelines
320
- - Adding deployment automation
321
- - Configuring branch protection or merge gates
322
-
323
- ## Quality Gate Pipeline (strict order)
324
-
325
- \`\`\`
326
- lint → types → unit tests → build → integration tests → (optional: E2E) → audit → bundle size
327
- \`\`\`
328
-
329
- Each gate must pass before the next runs. If any gate fails:
330
- 1. Stop the pipeline (fail fast)
331
- 2. Report which gate failed with actionable output
332
- 3. Do not proceed to deployment
333
-
334
- ## Pipeline Configuration Checklist
335
-
336
- ### Source Quality
337
- 1. Linter runs with zero warnings (treat warnings as errors in CI)
338
- 2. Type checker passes (TypeScript \`--noEmit\`, mypy, etc.)
339
- 3. Formatter check (Prettier \`--check\`, Black \`--check\`, gofmt)
340
-
341
- ### Testing
342
- 4. Unit tests run with coverage threshold (e.g., 80% lines)
343
- 5. Integration tests run against real dependencies (Docker services, test DB)
344
- 6. E2E tests run against a deployed preview (if applicable)
345
-
346
- ### Build & Deploy
347
- 7. Build produces artifacts without warnings
348
- 8. Bundle size checked against budget
349
- 9. Security audit: no critical CVEs (\`npm audit\`, \`pip audit\`)
350
- 10. Deploy to staging before production (if applicable)
351
-
352
- ### Secrets & Security
353
- 11. Secrets stored in CI vault (GitHub Secrets, Vault, etc.)
354
- 12. No secrets in logs (mask sensitive env vars)
355
- 13. OIDC tokens preferred over long-lived credentials
356
- 14. Pin dependencies to exact versions or verified hashes
357
-
358
- ## CI Debugging Protocol
359
-
360
- When CI fails:
361
- 1. Read the **full** error output (not just the last line)
362
- 2. Check: is it reproducible locally? (\`npm test\`, \`docker compose up\`)
363
- 3. Check: did it pass on the previous commit? (regression vs pre-existing)
364
- 4. Check: is it a flaky test? (re-run once; if it passes, fix the flakiness)
365
- 5. Check: is it an infrastructure issue? (timeout, rate limit, dependency outage)
366
-
367
- ## Anti-Patterns
368
-
369
- - "CI is slow so we skip tests on draft PRs" — draft PRs need CI too
370
- - Retry-until-green for flaky tests (fix the test, don't retry)
371
- - Manual deployment steps documented in a wiki (automate them)
372
- - \`--no-verify\` or \`--force\` as standard practice
373
- - CI config that only runs on main (run on all branches)
374
- `;
375
- }
376
- export function docsSkill() {
377
- return `---
378
- name: docs
379
- description: "Documentation and ADR guidance. Use when writing docs, recording architecture decisions, or establishing docs standards."
380
- ---
381
-
382
- # Documentation & ADRs
383
-
384
- ## Quick Start
385
-
386
- > 1. Document **why**, not just what. Code shows what; docs explain why.
387
- > 2. Every expensive-to-reverse decision gets an ADR.
388
- > 3. Keep docs next to the code they describe. Stale docs are worse than no docs.
389
-
390
- ## HARD-GATE
391
-
392
- Do not ship a new public API, architecture change, or breaking change without documentation.
393
-
394
- ## When to Use
395
-
396
- - Adding or changing a public API
397
- - Making an architecture decision that's expensive to reverse
398
- - Shipping a feature that changes user-visible behavior
399
- - Onboarding needs to explain "how this works" or "why we did this"
400
- - Existing docs are stale or misleading
401
-
402
- ## ADR (Architecture Decision Record)
403
-
404
- ### When to Write an ADR
405
-
406
- - Choosing a framework, database, or major dependency
407
- - Changing the data model, API contract, or deployment topology
408
- - Any decision where "why did we do this?" will be asked in 6 months
409
-
410
- ### ADR Template
411
-
412
- File: \`docs/decisions/NNNN-title.md\`
413
-
414
- \`\`\`markdown
415
- # NNNN. Title
416
-
417
- **Status:** Proposed | Accepted | Deprecated | Superseded by NNNN
418
- **Date:** YYYY-MM-DD
419
-
420
- ## Context
421
- What is the issue that we're seeing that motivates this decision?
422
-
423
- ## Decision
424
- What is the change that we're proposing or have agreed to?
425
-
426
- ## Alternatives Considered
427
- | Alternative | Pros | Cons |
428
- |------------|------|------|
429
- | Option A | ... | ... |
430
- | Option B | ... | ... |
431
-
432
- ## Consequences
433
- What becomes easier or harder as a result of this decision?
434
- \`\`\`
435
-
436
- ### ADR Rules
437
-
438
- - **Never delete** an ADR. If it's wrong, write a new one that supersedes it.
439
- - **Number sequentially.** Gaps are fine (deleted = superseded).
440
- - **Status matters.** "Proposed" is not "Accepted."
441
-
442
- ## README Guidance
443
-
444
- Every project README should answer:
445
- 1. **What** does this do? (one paragraph)
446
- 2. **How** do I run it? (quick start commands)
447
- 3. **How** do I develop on it? (install, test, build)
448
- 4. **Where** is the architecture documented? (link to ADRs or design docs)
449
-
450
- ## API Documentation
451
-
452
- For public APIs:
453
- - Every endpoint: method, path, parameters, request/response examples, error codes
454
- - Authentication: how to get and use tokens
455
- - Rate limits and pagination
456
- - Breaking change policy and versioning scheme
457
-
458
- ## Inline Documentation Standards
459
-
460
- - **Do:** Explain WHY (trade-offs, constraints, gotchas, non-obvious behavior)
461
- - **Don't:** Narrate WHAT the code does — the code already does that
462
- - **Do:** Document public interfaces (params, return, throws, side effects)
463
- - **Don't:** Comment every line or section with obvious descriptions
464
-
465
- ## Anti-Patterns
466
-
467
- - Docs in a wiki that nobody updates (keep docs in the repo)
468
- - "Self-documenting code" as excuse for zero docs
469
- - Copying code into docs (it will drift — link to source instead)
470
- - Giant monolithic README (split into focused docs)
471
- - Documenting internal implementation details of public APIs
472
- `;
473
- }
474
- export function executingPlansSkill() {
475
- return `---
476
- name: executing-plans
477
- description: "Execute approved plans with disciplined batching, explicit checkpoints, and gate-safe progress tracking."
478
- ---
479
-
480
- # Executing Plans
481
-
482
- ## Quick Start
483
-
484
- > 1. Confirm the plan and stage gates are approved before execution.
485
- > 2. Execute in batches, not as one giant untracked stream.
486
- > 3. Stop at checkpoint boundaries for verification and user visibility.
487
-
488
- ## HARD-GATE
489
-
490
- Do not start implementation execution without an approved plan artifact and explicit gate satisfaction for the current stage.
491
-
492
- ## Execution Protocol
493
-
494
- 1. **Load plan source of truth** from \`.cclaw/artifacts/05-plan.md\` (canonical run copy when available).
495
- 2. **Group tasks into batches** by dependency order and risk.
496
- 3. **Run one batch at a time** with evidence after each task (tests, build, lint, or review evidence as applicable).
497
- 4. **Checkpoint each batch** by updating stage artifact evidence and unresolved blockers.
498
- 5. **Stop immediately** on any hard blocker, failing gate, or unresolved critical finding.
499
-
500
- ## Batch Checklist
501
-
502
- - Batch scope is explicit (task IDs + expected outputs).
503
- - Verification command for each task is predetermined.
504
- - Machine-only checks are delegated to subagents when supported.
505
- - User approvals are requested only at required gate boundaries.
506
-
507
- ## Fresh Context Protocol (between batches)
508
-
509
- After a batch completes — especially after long agent turns — context drift is
510
- the #1 cause of degraded execution quality. Before starting the **next batch**,
511
- prefer a **fresh agent context** over continuing in a saturated session:
512
-
513
- 1. **Snapshot batch outcome** — append a short summary to the plan artifact
514
- (\`### Batch <N> outcome\` with: tasks done, evidence files, blockers, next-batch inputs).
515
- 2. **Capture handoff facts** — the minimum information the next agent needs:
516
- - Stage and run id (from \`.cclaw/state/flow-state.json\`)
517
- - List of completed task IDs from the plan
518
- - Open blockers / failing gates by name
519
- - File paths the next batch will touch (no full diffs)
520
- 3. **Decide: continue or rotate**
521
- - **Rotate** (start a new agent session) when: prior batch consumed > ~50% of the context budget, the prior batch required deep investigation that the next batch does not need, or you are about to cross a stage boundary.
522
- - **Continue** when: next batch is a tiny follow-up (≤ 1 task) and the prior context is directly relevant.
523
- 4. **Resume** in the new session via \`/cc-next\` — the session-start hook will restore flow state, checkpoint, and digest automatically.
524
-
525
- This is the same intuition as Compound Engineering's "fresh context per iteration": every batch starts with a clean, intentionally-loaded context, not a degraded carry-over.
526
-
527
- ### Handoff template (paste into next session)
528
-
529
- \`\`\`markdown
530
- ## Batch <N> handoff
531
- - Stage: <stage>
532
- - Run: <runId>
533
- - Completed task IDs: <list>
534
- - Blockers: <list or none>
535
- - Files next batch will touch: <list>
536
- - Verification command(s) used: <list>
537
- \`\`\`
538
-
539
- ## Anti-Patterns
540
-
541
- - Executing all tasks in one pass without intermediate verification.
542
- - Marking tasks done without command evidence.
543
- - Reordering critical dependencies for speed.
544
- - Continuing after a gate failure hoping later tasks fix it.
545
- - Carrying a saturated context across batch boundaries because "it has all the history" — saturated context is a liability, not an asset.
546
- `;
547
- }
548
- export function contextEngineeringSkill() {
549
- return `---
550
- name: context-engineering
551
- description: "Manage context modes and payload hygiene to keep agent execution reliable across long sessions."
552
- ---
553
-
554
- # Context Engineering
555
-
556
- ## Quick Start
557
-
558
- > 1. Read current mode from \`.cclaw/state/context-mode.json\`.
559
- > 2. Load only the context needed for the current stage/task.
560
- > 3. Switch modes intentionally when work type changes.
561
-
562
- ## HARD-GATE
563
-
564
- Do not keep stale or oversized context loaded when task intent changes. Context must match current stage purpose.
565
-
566
- ## Context Modes
567
-
568
- Modes are stored in \`.cclaw/contexts/\`:
569
- - \`default\` — balanced execution
570
- - \`execution\` — fast plan/tdd throughput
571
- - \`review\` — defect/risk discovery
572
- - \`incident\` — stabilization and recovery
573
-
574
- ## Mode Switching Protocol
575
-
576
- 1. Determine target mode based on current objective.
577
- 2. Update \`.cclaw/state/context-mode.json\`:
578
- - \`activeMode\`: target mode id
579
- - \`updatedAt\`: current ISO timestamp
580
- 3. Announce mode change in-session with one-line reason.
581
- 4. Continue using the corresponding \`.cclaw/contexts/<mode>.md\` guidance.
582
-
583
- ## Payload Hygiene Rules
584
-
585
- - Prefer stage artifacts + current diff over full-repo dumps.
586
- - Reference exact files/symbols, not broad vague prompts.
587
- - For subagents, pass self-contained instructions and expected output schema.
588
- - Trim or rotate outdated context after each major checkpoint.
589
-
590
- ## Anti-Patterns
591
-
592
- - Staying in execution mode while doing deep review triage.
593
- - Switching mode without updating state.
594
- - Shipping decisions based on stale pre-compaction context.
595
- `;
596
- }
597
- export function verificationBeforeCompletionSkill() {
598
- return `---
599
- name: verification-before-completion
600
- description: "Final verification discipline before stage closeout or ship. Use when preparing a completion claim."
601
- ---
602
-
603
- # Verification Before Completion
604
-
605
- ## Announce at start
606
-
607
- "Using verification-before-completion to validate fresh evidence before completion."
608
-
609
- ## HARD-GATE
610
-
611
- Do not claim completion from memory. Every pass claim requires fresh, in-turn evidence.
612
-
613
- ## Protocol
614
-
615
- 1. Identify changed scope (files, modules, user-facing behaviors).
616
- 2. Run the smallest command set that still proves the scope:
617
- - tests for changed area
618
- - typecheck/build/lint if the stack requires it
619
- 3. Capture exact command + pass/fail output in the artifact.
620
- 4. If this is a bug fix, include RED -> GREEN regression evidence.
621
- 5. If any check fails, stop completion and return to fix loop.
622
-
623
- ## Completion claim checklist
624
-
625
- - [ ] Commands were run in this turn (not reused from earlier output).
626
- - [ ] Output corresponds to the actual changed scope.
627
- - [ ] Failures (if any) are resolved or explicitly escalated.
628
- - [ ] Artifact includes evidence references.
629
- - [ ] Completion status reflects evidence (DONE / DONE_WITH_CONCERNS / BLOCKED).
630
-
631
- ## Anti-patterns
632
-
633
- - "Tests passed earlier today" without rerunning.
634
- - Reporting only "PASS" without command context.
635
- - Running unrelated checks while skipping changed scope checks.
636
- - Marking DONE while blockers still fail.
637
- `;
638
- }
639
- export function finishingDevelopmentBranchSkill() {
640
- return `---
641
- name: finishing-a-development-branch
642
- description: "Finalize implementation branch after review: verify, choose integration mode, execute safely, and clean up."
643
- ---
644
-
645
- # Finishing a Development Branch
646
-
647
- ## Announce at start
648
-
649
- "Using finishing-a-development-branch to complete this branch safely."
650
-
651
- ## HARD-GATE
652
-
653
- Do not merge, open PR, or discard branch until verification and rollback notes are explicit.
654
-
655
- ## Protocol
656
-
657
- 1. Verify readiness:
658
- - review verdict is APPROVED or APPROVED_WITH_CONCERNS
659
- - verification-before-completion checklist is satisfied
660
- 2. Choose one finalization mode:
661
- - FINALIZE_MERGE_LOCAL
662
- - FINALIZE_OPEN_PR
663
- - FINALIZE_KEEP_BRANCH
664
- - FINALIZE_DISCARD_BRANCH
665
- - FINALIZE_NO_VCS
666
- 3. If \`.git\` is unavailable, use FINALIZE_NO_VCS and record manual handoff + rollback owner.
667
- 4. Execute only the chosen mode and record exact result.
668
- 5. If merge or discard happened in a feature worktree, clean the worktree.
669
- 6. Update ship artifact with release notes, rollback, and finalization evidence.
670
-
671
- ## Rollback minimum
672
-
673
- - Trigger: what tells us release is wrong.
674
- - Steps: exact revert/reset/rollback commands.
675
- - Verification: how we confirm rollback worked.
676
-
677
- ## Anti-patterns
678
-
679
- - Multiple finalization modes in one run.
680
- - Merge without rollback section.
681
- - PR without test/verification summary.
682
- - Discarding branch without explicit user confirmation.
683
- `;
684
- }
685
- export function sourceDrivenDevelopmentSkill() {
686
- return `---
687
- name: source-driven-development
688
- description: "Drive implementation decisions from existing source patterns before introducing new abstractions."
689
- ---
690
-
691
- # Source-Driven Development
692
-
693
- ## Quick Start
694
-
695
- > 1. Search the repo for existing patterns before writing new code.
696
- > 2. Reuse proven modules/contracts unless a clear incompatibility is documented.
697
- > 3. Record deviations with rationale when creating net-new patterns.
698
-
699
- ## HARD-GATE
700
-
701
- Do not introduce new architecture patterns or helper layers without first checking whether an equivalent source pattern already exists.
702
-
703
- ## Protocol
704
-
705
- 1. **Discover**: inspect related modules, adapters, tests, and conventions.
706
- 2. **Compare**: list at least two in-repo pattern candidates.
707
- 3. **Select**: choose reuse/extension/new with explicit rationale.
708
- 4. **Implement**: follow selected pattern consistently across touched files.
709
- 5. **Verify**: ensure tests and docs reflect the adopted pattern.
710
-
711
- ## Selection Heuristics
712
-
713
- - Prefer extension over duplication.
714
- - Prefer explicit local adaptation over global abstraction when scope is narrow.
715
- - Prefer tested, production-used patterns over speculative design.
716
-
717
- ## Required Evidence
718
-
719
- - Paths of source references reused.
720
- - Rationale for any intentional divergence.
721
- - Tests proving behavior compatibility.
722
-
723
- ## Anti-Patterns
724
-
725
- - Creating “better” abstractions without source comparison.
726
- - Duplicating utility logic under a new name.
727
- - Mixing incompatible patterns in the same change set.
728
- `;
729
- }
730
- export function frontendAccessibilitySkill() {
731
- return `---
732
- name: frontend-accessibility
733
- description: "Frontend quality lens for usability and accessibility (WCAG-oriented) during implementation and review."
734
- ---
735
-
736
- # Frontend Accessibility
737
-
738
- ## Quick Start
739
-
740
- > 1. Validate keyboard navigation and focus order first.
741
- > 2. Confirm semantic roles/labels and screen-reader announcements.
742
- > 3. Check contrast, motion, and responsive behavior before ship.
743
-
744
- ## HARD-GATE
745
-
746
- Do not approve user-facing UI changes that break basic keyboard navigation or remove accessible name/role/value semantics.
747
-
748
- ## Checklist
749
-
750
- 1. Interactive elements are reachable and usable via keyboard only.
751
- 2. Focus indicators are visible and logical after navigation and dialogs.
752
- 3. Form fields have labels, error messages, and instructions tied programmatically.
753
- 4. Color contrast meets WCAG AA expectations for text and controls.
754
- 5. Dynamic updates (toasts/modals/async states) are announced accessibly.
755
- 6. Motion/animation respects reduced-motion preferences where relevant.
756
- 7. Mobile and narrow layouts preserve readability and interaction targets.
757
-
758
- ## Output Format
759
-
760
- - **Issue**: concise defect description
761
- - **Impact**: affected users and severity
762
- - **Evidence**: file/component path and failing behavior
763
- - **Fix**: concrete remediation guidance
764
-
765
- ## Anti-Patterns
766
-
767
- - Relying on placeholder text as the only form label.
768
- - Click-only interactions without keyboard fallback.
769
- - Hiding focus ring without accessible replacement.
770
- - Color-only status indicators with no text/aria support.
771
- `;
772
- }
773
- export function landscapeCheckSkill() {
774
- return `---
775
- name: landscape-check
776
- description: "Landscape survey before a design/scope decision. Use when deciding whether to build, reuse, or adopt — inside and outside the repo."
777
- ---
778
-
779
- # Landscape Check
780
-
781
- ## Quick Start
782
-
783
- > 1. Before committing to a build decision, survey the landscape: in-repo, in-ecosystem, and in-class.
784
- > 2. Produce a one-page table of candidates (build / reuse in-repo / adopt external) with evidence.
785
- > 3. Explicitly kill alternatives with a one-line reason. Do not leave implicit assumptions.
786
-
787
- ## HARD-GATE
788
-
789
- Do not approve a scope or design that introduces a new system, library,
790
- or abstraction without comparing at least **one in-repo candidate** and
791
- **one external/ecosystem candidate** (or explicitly stating why no such
792
- candidates exist).
793
-
794
- ## When to Use
795
-
796
- - Scope stage, before picking a mode (expand/selective/hold/reduce)
797
- - Design stage, before committing to a new architecture boundary
798
- - Brainstorm stage, when the user frames the problem as "let's build X"
799
- - Review stage, when a proposed change duplicates an existing capability
800
-
801
- ## Protocol
802
-
803
- 1. **Define the capability in one sentence.** "We need a way to <verb> <object> under <constraint>."
804
- 2. **In-repo search.** Grep for similar verbs/modules/components. Read the closest 1-3 candidates. Record their fit and why they are or are not a good adapter target.
805
- 3. **Ecosystem search.** Check ecosystem defaults (stdlib, framework primitives, common OSS packages in use). Do not invent new dependencies when an existing one covers 80%+ of the need.
806
- 4. **In-class search.** Look at how other well-known projects in the same class solve this. Cite at least one concrete example (even if you end up rejecting it).
807
- 5. **Produce the decision table.** Columns: Candidate, Kind (build / reuse / adopt), Fit (1-5), Effort (S/M/L/XL), Risk, Reason accepted or rejected.
808
- 6. **Commit.** Pick exactly one winner. All losers must have a one-line kill reason.
809
-
810
- ## Output Template
811
-
812
- \`\`\`markdown
813
- ### Landscape Check — <capability>
814
-
815
- | Candidate | Kind | Fit | Effort | Risk | Verdict |
816
- |---|---|---|---|---|---|
817
- | src/foo/Bar | reuse | 4/5 | S | Low | SELECTED — already covers 80% of the need |
818
- | external/lib-x | adopt | 3/5 | M | Med | REJECTED — heavy dep, 20% unused surface |
819
- | build new | build | 2/5 | L | High | REJECTED — premature abstraction |
820
-
821
- **Decision:** Reuse \`src/foo/Bar\` with a thin adapter. Kill reasons recorded above.
822
- \`\`\`
823
-
824
- ## Anti-Patterns
825
-
826
- - "We looked and nothing fits" without citing what was looked at.
827
- - Treating "nobody on the team knows library X" as a kill reason without evaluating the learning cost.
828
- - Choosing "build" because reuse would require a small refactor of the existing component.
829
- - Skipping the in-class search because "our case is special" — it usually is not.
830
-
831
- ## Red Flags
832
-
833
- - Decision table has only the winner listed.
834
- - Ecosystem search is empty when a well-known primitive obviously applies.
835
- - "Fit" scores without evidence (no file:line, no cited OSS repo, no framework docs reference).
836
- - The in-repo candidate was never read before being dismissed.
837
- `;
838
- }
839
- export function knowledgeCurationSkill() {
840
- return `---
841
- name: knowledge-curation
842
- description: "Read-only curation pass over the canonical strict-JSONL knowledge store at .cclaw/knowledge.jsonl. Surfaces stale, duplicate, or low-confidence entries and proposes a soft-archive plan that moves approved lines to .cclaw/knowledge.archive.jsonl. Never deletes without explicit user approval."
843
- ---
844
-
845
- # Knowledge Curation
846
-
847
- ## Quick Start
848
-
849
- > 1. This is a **read-only audit** of \`.cclaw/knowledge.jsonl\`. Never delete or rewrite entries here.
850
- > 2. Surface candidates for soft-archive when the active file > 50 entries OR contains stale/duplicate/superseded entries.
851
- > 3. Propose a single archive plan and require explicit user approval before any move.
852
-
853
- ## HARD-GATE
854
-
855
- - Do not modify \`.cclaw/knowledge.jsonl\` from this skill except via an explicit user-approved archive plan that **moves** full JSON lines verbatim to \`.cclaw/knowledge.archive.jsonl\`. Never physically delete history that is already archived — the archive file is append-only too.
856
- - Do not silently rewrite or summarize entries — preserve the original JSON line byte-for-byte.
857
- - Operate only on the canonical JSONL store. If you see a stray \`.cclaw/knowledge.md\`, report it as a drift signal; do **not** read or rewrite it.
858
-
859
- ## When to run
860
-
861
- - Triggered automatically by **\`/cc-learn curate\`**.
862
- - Recommended after \`/cc-ops archive\` (or archive runtime) of a feature run, when knowledge has grown.
863
- - Recommended when active entry count exceeds **50**.
864
-
865
- ## Audit dimensions
866
-
867
- For each JSON line in \`.cclaw/knowledge.jsonl\` produce a row with:
868
-
869
- | Field | Source |
870
- |---|---|
871
- | # | 1-based line number in the JSONL file |
872
- | Type | \`type\` field (\`rule\` / \`pattern\` / \`lesson\` / \`compound\`) |
873
- | Stage | \`stage\` field (or \`null\`) |
874
- | Age | days since \`created\` |
875
- | Confidence | \`confidence\` field |
876
- | Domain | \`domain\` field (or \`null\`) |
877
- | Trigger | \`trigger\` field, truncated to 60 chars |
878
- | Status hint | one of: keep / supersede-candidate / archive-candidate / duplicate |
879
-
880
- ### Status rules
881
-
882
- - **supersede-candidate**: a newer line shares the same \`trigger\` (case-insensitive) and a different \`action\`.
883
- - **duplicate**: \`trigger\` ≈ another line's AND \`action\` ≈ the same (caller's judgment).
884
- - **archive-candidate**:
885
- - \`type=lesson\` AND age > 180 days AND no newer line references the same \`trigger\`; OR
886
- - \`stage=brainstorm\` AND age > 90 days; OR
887
- - \`confidence=low\` AND age > 60 days; OR
888
- - Total active entries > 50 and entry has the lowest estimated reuse signal.
889
- - **keep**: everything else.
890
-
891
- ## Output format
892
-
893
- Produce two artifacts as **chat output only** (do not write files):
894
-
895
- ### 1. Audit table
896
-
897
- \`\`\`markdown
898
- | # | Type | Stage | Age | Confidence | Trigger | Status hint |
899
- |---|---|---|---|---|---|---|
900
- | 1 | … | … | … | … | … | … |
901
- \`\`\`
902
-
903
- ### 2. Soft-archive proposal
904
-
905
- \`\`\`markdown
906
- ## Proposed archive (requires user approval)
907
-
908
- Threshold reasoning: <why entries below were selected>
909
-
910
- Entries to archive:
911
- 1. line #<N> — <trigger> — reason
912
- 2. line #<N> — <trigger> — reason
913
-
914
- Action plan if approved:
915
- 1. Ensure \`.cclaw/knowledge.archive.jsonl\` exists (create empty if missing).
916
- 2. Move (cut/paste) the selected JSON lines verbatim from
917
- \`.cclaw/knowledge.jsonl\` into \`.cclaw/knowledge.archive.jsonl\`,
918
- preserving byte order within each file.
919
- 3. Do not rewrite, re-order, or pretty-print any remaining line in the active file.
920
-
921
- After approval: ask the user to run the move themselves, or — if they explicitly grant write access — perform the move atomically and report the new active count.
922
- \`\`\`
923
-
924
- ## Anti-patterns
925
-
926
- - Deleting entries instead of archiving — knowledge must be append-only.
927
- - Rewriting an entry to "clean it up" — preserve original wording verbatim.
928
- - Auto-archiving without user approval, even when above threshold.
929
- - Removing \`compound\` entries — these are the highest-leverage records.
930
- - Treating high age as a proxy for low value — a 2-year-old security rule may be the most important entry in the file.
931
- `;
932
- }
933
- export function securityAuditSkill() {
934
- return `---
935
- name: security-audit
936
- description: "Proactive security audit — hunts for vulnerabilities across the codebase using pattern-based detection. Distinct from security review (checklist for a specific diff)."
937
- ---
938
-
939
- # Security Audit
940
-
941
- ## Quick Start
942
-
943
- > 1. Scan the codebase for high-signal vulnerability patterns (not just the diff).
944
- > 2. Produce a finding register grouped by category with severity and file:line.
945
- > 3. For each Critical: provide a concrete exploit path (not just a category label).
946
-
947
- ## HARD-GATE
948
-
949
- Do not close a security audit pass while any Critical pattern match is
950
- unresolved. Each Critical finding must be either fixed, suppressed with
951
- a documented reason, or tracked as a named accepted risk with an owner.
952
-
953
- ## When to Use
954
-
955
- - Initial project onboarding (baseline audit)
956
- - Before a major release that expands attack surface
957
- - When new dependencies are introduced
958
- - After a security incident (to check for same-class issues)
959
- - On a scheduled cadence (quarterly for stable projects, monthly for high-risk)
960
-
961
- This is complementary to the \`security\` skill, which is a point-in-time
962
- review checklist scoped to a single diff.
963
-
964
- ## Audit Pattern Catalog
965
-
966
- Run each category as a focused pass. For every pattern, capture
967
- file:line evidence — never assume the project is clean just because
968
- there was "no obvious problem".
969
-
970
- ### 1. Secret Exposure
971
-
972
- Patterns to grep for (language-agnostic):
973
-
974
- - \`AKIA[0-9A-Z]{16}\` — AWS access key id
975
- - \`-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----\`
976
- - \`xox[bp]-[0-9a-zA-Z-]+\` — Slack tokens
977
- - \`ghp_[A-Za-z0-9]{36}\` — GitHub PAT
978
- - \`console\\.log.*(token|secret|password|api_key)\`
979
- - Hard-coded JWTs (3 base64 segments separated by \`.\`)
980
-
981
- Also inspect: .env.example for real values, logs for PII, git history for
982
- leaked secrets via \`git log -p | grep -i secret\`.
983
-
984
- ### 2. Injection
985
-
986
- - Raw SQL string concatenation with request data
987
- - \`eval(\`, \`new Function(\`, \`exec(\`, \`execSync(\` with untrusted input
988
- - \`dangerouslySetInnerHTML\`, \`innerHTML =\` with user-provided content
989
- - Shell command construction from user input
990
- - Template literal SQL (\`\\\`SELECT ... \${userInput}\\\`\`)
991
-
992
- ### 3. Auth and Session
993
-
994
- - Missing auth middleware on routes that mutate state
995
- - JWT verification that trusts the \`alg\` header (algorithm confusion)
996
- - \`setCookie\` without \`HttpOnly\`, \`Secure\`, or \`SameSite\`
997
- - Session fixation (no regenerate-on-login)
998
- - Rate limit absent on login, signup, password reset
999
-
1000
- ### 4. Trust Boundary and LLM Output
1001
-
1002
- - LLM output passed directly to \`exec\` / SQL / filesystem calls
1003
- - Tool-call arguments from the model used without schema validation
1004
- - Untrusted markdown rendered without sanitization
1005
- - Confused deputy: service acts on behalf of user without passing auth context
1006
-
1007
- ### 5. Crypto Misuse
1008
-
1009
- - MD5 / SHA1 for password hashing
1010
- - \`Math.random()\` used for security tokens
1011
- - Reused IV in AES-GCM (catastrophic)
1012
- - ECB mode cipher usage
1013
- - Missing constant-time comparison for secrets
1014
-
1015
- ### 6. Dependency and Supply Chain
1016
-
1017
- - \`npm audit\` / \`pip audit\` Critical or High advisories unresolved
1018
- - Dependencies pulled from non-locked tags instead of pinned versions
1019
- - Post-install scripts from new/unknown packages
1020
- - Un-reviewed direct-to-main dependency bumps
1021
-
1022
- ### 7. File System and Path Traversal
1023
-
1024
- - \`path.join\` with user input without \`path.normalize\` + prefix check
1025
- - Unzip/untar without entry path validation (zip-slip)
1026
- - Writing to user-supplied paths without allowlist
1027
- - Following symlinks inside trusted directories
1028
-
1029
- ### 8. Logging and Observability
1030
-
1031
- - Stack traces returned in API responses (production)
1032
- - Logs containing tokens, passwords, full request bodies
1033
- - Error messages that reveal DB schema or internal paths
1034
-
1035
- ## Output Format
1036
-
1037
- Produce a single audit report with this structure:
1038
-
1039
- \`\`\`markdown
1040
- # Security Audit — <scope>, <date>
1041
-
1042
- ## Summary
1043
- - Files scanned: <N>
1044
- - Categories checked: <list>
1045
- - Critical: <N>, Important: <N>, Suggestion: <N>
1046
-
1047
- ## Findings
1048
-
1049
- ### <Category> — <Pattern name>
1050
- - **Severity:** Critical | Important | Suggestion
1051
- - **File:line:** path/to/file.ts:42
1052
- - **Evidence:** short excerpt (≤ 3 lines)
1053
- - **Exploit path:** specific, concrete (not a category label)
1054
- - **Fix:** specific remediation with command/patch-level detail
1055
- - **Owner:** <name or role>
1056
- - **Target date:** <YYYY-MM-DD for Critical/Important>
1057
-
1058
- ## Accepted Risks
1059
- - <finding id>: <reason documented>, owner <name>, revisit <date>
1060
-
1061
- ## Suppressed (False Positives)
1062
- - <finding id>: <why this pattern is not exploitable here>
1063
- \`\`\`
1064
-
1065
- ## Anti-Patterns
1066
-
1067
- - "No Critical findings" without stating what patterns were actually run.
1068
- - Accepting a Critical risk without named owner + revisit date.
1069
- - Treating a lint rule as equivalent to a runtime security check.
1070
- - Running audits only on the diff — the diff does not contain legacy risks.
1071
- - Deleting audit reports after fixing findings (keep them as regression evidence).
1072
-
1073
- ## Red Flags
1074
-
1075
- - Audit claims coverage but cites zero file:line evidence.
1076
- - Every Critical pattern has zero matches (this is implausible for any non-trivial codebase — verify the grep commands were actually executed).
1077
- - Findings are Important-only (no Critical or Suggestion buckets) — usually means severity was compressed to avoid escalation.
1078
- `;
1079
- }
1080
- export function adversarialReviewSkill() {
1081
- return `---
1082
- name: adversarial-review
1083
- description: "Adversarial review lens. Use during review to deliberately attack the implementation — as a hostile user, a future maintainer, or a competitor."
1084
- ---
1085
-
1086
- # Adversarial Review
1087
-
1088
- ## Quick Start
1089
-
1090
- > 1. Stop assuming good-faith usage. Play three roles in sequence: hostile user, stressed operator, future maintainer.
1091
- > 2. For each role, produce at least 2 concrete attack/friction scenarios with file:line evidence.
1092
- > 3. Escalate any finding that a Critical severity review would miss.
1093
-
1094
- ## HARD-GATE
1095
-
1096
- Do not complete review stage without an adversarial-review pass when
1097
- **any** of the following apply: user-facing input surface changed,
1098
- trust boundary moved, concurrency was introduced, or a new failure
1099
- mode path was added.
1100
-
1101
- ## When to Use
1102
-
1103
- - Review stage, after Layer 2 quality checks complete
1104
- - Before shipping anything user-facing or revenue-sensitive
1105
- - When fuzz/property-testing exists but was not exercised against this change
1106
- - When the implementer has a strong "this is fine" prior
1107
-
1108
- ## Roles and Questions
1109
-
1110
- ### Role 1 — Hostile User
1111
-
1112
- You are trying to break, trick, or exploit the system. Ask:
1113
-
1114
- - What happens on empty / null / maximum / negative / unicode / newline inputs?
1115
- - What if I call the endpoint 1000 times per second? What about 1 every 10 minutes for a week?
1116
- - What if I send a payload that is almost valid (off-by-one schema, wrong content-type, duplicate keys)?
1117
- - What if two honest actions collide (double-click, race, retry after timeout)?
1118
- - Can I observe a secret through error messages, timing, or response size?
1119
-
1120
- ### Role 2 — Stressed Operator
1121
-
1122
- You are on call at 3 AM. Ask:
1123
-
1124
- - What does this look like in logs when it fails? Is the failure actionable?
1125
- - If I restart the service mid-request, does state recover cleanly?
1126
- - Is the rollback procedure real, tested, and under 15 minutes?
1127
- - Can I tell from metrics alone whether this is healthy?
1128
-
1129
- ### Role 3 — Future Maintainer
1130
-
1131
- You are reading this code in 6 months with no memory of the context. Ask:
1132
-
1133
- - Can I safely change this without breaking callers I cannot see?
1134
- - Are there hidden invariants not captured in tests?
1135
- - Will renaming this field silently break serialized consumers?
1136
- - Is the "obviously correct" path actually correct, or is it just plausible?
1137
-
1138
- ## Output Format
1139
-
1140
- For each finding:
1141
-
1142
- \`\`\`
1143
- - **Role:** Hostile User | Stressed Operator | Future Maintainer
1144
- - **Scenario:** concrete scenario (not a category)
1145
- - **File:line:** path/to/file.ts:42
1146
- - **Impact:** what breaks, for whom, under what frequency
1147
- - **Recommendation:** specific fix or mitigation
1148
- \`\`\`
1149
-
1150
- Escalate to the main review-army under the matching severity (Critical / Important / Suggestion).
1151
-
1152
- ## Anti-Patterns
1153
-
1154
- - Treating adversarial review as a category list without producing concrete scenarios.
1155
- - Assuming "our users would never do that" — they will, or the next integration will.
1156
- - Running adversarial review after the ship decision is already made.
1157
- - Only playing the hostile-user role and skipping operator + maintainer.
1158
- `;
1159
- }
1160
- export function documentReviewSkill() {
1161
- return `---
1162
- name: document-review
1163
- description: "Post-artifact scrub pass. Use after writing any cclaw artifact (brainstorm, scope, design, spec, plan, review, ship) and before asking the user for approval — catches placeholders, internal inconsistencies, dangling references, and vague language."
1164
- ---
1165
-
1166
- # Document Review
1167
-
1168
- ## Quick Start
1169
-
1170
- > 1. Run against the **just-written artifact** before you ask the user to approve it.
1171
- > 2. Walk the five lenses below. For each, produce either a concrete fix or the explicit string "no issues".
1172
- > 3. Apply all fixes yourself in the same artifact — this skill is a scrub, not a checklist for the user.
1173
-
1174
- ## HARD-GATE
1175
-
1176
- Do NOT surface an artifact to the user for approval while **any** of the
1177
- following are still present:
1178
-
1179
- - Unresolved placeholders (\`TBD\`, \`TODO\`, \`<fill me>\`, empty table rows
1180
- that the schema requires).
1181
- - Broken cross-references (e.g. \`AC-12\` in spec when spec table only goes
1182
- up to \`AC-8\`; \`R3\` referenced in a design decision when scope stops at \`R2\`).
1183
- - Contradictions between sections of the same artifact (e.g. \`In Scope\`
1184
- says X but \`Acceptance Criteria\` never mentions X).
1185
- - Vague language where the stage requires observable / measurable
1186
- statements (e.g. "fast", "simple", "seamless", "robust" without a metric).
1187
- - Missing required sections declared by the stage's \`artifactValidation\`.
1188
-
1189
- If any of these remain, fix them first, then re-run this skill; only then
1190
- ask for approval.
1191
-
1192
- ## When to Use
1193
-
1194
- - Immediately after writing \`.cclaw/artifacts/01-brainstorm.md\`
1195
- - Immediately after writing \`.cclaw/artifacts/02-scope.md\`
1196
- - Immediately after writing \`.cclaw/artifacts/03-design.md\`
1197
- - Immediately after writing \`.cclaw/artifacts/04-spec.md\`
1198
- - Immediately after writing \`.cclaw/artifacts/05-plan.md\`
1199
- - Immediately after writing \`.cclaw/artifacts/07-review.md\`
1200
- - Immediately after writing \`.cclaw/artifacts/08-ship.md\`
1201
- - Whenever you regenerate an artifact after a Reclassification pass
1202
-
1203
- Do NOT run during \`06-tdd.md\` — the TDD artifact is append-only evidence;
1204
- scrubbing risks destroying RED/GREEN history. Use \`Verification Before
1205
- Completion\` in the TDD skill instead.
1206
-
1207
- ## Five Lenses
1208
-
1209
- ### 1. Placeholder Scrub
1210
-
1211
- Grep the artifact for: \`TBD\`, \`TODO\`, \`FIXME\`, \`<fill me>\`,
1212
- \`<describe>\`, \`<owner>\`, \`N/A\` inside cells the schema marks as required,
1213
- and empty first-row table cells that the template left blank.
1214
-
1215
- **Output:** each placeholder replaced with real content, or a line added
1216
- explicitly stating "None — <reason>". Never leave a placeholder in a
1217
- required section.
1218
-
1219
- ### 2. Cross-Reference Integrity
1220
-
1221
- - Every \`R#\` referenced in this artifact must exist in \`02-scope.md\`.
1222
- - Every \`AC-#\` referenced must exist in \`04-spec.md\`.
1223
- - Every task ID referenced must exist in \`05-plan.md\`.
1224
- - Every file path cited must be the canonical casing used elsewhere.
1225
- - Every ADR / decision reference must resolve to an existing record.
1226
-
1227
- **Output:** broken refs fixed, or flagged with the exact upstream artifact
1228
- that needs updating first.
1229
-
1230
- ### 3. Internal Consistency
1231
-
1232
- - \`In Scope\` / \`Out of Scope\` lists do not overlap.
1233
- - Acceptance Criteria match the requirements they claim to verify.
1234
- - Plan tasks cover every AC (no AC left without at least one task).
1235
- - Failure modes listed in design appear in the spec's edge cases.
1236
- - Review verdict matches the evidence (no "Ship" with open Criticals).
1237
-
1238
- **Output:** contradictions resolved by amending whichever side is wrong,
1239
- with a one-line rationale.
1240
-
1241
- ### 4. Ambiguity Scan
1242
-
1243
- Flag words that masquerade as decisions:
1244
-
1245
- - "fast", "simple", "robust", "intuitive", "seamless", "scalable",
1246
- "production-ready", "high quality" — each must be replaced with an
1247
- observable metric or dropped.
1248
- - "etc.", "and so on", "similar to X" in requirements — enumerate or drop.
1249
- - Passive voice that hides the actor ("will be validated") — name the
1250
- actor ("the API gateway validates the payload").
1251
-
1252
- **Output:** every flagged term rewritten as observable, or escalated as a
1253
- Decision Protocol question before approval.
1254
-
1255
- ### 5. Schema Conformance
1256
-
1257
- Re-verify the artifact against the stage's \`artifactValidation\`:
1258
-
1259
- - Every required section is present with a non-empty body.
1260
- - Tables have the columns the template specifies (no dropped columns).
1261
- - Any "N/A" in a required section carries an inline reason.
1262
- - Required evidence links (test output, diff excerpts) resolve.
1263
-
1264
- **Output:** missing sections added, or escalated as a BLOCKED signal if
1265
- the artifact cannot honestly be completed without more work.
1266
-
1267
- ## Output Protocol
1268
-
1269
- After running all five lenses, emit a single one-line summary **before
1270
- asking the user for approval**:
1271
-
1272
- > Document review: 5/5 lenses clean; <N> fixes applied.
1273
-
1274
- If fixes were blocked (e.g. upstream artifact drift), do NOT claim
1275
- "clean" — surface the blocker explicitly and stop.
1276
-
1277
- ## Anti-Patterns
1278
-
1279
- - Running this skill as a "polish pass" after the user already approved
1280
- the artifact — by then it is too late.
1281
- - Treating placeholders as "documentation" ("TBD on rollback — we'll
1282
- figure it out"). Either decide now or mark it as an explicit BLOCKED.
1283
- - Silently rewriting user-approved content under the guise of "scrubbing".
1284
- - Using this skill as a substitute for the stage's own review sections —
1285
- it is a **last-mile check**, not a replacement for the stage review.
1286
-
1287
- ## Red Flags
1288
-
1289
- - "No issues" on an artifact that still has empty table rows.
1290
- - Cross-reference lens passes but the artifact cites IDs from a stage
1291
- that has not yet been written.
1292
- - Ambiguity scan finds nothing in a brainstorm / scope artifact (this is
1293
- implausible — those stages produce narrative by design, and narrative
1294
- always contains at least one vague phrase worth tightening).
1295
- `;
1296
- }
1297
- export function receivingCodeReviewSkill() {
1298
- return `---
1299
- name: receiving-code-review
1300
- description: "Incoming review-feedback workflow. Use when a human reviewer, PR bot, CI annotation, or security scan provides comments that must be triaged and resolved without losing traceability."
1301
- ---
1302
-
1303
- # Receiving Code Review
1304
-
1305
- ## Quick Start
1306
-
1307
- > 1. Collect every incoming review note into one queue before fixing anything.
1308
- > 2. Normalize each note into a structured record (id/source/severity/file:line/request/status).
1309
- > 3. Resolve one record at a time and attach evidence for the chosen disposition.
1310
-
1311
- ## HARD-GATE
1312
-
1313
- Do not claim "all comments addressed" until every incoming review record has:
1314
-
1315
- - a final disposition (\`resolved\`, \`accepted-risk\`, or \`rejected-with-evidence\`),
1316
- - linked evidence (commit, test output, spec reference, or rationale),
1317
- - and an updated status in the review queue.
1318
-
1319
- Silent drops are forbidden.
1320
-
1321
- ## When to Use
1322
-
1323
- - After a PR receives reviewer comments.
1324
- - After CI/static-analysis/security tooling posts annotations.
1325
- - During review/ship when new blocking feedback appears.
1326
- - When multiple feedback channels disagree and need reconciliation.
1327
-
1328
- ## Intake Sources
1329
-
1330
- Treat all of these as first-class review input:
1331
-
1332
- - Human reviewer comments (PR/UI/chat copy-paste)
1333
- - Bot comments (lint, security, code quality, policy)
1334
- - CI log findings linked to changed files
1335
- - Post-review user concerns ("this still feels risky")
1336
-
1337
- ## Workflow
1338
-
1339
- ### 1) Build an intake queue
1340
-
1341
- Create/update a queue table with one row per unique finding:
1342
-
1343
- | ID | Source | Severity | File:line | Request | Status | Evidence |
1344
- |---|---|---|---|---|---|---|
1345
- | CR-1 | reviewer | Critical/Important/Suggestion | path:line or n/a | concise ask | open/in-progress/resolved/accepted-risk/rejected-with-evidence | link or note |
1346
-
1347
- Rules:
1348
- - IDs stay stable across reruns.
1349
- - Deduplicate near-identical comments by fingerprint (\`file + concern + requested change\`).
1350
- - If comments conflict, keep both rows and mark them \`conflict\`.
1351
-
1352
- ### 2) Triage by ship impact
1353
-
1354
- - **Critical:** blocks merge/ship until resolved or explicitly accepted by user.
1355
- - **Important:** should be fixed in this iteration unless explicitly deferred.
1356
- - **Suggestion:** optional, but must still get a disposition.
1357
-
1358
- ### 3) Resolve one record at a time
1359
-
1360
- For each row:
1361
- 1. restate the comment in your own words,
1362
- 2. choose disposition:
1363
- - \`resolved\` (code/docs/tests changed),
1364
- - \`accepted-risk\` (intentional, user-approved),
1365
- - \`rejected-with-evidence\` (comment is incorrect or out of scope),
1366
- 3. attach concrete evidence (commit hash, diff path, test command output, or spec/plan citation),
1367
- 4. update row status.
1368
-
1369
- ### 4) Reconcile with review artifacts
1370
-
1371
- When in review stage, mirror outcomes into:
1372
- - \`.cclaw/artifacts/07-review.md\` (Layer 2 findings + readiness dashboard)
1373
- - \`.cclaw/artifacts/07-review-army.json\` (status + shipBlockers alignment)
1374
-
1375
- If any open Critical remains, final verdict cannot be \`APPROVED\`.
1376
-
1377
- ### 5) Verify
1378
-
1379
- Run the smallest relevant verification first, then full regression:
1380
- - targeted tests for changed paths,
1381
- - full suite/build for merge readiness.
1382
-
1383
- ### 6) Publish response bundle
1384
-
1385
- Produce a concise resolution report:
1386
- - fixed items,
1387
- - deferred/accepted-risk items (with owner/date),
1388
- - rejected items (with evidence),
1389
- - remaining blockers (if any).
1390
-
1391
- ## Anti-Patterns
1392
-
1393
- - "Addressed all comments" without a queue table.
1394
- - Collapsing multiple comments into one vague status line.
1395
- - Marking a comment resolved without evidence.
1396
- - Rewriting reviewer intent to make it easier to dismiss.
1397
- - Ignoring bot/CI findings because they are "automated."
1398
-
1399
- ## Red Flags
1400
-
1401
- - IDs change between passes (traceability lost).
1402
- - Critical comment has no explicit disposition.
1403
- - Queue says resolved, but review-army still lists open blocker.
1404
- - Response bundle omits rejected comments entirely.
1405
- `;
1406
- }
1407
- export function retrospectiveSkill() {
1408
- return `---
1409
- name: retrospective
1410
- description: "Post-ship retrospective lens. Use after a ship to extract durable lessons (rules, patterns, accelerators) before context fades. Distinct from the inline ship Compound Step — this is a deeper, optional sweep across the whole run."
1411
- ---
1412
-
1413
- # Retrospective
1414
-
1415
- ## Quick Start
1416
-
1417
- > 1. Run **after** the ship stage closes (PR merged or release tagged), while the run is still loaded in memory.
1418
- > 2. Walk the four lenses below; harvest concrete entries for \`.cclaw/knowledge.jsonl\`.
1419
- > 3. Stop when you have at least one durable entry **or** an explicit "no new lesson this run".
1420
-
1421
- ## HARD-GATE
1422
-
1423
- Do **not** run retrospective before ship gates pass. The goal is to learn from
1424
- a *closed* loop, not to evaluate work-in-progress.
1425
- Do **not** invent generic platitudes ("write more tests"). Every entry must cite
1426
- a concrete moment in *this* run (file, decision, blocker, surprise).
1427
-
1428
- ## When to use
1429
-
1430
- - Right after \`/cc-next\` reports the ship stage complete.
1431
- - Before starting the next \`/cc <idea>\` — fresh context, lessons captured.
1432
- - After an incident or surprise during ship (rollback, hotfix, regression).
1433
-
1434
- ## When NOT to use
1435
-
1436
- - Mid-flow (use the per-stage Operational Self-Improvement block instead).
1437
- - For trivial changes (typo fix, config bump) — the Compound Step in the
1438
- ship template is enough.
1439
-
1440
- ## Four Lenses
1441
-
1442
- For each lens, write either a knowledge entry **or** the explicit string
1443
- "no new lesson". Skipping a lens silently is forbidden.
1444
-
1445
- ### 1. What surprised us?
1446
-
1447
- - A bug that hid in a place no one suspected → \`[lesson]\`.
1448
- - A test that passed but missed a real failure mode → \`[lesson]\`.
1449
- - A library/API behavior that contradicted our mental model → \`[rule]\`.
1450
-
1451
- ### 2. What slowed us down?
1452
-
1453
- - Repeated context loss between batches → \`[compound]\` accelerator.
1454
- - Re-derivation of a fact already in upstream artifacts → \`[pattern]\` "re-read X first".
1455
- - Tooling friction (slow test loop, flaky CI) → \`[compound]\` follow-up.
1456
-
1457
- ### 3. What worked unreasonably well?
1458
-
1459
- - A refactor that unlocked the next 3 tasks → \`[pattern]\`.
1460
- - A skill/agent invocation that nailed it on first try → \`[pattern]\` (record the prompt shape).
1461
- - Adopting an existing solution instead of building → \`[rule]\` reinforcement.
1462
-
1463
- ### 4. What would we do differently next time?
1464
-
1465
- - Architectural decision that aged poorly within the same run → \`[lesson]\`.
1466
- - Scope mode chosen incorrectly → \`[rule]\` heuristic update.
1467
- - Order-of-operations mistake (e.g. spec drift before tdd) → \`[pattern]\` ordering.
1468
-
1469
- ## Output protocol
1470
-
1471
- For every harvested insight, append one strict-schema JSON line to
1472
- \`.cclaw/knowledge.jsonl\` (fields: \`type, trigger, action, confidence, domain, stage, origin_stage, origin_feature, frequency, universality, maturity, created, first_seen_ts, last_seen_ts, project\`; optional: \`source\`, \`severity\`).
1473
- See the \`learnings\` skill for the canonical shape. Choose \`type\`:
1474
-
1475
- - \`compound\` for process/speed accelerators.
1476
- - \`lesson\` for "we learned this the hard way".
1477
- - \`pattern\` for repeatable shapes that worked.
1478
- - \`rule\` only for hard constraints that must always hold.
1479
-
1480
- Then write a one-paragraph **Run Summary** at the top of the next
1481
- \`/cc <idea>\` brainstorm context citing the lessons in scope.
1482
-
1483
- ## Anti-patterns
1484
-
1485
- - Retrospective as performance review — frame is *system improvement*, not blame.
1486
- - Harvesting only positive ("what worked") and skipping uncomfortable lessons.
1487
- - Writing entries so generic they could apply to any project.
1488
- - Letting the retrospective drift into a re-design of the shipped feature.
1489
- `;
1490
- }
1491
5
  export function languageTypescriptSkill() {
1492
6
  return `---
1493
7
  name: language-typescript
@@ -1715,48 +229,3 @@ export const LEGACY_LANGUAGE_RULE_PACK_FOLDERS = [
1715
229
  "language-python",
1716
230
  "language-go"
1717
231
  ];
1718
- export const UTILITY_SKILL_FOLDERS = [
1719
- "security",
1720
- "debugging",
1721
- "performance",
1722
- "ci-cd",
1723
- "docs",
1724
- "executing-plans",
1725
- "verification-before-completion",
1726
- "finishing-a-development-branch",
1727
- "context-engineering",
1728
- "source-driven-development",
1729
- "frontend-accessibility",
1730
- "landscape-check",
1731
- "adversarial-review",
1732
- "security-audit",
1733
- "knowledge-curation",
1734
- "retrospective",
1735
- "document-review",
1736
- "receiving-code-review"
1737
- ];
1738
- /**
1739
- * One entry per `UTILITY_SKILL_FOLDERS` slot. Typed via the tuple so that
1740
- * adding a folder without a generator (or vice versa) is a TypeScript
1741
- * error — keeps the two sources of truth in lockstep at compile time.
1742
- */
1743
- export const UTILITY_SKILL_MAP = {
1744
- security: securityReviewSkill,
1745
- debugging: debuggingSkill,
1746
- performance: performanceSkill,
1747
- "ci-cd": ciCdSkill,
1748
- docs: docsSkill,
1749
- "executing-plans": executingPlansSkill,
1750
- "verification-before-completion": verificationBeforeCompletionSkill,
1751
- "finishing-a-development-branch": finishingDevelopmentBranchSkill,
1752
- "context-engineering": contextEngineeringSkill,
1753
- "source-driven-development": sourceDrivenDevelopmentSkill,
1754
- "frontend-accessibility": frontendAccessibilitySkill,
1755
- "landscape-check": landscapeCheckSkill,
1756
- "adversarial-review": adversarialReviewSkill,
1757
- "security-audit": securityAuditSkill,
1758
- "knowledge-curation": knowledgeCurationSkill,
1759
- retrospective: retrospectiveSkill,
1760
- "document-review": documentReviewSkill,
1761
- "receiving-code-review": receivingCodeReviewSkill
1762
- };