@causyne/agent 0.0.0-stage → 1.10.1

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 (274) hide show
  1. package/LICENSE +102 -0
  2. package/README.md +31 -2
  3. package/SECURITY.md +24 -0
  4. package/bin/causyne.js +13 -0
  5. package/docs/ARCHITECTURE.md +63 -0
  6. package/docs/PROVENANCE.md +29 -0
  7. package/docs/SECURITY_REVIEW.md +89 -0
  8. package/docs/THIRD_PARTY_NOTICES.md +49 -0
  9. package/native-skills/ai-engineering/context-window-management/SKILL.md +43 -0
  10. package/native-skills/ai-engineering/llm-evaluation/SKILL.md +46 -0
  11. package/native-skills/ai-engineering/model-cost-and-latency/SKILL.md +46 -0
  12. package/native-skills/ai-engineering/prompt-construction/SKILL.md +42 -0
  13. package/native-skills/ai-engineering/retrieval-augmented-generation/SKILL.md +42 -0
  14. package/native-skills/ai-engineering/structured-output-and-schemas/SKILL.md +45 -0
  15. package/native-skills/ai-engineering/tool-calling-agents/SKILL.md +43 -0
  16. package/native-skills/android/app-performance-profiling/SKILL.md +42 -0
  17. package/native-skills/android/background-work-scheduling/SKILL.md +47 -0
  18. package/native-skills/android/compose-state-and-recomposition/SKILL.md +43 -0
  19. package/native-skills/android/gradle-build-configuration/SKILL.md +41 -0
  20. package/native-skills/android/lifecycle-and-leaks/SKILL.md +46 -0
  21. package/native-skills/android/play-store-release/SKILL.md +43 -0
  22. package/native-skills/android/room-and-persistence/SKILL.md +40 -0
  23. package/native-skills/backend/authentication-and-sessions/SKILL.md +45 -0
  24. package/native-skills/backend/background-jobs-and-queues/SKILL.md +42 -0
  25. package/native-skills/backend/caching-strategy/SKILL.md +44 -0
  26. package/native-skills/backend/graceful-shutdown/SKILL.md +42 -0
  27. package/native-skills/backend/rate-limiting-and-quotas/SKILL.md +40 -0
  28. package/native-skills/backend/rest-api-design/SKILL.md +40 -0
  29. package/native-skills/backend/webhook-delivery-and-receipt/SKILL.md +43 -0
  30. package/native-skills/cloud/cost-optimisation/SKILL.md +46 -0
  31. package/native-skills/cloud/iam-least-privilege/SKILL.md +43 -0
  32. package/native-skills/cloud/infrastructure-as-code/SKILL.md +43 -0
  33. package/native-skills/cloud/multi-region-and-failover/SKILL.md +43 -0
  34. package/native-skills/cloud/serverless-patterns/SKILL.md +47 -0
  35. package/native-skills/data/data-quality-monitoring/SKILL.md +51 -0
  36. package/native-skills/data/etl-pipeline-reliability/SKILL.md +43 -0
  37. package/native-skills/data/exploratory-analysis/SKILL.md +43 -0
  38. package/native-skills/data/metric-definition/SKILL.md +42 -0
  39. package/native-skills/data/notebook-to-production/SKILL.md +43 -0
  40. package/native-skills/database/backup-and-recovery/SKILL.md +43 -0
  41. package/native-skills/database/connection-pooling/SKILL.md +42 -0
  42. package/native-skills/database/data-integrity-and-constraints/SKILL.md +42 -0
  43. package/native-skills/database/query-optimisation/SKILL.md +38 -0
  44. package/native-skills/database/safe-migrations/SKILL.md +47 -0
  45. package/native-skills/database/schema-design/SKILL.md +38 -0
  46. package/native-skills/database/transactions-and-isolation/SKILL.md +41 -0
  47. package/native-skills/design/colour-system-construction/SKILL.md +38 -0
  48. package/native-skills/design/design-direction-brief/SKILL.md +41 -0
  49. package/native-skills/design/motion-and-transitions/SKILL.md +38 -0
  50. package/native-skills/design/responsive-strategy/SKILL.md +39 -0
  51. package/native-skills/design/spacing-and-rhythm/SKILL.md +38 -0
  52. package/native-skills/design/type-scale-and-hierarchy/SKILL.md +39 -0
  53. package/native-skills/design/visual-qa-loop/SKILL.md +42 -0
  54. package/native-skills/devops/docker-multi-stage-builds/SKILL.md +60 -0
  55. package/native-skills/devops/github-actions-ci/SKILL.md +60 -0
  56. package/native-skills/devops/incident-triage/SKILL.md +38 -0
  57. package/native-skills/devops/kubernetes-deployment-hardening/SKILL.md +64 -0
  58. package/native-skills/devops/observability-baseline/SKILL.md +38 -0
  59. package/native-skills/devops/secret-management/SKILL.md +40 -0
  60. package/native-skills/devops/terraform-state-and-modules/SKILL.md +36 -0
  61. package/native-skills/devops/zero-downtime-deploys/SKILL.md +40 -0
  62. package/native-skills/git/bisect-regression-hunt/SKILL.md +43 -0
  63. package/native-skills/git/branch-strategy/SKILL.md +39 -0
  64. package/native-skills/git/commit-hygiene/SKILL.md +41 -0
  65. package/native-skills/git/history-recovery/SKILL.md +44 -0
  66. package/native-skills/git/large-repository-surgery/SKILL.md +46 -0
  67. package/native-skills/git/merge-conflict-resolution/SKILL.md +42 -0
  68. package/native-skills/media/cinematic-3d-shot/SKILL.md +104 -0
  69. package/native-skills/mobile/app-startup-optimisation/SKILL.md +41 -0
  70. package/native-skills/mobile/cross-platform-tradeoffs/SKILL.md +42 -0
  71. package/native-skills/mobile/deep-linking/SKILL.md +39 -0
  72. package/native-skills/mobile/mobile-storage-security/SKILL.md +45 -0
  73. package/native-skills/mobile/offline-first-sync/SKILL.md +42 -0
  74. package/native-skills/mobile/push-notifications/SKILL.md +38 -0
  75. package/native-skills/performance/algorithmic-complexity/SKILL.md +43 -0
  76. package/native-skills/performance/concurrency-and-parallelism/SKILL.md +42 -0
  77. package/native-skills/performance/load-testing/SKILL.md +42 -0
  78. package/native-skills/performance/memory-and-leak-hunting/SKILL.md +41 -0
  79. package/native-skills/performance/network-and-payload-efficiency/SKILL.md +42 -0
  80. package/native-skills/performance/profiling-methodology/SKILL.md +46 -0
  81. package/native-skills/python/async-correctness/SKILL.md +40 -0
  82. package/native-skills/python/cli-tool-construction/SKILL.md +44 -0
  83. package/native-skills/python/data-processing-pipelines/SKILL.md +38 -0
  84. package/native-skills/python/environment-isolation/SKILL.md +41 -0
  85. package/native-skills/python/packaging-and-distribution/SKILL.md +56 -0
  86. package/native-skills/python/pytest-suite-design/SKILL.md +39 -0
  87. package/native-skills/python/type-hints-and-static-checking/SKILL.md +42 -0
  88. package/native-skills/security/authorization-model/SKILL.md +42 -0
  89. package/native-skills/security/crypto-usage/SKILL.md +48 -0
  90. package/native-skills/security/dependency-supply-chain/SKILL.md +42 -0
  91. package/native-skills/security/input-validation-and-injection/SKILL.md +44 -0
  92. package/native-skills/security/secure-file-uploads/SKILL.md +46 -0
  93. package/native-skills/security/security-headers-and-csp/SKILL.md +44 -0
  94. package/native-skills/security/threat-modelling/SKILL.md +46 -0
  95. package/native-skills/testing/end-to-end-test-stability/SKILL.md +42 -0
  96. package/native-skills/testing/property-based-testing/SKILL.md +46 -0
  97. package/native-skills/testing/regression-test-from-a-bug/SKILL.md +41 -0
  98. package/native-skills/testing/snapshot-and-visual-regression/SKILL.md +42 -0
  99. package/native-skills/testing/test-doubles-and-mocking/SKILL.md +43 -0
  100. package/native-skills/testing/test-strategy-and-pyramid/SKILL.md +39 -0
  101. package/native-skills/testing/writing-good-assertions/SKILL.md +42 -0
  102. package/native-skills/web/accessible-components/SKILL.md +45 -0
  103. package/native-skills/web/api-client-resilience/SKILL.md +39 -0
  104. package/native-skills/web/bundle-size-reduction/SKILL.md +38 -0
  105. package/native-skills/web/core-web-vitals/SKILL.md +40 -0
  106. package/native-skills/web/css-layout-systems/SKILL.md +41 -0
  107. package/native-skills/web/form-validation-ux/SKILL.md +39 -0
  108. package/native-skills/web/react-state-architecture/SKILL.md +41 -0
  109. package/native-skills/web/ssr-hydration-correctness/SKILL.md +45 -0
  110. package/package.json +68 -4
  111. package/src/agentLoop.js +2458 -0
  112. package/src/appChannel.js +109 -0
  113. package/src/approvalGrants.js +66 -0
  114. package/src/auditLog.js +52 -0
  115. package/src/autoUpdate.js +12 -0
  116. package/src/capabilities.js +36 -0
  117. package/src/checkpoints.js +1199 -0
  118. package/src/cliMode.js +638 -0
  119. package/src/commands.js +805 -0
  120. package/src/compiledSkills.js +540 -0
  121. package/src/config.js +130 -0
  122. package/src/contextManager.js +498 -0
  123. package/src/cortex/autoCondenser.js +192 -0
  124. package/src/cortex/provisioner.js +27 -0
  125. package/src/cortex/vectorDb.js +447 -0
  126. package/src/designPalettes.js +99 -0
  127. package/src/devMode.js +6 -0
  128. package/src/embodimentSession.js +180 -0
  129. package/src/entrypoint.js +194 -0
  130. package/src/execSafe.js +21 -0
  131. package/src/gitSnapshot.js +378 -0
  132. package/src/mcp/jsonRpc.js +165 -0
  133. package/src/mcp/mcpClient.js +136 -0
  134. package/src/mcp/mcpRegistry.js +207 -0
  135. package/src/memory.js +62 -0
  136. package/src/memoryManager.js +124 -0
  137. package/src/modelCatalogue.js +132 -0
  138. package/src/modelIds.js +42 -0
  139. package/src/modelRouter.js +145 -0
  140. package/src/outputStore.js +246 -0
  141. package/src/perception.js +124 -0
  142. package/src/planCache.js +437 -0
  143. package/src/procSignal.js +32 -0
  144. package/src/providers/anthropic.js +408 -0
  145. package/src/providers/base.js +328 -0
  146. package/src/providers/dashscope-byok.js +86 -0
  147. package/src/providers/deepseek.js +80 -0
  148. package/src/providers/factory.js +37 -0
  149. package/src/providers/gemini.js +346 -0
  150. package/src/providers/moonshot.js +73 -0
  151. package/src/providers/muse.js +169 -0
  152. package/src/providers/ollama.js +104 -0
  153. package/src/providers/openai-compatible.js +84 -0
  154. package/src/providers/openai.js +20 -0
  155. package/src/providers/qwen-byok.js +76 -0
  156. package/src/providers/xai.js +73 -0
  157. package/src/provisioning/capabilityConsent.js +24 -0
  158. package/src/provisioning/capabilityProvisioner.js +271 -0
  159. package/src/provisioning/capabilityTools.js +29 -0
  160. package/src/reporting.js +373 -0
  161. package/src/sandbox.js +529 -0
  162. package/src/sessionStore.js +279 -0
  163. package/src/skillsManager.js +288 -0
  164. package/src/slopDetector.js +307 -0
  165. package/src/taskBuffer.js +45 -0
  166. package/src/taskShape.js +241 -0
  167. package/src/textDiff.js +150 -0
  168. package/src/tokenTracker.js +560 -0
  169. package/src/tool-scripts/ax_snapshot.applescript +39 -0
  170. package/src/tool-scripts/ax_snapshot.ps1 +10 -0
  171. package/src/tool-scripts/desktop_act.applescript +58 -0
  172. package/src/tool-scripts/resolve_automator.py +119 -0
  173. package/src/toolPacks.js +524 -0
  174. package/src/tools/archive.js +63 -0
  175. package/src/tools/astryxOracle.js +78 -0
  176. package/src/tools/axSnapshot.js +165 -0
  177. package/src/tools/blenderAutomator.js +349 -0
  178. package/src/tools/browserAutomator.js +252 -0
  179. package/src/tools/checkSystemSpecs.js +64 -0
  180. package/src/tools/clipboard.js +36 -0
  181. package/src/tools/codeSearchAst.js +101 -0
  182. package/src/tools/codeSearcher.js +230 -0
  183. package/src/tools/codeTools.js +262 -0
  184. package/src/tools/codebaseSearch.js +75 -0
  185. package/src/tools/createSkill.js +129 -0
  186. package/src/tools/deferredMcpSearch.js +246 -0
  187. package/src/tools/desktopAct.js +208 -0
  188. package/src/tools/desktopOpen.js +34 -0
  189. package/src/tools/dynamicLoader.js +44 -0
  190. package/src/tools/executeProceduralMedia.js +93 -0
  191. package/src/tools/fsDelete.js +51 -0
  192. package/src/tools/fsEdit.js +105 -0
  193. package/src/tools/fsFind.js +128 -0
  194. package/src/tools/fsList.js +77 -0
  195. package/src/tools/fsMove.js +57 -0
  196. package/src/tools/fsRead.js +87 -0
  197. package/src/tools/fsSearch.js +198 -0
  198. package/src/tools/fsWrite.js +41 -0
  199. package/src/tools/gameAiBehaviorTree.js +208 -0
  200. package/src/tools/gameAnimationRig.js +194 -0
  201. package/src/tools/gameAssetFetcher.js +372 -0
  202. package/src/tools/gameAssetHarvester.js +210 -0
  203. package/src/tools/gameAudioSynth.js +267 -0
  204. package/src/tools/gameBuilder.js +886 -0
  205. package/src/tools/gameCanvasAudit.js +101 -0
  206. package/src/tools/gameCinematicSequencer.js +151 -0
  207. package/src/tools/gameDataForge.js +124 -0
  208. package/src/tools/gameDialogueTreeGen.js +166 -0
  209. package/src/tools/gameEconomyBalancer.js +161 -0
  210. package/src/tools/gameEntitySpawner.js +207 -0
  211. package/src/tools/gameLoreForge.js +153 -0
  212. package/src/tools/gameQuestArcBuilder.js +152 -0
  213. package/src/tools/gameSceneBuilder.js +158 -0
  214. package/src/tools/gameShaderForge.js +181 -0
  215. package/src/tools/gameTilemapGenerator.js +164 -0
  216. package/src/tools/gameUiHudBuilder.js +292 -0
  217. package/src/tools/gameVfxEmitterGen.js +108 -0
  218. package/src/tools/gameWebRuntimeInspector.js +91 -0
  219. package/src/tools/generateMediaViaApi.js +358 -0
  220. package/src/tools/gitExec.js +54 -0
  221. package/src/tools/godotAutomator.js +437 -0
  222. package/src/tools/manageLocalAiDependencies.js +220 -0
  223. package/src/tools/memoryWrite.js +99 -0
  224. package/src/tools/multiEdit.js +107 -0
  225. package/src/tools/palmierAutomator.js +104 -0
  226. package/src/tools/pdfReader.js +112 -0
  227. package/src/tools/persistentShell.js +148 -0
  228. package/src/tools/printer.js +316 -0
  229. package/src/tools/procTerm.js +91 -0
  230. package/src/tools/processList.js +52 -0
  231. package/src/tools/readNativeSkill.js +39 -0
  232. package/src/tools/registry.js +277 -0
  233. package/src/tools/resolveAutomator.js +102 -0
  234. package/src/tools/screenshot.js +75 -0
  235. package/src/tools/subagentOrchestrator.js +305 -0
  236. package/src/tools/sysRun.js +125 -0
  237. package/src/tools/todoWrite.js +75 -0
  238. package/src/tools/toolDispatch.js +127 -0
  239. package/src/tools/toolForge.js +124 -0
  240. package/src/tools/updatePlan.js +88 -0
  241. package/src/tools/viewImage.js +82 -0
  242. package/src/tools/visionInspector.js +154 -0
  243. package/src/tools/webFetch.js +74 -0
  244. package/src/tools/webSearch.js +82 -0
  245. package/src/tui/ask.js +164 -0
  246. package/src/tui/banner.js +158 -0
  247. package/src/tui/block.js +152 -0
  248. package/src/tui/chatRenderer.js +953 -0
  249. package/src/tui/completion.js +424 -0
  250. package/src/tui/dialogs.js +606 -0
  251. package/src/tui/diff.js +296 -0
  252. package/src/tui/history.js +135 -0
  253. package/src/tui/home.js +217 -0
  254. package/src/tui/invocation.js +105 -0
  255. package/src/tui/keys.js +443 -0
  256. package/src/tui/lineEditor.js +256 -0
  257. package/src/tui/overlay.js +256 -0
  258. package/src/tui/prompt.js +1258 -0
  259. package/src/tui/selectList.js +335 -0
  260. package/src/tui/stage.js +330 -0
  261. package/src/tui/stageSurface.js +609 -0
  262. package/src/tui/statusLine.js +254 -0
  263. package/src/tui/text.js +345 -0
  264. package/src/tui/theme.js +393 -0
  265. package/src/tui/toolDisplay.js +176 -0
  266. package/src/tui/transcript.js +235 -0
  267. package/src/tui/viewport.js +337 -0
  268. package/src/uncertainty.js +271 -0
  269. package/src/userSkills.js +265 -0
  270. package/src/utils/cli_ui.js +0 -0
  271. package/src/utils/inquirer.js +12 -0
  272. package/src/utils/paths.js +37 -0
  273. package/src/version.js +38 -0
  274. package/src/vfeTracker.js +220 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: data-integrity-and-constraints
3
+ description: Enforce correctness rules in a database. Use when invalid data has been found in production, when rules live only in application code, or when several services write the same table.
4
+ ---
5
+
6
+ # Data Integrity and Constraints
7
+
8
+ ## Where the rules belong
9
+
10
+ In the database. Application-level validation is a user-experience feature; it is bypassed by every migration, every background job, every admin script, and every other service that writes the table. If a rule matters, the database enforces it.
11
+
12
+ ## Workflow
13
+
14
+ 1. Find what is already invalid.
15
+ - Write the constraint as a SELECT first and count the violations. There are almost always some, and adding the constraint blind will fail the migration.
16
+ - **Done when:** the current violation count is known for each intended constraint.
17
+
18
+ 2. Clean the existing data before constraining.
19
+ - Decide per violation class: fix, delete, or quarantine. Record the decision — this is a data change, not a schema change.
20
+ - **Done when:** the violation count is zero.
21
+
22
+ 3. Add the constraint at the right level.
23
+ - NOT NULL for required. UNIQUE for identity. FOREIGN KEY for references, with an explicit ON DELETE rule — the default is usually not what you want. CHECK for value rules. EXCLUDE for non-overlap, such as bookings.
24
+ - **Done when:** every rule has a constraint of the appropriate kind.
25
+
26
+ 4. Choose referential actions deliberately.
27
+ - CASCADE deletes children silently — powerful and dangerous. RESTRICT is the safe default. SET NULL requires the column to be nullable and the meaning of null to be defined.
28
+ - **Done when:** every foreign key states its action and the reason.
29
+
30
+ 5. Add constraints without locking.
31
+ - NOT VALID first, then VALIDATE separately. This avoids a full table scan under an exclusive lock.
32
+ - **Done when:** the constraint is added and validated without a long lock.
33
+
34
+ 6. Test that the constraint actually fires.
35
+ - Write a test that attempts the invalid write and asserts the failure. An untested constraint may be disabled or wrong.
36
+ - **Done when:** a test proves invalid data is rejected.
37
+
38
+ ## Verification
39
+
40
+ - Every stated business rule maps to a database constraint.
41
+ - A test attempts each invalid write and confirms rejection.
42
+ - The constraints were added without a long lock on a production-scale copy.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: query-optimisation
3
+ description: Make a slow database query fast. Use when an endpoint is slow, when a query times out, or when the database shows high CPU.
4
+ ---
5
+
6
+ # Query Optimisation
7
+
8
+ ## Workflow
9
+
10
+ 1. Read the actual plan, not the estimated one.
11
+ - `EXPLAIN ANALYZE` runs the query and reports what really happened. The estimate can be wildly wrong, and the difference between estimate and actual is itself the most useful diagnostic — it means the statistics are stale.
12
+ - **Done when:** you have a real plan with actual row counts and timings.
13
+
14
+ 2. Find the expensive node.
15
+ - Look for a sequential scan on a large table, a nested loop over many rows, or a sort that spills to disk. One node usually dominates.
16
+ - **Done when:** you can name the node consuming most of the time.
17
+
18
+ 3. Index what is filtered, joined and ordered.
19
+ - A composite index's column order matters: equality columns first, then the range or sort column. An index the planner will not use is usually in the wrong order, or the column is wrapped in a function.
20
+ - **Done when:** the plan shows an index scan and the timing has dropped.
21
+
22
+ 4. Fix the N+1 before optimising the one.
23
+ - One query in a loop over a hundred rows is a hundred round trips. This is far more common than a genuinely slow query, and no index fixes it. Batch or join instead.
24
+ - **Done when:** the request issues a bounded number of queries regardless of result size.
25
+
26
+ 5. Select only what you use.
27
+ - `SELECT *` prevents index-only scans and drags large columns across the wire. Name the columns.
28
+ - **Done when:** no query in the hot path selects columns the caller ignores.
29
+
30
+ 6. Confirm the statistics are current.
31
+ - A plan that is wrong by orders of magnitude usually means stale statistics after a bulk load. Analyse the table and re-check before adding an index that was never needed.
32
+ - **Done when:** estimated and actual row counts are within an order of magnitude.
33
+
34
+ ## Verification
35
+
36
+ - Report the before and after timing from `EXPLAIN ANALYZE`.
37
+ - The plan shows the intended access path.
38
+ - The request issues a bounded number of queries.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: safe-migrations
3
+ description: Change a production database schema. Use before any ALTER on a live table, when a migration might lock, or when a deploy includes a schema change.
4
+ ---
5
+
6
+ # Safe Migrations
7
+
8
+ ## The two rules
9
+
10
+ 1. Every migration must be safe while the OLD code is still running, because during a deploy it is.
11
+ 2. Nothing may hold a long lock on a table that is serving traffic.
12
+
13
+ ## The operations that lock, and their safe form
14
+
15
+ - **Add a column with a default** — safe on modern PostgreSQL; on older versions it rewrites the table. Add nullable, backfill in batches, then set the default.
16
+ - **Add NOT NULL** — add a CHECK constraint as NOT VALID, validate it separately, then convert. The direct form scans the whole table under an exclusive lock.
17
+ - **Add an index** — always CONCURRENTLY. The plain form blocks writes for the duration.
18
+ - **Rename a column** — never in one step. Add the new one, write to both, migrate readers, then drop.
19
+ - **Change a type** — usually a rewrite. Add a new column, backfill, switch, drop.
20
+ - **Add a foreign key** — add NOT VALID, then validate separately.
21
+
22
+ ## Workflow
23
+
24
+ 1. Classify the migration as additive or destructive.
25
+ - **Done when:** every statement is labelled, and no destructive statement ships alongside the code that stops using it.
26
+
27
+ 2. Set a lock timeout before the statement.
28
+ - `SET lock_timeout = '3s'`. Without it, a migration waiting on a lock queues every subsequent query behind it and takes the site down — the lock queue, not the migration, is what causes the outage.
29
+ - **Done when:** every migration sets a lock timeout and fails fast rather than queueing.
30
+
31
+ 3. Backfill in batches, outside the migration.
32
+ - A single UPDATE over millions of rows holds a long transaction and bloats the table. Batch with a delay, as a job.
33
+ - **Done when:** no migration updates an unbounded number of rows in one statement.
34
+
35
+ 4. Test on a copy with production-scale data.
36
+ - A migration that takes 3ms on a hundred rows can take twenty minutes on fifty million. Only a realistic copy tells you which.
37
+ - **Done when:** the migration has been timed against production-scale data.
38
+
39
+ 5. Write the reversal.
40
+ - Additive migrations reverse cleanly. Destructive ones cannot — which is why they ship last, separately, after the new path is proven.
41
+ - **Done when:** every migration has a tested down path, or is explicitly marked irreversible and shipped alone.
42
+
43
+ ## Verification
44
+
45
+ - Timed against a production-scale copy.
46
+ - Applied against a running old-code instance with no errors.
47
+ - Lock timeout set; the migration fails rather than queueing.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: schema-design
3
+ description: Design a database schema or add tables. Use when modelling new data, when a table has grown many nullable columns, or when queries need many joins to answer a simple question.
4
+ ---
5
+
6
+ # Schema Design
7
+
8
+ ## Workflow
9
+
10
+ 1. Normalise first, denormalise on evidence.
11
+ - Third normal form is the default. Denormalise only after a measured query problem, and write down which query justified it — otherwise the duplication outlives its reason and starts drifting.
12
+ - **Done when:** every denormalised column names the query it exists for.
13
+
14
+ 2. Choose keys deliberately.
15
+ - A surrogate key (integer or UUIDv7) for identity, a unique constraint on the natural key for correctness. UUIDv4 as a clustered primary key destroys insert locality; UUIDv7 is time-ordered and does not.
16
+ - **Done when:** every table has a primary key and a unique constraint on any natural identifier.
17
+
18
+ 3. Let the database enforce the invariants.
19
+ - NOT NULL, foreign keys, CHECK constraints, and unique indexes. An invariant enforced only in application code will be violated by a migration, a background job, or the second service that writes the table.
20
+ - **Done when:** every stated invariant has a constraint, not just a validation.
21
+
22
+ 4. Pick types precisely.
23
+ - Timestamps with time zone, never a naive local time. Decimal for money, never floating point. An enumerated type or a CHECK for a fixed set, not free text.
24
+ - **Done when:** no money column is floating point and no timestamp is zone-naive.
25
+
26
+ 5. Treat many nullable columns as a modelling smell.
27
+ - A table where different rows use different subsets of columns is usually several entities. Split it, or use a properly typed variant column.
28
+ - **Done when:** each table has one clear meaning per row.
29
+
30
+ 6. Plan for soft deletion or do not do it.
31
+ - A `deleted_at` column means every query must filter on it, and one that forgets leaks deleted data. If you need it, add a view or partial indexes so the filter cannot be forgotten.
32
+ - **Done when:** deleted rows cannot appear through a normal query path.
33
+
34
+ ## Verification
35
+
36
+ - Every table has a primary key and appropriate foreign keys.
37
+ - Inserting data that violates a business rule is rejected by the database itself.
38
+ - A representative query runs without an unexpected join.
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: transactions-and-isolation
3
+ description: Reason about database transactions or fix a concurrency bug. Use when two operations interfere, when a balance or counter goes wrong under load, or when deadlocks appear.
4
+ ---
5
+
6
+ # Transactions and Isolation
7
+
8
+ ## What the default does not protect you from
9
+
10
+ Most databases default to read committed. That prevents dirty reads and nothing else. Under it, a read-then-write sequence is a race: two transactions both read the old value, both write, and one update vanishes. Almost every "the counter is wrong" bug is this.
11
+
12
+ ## Workflow
13
+
14
+ 1. Identify read-modify-write sequences.
15
+ - Any code that SELECTs a value, computes from it, and UPDATEs. These are the races.
16
+ - **Done when:** every such sequence is listed.
17
+
18
+ 2. Fix each one with the cheapest sufficient tool.
19
+ - **Atomic update:** `UPDATE ... SET n = n + 1` — no read, no race. Always prefer this.
20
+ - **Pessimistic lock:** `SELECT ... FOR UPDATE` — locks the row for the transaction. Correct, and it serialises.
21
+ - **Optimistic lock:** a version column, and `UPDATE ... WHERE version = ?` with a retry on zero rows. Best under low contention.
22
+ - **Serializable isolation:** the database detects the anomaly and aborts one transaction. Correct and simple, but you MUST handle the serialisation failure by retrying.
23
+ - **Done when:** each sequence uses one of these and the choice is stated.
24
+
25
+ 3. Keep transactions short and free of external calls.
26
+ - A network request inside a transaction holds locks for the duration of someone else's outage. Do the external work outside and commit the result.
27
+ - **Done when:** no transaction contains a network call.
28
+
29
+ 4. Order locks consistently to avoid deadlocks.
30
+ - A deadlock is two transactions taking the same locks in different orders. Always acquire in a fixed order — by primary key, for example.
31
+ - **Done when:** every multi-row write takes locks in a defined order.
32
+
33
+ 5. Retry serialisation and deadlock failures.
34
+ - These are expected, not exceptional. Retry with backoff, with a bounded count.
35
+ - **Done when:** the retry path exists and is tested.
36
+
37
+ ## Verification
38
+
39
+ - A concurrency test with many parallel workers produces the correct final value.
40
+ - No transaction performs I/O outside the database.
41
+ - Deadlock and serialisation failures are retried rather than surfaced.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: colour-system-construction
3
+ description: Build a colour palette for an interface. Use when colours were chosen individually, when a dark mode is being added, or when contrast is failing.
4
+ ---
5
+
6
+ # Colour System Construction
7
+
8
+ ## Build roles, not colours
9
+
10
+ A palette is a set of ROLES — background, surface, border, muted text, body text, accent, and the status colours. Components ask for a role. This is the only way a theme can be swapped, a dark mode can be added, or a brand colour can be changed without editing every file.
11
+
12
+ ## Workflow
13
+
14
+ 1. Start from the neutrals.
15
+ - Most of an interface is grey. Build a ramp of seven to nine steps from near-background to near-foreground, then assign roles to steps. Getting the neutrals right is most of the work, and it is the step most often skipped.
16
+ - **Done when:** a neutral ramp exists and every structural element uses a step from it.
17
+
18
+ 2. Add one accent, then stop.
19
+ - A single accent used consistently reads as intentional. Three accents read as decoration. Add a second only when a genuine second meaning exists.
20
+ - **Done when:** the number of accents equals the number of distinct meanings.
21
+
22
+ 3. Check contrast as you assign, not afterwards.
23
+ - Body text against its background: at least 4.5:1. Large text and UI borders: at least 3:1. A palette that fails here needs rebuilding, not adjusting.
24
+ - **Done when:** every text-on-background pair in the design meets its ratio.
25
+
26
+ 4. Never encode meaning in hue alone.
27
+ - Error, success and warning must also differ by icon, text, or position. Roughly one in twelve men cannot distinguish red from green.
28
+ - **Done when:** every status is identifiable in greyscale.
29
+
30
+ 5. Define the dark theme by redefining ROLES.
31
+ - Not by inverting the values. Dark mode wants desaturated accents and lighter surfaces raised above the background, which an inversion gets backwards.
32
+ - **Done when:** both themes are defined as role assignments and neither is derived by inversion.
33
+
34
+ ## Verification
35
+
36
+ - Every colour used is a named role, not a literal value.
37
+ - Contrast checks pass for every text pair in both themes.
38
+ - The interface remains usable rendered in greyscale.
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: design-direction-brief
3
+ description: Choose a visual direction before building any UI, landing page, or graphic. Use at the start of any design work, and whenever output risks looking like a generic template.
4
+ ---
5
+
6
+ # Design Direction Brief
7
+
8
+ ## Why this comes first
9
+
10
+ Without a stated direction, generated design converges on the same defaults every time: a centred hero, a purple-to-blue gradient, three feature cards with outline icons, a rounded sans-serif. It is recognisable on sight and it reads as unconsidered. The direction is what prevents that, and it must be chosen BEFORE any markup is written.
11
+
12
+ ## Workflow
13
+
14
+ 1. Write the brief in four lines.
15
+ - **Audience:** who reads this, in what state of mind.
16
+ - **Feeling:** three adjectives, and three the design must NOT be. The negative list does more work than the positive one.
17
+ - **Reference:** a named movement or era, not "modern" or "clean" — those are not directions.
18
+ - **Constraint:** one rule that forces a decision. "No gradients." "Exactly two typefaces." "The grid is visible."
19
+ - **Done when:** all four lines are written and the reference names something specific.
20
+
21
+ 2. Pick the reference from an actual vocabulary.
22
+ - Swiss/International (grid, Helvetica-lineage, flush-left, generous whitespace), Brutalist (raw structure, system fonts, hard edges, visible borders), Editorial (serif display, strong hierarchy, wide measure columns), Bauhaus (primary colours, geometric forms), Memphis (asymmetry, pattern, clashing colour), Japanese minimalism (asymmetric balance, negative space, restrained palette), Art Deco (symmetry, metallic accents, high-contrast geometry), Terminal/technical (monospace, fixed grid, minimal chrome).
23
+ - **Done when:** one is named and the others are consciously rejected.
24
+
25
+ 3. Derive the system from the direction, not from habit.
26
+ - Type scale, spacing scale, palette and border treatment all follow from the reference. Swiss does not get rounded corners. Brutalist does not get soft shadows.
27
+ - **Done when:** each system decision can be traced to the reference.
28
+
29
+ 4. Check the negative list before finishing.
30
+ - Read the three "must not be" adjectives and look at the result. If any of them fits, the direction was not followed.
31
+ - **Done when:** none of the negative adjectives applies.
32
+
33
+ ## The default trap
34
+
35
+ If the output has a centred hero with a gradient headline, three equal cards below it, and rounded everything — the brief was skipped. Go back to step one.
36
+
37
+ ## Verification
38
+
39
+ - The brief exists in writing.
40
+ - Every system decision traces to the named reference.
41
+ - None of the three negative adjectives describes the result.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: motion-and-transitions
3
+ description: Add animation or transitions to an interface. Use when a UI changes state abruptly, when animations feel slow, or when motion is being added for its own sake.
4
+ ---
5
+
6
+ # Motion and Transitions
7
+
8
+ ## What motion is for
9
+
10
+ Explaining a change. Where something came from, where it went, what is loading. Motion that explains nothing is decoration, and decoration on a screen someone uses fifty times a day becomes an irritation.
11
+
12
+ ## Workflow
13
+
14
+ 1. Justify each animation in one sentence.
15
+ - "This shows the panel came from the button." If the sentence cannot be written, remove the animation.
16
+ - **Done when:** every transition has a stated purpose.
17
+
18
+ 2. Set duration by distance and size.
19
+ - Small local changes 100–150ms. Panels and modals 200–300ms. Full-page transitions up to 400ms. Anything over 400ms feels broken, however smooth.
20
+ - **Done when:** no interaction feedback exceeds 400ms.
21
+
22
+ 3. Choose easing by direction.
23
+ - Entering: ease-out — fast start, gentle settle. Leaving: ease-in — the element is going, so get on with it. Moving between two on-screen positions: ease-in-out. Never `linear` for anything physical.
24
+ - **Done when:** entrances and exits use different curves.
25
+
26
+ 4. Animate only compositor-friendly properties.
27
+ - `transform` and `opacity` do not trigger layout. Animating `width`, `height`, `top` or `margin` forces layout on every frame and drops to a visible stutter on a mid-tier device.
28
+ - **Done when:** the performance panel shows no layout recalculation during the animation.
29
+
30
+ 5. Honour the reduced-motion preference.
31
+ - `@media (prefers-reduced-motion: reduce)` must remove or shorten motion. For some people, motion causes nausea — this is an accessibility requirement, not a nicety.
32
+ - **Done when:** with the preference set, transitions are instant or minimal and nothing breaks.
33
+
34
+ ## Verification
35
+
36
+ - Every animation has a stated purpose.
37
+ - The performance panel shows no layout thrash during motion.
38
+ - With reduced motion enabled the interface is fully functional.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: responsive-strategy
3
+ description: Make an interface work across screen sizes. Use when a layout breaks on mobile, when breakpoints are copied from a framework, or when a design was built for one width.
4
+ ---
5
+
6
+ # Responsive Strategy
7
+
8
+ ## Breakpoints come from the content
9
+
10
+ The right breakpoint is the width at which THIS layout stops working — found by resizing until it breaks. Device-named breakpoints copied from a framework describe hardware that no longer exists and produce layouts that are wrong on real screens.
11
+
12
+ ## Workflow
13
+
14
+ 1. Design the narrow case first.
15
+ - A single column forces a decision about priority: what does the user need first. Widening then adds; narrowing from a wide design only ever removes, and the removal is arbitrary.
16
+ - **Done when:** the interface is complete and usable at 320px.
17
+
18
+ 2. Prefer intrinsic sizing to breakpoints.
19
+ - `clamp()` for type and spacing, `minmax()` with `auto-fit` for grids, `flex-wrap` for rows. Each of these removes a breakpoint entirely and adapts continuously rather than in jumps.
20
+ - **Done when:** the count of media queries is as low as the layout allows.
21
+
22
+ 3. Use container queries for components.
23
+ - A card in a sidebar and the same card in a main column should lay out differently. That depends on the CONTAINER width, not the viewport, and a media query cannot express it.
24
+ - **Done when:** components respond to their own container.
25
+
26
+ 4. Respect touch and pointer differences.
27
+ - Touch targets at least 44px. Hover-only affordances need a tap equivalent. Test with a real finger, not a narrow browser window.
28
+ - **Done when:** every action is reachable by touch without hovering.
29
+
30
+ 5. Handle the vertical axis too.
31
+ - Landscape phones and split-screen windows are short. A hero sized in `100vh` is unusable there. Use `100dvh` or a `min-height` with content-driven growth.
32
+ - **Done when:** the interface works at 320×480 as well as 1920×1080.
33
+
34
+ ## Verification
35
+
36
+ - No horizontal scroll from 320px to 2560px.
37
+ - Every interactive target is at least 44px on touch.
38
+ - Zooming text to 200% neither clips nor overlaps content.
39
+ - The layout is usable in a short landscape viewport.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: spacing-and-rhythm
3
+ description: Set spacing and alignment in an interface. Use when padding values look arbitrary, when a layout feels cramped or loose, or when elements do not line up.
4
+ ---
5
+
6
+ # Spacing and Rhythm
7
+
8
+ ## The single rule
9
+
10
+ Every space is a step on one scale. The moment an arbitrary value appears — `padding: 13px` — the rhythm is broken, and the eye reads the whole layout as slightly wrong without being able to say why.
11
+
12
+ ## Workflow
13
+
14
+ 1. Define the scale once.
15
+ - A geometric-ish ramp from a 4px or 8px base: 4, 8, 12, 16, 24, 32, 48, 64, 96. Name them and use only these.
16
+ - **Done when:** no spacing value in the codebase is outside the scale.
17
+
18
+ 2. Space by relationship, not by taste.
19
+ - Elements that belong together get less space than elements that do not. This proximity grouping carries more meaning than borders or boxes ever will, and it costs no ink.
20
+ - **Done when:** the grouping is readable from spacing alone, with all borders removed.
21
+
22
+ 3. Give sections room proportional to their weight.
23
+ - A page section needs several times the space of an element within it. Uniform spacing everywhere flattens the structure.
24
+ - **Done when:** the top-level structure is visible when scrolling quickly.
25
+
26
+ 4. Space in one direction.
27
+ - Set margin on one side only (`margin-block-end`, or a flex/grid `gap`). Margins on both sides collapse unpredictably and make spacing impossible to reason about.
28
+ - **Done when:** no element sets both a top and a bottom margin.
29
+
30
+ 5. Align to a small number of edges.
31
+ - Every element should line up with something. Multiple near-but-not-equal left edges is the most visible sign of an unconsidered layout.
32
+ - **Done when:** drawing vertical lines through the layout shows few distinct alignment edges.
33
+
34
+ ## Verification
35
+
36
+ - Grep the stylesheet for spacing values not on the scale — there should be none.
37
+ - With all borders and backgrounds removed, the grouping is still legible.
38
+ - Overlaying a vertical rule at each alignment edge produces a small number of lines.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: type-scale-and-hierarchy
3
+ description: Set typography for an interface or document. Use when text sizes were picked ad hoc, when headings and body are hard to tell apart, or when long text is hard to read.
4
+ ---
5
+
6
+ # Type Scale and Hierarchy
7
+
8
+ ## What makes typography read as designed
9
+
10
+ A small number of sizes, related by a ratio, with weight and space doing the rest of the work. Interfaces look amateurish when every element gets its own size, and when hierarchy is expressed only by making things bigger.
11
+
12
+ ## Workflow
13
+
14
+ 1. Build a scale, do not pick sizes.
15
+ - Choose a base (16px for body on the web) and a ratio: 1.2 for dense interfaces, 1.25 for general use, 1.333 or 1.5 for editorial with few levels.
16
+ - Round to whole pixels and keep five to seven steps total. More than that and the steps stop being distinguishable.
17
+ - **Done when:** every size in the design is a step on the scale.
18
+
19
+ 2. Set the measure before the size.
20
+ - 45–75 characters per line for body text. Longer and the eye loses the return; shorter and it breaks rhythm. `max-width: 65ch` is the direct expression of this.
21
+ - **Done when:** body text sits between 45 and 75 characters per line at every breakpoint.
22
+
23
+ 3. Set line height inversely to size.
24
+ - Body 1.5–1.6. Headings 1.1–1.25. A heading at body line height looks loose and disconnected from itself.
25
+ - **Done when:** each level has a line height appropriate to its size.
26
+
27
+ 4. Express hierarchy with three tools, not one.
28
+ - Size, weight, and colour or space. Two levels that differ only in size need a large gap to read as different; two that differ in weight and space can be one step apart.
29
+ - **Done when:** hierarchy survives a squint test — the reading order is obvious out of focus.
30
+
31
+ 5. Restrain the families.
32
+ - One typeface with a real range of weights beats two chosen for contrast. If two, make them genuinely different in category (a serif display against a sans body), never two similar sans faces.
33
+ - **Done when:** the design uses at most two families, with a stated reason for the second.
34
+
35
+ ## Verification
36
+
37
+ - Every text size in the rendered page is a step on the declared scale.
38
+ - Body measure is within 45–75 characters at all breakpoints.
39
+ - The page passes a squint test: the reading order is clear when blurred.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: visual-qa-loop
3
+ description: Check that a built interface actually looks right. Use after implementing any UI, and before declaring visual work finished.
4
+ ---
5
+
6
+ # Visual QA Loop
7
+
8
+ ## The rule
9
+
10
+ Look at it. A human developer opens the browser; anything building an interface must do the same. Code that compiles and tests that pass say nothing about whether the result is usable or whether it looks like a template.
11
+
12
+ ## Workflow
13
+
14
+ 1. Render it and capture the result.
15
+ - Take a screenshot at a realistic width. Reading the markup is not a substitute — spacing, contrast and hierarchy are only visible when rendered.
16
+ - **Done when:** a screenshot of the actual rendered page exists.
17
+
18
+ 2. Run the squint test.
19
+ - Blur the image mentally or literally. The reading order should be obvious, the primary action should stand out, and the grouping should be visible. If everything has equal weight, the hierarchy failed.
20
+ - **Done when:** the intended reading order survives blurring.
21
+
22
+ 3. Check against the design brief.
23
+ - Re-read the direction that was chosen. Does the result match the named reference and avoid the three negative adjectives?
24
+ - **Done when:** the result matches the brief, or the mismatch is named and fixed.
25
+
26
+ 4. Check the states, not just the happy path.
27
+ - Empty, loading, error, one item, and far too many items. Long names, long text, missing images. Most visual bugs live in the states nobody screenshots.
28
+ - **Done when:** every state has been rendered and looks deliberate.
29
+
30
+ 5. Check both themes and both extremes of width.
31
+ - Light and dark, 320px and 2560px. A design checked at one width in one theme is checked at a quarter of its surface.
32
+ - **Done when:** all four combinations are rendered and correct.
33
+
34
+ 6. If it looks generic, rebuild rather than adjust.
35
+ - A centred hero, a gradient headline, three equal cards and rounded everything is the default shape, not a design. Adjusting its padding does not fix it.
36
+ - **Done when:** the result would not be mistaken for a template.
37
+
38
+ ## Verification
39
+
40
+ - Screenshots exist for every state, both themes, and both width extremes.
41
+ - The squint test passes.
42
+ - The result traces to the design brief.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: docker-multi-stage-builds
3
+ description: Build a Dockerfile for a compiled or bundled project. Use when adding containerisation, when an image exceeds a few hundred megabytes, or when a build copies source into the runtime layer.
4
+ ---
5
+
6
+ # Docker Multi-Stage Builds
7
+
8
+ ## Invariants
9
+
10
+ 1. Compiled and bundled languages get a build stage and a runtime stage. Never one stage.
11
+ 2. The final image never runs as `root`.
12
+ 3. Secrets never enter a layer. `COPY .env` is a leak even if a later stage deletes it — layers are additive and readable with `docker history`.
13
+
14
+ ## Workflow
15
+
16
+ 1. Read the existing build.
17
+ - Identify the build command, the artefact directory, and the runtime entrypoint.
18
+ - **Done when:** you can name the exact directory the runtime needs and nothing else.
19
+
20
+ 2. Split the stages.
21
+ - Stage one installs every dependency and builds. Stage two starts from a clean base and copies only the artefact plus production dependencies.
22
+ - Order layers by change frequency: manifest first, `install` second, source last. A source edit must not invalidate the dependency layer.
23
+ - **Done when:** editing one source file rebuilds only the final layers.
24
+
25
+ 3. Drop privileges.
26
+ - Create a user in the runtime stage and switch to it before `CMD`.
27
+ - **Done when:** `docker run --rm IMAGE id -u` prints a non-zero uid.
28
+
29
+ 4. Add a `.dockerignore`.
30
+ - At minimum `node_modules`, `.git`, `.env*`, build output, and test fixtures. Without it the whole working tree enters the build context and slows every build.
31
+ - **Done when:** `docker build` reports a context under a few megabytes for a typical app.
32
+
33
+ ## Node template
34
+
35
+ ```dockerfile
36
+ FROM node:24-alpine AS build
37
+ WORKDIR /app
38
+ COPY package*.json ./
39
+ RUN npm ci
40
+ COPY . .
41
+ RUN npm run build
42
+
43
+ FROM node:24-alpine
44
+ WORKDIR /app
45
+ ENV NODE_ENV=production
46
+ RUN addgroup -S app && adduser -S app -G app
47
+ COPY package*.json ./
48
+ RUN npm ci --omit=dev && npm cache clean --force
49
+ COPY --from=build /app/dist ./dist
50
+ USER app
51
+ EXPOSE 3000
52
+ CMD ["node", "dist/index.js"]
53
+ ```
54
+
55
+ ## Verification
56
+
57
+ - `docker build -t app .` succeeds.
58
+ - `docker image ls app` shows a size in line with the base image plus the artefact.
59
+ - `docker history app` shows no layer containing a secret file.
60
+ - The container starts and answers a request.
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: github-actions-ci
3
+ description: Write or repair a GitHub Actions workflow for build, test, or release. Use when a repository has no CI, when a workflow is slow, or when a job fails only in CI and not locally.
4
+ ---
5
+
6
+ # GitHub Actions CI
7
+
8
+ ## Workflow
9
+
10
+ 1. Establish what must be true before a merge.
11
+ - Usually: install, lint, test, build. Ask which of those already exist as scripts rather than inventing commands.
12
+ - **Done when:** every gate maps to a command that already runs locally.
13
+
14
+ 2. Pin the trigger narrowly.
15
+ - `pull_request` plus `push` on the default branch. A workflow that runs on every push to every branch burns minutes and teaches people to ignore red.
16
+ - **Done when:** the trigger block names specific branches or paths.
17
+
18
+ 3. Cache the dependency layer.
19
+ - `actions/setup-node` and `actions/setup-python` take a `cache` input; use it rather than hand-rolling `actions/cache`.
20
+ - **Done when:** a second run reports a cache hit and installs in a fraction of the first run's time.
21
+
22
+ 4. Make failure legible.
23
+ - Upload test reports and build logs as artifacts on failure. A red check with no artefact costs someone a local reproduction.
24
+ - **Done when:** a deliberately failing run leaves an artefact that explains the failure.
25
+
26
+ 5. Lock down the token.
27
+ - Set `permissions:` explicitly at the workflow level. The default grant is far wider than a test job needs.
28
+ - **Done when:** `permissions` names only what the job writes, typically `contents: read`.
29
+
30
+ ## Template
31
+
32
+ ```yaml
33
+ name: ci
34
+ on:
35
+ pull_request:
36
+ push:
37
+ branches: [main]
38
+ permissions:
39
+ contents: read
40
+ concurrency:
41
+ group: ci-${{ github.ref }}
42
+ cancel-in-progress: true
43
+ jobs:
44
+ test:
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: actions/setup-node@v4
49
+ with:
50
+ node-version: 24
51
+ cache: npm
52
+ - run: npm ci
53
+ - run: npm test
54
+ ```
55
+
56
+ ## Verification
57
+
58
+ - Push a branch and confirm the workflow runs and passes.
59
+ - Confirm a second run hits the cache.
60
+ - Confirm `concurrency` cancels a superseded run rather than queueing it.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: incident-triage
3
+ description: Respond to a production incident or a failing deployment. Use when a service is down, error rates have spiked, or a release must be assessed under time pressure.
4
+ ---
5
+
6
+ # Incident Triage
7
+
8
+ ## Order of operations
9
+
10
+ Stop the bleeding, then find the cause. Diagnosis while users are down is the most common way an incident doubles in length.
11
+
12
+ ## Workflow
13
+
14
+ 1. Establish the blast radius before touching anything.
15
+ - What is failing, for whom, since when, and what changed in that window. The last question resolves most incidents on its own.
16
+ - **Done when:** you can state the start time and the last change before it.
17
+
18
+ 2. Mitigate with the fastest reversible action.
19
+ - Roll back, disable the feature flag, or shift traffic. Do not fix forward under pressure — a hurried fix is a second incident.
20
+ - **Done when:** the user-visible symptom is gone, whether or not the cause is known.
21
+
22
+ 3. Preserve the evidence.
23
+ - Capture logs, metrics windows and a heap or thread dump before restarting anything. A restart usually destroys the only copy of the state that explains the failure.
24
+ - **Done when:** the evidence is saved somewhere that survives the restart.
25
+
26
+ 4. Confirm recovery against a signal, not a feeling.
27
+ - Watch the same error-rate and latency series that showed the problem, for long enough to cover a full request cycle.
28
+ - **Done when:** the series has returned to its pre-incident band and stayed there.
29
+
30
+ 5. Write the timeline while it is fresh.
31
+ - Times, actions, and what each one changed. Blameless: the target is the system that allowed it, not the person who triggered it.
32
+ - **Done when:** someone who was not present can follow the sequence.
33
+
34
+ ## Verification
35
+
36
+ - The symptom is gone and confirmed by the original alerting signal.
37
+ - Evidence is captured.
38
+ - A follow-up action exists for the cause, separate from the mitigation.