ada-agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -0
  3. package/bench/README.md +88 -0
  4. package/bench/swebench.mjs +242 -0
  5. package/bin/ada-server.mjs +6 -0
  6. package/bin/ada.mjs +7 -0
  7. package/docs/agent-loop.svg +66 -0
  8. package/docs/architecture.md +139 -0
  9. package/docs/architecture.svg +73 -0
  10. package/docs/connectors.md +48 -0
  11. package/docs/integrations.md +59 -0
  12. package/docs/login-flow.svg +56 -0
  13. package/docs/orchestration.md +45 -0
  14. package/package.json +64 -0
  15. package/skills/accessibility/SKILL.md +23 -0
  16. package/skills/add-logging/SKILL.md +23 -0
  17. package/skills/add-metrics/SKILL.md +23 -0
  18. package/skills/adr/SKILL.md +24 -0
  19. package/skills/aesthetic-direction/SKILL.md +24 -0
  20. package/skills/agent-loop/SKILL.md +23 -0
  21. package/skills/alerting/SKILL.md +23 -0
  22. package/skills/alpha-compositing/SKILL.md +23 -0
  23. package/skills/android-compose/SKILL.md +23 -0
  24. package/skills/angular-module/SKILL.md +23 -0
  25. package/skills/ansible-playbook/SKILL.md +24 -0
  26. package/skills/api-docs/SKILL.md +24 -0
  27. package/skills/app-store-prep/SKILL.md +23 -0
  28. package/skills/architecture-diagram/SKILL.md +21 -0
  29. package/skills/architecture-doc/SKILL.md +24 -0
  30. package/skills/audit-log/SKILL.md +23 -0
  31. package/skills/authz-review/SKILL.md +23 -0
  32. package/skills/aws-lambda/SKILL.md +24 -0
  33. package/skills/bash-script/SKILL.md +23 -0
  34. package/skills/batch/SKILL.md +23 -0
  35. package/skills/bisect/SKILL.md +23 -0
  36. package/skills/bounding-box/SKILL.md +24 -0
  37. package/skills/branch-cleanup/SKILL.md +23 -0
  38. package/skills/bundle-analyze/SKILL.md +23 -0
  39. package/skills/cache/SKILL.md +23 -0
  40. package/skills/call-graph/SKILL.md +23 -0
  41. package/skills/canvas-debug/SKILL.md +23 -0
  42. package/skills/cdn-setup/SKILL.md +23 -0
  43. package/skills/changelog/SKILL.md +24 -0
  44. package/skills/cherry-pick/SKILL.md +23 -0
  45. package/skills/ci-setup/SKILL.md +23 -0
  46. package/skills/cleanup/SKILL.md +23 -0
  47. package/skills/cli-tool/SKILL.md +23 -0
  48. package/skills/cloudformation/SKILL.md +23 -0
  49. package/skills/code-examples/SKILL.md +24 -0
  50. package/skills/code-review/SKILL.md +23 -0
  51. package/skills/color-palette/SKILL.md +24 -0
  52. package/skills/color-space/SKILL.md +24 -0
  53. package/skills/comment-why/SKILL.md +23 -0
  54. package/skills/commit/SKILL.md +26 -0
  55. package/skills/complexity-audit/SKILL.md +23 -0
  56. package/skills/component/SKILL.md +23 -0
  57. package/skills/component-library/SKILL.md +23 -0
  58. package/skills/connect-github/SKILL.md +20 -0
  59. package/skills/connect-mcp/SKILL.md +21 -0
  60. package/skills/connect-postgres/SKILL.md +20 -0
  61. package/skills/connect-remote/SKILL.md +23 -0
  62. package/skills/connect-slack/SKILL.md +20 -0
  63. package/skills/contract-audit/SKILL.md +25 -0
  64. package/skills/contributing/SKILL.md +23 -0
  65. package/skills/cpp-raii/SKILL.md +23 -0
  66. package/skills/cron-job/SKILL.md +23 -0
  67. package/skills/cv-preprocess/SKILL.md +24 -0
  68. package/skills/dark-mode/SKILL.md +24 -0
  69. package/skills/dashboard/SKILL.md +23 -0
  70. package/skills/dashboard-ui/SKILL.md +23 -0
  71. package/skills/data-export/SKILL.md +23 -0
  72. package/skills/data-validation/SKILL.md +23 -0
  73. package/skills/dataframe/SKILL.md +23 -0
  74. package/skills/db-index/SKILL.md +24 -0
  75. package/skills/dead-code/SKILL.md +23 -0
  76. package/skills/debug/SKILL.md +24 -0
  77. package/skills/deck-review/SKILL.md +24 -0
  78. package/skills/dedupe/SKILL.md +23 -0
  79. package/skills/dedupe-deps/SKILL.md +23 -0
  80. package/skills/dependency-audit/SKILL.md +23 -0
  81. package/skills/dependency-update/SKILL.md +23 -0
  82. package/skills/deploy/SKILL.md +23 -0
  83. package/skills/design-system/SKILL.md +24 -0
  84. package/skills/design-tokens/SKILL.md +24 -0
  85. package/skills/diagram-as-code/SKILL.md +24 -0
  86. package/skills/diff-explain/SKILL.md +23 -0
  87. package/skills/django-view/SKILL.md +23 -0
  88. package/skills/doc-lint/SKILL.md +24 -0
  89. package/skills/docker-compose/SKILL.md +23 -0
  90. package/skills/dockerize/SKILL.md +23 -0
  91. package/skills/docstrings/SKILL.md +23 -0
  92. package/skills/dotfiles/SKILL.md +23 -0
  93. package/skills/dpi-scaling/SKILL.md +23 -0
  94. package/skills/e2e-test/SKILL.md +23 -0
  95. package/skills/embeddings/SKILL.md +23 -0
  96. package/skills/empty-states/SKILL.md +23 -0
  97. package/skills/env-setup/SKILL.md +23 -0
  98. package/skills/erc20/SKILL.md +24 -0
  99. package/skills/error-tracking/SKILL.md +23 -0
  100. package/skills/estimate/SKILL.md +23 -0
  101. package/skills/etl-pipeline/SKILL.md +24 -0
  102. package/skills/eval-harness/SKILL.md +23 -0
  103. package/skills/exif-orientation/SKILL.md +23 -0
  104. package/skills/explain-code/SKILL.md +23 -0
  105. package/skills/express-middleware/SKILL.md +23 -0
  106. package/skills/extract-function/SKILL.md +23 -0
  107. package/skills/faq/SKILL.md +24 -0
  108. package/skills/fastapi-endpoint/SKILL.md +23 -0
  109. package/skills/favicon/SKILL.md +23 -0
  110. package/skills/feature-engineering/SKILL.md +23 -0
  111. package/skills/few-shot/SKILL.md +23 -0
  112. package/skills/find-owner/SKILL.md +23 -0
  113. package/skills/firmware-driver/SKILL.md +23 -0
  114. package/skills/fix-flaky-tests/SKILL.md +23 -0
  115. package/skills/flutter-widget/SKILL.md +23 -0
  116. package/skills/font-rendering/SKILL.md +23 -0
  117. package/skills/form-validation/SKILL.md +23 -0
  118. package/skills/format/SKILL.md +23 -0
  119. package/skills/game-loop/SKILL.md +23 -0
  120. package/skills/gas-optimize/SKILL.md +25 -0
  121. package/skills/gdpr-review/SKILL.md +24 -0
  122. package/skills/github-actions/SKILL.md +23 -0
  123. package/skills/glossary/SKILL.md +24 -0
  124. package/skills/go-idioms/SKILL.md +23 -0
  125. package/skills/gpu-profile/SKILL.md +23 -0
  126. package/skills/graphify/SKILL.md +21 -0
  127. package/skills/graphql-resolver/SKILL.md +23 -0
  128. package/skills/grpc-service/SKILL.md +23 -0
  129. package/skills/guardrails/SKILL.md +23 -0
  130. package/skills/healthcheck/SKILL.md +23 -0
  131. package/skills/heisenbug/SKILL.md +23 -0
  132. package/skills/helm-chart/SKILL.md +24 -0
  133. package/skills/hero-section/SKILL.md +23 -0
  134. package/skills/html-email/SKILL.md +24 -0
  135. package/skills/html-form/SKILL.md +23 -0
  136. package/skills/html-sanitize/SKILL.md +23 -0
  137. package/skills/html-table/SKILL.md +23 -0
  138. package/skills/html-to-pdf/SKILL.md +23 -0
  139. package/skills/http-client/SKILL.md +23 -0
  140. package/skills/i18n/SKILL.md +23 -0
  141. package/skills/i2c-spi/SKILL.md +23 -0
  142. package/skills/image-decode/SKILL.md +24 -0
  143. package/skills/image-memory/SKILL.md +24 -0
  144. package/skills/image-perf/SKILL.md +24 -0
  145. package/skills/image-pipeline/SKILL.md +24 -0
  146. package/skills/image-upload/SKILL.md +24 -0
  147. package/skills/infra-cost/SKILL.md +24 -0
  148. package/skills/input-validation/SKILL.md +23 -0
  149. package/skills/issue-template/SKILL.md +23 -0
  150. package/skills/java-streams/SKILL.md +23 -0
  151. package/skills/k8s-manifest/SKILL.md +23 -0
  152. package/skills/kotlin-coroutines/SKILL.md +23 -0
  153. package/skills/landing-page/SKILL.md +24 -0
  154. package/skills/laravel-controller/SKILL.md +23 -0
  155. package/skills/lazy-load/SKILL.md +23 -0
  156. package/skills/license-check/SKILL.md +23 -0
  157. package/skills/license-header/SKILL.md +23 -0
  158. package/skills/lint-fix/SKILL.md +23 -0
  159. package/skills/llm-cost/SKILL.md +23 -0
  160. package/skills/lockfile-fix/SKILL.md +23 -0
  161. package/skills/low-power/SKILL.md +23 -0
  162. package/skills/makefile/SKILL.md +23 -0
  163. package/skills/man-page/SKILL.md +24 -0
  164. package/skills/mcp-server/SKILL.md +23 -0
  165. package/skills/memory-leak/SKILL.md +23 -0
  166. package/skills/mermaid-diagram/SKILL.md +23 -0
  167. package/skills/meta-tags/SKILL.md +23 -0
  168. package/skills/micro-interactions/SKILL.md +23 -0
  169. package/skills/migration/SKILL.md +23 -0
  170. package/skills/migration-guide/SKILL.md +24 -0
  171. package/skills/mkdocs-setup/SKILL.md +24 -0
  172. package/skills/mobile-permissions/SKILL.md +23 -0
  173. package/skills/mock-api/SKILL.md +23 -0
  174. package/skills/modernize/SKILL.md +23 -0
  175. package/skills/monorepo-setup/SKILL.md +23 -0
  176. package/skills/motion-design/SKILL.md +23 -0
  177. package/skills/n-plus-one/SKILL.md +23 -0
  178. package/skills/naming-review/SKILL.md +23 -0
  179. package/skills/nextjs-route/SKILL.md +23 -0
  180. package/skills/nginx-config/SKILL.md +23 -0
  181. package/skills/ocr-debug/SKILL.md +24 -0
  182. package/skills/onboard/SKILL.md +23 -0
  183. package/skills/onboarding-map/SKILL.md +23 -0
  184. package/skills/open-pr/SKILL.md +24 -0
  185. package/skills/openapi/SKILL.md +23 -0
  186. package/skills/opencv-debug/SKILL.md +24 -0
  187. package/skills/orm-model/SKILL.md +23 -0
  188. package/skills/owasp-check/SKILL.md +24 -0
  189. package/skills/page-transitions/SKILL.md +23 -0
  190. package/skills/pagination/SKILL.md +23 -0
  191. package/skills/perf-optimize/SKILL.md +23 -0
  192. package/skills/perf-profile/SKILL.md +23 -0
  193. package/skills/physics/SKILL.md +23 -0
  194. package/skills/pitch-deck/SKILL.md +24 -0
  195. package/skills/pixel-diff/SKILL.md +23 -0
  196. package/skills/ponytail/SKILL.md +46 -0
  197. package/skills/postmortem/SKILL.md +24 -0
  198. package/skills/pptx-deck/SKILL.md +23 -0
  199. package/skills/pptx-export/SKILL.md +23 -0
  200. package/skills/pptx-from-markdown/SKILL.md +23 -0
  201. package/skills/pptx-template/SKILL.md +24 -0
  202. package/skills/pr-review/SKILL.md +24 -0
  203. package/skills/precommit/SKILL.md +23 -0
  204. package/skills/pricing-page/SKILL.md +23 -0
  205. package/skills/project-overview/SKILL.md +22 -0
  206. package/skills/prompt-template/SKILL.md +23 -0
  207. package/skills/property-test/SKILL.md +23 -0
  208. package/skills/protobuf/SKILL.md +23 -0
  209. package/skills/py-async/SKILL.md +23 -0
  210. package/skills/py-typing/SKILL.md +23 -0
  211. package/skills/query-optimize/SKILL.md +23 -0
  212. package/skills/rag-pipeline/SKILL.md +23 -0
  213. package/skills/rails-resource/SKILL.md +23 -0
  214. package/skills/rate-limit/SKILL.md +23 -0
  215. package/skills/react-hooks/SKILL.md +23 -0
  216. package/skills/react-native-screen/SKILL.md +23 -0
  217. package/skills/react-perf/SKILL.md +23 -0
  218. package/skills/readme/SKILL.md +24 -0
  219. package/skills/rebase/SKILL.md +24 -0
  220. package/skills/refactor/SKILL.md +23 -0
  221. package/skills/regression-test/SKILL.md +23 -0
  222. package/skills/release-notes/SKILL.md +24 -0
  223. package/skills/rename-symbol/SKILL.md +23 -0
  224. package/skills/repro/SKILL.md +23 -0
  225. package/skills/resolve-conflicts/SKILL.md +23 -0
  226. package/skills/responsive/SKILL.md +23 -0
  227. package/skills/rest-endpoint/SKILL.md +23 -0
  228. package/skills/retro/SKILL.md +23 -0
  229. package/skills/rtos-task/SKILL.md +23 -0
  230. package/skills/runbook/SKILL.md +25 -0
  231. package/skills/rust-borrow/SKILL.md +23 -0
  232. package/skills/rust-unsafe-audit/SKILL.md +23 -0
  233. package/skills/sanitize/SKILL.md +23 -0
  234. package/skills/schema-design/SKILL.md +23 -0
  235. package/skills/screenshot-debug/SKILL.md +22 -0
  236. package/skills/scroll-animation/SKILL.md +23 -0
  237. package/skills/secret-scan/SKILL.md +23 -0
  238. package/skills/security-audit/SKILL.md +23 -0
  239. package/skills/security-review/SKILL.md +23 -0
  240. package/skills/seed-data/SKILL.md +23 -0
  241. package/skills/self-review/SKILL.md +23 -0
  242. package/skills/semantic-html/SKILL.md +23 -0
  243. package/skills/semver-bump/SKILL.md +24 -0
  244. package/skills/shader/SKILL.md +23 -0
  245. package/skills/shader-debug/SKILL.md +23 -0
  246. package/skills/simplify-conditionals/SKILL.md +23 -0
  247. package/skills/sitemap/SKILL.md +23 -0
  248. package/skills/skeleton-loader/SKILL.md +23 -0
  249. package/skills/slide-charts/SKILL.md +24 -0
  250. package/skills/slide-outline/SKILL.md +23 -0
  251. package/skills/snapshot-update/SKILL.md +23 -0
  252. package/skills/solidity-contract/SKILL.md +25 -0
  253. package/skills/speaker-notes/SKILL.md +23 -0
  254. package/skills/spike/SKILL.md +23 -0
  255. package/skills/split-file/SKILL.md +23 -0
  256. package/skills/spring-controller/SKILL.md +23 -0
  257. package/skills/sprite-anim/SKILL.md +23 -0
  258. package/skills/sql-report/SKILL.md +23 -0
  259. package/skills/squash/SKILL.md +24 -0
  260. package/skills/ssl-setup/SKILL.md +23 -0
  261. package/skills/stacktrace/SKILL.md +23 -0
  262. package/skills/static-site/SKILL.md +24 -0
  263. package/skills/structured-logging/SKILL.md +23 -0
  264. package/skills/svelte-store/SKILL.md +23 -0
  265. package/skills/swiftui-view/SKILL.md +23 -0
  266. package/skills/tailwind-theme/SKILL.md +24 -0
  267. package/skills/tcp-server/SKILL.md +23 -0
  268. package/skills/tdd/SKILL.md +23 -0
  269. package/skills/terraform-module/SKILL.md +24 -0
  270. package/skills/test-coverage/SKILL.md +23 -0
  271. package/skills/texture-debug/SKILL.md +23 -0
  272. package/skills/threat-model/SKILL.md +23 -0
  273. package/skills/thumbnail/SKILL.md +24 -0
  274. package/skills/todo-scan/SKILL.md +23 -0
  275. package/skills/tool-definition/SKILL.md +23 -0
  276. package/skills/trace-flow/SKILL.md +23 -0
  277. package/skills/tracing/SKILL.md +23 -0
  278. package/skills/train-model/SKILL.md +24 -0
  279. package/skills/tree-shake/SKILL.md +23 -0
  280. package/skills/ts-generics/SKILL.md +23 -0
  281. package/skills/ts-strict/SKILL.md +23 -0
  282. package/skills/tui-app/SKILL.md +23 -0
  283. package/skills/tutorial/SKILL.md +24 -0
  284. package/skills/type-tighten/SKILL.md +23 -0
  285. package/skills/typography/SKILL.md +24 -0
  286. package/skills/ui-bug-repro/SKILL.md +23 -0
  287. package/skills/ui-polish/SKILL.md +24 -0
  288. package/skills/ui-review/SKILL.md +24 -0
  289. package/skills/vendor/SKILL.md +23 -0
  290. package/skills/visual-diff-ci/SKILL.md +24 -0
  291. package/skills/visual-regression/SKILL.md +23 -0
  292. package/skills/vue-composition/SKILL.md +23 -0
  293. package/skills/web-component/SKILL.md +23 -0
  294. package/skills/web-fonts/SKILL.md +24 -0
  295. package/skills/web3-frontend/SKILL.md +25 -0
  296. package/skills/webgl-debug/SKILL.md +23 -0
  297. package/skills/webhook/SKILL.md +23 -0
  298. package/skills/websocket/SKILL.md +23 -0
  299. package/skills/write-tests/SKILL.md +19 -0
  300. package/src/client/agent.ts +803 -0
  301. package/src/client/background.ts +39 -0
  302. package/src/client/checkpoint.ts +48 -0
  303. package/src/client/cli.ts +1253 -0
  304. package/src/client/compaction.ts +86 -0
  305. package/src/client/extensions.ts +83 -0
  306. package/src/client/hooks.ts +40 -0
  307. package/src/client/image.ts +26 -0
  308. package/src/client/lsp.ts +0 -0
  309. package/src/client/mcp.ts +276 -0
  310. package/src/client/models-dev.ts +52 -0
  311. package/src/client/pkg.ts +41 -0
  312. package/src/client/platform.ts +94 -0
  313. package/src/client/prompts.ts +47 -0
  314. package/src/client/render.ts +138 -0
  315. package/src/client/session.ts +107 -0
  316. package/src/client/settings.ts +86 -0
  317. package/src/client/skill-router.ts +79 -0
  318. package/src/client/skills.ts +199 -0
  319. package/src/client/snapshot.ts +56 -0
  320. package/src/client/telemetry.ts +24 -0
  321. package/src/client/todos.ts +23 -0
  322. package/src/client/tools.ts +756 -0
  323. package/src/client/tui-mode.ts +41 -0
  324. package/src/client/tui.ts +224 -0
  325. package/src/sdk/index.ts +36 -0
  326. package/src/selfcheck.ts +364 -0
  327. package/src/server/config.ts +58 -0
  328. package/src/server/credentials.ts +89 -0
  329. package/src/server/identity.ts +58 -0
  330. package/src/server/index.ts +113 -0
  331. package/src/server/oauth.ts +93 -0
  332. package/src/server/providers/adapter.ts +25 -0
  333. package/src/server/providers/anthropic.ts +189 -0
  334. package/src/server/providers/openai-compat.ts +76 -0
  335. package/src/server/providers/registry.ts +31 -0
  336. package/src/server/router.ts +29 -0
  337. package/src/server/sse.ts +20 -0
  338. package/src/shared/types.ts +20 -0
  339. package/tsconfig.json +15 -0
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: dpi-scaling
3
+ description: Fix retina/HiDPI blur and layout — devicePixelRatio mismatch between canvas backing store and CSS size
4
+ category: graphics
5
+ ---
6
+
7
+ # DPI Scaling
8
+
9
+ Reach for this when a canvas, chart, or rendered surface looks blurry or soft on retina/HiDPI displays but sharp on standard ones.
10
+
11
+ 1. Confirm the symptom is DPR-related: read `window.devicePixelRatio`. If it's >1 and the canvas looks fuzzy, the backing store is smaller than the displayed pixels and the browser is upscaling.
12
+ 2. Inspect the two sizes that must differ: CSS size (`canvas.style.width`/`getBoundingClientRect().width`, in CSS px) and backing-store size (`canvas.width`, in device px). The blur appears when `canvas.width === cssWidth` on a DPR-2 screen.
13
+ 3. Fix the pattern: set `canvas.width = Math.round(cssWidth * dpr)` and `canvas.height = Math.round(cssHeight * dpr)`, keep `canvas.style.width/height` in CSS px, then `ctx.scale(dpr, dpr)` (2D) or `gl.viewport(0,0, canvas.width, canvas.height)` (WebGL) so your draw code stays in CSS units.
14
+ 4. Re-run on a DPR change: listen for `matchMedia('(resolution: ...)')` or just recompute on `resize`; dragging a window between monitors changes DPR live.
15
+ 5. Verify text/lines are crisp: a 1px line should hit a single device row — half-pixel offsets cause residual softness, so align strokes to `0.5` in 2D contexts after scaling.
16
+ 6. Avoid double-scaling: don't both `ctx.scale(dpr)` and multiply coordinates by dpr — pick one (scale the context, draw in CSS px).
17
+
18
+ ## Rules
19
+ - Backing store (`canvas.width`) must be CSS size times `devicePixelRatio`; the style width stays in CSS px.
20
+ - `ctx.scale(dpr,dpr)` once after sizing lets all draw code stay in logical units — don't also scale coordinates.
21
+ - Recompute on resize and on monitor change; `devicePixelRatio` is not constant.
22
+ - For WebGL, scale via `gl.viewport` and the drawing-buffer size, not by `ctx.scale`.
23
+ - Cap DPR (e.g. min(dpr,2)) for fill-rate-heavy scenes to avoid rendering 9x pixels on a 3x phone.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: e2e-test
3
+ description: Write an end-to-end test that drives the real app through a user flow with Playwright or Cypress
4
+ category: testing
5
+ ---
6
+
7
+ # E2E Test
8
+
9
+ Use when you need to verify a complete user journey through the running app, not isolated units.
10
+
11
+ 1. Identify the user-facing flow and its success criteria (what the user does, what they should see/get at the end).
12
+ 2. Set up the test against a real or test-seeded environment; ensure known starting state (logged-out, empty cart, etc.).
13
+ 3. Drive the flow by user-visible interactions — click buttons, fill fields, follow links — as a real user would.
14
+ 4. Locate elements by accessible role, label, or test id rather than brittle CSS/XPath tied to styling.
15
+ 5. Assert on observable outcomes (visible text, URL, network result), using the framework's auto-waiting instead of fixed sleeps.
16
+ 6. Run it headless and headed, confirm it passes repeatably, and wire it into CI.
17
+
18
+ ## Rules
19
+ - Test critical paths end-to-end (signup, checkout, core action); keep E2E count small since they are slow and costly.
20
+ - Select elements by role/label/`data-testid`, never by auto-generated class names or deep DOM position.
21
+ - Rely on built-in waiting for conditions; never paper over timing with `sleep`/fixed `waitForTimeout`.
22
+ - Seed and reset state per test so runs are independent and repeatable; don't depend on leftover data.
23
+ - Keep secrets and base URLs in env/config, not hardcoded, so the test runs across local/CI/staging.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: embeddings
3
+ description: Set up embeddings and a vector store for semantic search or retrieval
4
+ category: data-ml
5
+ ---
6
+
7
+ # Embeddings
8
+
9
+ Use when you need semantic search, clustering, dedup, or retrieval and must turn text (or other data) into vectors stored in an index.
10
+
11
+ 1. Pick an embedding model matched to the domain and language; note its dimensionality, max input length, and cost.
12
+ 2. Preprocess and chunk inputs to fit the model's token limit, keeping a stable id and metadata for each item.
13
+ 3. Batch the embedding calls, handle rate limits/retries, and normalize vectors if your similarity metric expects it (cosine).
14
+ 4. Store vectors in a vector store (FAISS, pgvector, or a managed index) with the chosen distance metric and an ANN index sized to your recall/latency target.
15
+ 5. Query by embedding the query the same way, retrieving top-k, and verifying results make semantic sense on real queries.
16
+ 6. Persist the model name and version with the index so you can detect and handle re-embedding needs.
17
+
18
+ ## Rules
19
+ - Embed queries and documents with the exact same model and preprocessing — mismatches silently wreck recall.
20
+ - Match the index's distance metric to the model (most use cosine/dot on normalized vectors); don't mix metrics.
21
+ - Re-embedding is required when you change the model, dimension, or chunking — version the index accordingly.
22
+ - Store source ids and metadata alongside vectors so retrieved hits can be traced back and filtered.
23
+ - Benchmark recall and latency at your real data size; small-sample behavior doesn't predict ANN tradeoffs.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: empty-states
3
+ description: Design empty, loading, and error states that orient the user and offer a clear next action.
4
+ category: ui-design
5
+ ---
6
+
7
+ # Empty States
8
+
9
+ Reach for this whenever a view can have no data, be loading, or fail — these states are most of the real experience and deserve the same care as the happy path.
10
+
11
+ 1. Distinguish the three cases and design each: first-run empty (no data yet), cleared empty (filters/search returned nothing), and error (something broke) — they need different copy and actions.
12
+ 2. For first-run, make it a launchpad: a short encouraging line, a focused illustration or icon, and one primary CTA that creates the first item — turn the void into onboarding.
13
+ 3. For "no results", explain why and give an out: echo the active query/filters and offer "clear filters" or a broader suggestion, not a generic shrug.
14
+ 4. For errors, be specific and recoverable: plain-language cause, a "Try again" action, and a path to support — never expose a raw stack trace or a bare "Something went wrong".
15
+ 5. Match the layout to the eventual content so the page doesn't jump when data arrives, and keep tone consistent with the product's voice (helpful, not cute-at-the-user's-expense).
16
+ 6. Respect hierarchy and restraint: one illustration, one heading, one action; muted supporting text; accessible contrast and a real `role`/announcement for error states.
17
+
18
+ ## Rules
19
+ - Every empty/error state offers at least one obvious next step — a dead end with no action is a bug.
20
+ - Error copy names what happened and what to do; "Oops!" with no recovery path is failure theater.
21
+ - Don't reuse the first-run empty state for "no search results" — they imply different user situations.
22
+ - Keep illustrations subtle and on-brand; they support the message, they aren't the message.
23
+ - Announce errors to assistive tech (`aria-live="assertive"` / `role="alert"`) and keep focus recoverable.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: env-setup
3
+ description: Add a .env.example and validate required config at startup so missing vars fail fast
4
+ category: ci-cd
5
+ ---
6
+
7
+ # Env Setup
8
+
9
+ Use when config is read from environment variables and you want a discoverable template plus a hard fail on missing/invalid values.
10
+
11
+ 1. Grep the codebase for every environment variable read (`process.env.X`, `os.environ[...]`, `getenv`) to build the full list.
12
+ 2. Create `.env.example` listing each var with a safe placeholder or sane default and a one-line comment on its purpose.
13
+ 3. Centralize config loading in one module that reads, type-coerces, and validates all vars at startup.
14
+ 4. Validate on boot with a schema (zod, pydantic, envalid, or a manual check) and exit non-zero with a clear message naming any missing/invalid var.
15
+ 5. Ensure real `.env` is gitignored and document the `cp .env.example .env` bootstrap step.
16
+ 6. Run the app with a deliberately missing var to confirm it fails fast with an actionable error rather than crashing later.
17
+
18
+ ## Rules
19
+ - Keep `.env.example` in sync with the code — a var read but undocumented is a setup trap.
20
+ - Never commit a real `.env` or real secret values; placeholders only in the example.
21
+ - Validate at startup, not lazily at first use, so misconfig surfaces immediately.
22
+ - Fail with a message that names the offending variable and what it expects.
23
+ - Read each var through the central config module, not scattered `process.env` access.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: erc20
3
+ description: Implement a standards-compliant ERC-20 token using OpenZeppelin with tests
4
+ category: web3
5
+ ---
6
+
7
+ # ERC-20 Token
8
+
9
+ Reach for this to ship a fungible token. Extend OpenZeppelin's audited base rather than implementing the standard by hand.
10
+
11
+ 1. Inherit `ERC20` from OpenZeppelin and set name/symbol in the constructor; decimals default to 18 unless you override for a reason.
12
+ 2. Decide supply policy: fixed (mint all in constructor) or mintable (`ERC20` + `Ownable`/`AccessControl` gating `mint`); add `ERC20Burnable` only if burning is intended.
13
+ 3. Add only the extensions you need — `ERC20Permit` (EIP-2612 gasless approvals), `ERC20Pausable`, `ERC20Capped` — and avoid feature creep.
14
+ 4. Wire access control: restrict `mint`/`pause` to roles, never leave them public.
15
+ 5. Write tests covering transfer, `approve`/`transferFrom`, allowance edge cases, zero-address reverts, and supply invariants.
16
+ 6. Deploy with a script that records the token address, then verify the source on the block explorer (Etherscan/Sourcify).
17
+
18
+ ## Rules
19
+ - Do not reimplement transfer/allowance logic — inherit it; custom logic reintroduces known bugs.
20
+ - Be aware of the `approve` race; prefer `ERC20Permit` or increase/decrease-allowance patterns.
21
+ - Never override `decimals()` casually — wallets and integrators assume the value you publish.
22
+ - Gate `mint` and `pause`; an open mint function is an instant exploit.
23
+ - Don't add transfer fees/rebasing without warning — they break DEXes and many integrators.
24
+ - Account for decimals in every amount; mixing raw and human units is a common bug.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: error-tracking
3
+ description: Wire up Sentry/error reporting with context, releases, and source maps
4
+ category: observability
5
+ ---
6
+
7
+ # Error Tracking
8
+
9
+ Use this when uncaught exceptions and crashes need to be captured, grouped, and triaged with enough context to fix them.
10
+
11
+ 1. Add the SDK (Sentry or equivalent) and initialize it as early as possible in startup with the DSN from an env var and the `environment` set.
12
+ 2. Set `release` to the build SHA/version and upload source maps (or debug symbols) in CI so stack traces de-minify to real source lines.
13
+ 3. Let the SDK install global handlers for uncaught exceptions and unhandled rejections; add framework middleware so request errors are captured automatically.
14
+ 4. Enrich events with context — user (non-PII id), tags (`route`, `tenant`), and breadcrumbs — and scrub sensitive fields with `beforeSend`.
15
+ 5. Tune sampling: capture 100% of errors but sample performance/traces; set rate limits so a storm doesn't blow your quota.
16
+ 6. Trigger a test error post-deploy, confirm it lands grouped with a readable stack trace and correct release, then wire alerts/ownership for new issues.
17
+
18
+ ## Rules
19
+ - Scrub PII and secrets in `beforeSend` — request bodies, headers, tokens, emails.
20
+ - Always set `release` + upload source maps, or stack traces are useless.
21
+ - Don't capture expected/handled control-flow errors (validation, 404s) — filter them to cut noise.
22
+ - Link error events to `trace_id` so you can pivot to traces and logs.
23
+ - Fail open: SDK init or transport errors must never crash the app.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: estimate
3
+ description: Break a task into estimated subtasks with assumptions, dependencies, and a total range
4
+ category: productivity
5
+ ---
6
+
7
+ # Estimate
8
+
9
+ Reach for this when someone asks "how long will this take?" — turn a vague task into a decomposed, defensible estimate with the uncertainty made explicit instead of a single hopeful number.
10
+
11
+ 1. Clarify the scope and the definition of done; note anything ambiguous as an explicit assumption you are estimating against.
12
+ 2. Decompose the task into subtasks small enough that each is obvious in size (roughly a half-day or less); split anything you can't size.
13
+ 3. For each subtask give a three-point estimate — optimistic / likely / pessimistic — and a one-line reason for the spread.
14
+ 4. Mark dependencies and ordering between subtasks, plus any external blockers (reviews, access, third-party APIs).
15
+ 5. Add explicit line items for testing, code review, and integration — the work that estimates usually forget.
16
+ 6. Total the likely column for a point estimate and the optimistic-to-pessimistic span for a range; flag the riskiest 1-2 subtasks driving the spread.
17
+
18
+ ## Rules
19
+ - Never give a single bare number — always a range, and always with the assumptions it rests on.
20
+ - Estimate effort, not calendar time; do not bake in meetings, context-switching, or someone's availability.
21
+ - If a subtask's pessimistic case is more than ~3x its optimistic, it's underspecified — split it or spike it first.
22
+ - Don't pad silently; if you add buffer, label it as buffer so it can be challenged.
23
+ - Re-estimate when scope or assumptions change rather than defending a stale number.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: etl-pipeline
3
+ description: Build an ETL/data pipeline that extracts, transforms, and loads data idempotently
4
+ category: data-ml
5
+ ---
6
+
7
+ # ETL Pipeline
8
+
9
+ Reach for this when moving data between systems (files, APIs, databases, warehouses) on a schedule or one-shot, and you need it to be re-runnable without duplicating or corrupting data.
10
+
11
+ 1. Pin down source and sink contracts: schema, primary keys, volume, update frequency, and whether the source is append-only or mutable.
12
+ 2. Split the job into explicit extract, transform, and load stages so each can be tested and re-run in isolation.
13
+ 3. Make loads idempotent: upsert on a natural/surrogate key, or stage-then-swap, so a re-run never double-writes.
14
+ 4. Process incrementally using a watermark (updated_at, sequence id, or partition) and persist the high-water mark after a successful load.
15
+ 5. Validate row counts and key invariants between stages; fail loud and stop before loading bad data downstream.
16
+ 6. Add structured logging and a dead-letter path for bad records, then wire retries with backoff on transient failures.
17
+ 7. Make the run parameterized (date range, env) and schedulable via cron/Airflow/Prefect rather than hardcoded.
18
+
19
+ ## Rules
20
+ - Never mutate the source; treat raw extracts as immutable and transform into a separate layer.
21
+ - Idempotency is non-negotiable — assume every run can be retried or run twice.
22
+ - Keep transforms pure and deterministic; isolate I/O so logic is unit-testable without the network.
23
+ - Checkpoint the watermark only after the load commits, never before.
24
+ - Surface partial failures explicitly; a green exit code must mean the data is actually correct.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: eval-harness
3
+ description: Build a reproducible evaluation harness for a model or agent
4
+ category: data-ml
5
+ ---
6
+
7
+ # Eval Harness
8
+
9
+ Use when you need to measure how well a model, prompt, or agent performs against a fixed dataset, and compare versions over time without moving goalposts.
10
+
11
+ 1. Define the task as inputs plus a scoring function; pick metrics that actually reflect the goal (accuracy, F1, pass@k, exact match, rubric score).
12
+ 2. Build a versioned dataset of cases with expected outputs or grading criteria; keep a small dev set and a frozen test set.
13
+ 3. Make each case independent and the runner deterministic where possible — fix seeds and temperature, record model/version.
14
+ 4. Run cases in parallel with isolation, capturing the raw output, score, latency, and cost per case.
15
+ 5. Aggregate into a scorecard (overall and per-category) and persist results keyed by model/prompt version for diffing.
16
+ 6. Inspect failures by reading actual transcripts, not just the aggregate; add hard cases back into the dataset.
17
+
18
+ ## Rules
19
+ - Freeze the eval set; changing cases and the system in the same run makes results uncomparable.
20
+ - Save raw outputs alongside scores so any regression can be inspected after the fact.
21
+ - For LLM-as-judge graders, validate the judge against human labels and pin the judge model/prompt.
22
+ - Report cost and latency next to quality — a better score that's 10x slower is a real tradeoff.
23
+ - Always look at concrete failing cases; aggregate metrics hide systematic errors.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: exif-orientation
3
+ description: Fix images that appear rotated or flipped because EXIF orientation metadata was ignored or double-applied
4
+ category: image
5
+ ---
6
+
7
+ # EXIF Orientation
8
+
9
+ Reach for this when photos (often phone camera uploads) show up sideways or upside-down in your app but look correct in the OS file viewer — or vice versa.
10
+
11
+ 1. Reproduce with the actual offending file (orientation bugs are per-file); confirm it looks correct in a viewer that honors EXIF and wrong in your pipeline, or the reverse.
12
+ 2. Read the EXIF Orientation tag (values 1–8). Values other than 1 mean the stored pixels are rotated/mirrored and metadata says how to display them. `exiftool`, `identify -verbose`, or `PIL.Image.getexif()` will show it.
13
+ 3. Decide the symptom class: if your app ignores the tag, the image stays in stored (sideways) orientation. If two layers BOTH apply it (e.g. browser auto-rotates AND your code rotates), it gets double-rotated.
14
+ 4. Normalize once, early: bake the orientation into the pixels (e.g. `ImageOps.exif_transpose`) immediately after decode, then STRIP the orientation tag so nothing downstream re-applies it.
15
+ 5. Verify across the consumers: thumbnail generator, the viewer/browser, and any re-encode step must all agree — test a sideways and a mirrored sample (orientation 6 and 2 are good probes).
16
+ 6. Check the encode path too: when you write the corrected image, ensure you don't copy the old orientation tag back into the output.
17
+
18
+ ## Rules
19
+ - Apply EXIF orientation exactly once, then remove the tag — double-application is the most common regression.
20
+ - Browsers and image CDNs may auto-rotate; account for whether the consumer already honors EXIF before you also rotate.
21
+ - Cropping/face-detection/coordinate work must happen AFTER orientation is baked in, or boxes land on the wrong region.
22
+ - Test orientation 6 (rotate 90 CW) and 2/4 (mirrored) specifically — plain 180 hides flip vs rotate confusion.
23
+ - Don't trust width/height from headers before normalization; a sideways image reports swapped dimensions.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: explain-code
3
+ description: Explain an unfamiliar region of the codebase by reading it in context and summarizing intent and risks
4
+ category: code-understanding
5
+ ---
6
+
7
+ # Explain Code
8
+
9
+ Reach for this when asked "what does this do?" about a file, function, or block you have not read yet. The goal is an accurate plain-language account, not a line-by-line restatement.
10
+
11
+ 1. Read the whole unit (function/class/file), not just the lines pointed at — context above and below changes meaning.
12
+ 2. Identify inputs, outputs, and side effects: what comes in, what goes out, what state or I/O it touches.
13
+ 3. Resolve unfamiliar symbols by grepping their definition rather than guessing from the name.
14
+ 4. Note the control flow: branches, loops, early returns, error/exception paths, and what triggers each.
15
+ 5. State the purpose in one or two sentences, then explain the non-obvious parts (edge cases, why it exists, surprising behavior).
16
+ 6. Flag anything risky or unclear: dead code, TODOs, implicit assumptions, or behavior that contradicts the names.
17
+
18
+ ## Rules
19
+ - Explain intent and behavior, not syntax — assume the reader knows the language.
20
+ - Quote exact identifiers and file paths so the reader can navigate; never paraphrase a function name.
21
+ - If behavior depends on a caller or config you have not seen, say so instead of inventing it.
22
+ - Distinguish what the code does from what it appears intended to do when they diverge.
23
+ - Keep it proportional: a short helper gets a sentence, not a page.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: express-middleware
3
+ description: Add Express middleware for auth, logging, or error handling in the right order
4
+ category: frameworks
5
+ ---
6
+
7
+ # Express Middleware
8
+
9
+ Use to add cross-cutting behavior (authentication, request logging, error handling) to an Express app via middleware, registered in the correct order.
10
+
11
+ 1. Decide the type: request middleware `(req, res, next)` for logging/auth, or error middleware `(err, req, res, next)` (four args) for errors.
12
+ 2. Write it in its own module; do work, attach to `req` (e.g. `req.user`), then call `next()` — or `next(err)` to fail.
13
+ 3. Register globally with `app.use(fn)` or per-route with `router.get(path, mw, handler)`; order matters — earlier `use` runs first.
14
+ 4. For auth, validate the token/session, reject with `401`/`403` (don't call `next()`), or set `req.user` and continue.
15
+ 5. Mount error-handling middleware last, after all routes, so thrown/`next(err)` errors funnel into one place.
16
+ 6. Run the server and verify: logs appear, protected routes reject without creds, and errors return clean JSON not stack traces.
17
+
18
+ ## Rules
19
+ - Always call `next()` (or send a response) — forgetting it hangs the request.
20
+ - Error middleware MUST have four parameters or Express treats it as normal middleware.
21
+ - Register body parsers and loggers before routes; register the error handler after them.
22
+ - In async middleware, wrap or `try/catch` and pass errors to `next(err)` — thrown async errors aren't auto-caught (pre-Express 5).
23
+ - Don't leak internals: log the full error server-side, return a sanitized message/status to the client.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: extract-function
3
+ description: Pull a cohesive block of code into a well-named function or method
4
+ category: refactoring
5
+ ---
6
+
7
+ # Extract Function
8
+
9
+ Use when a function is too long, a block needs a comment to explain it, or the same logic is about to be reused. A good extraction names the "what" so the caller reads like prose.
10
+
11
+ 1. Identify the exact block to extract and confirm it is cohesive (one job, clear boundary).
12
+ 2. Determine inputs (variables read) and outputs (variables written/returned after the block).
13
+ 3. Create the new function with those inputs as parameters and the outputs as return value(s).
14
+ 4. Replace the original block with a call; pass arguments and assign results back.
15
+ 5. Name the function for its intent, not its mechanics (`computeTax`, not `doStep2`).
16
+ 6. Run tests; the behavior and outputs must be identical.
17
+
18
+ ## Rules
19
+ - If the block writes more than one or two outer variables, return a small object/tuple instead of using side effects.
20
+ - Keep the new function pure when feasible — pass dependencies in rather than reaching for globals.
21
+ - Don't over-parameterize; if a value is constant at the call site, inline it.
22
+ - Place the new function at a sensible scope (same module/class) before reaching for shared utils.
23
+ - Preserve early returns and error paths exactly; extracting can silently swallow a `return`.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: faq
3
+ description: Build and maintain an FAQ from real, recurring questions — answer-first, searchable, and kept current.
4
+ category: docs
5
+ ---
6
+
7
+ # FAQ
8
+
9
+ Use when the same questions keep landing in support, issues, or chat — an FAQ deflects them, but only if it's sourced from real questions, not invented ones.
10
+
11
+ 1. Mine sources: support tickets, issue tracker, chat threads, PR comments. Collect the actual wording people use.
12
+ 2. Cluster duplicates and rank by frequency × pain; write the top items first, drop the long tail.
13
+ 3. Phrase each question the way a user would search it ("Why is my build slow?"), not in internal jargon.
14
+ 4. Answer-first: lead with the direct answer in 1-2 sentences, then optional detail and a link to the full doc.
15
+ 5. Group into sections (Setup, Billing, Errors…) and add anchor links so answers are shareable.
16
+ 6. Add a "last reviewed" date and a feedback path ("still stuck? open an issue").
17
+ 7. Revisit quarterly: promote new recurring questions, delete ones that no longer apply, fix answers that drifted.
18
+
19
+ ## Rules
20
+ - Source from real questions only — a guessed FAQ answers nothing anyone asked.
21
+ - One question per entry, in the user's words, not the team's.
22
+ - Lead with the answer; don't make readers scroll through context to find it.
23
+ - Link to canonical docs instead of duplicating them — duplicated answers rot out of sync.
24
+ - Prune ruthlessly; a bloated FAQ is as useless as none.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: fastapi-endpoint
3
+ description: Add a FastAPI endpoint with Pydantic request/response models and DI
4
+ category: frameworks
5
+ ---
6
+
7
+ # FastAPI Endpoint
8
+
9
+ Use to add a typed FastAPI route with Pydantic schemas for validation and serialization, plus dependency injection where needed.
10
+
11
+ 1. Define Pydantic models for the request body and response (`response_model=`); use separate input/output schemas to avoid leaking fields.
12
+ 2. Add the path operation on a `router`/`app` with the right verb decorator (`@router.post("/items")`) and type-annotated params.
13
+ 3. Declare params by source: path (`item_id: int`), query (defaults), body (Pydantic model) — FastAPI infers from the annotation.
14
+ 4. Inject shared resources (DB session, current user) via `Depends(...)`; raise `HTTPException` for error cases.
15
+ 5. Set `status_code=` and `response_model=` explicitly; keep the handler thin and delegate logic to functions/services.
16
+ 6. Run `uvicorn app:app --reload`, check `/docs`, and exercise the endpoint to confirm validation and shape.
17
+
18
+ ## Rules
19
+ - Use distinct input vs output Pydantic models; never return ORM objects without a `response_model` to filter fields.
20
+ - Type every parameter — FastAPI's validation and docs derive entirely from annotations.
21
+ - Use `Depends` for DB sessions/auth instead of globals; it makes endpoints testable.
22
+ - Raise `HTTPException(status_code, detail)` for expected errors; don't return ad-hoc error dicts.
23
+ - For DB or external I/O, prefer `async def` with async clients, or keep blocking calls in `def` handlers (FastAPI offloads them).
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: favicon
3
+ description: Generate a full favicon and app-icon set (SVG, PNG, Apple touch, manifest) with the correct head markup.
4
+ category: html
5
+ ---
6
+
7
+ # Favicon
8
+
9
+ Use when a site needs proper tab icons, iOS home-screen icons, and PWA install icons across browsers and platforms.
10
+
11
+ 1. Start from a square master (SVG or 512x512+ PNG) with a simple, high-contrast mark that stays legible at 16x16.
12
+ 2. Generate the set: `favicon.svg` (scalable, preferred), `favicon.ico` (multi-size 16/32/48 for legacy), `apple-touch-icon.png` (180x180), and 192/512 PNGs for the manifest.
13
+ 3. Provide a maskable icon variant (safe-zone padded) so Android adaptive icons don't crop the mark; mark it `purpose: "maskable"` in the manifest.
14
+ 4. Add a `site.webmanifest` listing icons, `name`, `short_name`, `theme_color`, and `background_color` for PWA installs.
15
+ 5. Wire the `<head>`: `<link rel="icon" type="image/svg+xml" href="/favicon.svg">`, `<link rel="icon" href="/favicon.ico" sizes="any">`, `<link rel="apple-touch-icon" href="/apple-touch-icon.png">`, `<link rel="manifest" href="/site.webmanifest">`.
16
+ 6. Add a `<link rel="icon">` dark variant via media query if the mark needs it, then verify in a real browser tab, an iOS Add-to-Home-Screen, and an Android install prompt.
17
+
18
+ ## Rules
19
+ - Provide an SVG favicon plus a fallback `.ico`; don't rely on the legacy root `/favicon.ico` auto-discovery alone.
20
+ - Apple touch icons need an opaque background and no transparency — iOS adds its own rounded corners.
21
+ - Maskable icons must keep the logo inside the ~80% safe zone or Android will crop it.
22
+ - Use absolute or root-relative icon paths so they resolve on every route.
23
+ - Bust the cache (filename hash or query) when updating an icon; browsers cache favicons aggressively.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: feature-engineering
3
+ description: Engineer features for a model without leakage and reproducibly
4
+ category: data-ml
5
+ ---
6
+
7
+ # Feature Engineering
8
+
9
+ Use when deriving model inputs from raw data — encodings, aggregates, time-window features — and you need them correct, leakage-free, and consistent between training and serving.
10
+
11
+ 1. Start from the prediction point: for each row, only use information available before the label is known (the "as-of" time).
12
+ 2. Derive features explicitly — encodings, ratios, datetime parts, rolling/window aggregates, and target-relative stats — one transform at a time.
13
+ 3. Fit any feature that learns from data (scalers, target/mean encoders, imputers) on the training split only, then apply to val/test.
14
+ 4. For time-windowed and aggregate features, compute them strictly from past rows to avoid look-ahead leakage.
15
+ 5. Encapsulate the transformations so the exact same code runs at training and at serving (avoid train/serve skew).
16
+ 6. Check feature distributions, null rates, and correlation with the target; drop constant, duplicate, or leaky features.
17
+
18
+ ## Rules
19
+ - Leakage is the cardinal sin: never use future information or the target (directly or via fitted stats) for a row's features.
20
+ - Fit data-dependent transforms on train only; refit per fold under cross-validation.
21
+ - Use the same transformation code path in training and production to prevent train/serve skew.
22
+ - Respect the as-of time for every time-based feature — joins and rolling windows must not peek ahead.
23
+ - A feature that's suspiciously predictive is usually leakage; investigate before trusting it.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: few-shot
3
+ description: Build few-shot examples that steer an LLM toward the format and behavior you want
4
+ category: agent-llm
5
+ ---
6
+
7
+ # Few-Shot Examples
8
+
9
+ Use this when zero-shot prompting gives inconsistent format or quality and you want to demonstrate the target behavior by example.
10
+
11
+ 1. Pin down the exact target: the input shape, the output format, and the edge cases the model keeps getting wrong.
12
+ 2. Write 3-5 examples as input/output pairs that match production data — same fields, same tone, same length you actually expect.
13
+ 3. Cover variety deliberately: include a hard case, an edge case, and a "what not to do is implied" case, not five near-identical easy ones.
14
+ 4. Make every example's output perfect and consistent in format — the model copies form as much as content, including mistakes.
15
+ 5. Structure the prompt clearly: delimit examples (XML tags or labels) and separate them from the live input the model must answer.
16
+ 6. Evaluate on a held-out set; add an example only when it fixes a real failure, and remove ones that don't move accuracy.
17
+
18
+ ## Rules
19
+ - Consistency beats quantity — 3 flawless, format-aligned examples outperform 10 sloppy ones.
20
+ - Order can matter; put the most representative example last since recency biases the model.
21
+ - Don't let examples leak the test answer or encode spurious patterns (e.g. all positive labels first).
22
+ - More examples cost tokens on every call — prune to the minimum set that holds quality, then consider caching them.
23
+ - If the task is purely structural, prefer a schema/structured-output constraint over spending tokens on examples.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: find-owner
3
+ description: Locate where a feature or behavior lives in the codebase starting from a symptom or user-facing string
4
+ category: code-understanding
5
+ ---
6
+
7
+ # Find Owner
8
+
9
+ Use when you know what the software does but not where the code is — "where is the discount applied?" or "what renders this error?" Start from observable anchors and work inward.
10
+
11
+ 1. Extract searchable anchors: user-facing strings, error messages, log lines, route paths, config keys, or feature-flag names.
12
+ 2. Grep for the most literal anchor first; exact strings beat guessed identifiers.
13
+ 3. From a hit, walk outward to the owning function/module and confirm it matches the behavior, not just the wording.
14
+ 4. If the string is composed or templated, search for its stable fragments or the format template instead of the full text.
15
+ 5. Cross-check with git history (`git log -S` / blame) to find when and where the behavior was introduced.
16
+ 6. Report the owning file(s) and entry function, plus adjacent code (tests, config) that confirms it is the right place.
17
+
18
+ ## Rules
19
+ - Strings shown to users are the strongest anchors — prefer them over guessing function names.
20
+ - Watch for interpolation, i18n keys, and concatenation that prevent a full-string match; fall back to fragments.
21
+ - Confirm the candidate actually produces the behavior; a matching string can live in dead code or a comment.
22
+ - Use `git log -S"<snippet>"` to pinpoint the introducing commit when grep alone is ambiguous.
23
+ - If the behavior comes from a dependency or generated code, say so rather than forcing a match in app source.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: firmware-driver
3
+ description: Write a bare-metal peripheral driver against a memory-mapped register interface
4
+ category: gamedev
5
+ ---
6
+
7
+ # Firmware Driver
8
+
9
+ Reach for this when bringing up an MCU peripheral or external chip from the datasheet with no HAL to lean on.
10
+
11
+ 1. Read the datasheet/reference manual: find the register map, base address, bit fields, and the reset/init sequence.
12
+ 2. Define registers as `volatile` typed pointers or a packed struct at the base address; mirror field names from the manual.
13
+ 3. Write a blocking init: enable the peripheral clock, configure mode/pins, set dividers, then enable the peripheral.
14
+ 4. Implement read/write as small functions that poll status flags or use interrupts; never busy-spin without a timeout.
15
+ 5. Add a timeout and error return to every wait loop so a missing/hung device cannot lock the firmware.
16
+ 6. Bring up incrementally: verify clock and a known read-only ID register before attempting full transfers.
17
+
18
+ ## Rules
19
+ - Mark every register access `volatile`; the compiler will otherwise cache or reorder hardware reads/writes.
20
+ - Use read-modify-write for shared registers; blind writes clobber neighboring control bits.
21
+ - Respect required ordering and delays in the init sequence — some bits must settle before the next write.
22
+ - Guard every hardware wait loop with a timeout and surface failures; silent infinite loops are unrecoverable in the field.
23
+ - Watch volatile aliasing and memory barriers around DMA buffers shared with the peripheral.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: fix-flaky-tests
3
+ description: Diagnose an intermittently failing test and stabilize it by removing the source of nondeterminism
4
+ category: testing
5
+ ---
6
+
7
+ # Fix Flaky Tests
8
+
9
+ Use when a test passes and fails without code changes, eroding trust in the suite.
10
+
11
+ 1. Reproduce the flake: run the test in a loop (e.g. 50-100x) and run it both isolated and within the full suite.
12
+ 2. Capture failing output and compare it to passing runs to pinpoint what varies between them.
13
+ 3. Classify the cause: timing/async races, test-order or shared-state leakage, unmocked clock/random/network, or resource contention.
14
+ 4. Fix the root cause — await real conditions instead of sleeping, isolate or reset shared state, inject the clock/seed, stub the network.
15
+ 5. Re-run the loop (100x+) to confirm the flake is gone, not just hidden behind a longer timeout.
16
+ 6. If you cannot fix it now, quarantine it explicitly with a tracked issue rather than leaving it to randomly red the CI.
17
+
18
+ ## Rules
19
+ - Never "fix" a flake by bumping a sleep or adding a blind retry — that masks the race, not removes it.
20
+ - Replace fixed delays with polling on the actual condition (element present, value settled, job done).
21
+ - Suspect order-dependence: run the suite shuffled and in reverse to surface state leakage between tests.
22
+ - Pin nondeterministic inputs — freeze time, seed RNG, fix timezone/locale — rather than asserting loosely.
23
+ - A test you quarantine must have an owner and a tracking issue; quarantine is a pause, not a fix.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: flutter-widget
3
+ description: Build a Flutter widget that owns and updates local state
4
+ category: mobile
5
+ ---
6
+
7
+ # Flutter Widget
8
+
9
+ Reach for this when you need a reusable Flutter widget that holds and mutates its own state (toggles, counters, form fields, animations) rather than a pure stateless layout.
10
+
11
+ 1. Decide stateless vs stateful: if nothing changes after build, use `StatelessWidget`; if the widget mutates over its lifetime, use `StatefulWidget` with a paired `State` class.
12
+ 2. Declare constructor params as `final` fields and pass a `Key? key` through to `super`; mark required params `required`.
13
+ 3. Put mutable values as fields on the `State` class and wrap every mutation in `setState(() { ... })` so the framework reschedules `build`.
14
+ 4. Implement `build(BuildContext context)` returning the widget tree; pull colors and text styles from `Theme.of(context)` instead of hardcoding.
15
+ 5. Override `initState` for one-time setup (controllers, listeners) and `dispose` to tear them down; never start work in the constructor.
16
+ 6. Run `flutter analyze` and exercise the widget with a `WidgetTester` (`pumpWidget`, `tap`, `pump`) to confirm state transitions.
17
+
18
+ ## Rules
19
+ - Never call `setState` in `build`, after `dispose`, or inside `initState` — it triggers loops or "called after disposed" errors.
20
+ - Always `dispose` of `AnimationController`, `TextEditingController`, `FocusNode`, and stream subscriptions.
21
+ - Keep `build` pure and cheap: no I/O, no allocations you can hoist, no side effects.
22
+ - Prefer `const` constructors and `const` child widgets to cut rebuild cost.
23
+ - For state shared across the tree, lift it up or use a state-management package instead of widget-local `setState`.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: font-rendering
3
+ description: Debug text rendering — missing glyphs/tofu, wrong fallback font, bad kerning, blurry or clipped subpixel text
4
+ category: graphics
5
+ ---
6
+
7
+ # Font Rendering
8
+
9
+ Reach for this when text shows boxes/question marks, jumps to the wrong typeface, looks blurry, or clips at the edges.
10
+
11
+ 1. Identify the failure mode first: "tofu" boxes (□) mean the glyph is missing from the loaded font; a different-looking-but-readable face means fallback kicked in; blur/clipping is a rasterization or metrics issue.
12
+ 2. For missing glyphs, confirm the font actually loaded and covers the codepoints: use `document.fonts.check('16px MyFont')` / `document.fonts.ready`, and verify the character's Unicode range is in the font (CJK, emoji, and rare symbols are often absent).
13
+ 3. For wrong-font fallback, check the `@font-face` URL loads (network tab, no 404/CORS), `font-family` name matches exactly, and the `font-weight`/`font-style` you request exists — requesting bold from a regular-only file triggers synthetic or fallback rendering.
14
+ 4. For FOUT/FOIT flashes, set `font-display` deliberately and preload the font; layout shift on swap is a metrics mismatch between fallback and real font — tune with `size-adjust`/`ascent-override` or a closer fallback.
15
+ 5. For canvas text, remember the font must be loaded before `fillText`; call `await document.fonts.load('16px MyFont')` first or you'll silently rasterize in the fallback face.
16
+ 6. For blur/clipping, check subpixel positioning and DPI scaling (see dpi-scaling), ensure the baseline/`textBaseline` and line-height give enough box, and that no `transform` is fractional-translating the text off the pixel grid.
17
+
18
+ ## Rules
19
+ - Tofu = glyph absent from the font; pick a font with the needed Unicode coverage, don't fight the renderer.
20
+ - Always await font load before drawing canvas text — `fillText` won't wait and falls back silently.
21
+ - The CSS `font-family` name must match the `@font-face` `font-family` exactly, including case and spaces.
22
+ - Requesting a weight/style the file lacks yields synthetic faux-bold/italic or fallback — ship the real weights.
23
+ - Blurry text is usually DPI/subpixel, not the font; rule out devicePixelRatio before blaming the typeface.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: form-validation
3
+ description: Add client-side and server-side form validation with a shared schema and clear error UX
4
+ category: frontend
5
+ ---
6
+
7
+ # Form Validation
8
+
9
+ Use when a form accepts user input that must be validated — required fields, formats, ranges — on both the client and the server.
10
+
11
+ 1. Define one validation schema (e.g. Zod/Yup/Valibot) as the source of truth for field rules, and share it between client and server so they can't drift.
12
+ 2. Validate on the client for fast feedback: validate a field on blur/change and the whole form on submit; disable submit while invalid or in-flight.
13
+ 3. Show errors inline next to each field, tie them to the input via `aria-describedby`/`aria-invalid`, and move focus to the first error on failed submit.
14
+ 4. Re-validate on the server with the same schema — treat client validation as UX only and never trust the incoming payload.
15
+ 5. Return structured field-level errors from the server and map them back onto the matching inputs, plus a form-level message for non-field failures.
16
+ 6. Cover edge cases: trimming/normalizing input, duplicate submits, async checks (e.g. unique email), and preserving entered values after a failed submit.
17
+
18
+ ## Rules
19
+ - Server validation is mandatory; client validation can be bypassed and is for UX only.
20
+ - Keep one schema as the single source of truth — don't duplicate rules in two places.
21
+ - Associate every error message with its input via ARIA so it's announced and reachable.
22
+ - Validate format AND business rules (uniqueness, allowed values), not just "non-empty".
23
+ - Don't block typing or wipe the user's input on error; show the problem and let them fix it.