claude-code-superkit 0.0.0-stage → 1.5.3

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 (353) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +374 -2
  3. package/bin/cli.js +153 -0
  4. package/bin/inject-tokens.js +224 -0
  5. package/bin/measure-tokens.js +17 -0
  6. package/bin/superkit-counts-verify.sh +30 -0
  7. package/lib/codex.js +246 -0
  8. package/lib/docs-scaffold.js +147 -0
  9. package/lib/installer.js +499 -0
  10. package/lib/prompts.js +51 -0
  11. package/lib/settings-builder.js +51 -0
  12. package/lib/superpowers.js +99 -0
  13. package/lib/utils.js +117 -0
  14. package/lib/validator.js +84 -0
  15. package/package.json +49 -4
  16. package/packages/codex/AGENTS.md +396 -0
  17. package/packages/codex/INSTALL.md +342 -0
  18. package/packages/codex/config.toml +22 -0
  19. package/packages/codex/hooks/superkit.mjs +203 -0
  20. package/packages/codex/hooks.json +30 -0
  21. package/packages/codex/legacy-baseline.json +88 -0
  22. package/packages/codex/native-skills.txt +65 -0
  23. package/packages/codex/rules/default.rules +565 -0
  24. package/packages/codex/skills/ai-slop-cleaner/SKILL.md +44 -0
  25. package/packages/codex/skills/api-contract-sync/SKILL.md +96 -0
  26. package/packages/codex/skills/architect/SKILL.md +49 -0
  27. package/packages/codex/skills/audit-backend/SKILL.md +80 -0
  28. package/packages/codex/skills/audit-frontend/SKILL.md +82 -0
  29. package/packages/codex/skills/audit-infra/SKILL.md +87 -0
  30. package/packages/codex/skills/audit-orchestrator/SKILL.md +114 -0
  31. package/packages/codex/skills/behavioral-nudge-engine/SKILL.md +110 -0
  32. package/packages/codex/skills/benchmark/SKILL.md +49 -0
  33. package/packages/codex/skills/bot-reviewer/SKILL.md +94 -0
  34. package/packages/codex/skills/code-reviewer/SKILL.md +67 -0
  35. package/packages/codex/skills/codebase-onboarding-engineer/SKILL.md +46 -0
  36. package/packages/codex/skills/comment-rot-analyzer/SKILL.md +75 -0
  37. package/packages/codex/skills/commit-helper/SKILL.md +101 -0
  38. package/packages/codex/skills/critic/SKILL.md +56 -0
  39. package/packages/codex/skills/database-reviewer/SKILL.md +79 -0
  40. package/packages/codex/skills/debug-observer/SKILL.md +107 -0
  41. package/packages/codex/skills/dependency-checker/SKILL.md +69 -0
  42. package/packages/codex/skills/design-system-reviewer/SKILL.md +121 -0
  43. package/packages/codex/skills/dev-orchestrator/SKILL.md +304 -0
  44. package/packages/codex/skills/docs-reviewer/SKILL.md +86 -0
  45. package/packages/codex/skills/drizzle-orm-expert/SKILL.md +246 -0
  46. package/packages/codex/skills/e2e-test-generator/SKILL.md +95 -0
  47. package/packages/codex/skills/evaluator/SKILL.md +63 -0
  48. package/packages/codex/skills/frontend-perf-reviewer/SKILL.md +95 -0
  49. package/packages/codex/skills/frontend-ui-color-reviewer/SKILL.md +68 -0
  50. package/packages/codex/skills/frontend-ui-design-critic/SKILL.md +99 -0
  51. package/packages/codex/skills/frontend-ui-interaction-reviewer/SKILL.md +102 -0
  52. package/packages/codex/skills/frontend-ui-motion-reviewer/SKILL.md +85 -0
  53. package/packages/codex/skills/frontend-ui-reviewer/SKILL.md +81 -0
  54. package/packages/codex/skills/frontend-ui-typography-reviewer/SKILL.md +62 -0
  55. package/packages/codex/skills/gltf-debugging/SKILL.md +128 -0
  56. package/packages/codex/skills/go-benchmark/SKILL.md +217 -0
  57. package/packages/codex/skills/go-concurrency-reviewer/SKILL.md +113 -0
  58. package/packages/codex/skills/go-error-reviewer/SKILL.md +107 -0
  59. package/packages/codex/skills/go-grpc-patterns/SKILL.md +285 -0
  60. package/packages/codex/skills/go-modernizer/SKILL.md +111 -0
  61. package/packages/codex/skills/go-observability-reviewer/SKILL.md +121 -0
  62. package/packages/codex/skills/go-performance-reviewer/SKILL.md +112 -0
  63. package/packages/codex/skills/go-reviewer/SKILL.md +109 -0
  64. package/packages/codex/skills/go-samber-do/SKILL.md +158 -0
  65. package/packages/codex/skills/go-samber-lo/SKILL.md +178 -0
  66. package/packages/codex/skills/go-samber-oops/SKILL.md +174 -0
  67. package/packages/codex/skills/goal-verifier/SKILL.md +53 -0
  68. package/packages/codex/skills/health-checker/SKILL.md +109 -0
  69. package/packages/codex/skills/html-to-3d-texture/SKILL.md +153 -0
  70. package/packages/codex/skills/impeccable-craft/SKILL.md +101 -0
  71. package/packages/codex/skills/lint-runner/SKILL.md +85 -0
  72. package/packages/codex/skills/migrate/SKILL.md +60 -0
  73. package/packages/codex/skills/migration-reviewer/SKILL.md +88 -0
  74. package/packages/codex/skills/minimal-change-engineer/SKILL.md +44 -0
  75. package/packages/codex/skills/new-migration/SKILL.md +59 -0
  76. package/packages/codex/skills/nextjs-supabase-auth/SKILL.md +227 -0
  77. package/packages/codex/skills/output-enforcement/SKILL.md +71 -0
  78. package/packages/codex/skills/plan-checker/SKILL.md +53 -0
  79. package/packages/codex/skills/postgresql-optimization/SKILL.md +159 -0
  80. package/packages/codex/skills/pre-deploy-validator/SKILL.md +111 -0
  81. package/packages/codex/skills/presentation-reviewer/SKILL.md +88 -0
  82. package/packages/codex/skills/product-3d-lighting/SKILL.md +137 -0
  83. package/packages/codex/skills/project-architecture/SKILL.md +52 -0
  84. package/packages/codex/skills/py-reviewer/SKILL.md +100 -0
  85. package/packages/codex/skills/r3f-scene-reviewer/SKILL.md +88 -0
  86. package/packages/codex/skills/r3f-scroll-driven-3d/SKILL.md +162 -0
  87. package/packages/codex/skills/reality-checker/SKILL.md +61 -0
  88. package/packages/codex/skills/redis-patterns/SKILL.md +260 -0
  89. package/packages/codex/skills/review-orchestrator/SKILL.md +151 -0
  90. package/packages/codex/skills/rs-reviewer/SKILL.md +98 -0
  91. package/packages/codex/skills/ru-text/SKILL.md +132 -0
  92. package/packages/codex/skills/scaffold-endpoint/SKILL.md +44 -0
  93. package/packages/codex/skills/security-scanner/SKILL.md +94 -0
  94. package/packages/codex/skills/silent-failure-hunter/SKILL.md +176 -0
  95. package/packages/codex/skills/telegram-bot-builder/SKILL.md +120 -0
  96. package/packages/codex/skills/test-generator/SKILL.md +79 -0
  97. package/packages/codex/skills/test-runner/SKILL.md +101 -0
  98. package/packages/codex/skills/threejs-color-management/SKILL.md +97 -0
  99. package/packages/codex/skills/tree-generator/SKILL.md +63 -0
  100. package/packages/codex/skills/ts-reviewer/SKILL.md +90 -0
  101. package/packages/codex/skills/ui-design-reviewer/SKILL.md +89 -0
  102. package/packages/codex/skills/ui-reviewer/SKILL.md +103 -0
  103. package/packages/codex/skills/visual-reviewer/SKILL.md +85 -0
  104. package/packages/codex/skills/writing-agents/SKILL.md +165 -0
  105. package/packages/codex/skills/writing-commands/SKILL.md +173 -0
  106. package/packages/core/CLAUDE.md +118 -0
  107. package/packages/core/INTERNAL-FILES +16 -0
  108. package/packages/core/agents/ai-slop-cleaner.md +187 -0
  109. package/packages/core/agents/api-contract-sync.md +127 -0
  110. package/packages/core/agents/architect.md +205 -0
  111. package/packages/core/agents/audit-backend.md +137 -0
  112. package/packages/core/agents/audit-frontend.md +129 -0
  113. package/packages/core/agents/audit-infra.md +182 -0
  114. package/packages/core/agents/behavioral-nudge-engine.md +170 -0
  115. package/packages/core/agents/code-reviewer.md +195 -0
  116. package/packages/core/agents/codebase-onboarding-engineer.md +172 -0
  117. package/packages/core/agents/comment-rot-analyzer.md +115 -0
  118. package/packages/core/agents/critic.md +172 -0
  119. package/packages/core/agents/database-reviewer.md +201 -0
  120. package/packages/core/agents/debug-observer.md +261 -0
  121. package/packages/core/agents/dependency-checker.md +199 -0
  122. package/packages/core/agents/docs-reviewer.md +206 -0
  123. package/packages/core/agents/e2e-test-generator.md +261 -0
  124. package/packages/core/agents/evaluator.md +141 -0
  125. package/packages/core/agents/goal-verifier.md +130 -0
  126. package/packages/core/agents/health-checker.md +194 -0
  127. package/packages/core/agents/migration-reviewer.md +161 -0
  128. package/packages/core/agents/minimal-change-engineer.md +219 -0
  129. package/packages/core/agents/plan-checker.md +139 -0
  130. package/packages/core/agents/pre-deploy-validator.md +189 -0
  131. package/packages/core/agents/reality-checker.md +175 -0
  132. package/packages/core/agents/scaffold-endpoint.md +162 -0
  133. package/packages/core/agents/security-scanner.md +236 -0
  134. package/packages/core/agents/silent-failure-hunter.md +276 -0
  135. package/packages/core/agents/test-generator.md +146 -0
  136. package/packages/core/agents/tree-generator.md +141 -0
  137. package/packages/core/agents/ui-reviewer.md +172 -0
  138. package/packages/core/agents/visual-reviewer.md +211 -0
  139. package/packages/core/commands/audit.md +166 -0
  140. package/packages/core/commands/benchmark.md +130 -0
  141. package/packages/core/commands/commit.md +148 -0
  142. package/packages/core/commands/dev.md +302 -0
  143. package/packages/core/commands/docs-init.md +75 -0
  144. package/packages/core/commands/lint.md +137 -0
  145. package/packages/core/commands/migrate.md +146 -0
  146. package/packages/core/commands/new-migration.md +182 -0
  147. package/packages/core/commands/pair.md +209 -0
  148. package/packages/core/commands/review.md +195 -0
  149. package/packages/core/commands/security-scan.md +142 -0
  150. package/packages/core/commands/superkit-evolve.md +231 -0
  151. package/packages/core/commands/superkit-init.md +274 -0
  152. package/packages/core/commands/test.md +108 -0
  153. package/packages/core/commands/workflow.md +150 -0
  154. package/packages/core/docs/guide/01-getting-started.md +41 -0
  155. package/packages/core/docs-templates/README.md +33 -0
  156. package/packages/core/docs-templates/adr-template.md +62 -0
  157. package/packages/core/docs-templates/architecture/api-contracts.md +26 -0
  158. package/packages/core/docs-templates/architecture/api-reference.md +48 -0
  159. package/packages/core/docs-templates/architecture/auth-and-sessions.md +38 -0
  160. package/packages/core/docs-templates/architecture/backend-layers.md +42 -0
  161. package/packages/core/docs-templates/architecture/data-flow.md +26 -0
  162. package/packages/core/docs-templates/architecture/database-schema.md +51 -0
  163. package/packages/core/docs-templates/architecture/deployment.md +41 -0
  164. package/packages/core/docs-templates/architecture/frontend-state.md +46 -0
  165. package/packages/core/helpers/statusline.cjs +370 -0
  166. package/packages/core/hooks/CHAIN-SEMANTICS.md +84 -0
  167. package/packages/core/hooks/audit-settings-source.sh +98 -0
  168. package/packages/core/hooks/audit-trail.sh +120 -0
  169. package/packages/core/hooks/block-dangerous-git.sh +189 -0
  170. package/packages/core/hooks/bundle-import-check.sh +64 -0
  171. package/packages/core/hooks/compact-state-inject.sh +84 -0
  172. package/packages/core/hooks/config-protection.sh +68 -0
  173. package/packages/core/hooks/console-log-warning.sh +28 -0
  174. package/packages/core/hooks/context-monitor.sh +35 -0
  175. package/packages/core/hooks/dev-edit-counter.sh +59 -0
  176. package/packages/core/hooks/dev-marker-set.sh +55 -0
  177. package/packages/core/hooks/dev-required-on-commit.sh +426 -0
  178. package/packages/core/hooks/doc-check-on-commit.sh +396 -0
  179. package/packages/core/hooks/edit-streak-check.sh +63 -0
  180. package/packages/core/hooks/evolve-check.sh +78 -0
  181. package/packages/core/hooks/gateguard-pre-edit.sh +154 -0
  182. package/packages/core/hooks/gateguard-record-facts.sh +37 -0
  183. package/packages/core/hooks/intake-classifier.py +449 -0
  184. package/packages/core/hooks/lib/profile.sh +141 -0
  185. package/packages/core/hooks/loop-guard.sh +75 -0
  186. package/packages/core/hooks/migration-safety.sh +56 -0
  187. package/packages/core/hooks/plan-completion-gate.sh +61 -0
  188. package/packages/core/hooks/pre-compact-save.sh +89 -0
  189. package/packages/core/hooks/security-patterns.sh +119 -0
  190. package/packages/core/hooks/session-context-restore.sh +76 -0
  191. package/packages/core/hooks/subagent-stop-validate.sh +73 -0
  192. package/packages/core/hooks/superkit-counts-verify.sh +346 -0
  193. package/packages/core/hooks/superkit-update.sh +367 -0
  194. package/packages/core/hooks/tests/README.md +42 -0
  195. package/packages/core/hooks/tests/audit-trail-chain_test.sh +62 -0
  196. package/packages/core/hooks/tests/block-dangerous-git_test.sh +144 -0
  197. package/packages/core/hooks/tests/chain-semantics/h1.sh +11 -0
  198. package/packages/core/hooks/tests/chain-semantics/h2.sh +9 -0
  199. package/packages/core/hooks/tests/chain-semantics/h3.sh +11 -0
  200. package/packages/core/hooks/tests/chain-semantics/run-experiment.sh +65 -0
  201. package/packages/core/hooks/tests/chain-semantics/settings-experiment.json +15 -0
  202. package/packages/core/hooks/tests/counts-verify_test.sh +118 -0
  203. package/packages/core/hooks/tests/dev-required-on-commit_test.sh +207 -0
  204. package/packages/core/hooks/tests/dev-required-wip-on-main_test.sh +20 -0
  205. package/packages/core/hooks/tests/doc-check-on-commit_test.sh +122 -0
  206. package/packages/core/hooks/tests/edit-streak-check_test.sh +106 -0
  207. package/packages/core/hooks/tests/internal-manifest_test.sh +130 -0
  208. package/packages/core/hooks/tests/json-path_test.sh +108 -0
  209. package/packages/core/hooks/tests/mirror-invariants_test.sh +139 -0
  210. package/packages/core/hooks/tests/nudge-throttle_test.sh +95 -0
  211. package/packages/core/hooks/tests/profile-helper_test.sh +21 -0
  212. package/packages/core/hooks/tests/run-all.sh +47 -0
  213. package/packages/core/hooks/tests/session-key-helper_test.sh +17 -0
  214. package/packages/core/hooks/tests/superkit-update_test.sh +311 -0
  215. package/packages/core/hooks/tests/warn-visibility_test.sh +59 -0
  216. package/packages/core/hooks/user-intent-detect.sh +44 -0
  217. package/packages/core/hooks/verify-hooks.sh +69 -0
  218. package/packages/core/rules/auto-commands.md +124 -0
  219. package/packages/core/rules/coding-style.md +68 -0
  220. package/packages/core/rules/dev-workflow.md +77 -0
  221. package/packages/core/rules/documentation.md +106 -0
  222. package/packages/core/rules/frontend-aesthetics.md +53 -0
  223. package/packages/core/rules/git-workflow.md +14 -0
  224. package/packages/core/rules/security.md +29 -0
  225. package/packages/core/rules/superkit-integrity.md +114 -0
  226. package/packages/core/settings.json +229 -0
  227. package/packages/core/skills/drizzle-orm-expert/SKILL.md +260 -0
  228. package/packages/core/skills/nextjs-supabase-auth/SKILL.md +259 -0
  229. package/packages/core/skills/postgresql-optimization/SKILL.md +150 -0
  230. package/packages/core/skills/project-architecture/SKILL.md +31 -0
  231. package/packages/core/skills/project-scanner/SKILL.md +132 -0
  232. package/packages/core/skills/redis-patterns/SKILL.md +261 -0
  233. package/packages/core/skills/ru-text/SKILL.md +156 -0
  234. package/packages/core/skills/telegram-bot-builder/SKILL.md +145 -0
  235. package/packages/core/skills/writing-agents/SKILL.md +220 -0
  236. package/packages/core/skills/writing-commands/SKILL.md +176 -0
  237. package/packages/core/skills/writing-hooks/SKILL.md +335 -0
  238. package/packages/extras/bot-reviewer.md +279 -0
  239. package/packages/extras/design-system-reviewer.md +234 -0
  240. package/packages/extras/red-blue-auditor/README.md +117 -0
  241. package/packages/extras/red-blue-auditor/agent.md +128 -0
  242. package/packages/extras/red-blue-auditor/patterns/agent-config.txt +4 -0
  243. package/packages/extras/red-blue-auditor/patterns/hook-injection.txt +8 -0
  244. package/packages/extras/red-blue-auditor/patterns/mcp-risk.txt +5 -0
  245. package/packages/extras/red-blue-auditor/patterns/permission-abuse.txt +6 -0
  246. package/packages/extras/red-blue-auditor/patterns/secrets.txt +17 -0
  247. package/packages/extras/red-blue-auditor/scan.sh +88 -0
  248. package/packages/extras/skillsmp-search/SKILL.md +134 -0
  249. package/packages/frontend-3d/README.md +62 -0
  250. package/packages/frontend-3d/agents/frontend-perf-reviewer.md +164 -0
  251. package/packages/frontend-3d/agents/presentation-reviewer.md +146 -0
  252. package/packages/frontend-3d/agents/r3f-scene-reviewer.md +128 -0
  253. package/packages/frontend-3d/agents/ui-design-reviewer.md +169 -0
  254. package/packages/frontend-3d/commands/capture-screen.md +166 -0
  255. package/packages/frontend-3d/hooks/bundle-size-warn.sh +93 -0
  256. package/packages/frontend-3d/hooks/gsap-pattern-check.sh +74 -0
  257. package/packages/frontend-3d/hooks/r3f-color-check.sh +76 -0
  258. package/packages/frontend-3d/hooks/tailwind-version-guard.sh +98 -0
  259. package/packages/frontend-3d/rules/frontend-aesthetics-3d.md +81 -0
  260. package/packages/frontend-3d/rules/gsap-conventions.md +129 -0
  261. package/packages/frontend-3d/rules/threejs-conventions.md +116 -0
  262. package/packages/frontend-3d/skills/gltf-debugging/SKILL.md +145 -0
  263. package/packages/frontend-3d/skills/html-to-3d-texture/SKILL.md +183 -0
  264. package/packages/frontend-3d/skills/output-enforcement/SKILL.md +79 -0
  265. package/packages/frontend-3d/skills/product-3d-lighting/SKILL.md +166 -0
  266. package/packages/frontend-3d/skills/r3f-scroll-driven-3d/SKILL.md +209 -0
  267. package/packages/frontend-3d/skills/threejs-color-management/SKILL.md +111 -0
  268. package/packages/frontend-ui/NOTICE.md +99 -0
  269. package/packages/frontend-ui/README.md +59 -0
  270. package/packages/frontend-ui/agents/ui-color-reviewer.md +174 -0
  271. package/packages/frontend-ui/agents/ui-design-critic.md +198 -0
  272. package/packages/frontend-ui/agents/ui-interaction-reviewer.md +259 -0
  273. package/packages/frontend-ui/agents/ui-motion-reviewer.md +266 -0
  274. package/packages/frontend-ui/agents/ui-reviewer.md +251 -0
  275. package/packages/frontend-ui/agents/ui-typography-reviewer.md +222 -0
  276. package/packages/frontend-ui/hooks/tests/ui-animation-easing-check_test.sh +78 -0
  277. package/packages/frontend-ui/hooks/tests/ui-banned-fonts-check_test.sh +77 -0
  278. package/packages/frontend-ui/hooks/tests/ui-color-check_test.sh +75 -0
  279. package/packages/frontend-ui/hooks/ui-animation-easing-check.sh +86 -0
  280. package/packages/frontend-ui/hooks/ui-banned-fonts-check.sh +90 -0
  281. package/packages/frontend-ui/hooks/ui-color-check.sh +102 -0
  282. package/packages/frontend-ui/rules/color-and-contrast.md +230 -0
  283. package/packages/frontend-ui/rules/frontend-design-aesthetics.md +124 -0
  284. package/packages/frontend-ui/rules/interaction-polish.md +335 -0
  285. package/packages/frontend-ui/rules/motion-and-animation.md +283 -0
  286. package/packages/frontend-ui/rules/spatial-and-layout.md +212 -0
  287. package/packages/frontend-ui/rules/typography-guidelines.md +185 -0
  288. package/packages/frontend-ui/rules/ui-anti-patterns.md +309 -0
  289. package/packages/frontend-ui/settings.json +24 -0
  290. package/packages/frontend-ui/skills/impeccable-craft/SKILL.md +187 -0
  291. package/packages/gan/README.md +232 -0
  292. package/packages/gan/agents/gan-evaluator.md +214 -0
  293. package/packages/gan/agents/gan-generator.md +171 -0
  294. package/packages/gan/agents/gan-planner.md +206 -0
  295. package/packages/gan/rubrics/functionality.md +66 -0
  296. package/packages/gan/rubrics/ui-quality.md +77 -0
  297. package/packages/gan/skills/gan-evaluator/SKILL.md +91 -0
  298. package/packages/gan/skills/gan-generator/SKILL.md +72 -0
  299. package/packages/gan/skills/gan-planner/SKILL.md +93 -0
  300. package/packages/stack-agents/go/go-concurrency-reviewer.md +210 -0
  301. package/packages/stack-agents/go/go-error-reviewer.md +187 -0
  302. package/packages/stack-agents/go/go-modernizer.md +160 -0
  303. package/packages/stack-agents/go/go-observability-reviewer.md +185 -0
  304. package/packages/stack-agents/go/go-performance-reviewer.md +160 -0
  305. package/packages/stack-agents/go/go-reviewer.md +277 -0
  306. package/packages/stack-agents/go/references/benchmark-methodology.md +280 -0
  307. package/packages/stack-agents/go/references/channel-patterns.md +384 -0
  308. package/packages/stack-agents/go/references/cli-cobra-viper.md +190 -0
  309. package/packages/stack-agents/go/references/code-style.md +262 -0
  310. package/packages/stack-agents/go/references/context-propagation.md +317 -0
  311. package/packages/stack-agents/go/references/data-structures.md +315 -0
  312. package/packages/stack-agents/go/references/database-patterns.md +334 -0
  313. package/packages/stack-agents/go/references/design-patterns.md +411 -0
  314. package/packages/stack-agents/go/references/di-frameworks.md +146 -0
  315. package/packages/stack-agents/go/references/error-creation.md +251 -0
  316. package/packages/stack-agents/go/references/error-inspection.md +348 -0
  317. package/packages/stack-agents/go/references/error-wrapping.md +230 -0
  318. package/packages/stack-agents/go/references/gopls-driving.md +62 -0
  319. package/packages/stack-agents/go/references/goroutine-lifecycle.md +351 -0
  320. package/packages/stack-agents/go/references/graphql-patterns.md +221 -0
  321. package/packages/stack-agents/go/references/grpc-patterns.md +373 -0
  322. package/packages/stack-agents/go/references/modernize-guide.md +522 -0
  323. package/packages/stack-agents/go/references/module-management.md +191 -0
  324. package/packages/stack-agents/go/references/naming-conventions.md +176 -0
  325. package/packages/stack-agents/go/references/observability-pipeline.md +352 -0
  326. package/packages/stack-agents/go/references/performance-profiling.md +250 -0
  327. package/packages/stack-agents/go/references/refactoring-mechanics.md +127 -0
  328. package/packages/stack-agents/go/references/rest-openapi-patterns.md +160 -0
  329. package/packages/stack-agents/go/references/samber-do.md +201 -0
  330. package/packages/stack-agents/go/references/samber-libraries.md +363 -0
  331. package/packages/stack-agents/go/references/samber-lo.md +260 -0
  332. package/packages/stack-agents/go/references/samber-oops.md +200 -0
  333. package/packages/stack-agents/go/references/security-checklist.md +441 -0
  334. package/packages/stack-agents/go/references/standard-stdlib-now.md +181 -0
  335. package/packages/stack-agents/go/references/stay-updated.md +147 -0
  336. package/packages/stack-agents/go/references/structs-interfaces.md +312 -0
  337. package/packages/stack-agents/go/references/sync-primitives.md +395 -0
  338. package/packages/stack-agents/go/references/testing-patterns.md +483 -0
  339. package/packages/stack-agents/go/references/troubleshooting.md +98 -0
  340. package/packages/stack-agents/python/py-reviewer.md +194 -0
  341. package/packages/stack-agents/rust/rs-reviewer.md +188 -0
  342. package/packages/stack-agents/typescript/ts-reviewer.md +135 -0
  343. package/packages/stack-hooks/go/go-context-check-on-edit.sh +56 -0
  344. package/packages/stack-hooks/go/go-error-check-on-edit.sh +54 -0
  345. package/packages/stack-hooks/go/go-format-on-edit.sh +32 -0
  346. package/packages/stack-hooks/go/go-safety-check-on-edit.sh +54 -0
  347. package/packages/stack-hooks/go/go-vet-on-edit.sh +61 -0
  348. package/packages/stack-hooks/go/golangci-lint-on-edit.sh +54 -0
  349. package/packages/stack-hooks/python/ruff-on-edit.sh +67 -0
  350. package/packages/stack-hooks/rust/cargo-check-on-edit.sh +64 -0
  351. package/packages/stack-hooks/typescript/typecheck-on-edit.sh +76 -0
  352. package/packages/stack-rules/go/go-conventions.md +44 -0
  353. package/packages/stack-rules/go/go-safety.md +35 -0
@@ -0,0 +1,137 @@
1
+ ---
2
+ description: Auto-detect and run project linters — supports Go, TypeScript, Python, Rust, and more
3
+ argument-hint: "[backend|frontend|all] [--fix]"
4
+ allowed-tools: Bash
5
+ ---
6
+
7
+ # Lint
8
+
9
+ ## Role
10
+
11
+ Auto-detect the project's formatters and linters from stack-marker files and run them — optionally scoped to backend or frontend, optionally in `--fix` mode.
12
+
13
+ ## Hard Rules
14
+
15
+ - Run the formatter before the linter for each stack (format first, then check).
16
+ - Prefer a Makefile `lint` / `fmt` target over the raw tool when one exists — it may carry project-specific setup.
17
+ - Run only the commands in the Step 2 table (and the Step 4 `--fix` variants); never invent linters, flags, or tools not listed there.
18
+ - Treat `--fix` as a modifier combinable with any scope, not as a scope of its own.
19
+ - `--fix` rewrites files in place — apply it only to the Step 4 format and auto-fix commands, never to check-only commands (`go vet`, `tsc --noEmit`, `mypy`, `flake8`).
20
+ - Report every detected in-scope linter, including PASS and unavailable ones; one block per detected in-scope linter.
21
+ - Default to scope `all` for empty or unrecognized input — never guess a narrower scope.
22
+
23
+ ## Step 1 — Parse Arguments
24
+
25
+ Read the request and derive two independent values from it. Scope and fix are orthogonal: any scope may carry `--fix`.
26
+
27
+ $ARGUMENTS
28
+
29
+ - **scope** = the first bare token equal to `backend`, `frontend`, or `all`. Empty input or any unrecognized token → `all`.
30
+ - **fix** = `true` if the token `--fix` appears anywhere in the input, else `false`.
31
+
32
+ Done-when: `scope` is exactly one of `backend` / `frontend` / `all`, and `fix` is `true` or `false`.
33
+
34
+ ## Step 2 — Detect Linters
35
+
36
+ Scan the project for stack markers and map each present marker to its commands. Detect with Bash only: `test -f <marker>` for files, `grep -qF '<section>' pyproject.toml` for a config section (fixed-string `-F` so the `[...]` in section names like `[tool.ruff]` is matched literally, not as a regex character class), `command -v <tool>` for a tool on PATH.
37
+
38
+ | Marker | Format Command | Lint Command | Stack |
39
+ |--------|---------------|-------------|-------|
40
+ | `go.mod` | `gofmt -w .` | `go vet ./...` | Go |
41
+ | `go.mod` + `golangci-lint` in PATH | `gofmt -w .` | `golangci-lint run` | Go (extended) |
42
+ | `package.json` + `.eslintrc*` / `eslint.config.*` | — | `npx eslint .` | ESLint |
43
+ | `package.json` + `tsconfig.json` | — | `npx tsc --noEmit` | TypeScript |
44
+ | `package.json` + prettier config (`.prettierrc*`, `prettier.config.*`, or a `prettier` key in `package.json`) | `npx prettier --write .` | `npx prettier --check .` | Prettier |
45
+ | `pyproject.toml` + `[tool.ruff]` | `ruff format .` | `ruff check .` | Python (ruff) |
46
+ | `pyproject.toml` + `[tool.black]` | `black .` | — | Python (black) |
47
+ | `pyproject.toml` + `[tool.flake8]` / `setup.cfg` | — | `flake8` | Python (flake8) |
48
+ | `pyproject.toml` + `[tool.mypy]` | — | `mypy .` | Python (mypy) |
49
+ | `Cargo.toml` | `cargo fmt` | `cargo clippy -- -D warnings` | Rust |
50
+ | `Makefile` with `lint` target | — | `make lint` | Makefile |
51
+ | `Makefile` with `fmt` target | `make fmt` | — | Makefile |
52
+
53
+ A `—` cell means that stack has no command for that slot — skip it. If a `Makefile` with `lint` / `fmt` targets exists, prefer them over the raw tool for that slot — they may include project-specific setup.
54
+
55
+ Done-when: every marker present in the repo is mapped to its format/lint commands; the set of detected linters is fixed.
56
+
57
+ ## Step 3 — Resolve Scope Directory
58
+
59
+ Pick where to run based on `scope` from Step 1:
60
+
61
+ - **`all`** — run every linter detected in Step 2. For each directory that carries its own markers (the repo root, plus each depth-1 subdirectory that has markers in a monorepo), run that directory's linters from within it. Enter each marked directory in turn; no single `cd`.
62
+ - **`backend`** — locate the backend directory, then run only the linters detected there:
63
+ 1. A backend directory carries `go.mod`, `pyproject.toml`, `Cargo.toml`, or a `package.json` with no frontend-framework dependency.
64
+ 2. Check the repo root first; if it has no backend marker, scan direct subdirectories (depth 1) for one.
65
+ 3. Exactly one match → `cd` into it. More than one → list the candidates and ask which to lint. Zero → fall back to `all` and note the fallback.
66
+ - **`frontend`** — locate the frontend directory, then run only the linters detected there:
67
+ 1. A frontend directory has a `package.json` that declares a frontend framework — detect with `grep -E '"(react|vue|svelte|next|nuxt|@angular/core|solid-js|astro|vite)"' package.json`.
68
+ 2. Check the repo root first, then direct subdirectories (depth 1).
69
+ 3. Exactly one match → `cd` into it. More than one → list the candidates and ask which to lint. Zero → fall back to `all` and note the fallback.
70
+
71
+ Done-when: the working directory (or set of directories) for the chosen scope is fixed, or the run has fallen back to `all`.
72
+
73
+ ## Step 4 — Run Linters
74
+
75
+ For each in-scope linter, run format first, then check. Skip any table cell shown as `—`.
76
+
77
+ - **fix = false** — run the linter's Format Command then its Lint Command from the Step 2 table.
78
+ - **fix = true** — replace the table's Format Command with the auto-fix variant below, then still run the Lint Command. A detected linter with no fix variant listed here runs its table Lint Command unchanged (check-only):
79
+ - Go: `gofmt -w .`
80
+ - ESLint: `npx eslint . --fix`
81
+ - Prettier: `npx prettier --write .`
82
+ - ruff: `ruff check . --fix && ruff format .`
83
+ - black: `black .`
84
+ - Rust: `cargo fmt` then `cargo clippy --fix --allow-dirty`
85
+
86
+ For a TypeScript project, run both ESLint and `npx tsc --noEmit` — ESLint catches style, `tsc` catches types. `tsc --noEmit`, `mypy`, `flake8`, and `go vet` are check-only, so `--fix` leaves them unchanged.
87
+
88
+ If a tool named in the table is not installed (command not found), mark it `unavailable` and continue with the remaining linters.
89
+
90
+ Done-when: every detected in-scope linter has either produced output or been marked `unavailable`.
91
+
92
+ ## Output
93
+
94
+ Emit exactly this structure — one `### <Linter Name>` block per detected in-scope linter, then one `### Summary`:
95
+
96
+ ```
97
+ ## Lint Results
98
+
99
+ ### [Linter Name]
100
+ - Command: `[exact command run]`
101
+ - Result: PASS / N issues found / unavailable
102
+ - Details: [first 10 issues if any]
103
+
104
+ ### Summary
105
+ - Format: PASS/FAIL
106
+ - Lint: PASS/FAIL (N issues)
107
+ - Types: PASS/FAIL (N errors)
108
+ ```
109
+
110
+ Filled example:
111
+
112
+ ```
113
+ ## Lint Results
114
+
115
+ ### Go (extended)
116
+ - Command: `golangci-lint run`
117
+ - Result: 2 issues found
118
+ - Details: cmd/main.go:14 ineffassign · internal/db/pool.go:88 errcheck
119
+
120
+ ### Summary
121
+ - Format: PASS
122
+ - Lint: FAIL (2 issues)
123
+ - Types: PASS
124
+ ```
125
+
126
+ ## Done ONLY when
127
+
128
+ - [ ] Every linter detected in Step 2 that falls within scope was run, or explicitly reported as `unavailable`.
129
+ - [ ] The report has one `### <Linter>` block per detected in-scope linter — block count equals the detected in-scope linter count.
130
+
131
+ ## Recap — non-negotiables
132
+
133
+ - Format before check, per stack; Makefile `lint` / `fmt` targets win over raw tools.
134
+ - Run only Step 2 table commands and Step 4 `--fix` variants — `--fix` is a modifier that rewrites files in place, never a scope.
135
+ - Empty or unrecognized scope → `all`; never narrow by guessing.
136
+ - For TypeScript run both ESLint and `tsc --noEmit`; check-only tools stay unchanged under `--fix`.
137
+ - Not done until every in-scope linter ran or was reported `unavailable`.
@@ -0,0 +1,146 @@
1
+ ---
2
+ description: Apply or rollback database migrations — auto-detects migration tool
3
+ argument-hint: "[up|down|down N|status]"
4
+ allowed-tools: Bash, Read, Glob
5
+ ---
6
+
7
+ # Database Migrations
8
+
9
+ Role: apply, roll back, or report the status of database migrations, auto-detecting the project's migration tool. Rollbacks destroy data — every destructive step is gated behind explicit user confirmation.
10
+
11
+ ## Hard Rules
12
+
13
+ 1. **Destructive-action gate**: before running ANY command that can destroy data (`down`, `rollback`, `downgrade`, `reset`, `drop`, any `--force` flag), STOP and ask the user for confirmation AT THAT STEP. Show the exact command and exactly what will be lost (which migrations revert; which tables/columns they drop, from reading the migration files). Run only after the user explicitly agrees.
14
+ 2. NEVER run `npx prisma migrate reset` (or any tool's reset/drop-and-recreate) as a routine rollback — it drops the ENTIRE database. Offer it only as a clearly labeled last resort, and only run it after the user explicitly accepts total data loss.
15
+ 3. NEVER guess a database connection string. Locate it (Step 2) or report where you looked and ask the user.
16
+ 4. Run the tool's read-only `status` command before any `up` or `down`, whenever the tool has one.
17
+ 5. If no migration tool is detected, report that and stop. If the detected tool has no true rollback (Prisma, Drizzle), follow its down branch in Step 4 — present only the options listed there, auto-run none of them, and do not improvise a workaround.
18
+ 6. For `down N` with N > 1: in the confirmation (Rule 1), restate N and list the N migrations that will be reverted; if the user's answer does not clearly cover N migrations, do not run.
19
+ 7. Prefer Makefile migration targets over raw tool commands — they may include environment setup.
20
+
21
+ ## Arguments
22
+
23
+ Requested action: $ARGUMENTS
24
+
25
+ | Argument | Action |
26
+ |----------|--------|
27
+ | (empty) | `up` |
28
+ | `up` | apply all pending migrations |
29
+ | `down` | rollback 1 migration (confirmation-gated) |
30
+ | `down N` | rollback N migrations (confirmation-gated, Rule 6) |
31
+ | `status` | read-only status report |
32
+ | anything else | report `Unknown action: <arg>` with the list above, stop |
33
+
34
+ ## Step 1 — Detect Migration Tool
35
+
36
+ Check markers top to bottom; first match wins (Makefile first, per Rule 7):
37
+
38
+ | Marker | Tool | Apply Command |
39
+ |--------|------|---------------|
40
+ | `Makefile` with `migrate-up` target | Make | `make migrate-up` |
41
+ | `Makefile` with `migrate` target | Make | `make migrate` |
42
+ | `golang-migrate` in deps, or numbered `.sql` up/down pairs | golang-migrate | `migrate -path <dir> -database <url> up` |
43
+ | `dbmate` in deps or PATH | dbmate | `dbmate up` |
44
+ | `alembic.ini` or `alembic/` | Alembic | `alembic upgrade head` |
45
+ | `prisma/` + `package.json` | Prisma | `npx prisma migrate deploy` |
46
+ | `db/migrate/` + `Rakefile` | Rails | `rails db:migrate` |
47
+ | `drizzle.config.ts` | Drizzle | `npx drizzle-kit migrate` |
48
+ | `knexfile.js` / `knexfile.ts` | Knex | `npx knex migrate:latest` |
49
+
50
+ Done when: exactly one tool selected — or no marker matched and you reported `No migration tool detected — checked: [list of markers]` and stopped.
51
+
52
+ ## Step 2 — Locate Connection & Check Infra
53
+
54
+ Skip for tools that read their own config automatically when it is already present (Alembic `alembic.ini`, Prisma `schema.prisma` datasource, Knex `knexfile.*`, Rails). For tools needing an explicit URL or env (golang-migrate `-database`, dbmate/`DATABASE_URL`), find the real value — check in order:
55
+
56
+ 1. Makefile variables used by the migrate target
57
+ 2. `.env` / `.env.local`
58
+ 3. `docker-compose*.yml` environment blocks
59
+ 4. Tool config files (`alembic.ini` `sqlalchemy.url`, `prisma/schema.prisma`, `knexfile.*`)
60
+
61
+ Not found in any of these → apply Rule 3: report the four places checked, ask the user, stop.
62
+
63
+ Migrations require a running database. If the connection points at local infra (docker-compose service, localhost), verify it is reachable (e.g. the compose service is up); if not, tell the user to start infrastructure first and stop.
64
+
65
+ Done when: connection source identified (never guessed) and DB assumed reachable — or you stopped and asked.
66
+
67
+ ## Step 3 — Status First
68
+
69
+ If the action is `status`, or before executing `up`/`down` (Rule 4): run the status command and capture its output.
70
+
71
+ | Tool | Status Command |
72
+ |------|----------------|
73
+ | Make | `migrate-status`/`status` target if the Makefile has one; else use the underlying tool's row if identifiable; else note "no status command" |
74
+ | golang-migrate | `migrate -path <dir> -database <url> version` |
75
+ | dbmate | `dbmate status` |
76
+ | Alembic | `alembic current` + `alembic history` |
77
+ | Prisma | `npx prisma migrate status` |
78
+ | Rails | `rails db:migrate:status` |
79
+ | Drizzle | none — note "status not supported by drizzle-kit"; for `status` action, list local migration files instead |
80
+ | Knex | `npx knex migrate:list` |
81
+
82
+ If the action is `status`, go straight to Step 5 after this.
83
+
84
+ Done when: status output captured, or "no status command for [tool]" noted.
85
+
86
+ ## Step 4 — Execute Action
87
+
88
+ ### up
89
+
90
+ Run the Apply Command from Step 1. No confirmation gate — applying pending migrations is the normal forward path.
91
+
92
+ ### down / down N
93
+
94
+ 1. From Step 3 status output (or the migration directory), identify by name the migration(s) that will be reverted; read them to state what schema/data is lost.
95
+ 2. Apply Rule 1 (and Rule 6 if N > 1): show the exact rollback command, the migration names, and the concrete loss. Wait for explicit user agreement.
96
+ 3. User declined or did not clearly agree → record "user declined", go to Step 5.
97
+ 4. User agreed → run the rollback command:
98
+
99
+ | Tool | Rollback 1 | Rollback N |
100
+ |------|-----------|------------|
101
+ | Make | `make migrate-down` (or `make migrate-rollback`) | run the target N times, unless it accepts a count |
102
+ | golang-migrate | `migrate -path <dir> -database <url> down 1` | `migrate ... down N` |
103
+ | dbmate | `dbmate down` | run `dbmate down` N times |
104
+ | Alembic | `alembic downgrade -1` | `alembic downgrade -N` |
105
+ | Prisma | **no true down** — see Prisma branch below | same |
106
+ | Rails | `rails db:rollback` | `rails db:rollback STEP=N` |
107
+ | Drizzle | **not supported** — see Drizzle branch below | same |
108
+ | Knex | `npx knex migrate:rollback` — reverts the last **batch**, which may contain more than one migration; list every migration in that batch in the confirmation | run `npx knex migrate:rollback` N times (each run reverts one batch) |
109
+
110
+ ### Prisma down branch
111
+
112
+ Prisma has no down command. Present exactly these options to the user and wait — never auto-run any of them:
113
+
114
+ 1. **Generate a down script**: use `npx prisma migrate diff` (check `--help` for the flag set in the installed version) to produce reverse SQL from the current schema vs. the target state; the user reviews and applies it manually.
115
+ 2. **Restore from a database backup** taken before the migration.
116
+ 3. **LAST RESORT — `npx prisma migrate reset`**: drops the ENTIRE database and replays all migrations. ALL data is lost. Runs only under Rules 1–2: the user must explicitly accept total data loss in response to a message that says so in those words.
117
+
118
+ ### Drizzle down branch
119
+
120
+ drizzle-kit has no rollback command. Report: "Drizzle does not support rollback via drizzle-kit. Options: write a reverse SQL migration and apply it forward, or restore from backup." Stop (Rule 5).
121
+
122
+ Done when: `up` — apply command ran, exit code and output captured; `down` — rollback ran after confirmation, or you stopped with "user declined" / "unsupported" recorded.
123
+
124
+ ## Step 5 — Report
125
+
126
+ Emit exactly this template:
127
+
128
+ ```
129
+ ## Migration Result
130
+
131
+ - Tool: [detected tool]
132
+ - Action: [up/down/down N/status]
133
+ - Command: `[exact command run]` — or "not run: [user declined | unsupported for this tool | no tool detected | connection not found]"
134
+ - Confirmation: [not required (up/status) | user confirmed: "<quoted answer>" | user declined]
135
+ - Result: [success/failure — paste the real command output, not a summary]
136
+ - Current version: [from status output, if available]
137
+ ```
138
+
139
+ Done when: the report matches the template, with `Result` taken from actual command output.
140
+
141
+ ## Recap
142
+
143
+ - Destructive commands run only after explicit user confirmation at that step, with the exact command and concrete data loss spelled out.
144
+ - `prisma migrate reset` is never a routine rollback — last resort, explicit total-data-loss consent only.
145
+ - Connection strings are located (Makefile/.env/compose/tool config) or asked for — never guessed.
146
+ - Status first where supported; no tool detected → report and stop; no true down (Prisma/Drizzle) → only the Step 4 branch options, nothing auto-run.
@@ -0,0 +1,182 @@
1
+ ---
2
+ description: Scaffold a new database migration file pair (up + down) with auto-detection of migration tool and numbering
3
+ argument-hint: <migration-description>
4
+ allowed-tools: Bash, Read, Write, Glob
5
+ ---
6
+
7
+ # New Migration
8
+
9
+ ## Role
10
+
11
+ Scaffold a database migration that matches the project's existing migration tool, directory, numbering scheme, and SQL dialect.
12
+
13
+ Migration description: $ARGUMENTS
14
+
15
+ ## Hard Rules
16
+
17
+ 1. NEVER invent a migrations directory, numbering scheme, or naming pattern — copy every convention from existing migrations, or ask the user (Step 2).
18
+ 2. No migration system detected, OR the migrations directory is empty → Step 2: report and ask. Create zero files on that branch.
19
+ 3. Match the project's SQL dialect (Step 3). NEVER emit PostgreSQL-only types (`TIMESTAMPTZ`, `BIGSERIAL`, `JSONB`) into a MySQL or SQLite project.
20
+ 4. SQL-file tools always get BOTH files: `.up.sql` and `.down.sql`. Down is the exact reverse of up.
21
+ 5. Use `IF NOT EXISTS` / `IF EXISTS` guards where the dialect supports them; never a destructive operation (`DROP TABLE`, `DROP COLUMN`) without `IF EXISTS`.
22
+ 6. Report only after verifying the created files exist on disk (`ls` or Read).
23
+
24
+ ## Step 1 — Detect Migration System
25
+
26
+ Check each marker with Glob. A row matches only if the directory contains at least one existing migration file:
27
+
28
+ | Marker | Tool | Directory | Naming Pattern |
29
+ |--------|------|-----------|----------------|
30
+ | `backend/migrations/*.sql` with numbered names | golang-migrate | `backend/migrations/` | `000NNN_desc.{up,down}.sql` |
31
+ | `migrations/*.sql` with numbered names | golang-migrate | `migrations/` | `000NNN_desc.{up,down}.sql` |
32
+ | `db/migrations/*.sql` | golang-migrate / dbmate | `db/migrations/` | `NNNNNN_desc.{up,down}.sql` |
33
+ | `db/migrate/*.rb` | Rails | `db/migrate/` | `YYYYMMDDHHMMSS_desc.rb` |
34
+ | `alembic/versions/*.py` | Alembic | `alembic/versions/` | `rev_desc.py` |
35
+ | `prisma/migrations/` | Prisma | `prisma/migrations/` | `YYYYMMDDHHMMSS_desc/` |
36
+ | `drizzle/` + `drizzle.config.ts` | Drizzle | `drizzle/` | `NNNN_desc.sql` |
37
+
38
+ Branches — exactly one applies:
39
+ - Exactly one row matches → Step 3.
40
+ - Two or more rows match → list the candidate directories, ask the user which one to use, wait for the answer.
41
+ - No row matches, or a directory exists but holds no migration files → Step 2.
42
+
43
+ Done when: you have one confirmed tool + directory containing existing migrations, or you branched to Step 2.
44
+
45
+ ## Step 2 — No Migration System Detected (ask, never invent)
46
+
47
+ Runs only when Step 1 found no system or an empty migrations directory. Do NOT create files or pick a numbering scheme yourself.
48
+
49
+ 1. Report which locations you searched (the Directory column of the Step 1 table, plus any project-specific paths you globbed).
50
+ 2. List tool options that match the detected stack:
51
+ - `go.mod` present → golang-migrate or dbmate
52
+ - `package.json` present → Prisma, Drizzle, or dbmate
53
+ - `pyproject.toml` / `requirements.txt` present → Alembic
54
+ - `Gemfile` present → Rails built-in migrations
55
+ 3. Ask the user which tool and directory to use. If a tool config exists but its directory is empty, also ask which numbering scheme to start with (sequential `000001` vs timestamp). Then STOP — proceed only after they answer.
56
+
57
+ Done when: the report + question are posted and zero files were created.
58
+
59
+ ## Step 3 — Detect SQL Dialect
60
+
61
+ Applies to raw-SQL tools (golang-migrate, dbmate). For Rails / Alembic / Prisma / Drizzle set dialect = `n/a` (the tool or schema owns the SQL) and go to Step 4.
62
+
63
+ Check in priority order; first signal wins:
64
+ 1. **Existing migration SQL** (search the migrations directory with `grep`): `TIMESTAMPTZ` / `JSONB` / `BIGSERIAL` → PostgreSQL · `AUTO_INCREMENT` / `ENGINE=` → MySQL · `AUTOINCREMENT` → SQLite.
65
+ 2. **Database driver in dependencies**: `go.mod`: `jackc/pgx` or `lib/pq` → PostgreSQL, `go-sql-driver/mysql` → MySQL, `mattn/go-sqlite3` or `modernc.org/sqlite` → SQLite · `package.json`: `pg` or `postgres` → PostgreSQL, `mysql2` → MySQL, `better-sqlite3` → SQLite · Python deps: `psycopg`/`asyncpg` → PostgreSQL, `pymysql`/`mysqlclient` → MySQL.
66
+ 3. **Connection string scheme** in `.env*` or config files: `postgres://`/`postgresql://` → PostgreSQL · `mysql://` → MySQL · `sqlite:` → SQLite.
67
+
68
+ No signal, or signals conflict → dialect = `unknown`: write `dialect: unknown — match existing schema` in the template comment and in the report. Do not guess types.
69
+
70
+ Done when: dialect is set to exactly one of `postgresql` / `mysql` / `sqlite` / `n/a` / `unknown`.
71
+
72
+ ## Step 4 — Compute the Next Number
73
+
74
+ Sequential-numbered tools (golang-migrate, dbmate, Drizzle SQL files) only. Timestamp- or hash-named tools (Rails, Prisma, Alembic) get their identifier from the generator in Step 6 — skip this step. An empty directory cannot reach this step (Step 1 routes it to Step 2).
75
+
76
+ ```bash
77
+ # Highest existing numeric prefix. Numeric sort — plain lexicographic sort mis-orders mixed zero-padding.
78
+ ls <migrations_dir> | grep -oE '^[0-9]+' | sort -n | tail -1
79
+ ```
80
+
81
+ Next number = highest + 1, zero-padded to the same width as the prefix of the newest existing migration (latest is `000042_...` → next is `000043`, width 6).
82
+
83
+ Done when: next identifier computed and its padding width equals the newest existing migration's prefix width.
84
+
85
+ ## Step 5 — Build the Filename
86
+
87
+ Convert the migration description to `snake_case`: lowercase, spaces and hyphens become underscores, drop other punctuation.
88
+ - "add user preferences" → `add_user_preferences`
89
+ - "Create events table" → `create_events_table`
90
+
91
+ Done when: filename slug produced.
92
+
93
+ ## Step 6 — Create the Migration
94
+
95
+ ### golang-migrate / dbmate — Write both files in the detected directory
96
+
97
+ **Up** (`<NNN>_<slug>.up.sql`):
98
+ ```sql
99
+ -- <NNN>_<slug>.up.sql
100
+ -- Description: <migration description>
101
+ -- Follow "Migration Conventions" below (dialect: <detected dialect>)
102
+
103
+ -- TODO: migration SQL
104
+ ```
105
+
106
+ **Down** (`<NNN>_<slug>.down.sql`):
107
+ ```sql
108
+ -- <NNN>_<slug>.down.sql
109
+ -- Rollback: exact reverse of the up migration, statements in reverse order
110
+
111
+ -- TODO: reverse every statement from the up file
112
+ ```
113
+
114
+ ### Rails
115
+ Run `bin/rails generate migration <SlugInCamelCase>` — the generator assigns the timestamp.
116
+
117
+ ### Alembic
118
+ `alembic revision --autogenerate -m "<slug>"` if autogenerate is configured; otherwise `alembic revision -m "<slug>"`.
119
+
120
+ ### Prisma
121
+ Edit `prisma/schema.prisma`, then run `npx prisma migrate dev --name <slug>`.
122
+
123
+ ### Drizzle
124
+ Edit the schema file, then run the project's drizzle-kit generate script — check `package.json` scripts for its exact name.
125
+
126
+ Done when: SQL tools — both files exist on disk (verified with `ls`); generator tools — the command ran and printed the created file path.
127
+
128
+ ## Step 7 — Report
129
+
130
+ Verify the created paths exist, then fill this template exactly:
131
+
132
+ ```
133
+ ## Migration Scaffolded
134
+
135
+ Tool: <tool> · Directory: <dir> · Dialect: <postgresql|mysql|sqlite|n/a|unknown>
136
+
137
+ Created:
138
+ - <path to up file>
139
+ - <path to down file> (SQL tools; generator tools: path(s) from the tool's output)
140
+
141
+ Next steps:
142
+ 1. Edit the file(s): replace the TODO with your SQL / schema change.
143
+ 2. Apply: <apply command>
144
+ 3. Confirm the down migration rolls back cleanly before committing.
145
+ ```
146
+
147
+ Apply command: prefer the project's documented one (Makefile target, `package.json` script, README). If none is documented, use the tool default: `migrate -path <dir> -database "$DATABASE_URL" up` · `dbmate up` · `alembic upgrade head` · `bin/rails db:migrate` · `npx prisma migrate dev`.
148
+
149
+ ## Migration Conventions
150
+
151
+ Existing tables win: when this table conflicts with what existing migrations already do, copy the existing migrations.
152
+
153
+ | Need | PostgreSQL | MySQL | SQLite |
154
+ |------|------------|-------|--------|
155
+ | Timestamps | `TIMESTAMPTZ` | `DATETIME(6)` | `TEXT` (ISO 8601) |
156
+ | Auto-increment PK | `BIGSERIAL` (or `UUID`) | `BIGINT AUTO_INCREMENT` | `INTEGER PRIMARY KEY` |
157
+ | Flexible metadata | `JSONB` | `JSON` | `TEXT` (JSON string) |
158
+
159
+ Dialect-neutral rules:
160
+ - `IF NOT EXISTS` / `IF EXISTS` on every CREATE/DROP the dialect supports.
161
+ - New tables get `created_at` (timestamp type from the table above) `NOT NULL` with a current-timestamp default.
162
+ - `CREATE INDEX` for columns that will be filtered or joined on.
163
+ - Foreign keys: `ON DELETE CASCADE` when child rows are meaningless without the parent; `ON DELETE SET NULL` when they must outlive it.
164
+ - Down migration is the exact reverse of up, statements in reverse order.
165
+ - Destructive operations (`DROP TABLE`, `DROP COLUMN`) only with `IF EXISTS`.
166
+
167
+ ## Done ONLY when
168
+
169
+ - [ ] Scaffold branch: created file(s) exist on disk — verified with `ls`/Read, not from memory; SQL tools have BOTH `.up.sql` and `.down.sql`.
170
+ - [ ] The down file mirrors the up file (exact reverse).
171
+ - [ ] Report emitted with exact paths, dialect, and apply command.
172
+ - [ ] Ask branch (Step 2) instead: searched locations reported, stack-matched options listed, question asked, zero files created.
173
+
174
+ Not all applicable boxes checked → say what is missing; do not claim completion.
175
+
176
+ ## Recap — non-negotiables
177
+
178
+ - Conventions come from existing migrations or the user — never invented; no system or empty directory → Step 2 ask.
179
+ - Dialect-gate all SQL: PostgreSQL types only on PostgreSQL (see Migration Conventions).
180
+ - SQL tools: always an up + down pair; down reverses up exactly.
181
+ - `IF NOT EXISTS` / `IF EXISTS` guards; no destructive operation without `IF EXISTS`.
182
+ - Verify files on disk before reporting.
@@ -0,0 +1,209 @@
1
+ ---
2
+ description: AI pair programming — switch between Driver, Navigator, TDD, Review, and Debug modes
3
+ argument-hint: "<mode: driver|navigator|tdd|review|debug> [task]"
4
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, Agent
5
+ ---
6
+
7
+ # Pair Programming
8
+
9
+ ## Role
10
+
11
+ Run an interactive pair-programming session with the user in one of five modes. This command is a dialogue loop: work in small increments, wait for the user at every check-in, and continue until the user ends the session.
12
+
13
+ ## Hard Rules
14
+
15
+ 1. This is an interactive session — stop and WAIT for the user's reply at every check-in point. Never push through an entire task without user responses.
16
+ 2. Driver mode: never write more than ~50 lines of code without checking in.
17
+ 3. Navigator mode: suggest, don't rewrite — ask before making any edit yourself.
18
+ 4. Review mode: present ONE finding at a time; wait for the user's response before the next.
19
+ 5. Never manufacture issues — if code is clean, say "Looks good". 0 findings is a valid result.
20
+ 6. Debug mode: never guess — trace the actual code path; ask the user for runtime data you cannot see (logs, debugger output, network).
21
+ 7. When the user says "done" or "pause", emit the Session Summary (Output template below) before stopping. No silent exits.
22
+
23
+ ## Step 1 — Select Mode
24
+
25
+ Arguments: $ARGUMENTS
26
+
27
+ The first word is the mode; the remainder is the task description. If the first word is not a mode name, default to **driver** and treat the entire input as the task.
28
+
29
+ | Input | Mode | Who codes | Who reviews |
30
+ |-------|------|-----------|-------------|
31
+ | `driver` or empty | Driver | Claude writes code | User guides direction |
32
+ | `navigator` | Navigator | User writes code | Claude reviews each change |
33
+ | `tdd` | TDD Ping-Pong | Alternating | Default: Claude writes tests, user implements (Option A) |
34
+ | `review` | Review | — | Claude reviews recent changes with dialogue |
35
+ | `debug` | Debug | Collaborative | Claude traces execution, user provides runtime context |
36
+
37
+ Done when: mode is selected.
38
+
39
+ ## Step 2 — Setup
40
+
41
+ 1. Read `CLAUDE.md` and relevant `docs/architecture/` files (skip silently if absent).
42
+ 2. Detect project stack (Go, TypeScript, Python, Rust).
43
+ 3. Identify the scope of work from the task description — ask ONE clarifying question if it is ambiguous.
44
+ 4. Announce the mode and its Rules block (from the matching Mode Playbook below).
45
+
46
+ Done when: mode and ground rules are announced to the user.
47
+
48
+ ## Step 3 — Run the Mode Loop
49
+
50
+ Execute the Mode Playbook matching the selected mode. Stay in the loop and honor these session controls at any time:
51
+
52
+ | User says | Action |
53
+ |-----------|--------|
54
+ | "switch to X" / "let's do X" | Announce mode X and its rules, continue in mode X |
55
+ | "pause" | Go to Step 4 (emit Session Summary), then stop |
56
+ | "resume" | Restate where you left off, continue in the previous mode |
57
+ | "done" | Go to Step 4 (emit Session Summary), end session |
58
+
59
+ Done when: the user says "pause" or "done".
60
+
61
+ ### Mode Playbook — Driver
62
+
63
+ Claude writes code, user steers.
64
+
65
+ Process:
66
+ 1. **Propose approach** — brief plan (3–5 bullet points), wait for user OK.
67
+ 2. **Implement incrementally** — write code in small chunks (1 function or 1 component at a time).
68
+ 3. **Pause after each chunk** — show what was written, ask: "Continue with [next piece], or adjust?"
69
+ 4. Repeat 2–3 until the scope is complete. Hard Rule 2 applies: ≤50 lines between check-ins.
70
+
71
+ Rules:
72
+ - Small increments, frequent check-ins.
73
+ - Explain non-obvious decisions inline (1-line comment, not a paragraph).
74
+ - If user says "faster" — reduce check-in frequency, batch larger chunks.
75
+ - If user says "slower" — break into smaller pieces, explain more.
76
+
77
+ ### Mode Playbook — Navigator
78
+
79
+ User writes code, Claude reviews in real-time.
80
+
81
+ Process:
82
+ 1. **Set scope** — agree on what the user will implement.
83
+ 2. **Watch changes** — after each user edit, review for:
84
+ - Logic errors or missed edge cases
85
+ - Convention violations (from CLAUDE.md)
86
+ - Security issues (injection, auth bypass)
87
+ - Missing error handling
88
+ 3. **Suggest, don't rewrite** — point out issues with specific suggestions:
89
+ ```
90
+ Line 42: This fetch has no error handling.
91
+ Suggestion: wrap in try/catch, return error to caller.
92
+ ```
93
+ 4. **Track progress** — remind user of remaining scope items.
94
+
95
+ Rules:
96
+ - Only flag real issues, not style preferences.
97
+ - Use [CRITICAL], [WARNING], [SUGGESTION] severity levels.
98
+ - If code is clean, say "Looks good" — don't manufacture issues (Hard Rule 5).
99
+ - Ask before making any edits yourself (Hard Rule 3).
100
+
101
+ ### Mode Playbook — TDD Ping-Pong
102
+
103
+ Alternating between writing tests and implementation.
104
+
105
+ Default: **Option A** (Claude writes tests first). Use Option B only if the user says they will write the tests.
106
+
107
+ Option A — Claude writes tests first:
108
+ 1. Claude writes a failing test for the next requirement.
109
+ 2. User implements code to make it pass.
110
+ 3. Claude reviews the implementation.
111
+ 4. Claude writes the next failing test.
112
+ 5. Repeat until all requirements covered.
113
+
114
+ Option B — User writes tests first:
115
+ 1. User writes a failing test.
116
+ 2. Claude implements the minimal code to pass.
117
+ 3. User reviews and writes the next test.
118
+ 4. Repeat until all requirements covered.
119
+
120
+ Rules:
121
+ - Each test covers ONE behavior.
122
+ - Tests must fail before implementation (Red-Green-Refactor).
123
+ - After 3–5 cycles, pause for refactoring if needed.
124
+ - Name tests: `should [behavior] when [condition]`.
125
+ - Use the project's existing test framework and patterns.
126
+
127
+ ### Mode Playbook — Review
128
+
129
+ Interactive code review with dialogue.
130
+
131
+ Process:
132
+ 1. **Identify scope** — use `git diff` or user-specified files.
133
+ 2. **First pass** — read all changed files, note issues.
134
+ 3. **Present findings one at a time** (Hard Rule 4):
135
+ ```
136
+ [WARNING] src/handler.go:45 — Missing context propagation
137
+ The handler creates a new context instead of using the request context.
138
+ This breaks tracing and cancellation.
139
+
140
+ Fix: Use r.Context() instead of context.Background()
141
+
142
+ Agree? Should I fix it?
143
+ ```
144
+ 4. **Wait for user response** before moving to the next finding.
145
+ 5. **Apply agreed fixes** immediately.
146
+ 6. **Summary** — list all findings, which were fixed, which were deferred.
147
+
148
+ Rules:
149
+ - If user disagrees, accept and move on (they may have context you don't).
150
+ - After all findings, offer to run linters/tests.
151
+
152
+ ### Mode Playbook — Debug
153
+
154
+ Collaborative debugging with execution tracing.
155
+
156
+ Process:
157
+ 1. **Reproduce** — understand the bug: expected vs actual behavior.
158
+ 2. **Hypothesize** — propose 2–3 likely causes based on code structure.
159
+ 3. **Trace** — read code along the execution path, noting:
160
+ - Where data transforms
161
+ - Where errors could be swallowed
162
+ - Where state could be unexpected
163
+ 4. **Narrow down** — ask user targeted questions:
164
+ - "Does the error happen on first request or subsequent?"
165
+ - "What does the log show at [specific point]?"
166
+ - "Can you check the value of X in the debugger?"
167
+ 5. **Fix** — once root cause is found, propose a minimal fix.
168
+ 6. **Verify** — run tests, check the fix doesn't break related functionality.
169
+
170
+ Rules:
171
+ - Don't guess — trace the actual code path (Hard Rule 6).
172
+ - Ask user for runtime data you can't see (logs, debugger output, network).
173
+ - Dispatch the **debug-observer** agent if Docker/Redis/SQL diagnostics are needed.
174
+ - After the fix, write a regression test.
175
+
176
+ ## Step 4 — End Session
177
+
178
+ Triggered by "done" or "pause" (Hard Rule 7). Fill the Output template below — every section filled, write "none" where a section is empty.
179
+
180
+ Done when: the Session Summary is emitted matching the template.
181
+
182
+ ## Output template
183
+
184
+ ```
185
+ ## Pair Session Summary
186
+
187
+ Mode(s): [modes used]
188
+ Check-in cycles: [number of check-in/review/test cycles completed]
189
+
190
+ ### Changes Made
191
+ | File | Action | Description |
192
+ |------|--------|-------------|
193
+ | ... | ... | ... |
194
+
195
+ ### Decisions
196
+ - [key decision 1]
197
+ - [key decision 2]
198
+
199
+ ### Follow-up
200
+ - [ ] [remaining work; "none" if complete]
201
+ ```
202
+
203
+ ## Recap
204
+
205
+ - Wait for the user at every check-in — this is a dialogue, not a batch task.
206
+ - Driver: ≤50 lines between check-ins. Navigator: ask before editing. Review: one finding at a time.
207
+ - Clean code gets "Looks good" — never manufacture issues.
208
+ - TDD defaults to Option A (Claude writes tests) unless the user claims the tests.
209
+ - "done" or "pause" → Session Summary is mandatory before stopping.