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,141 @@
1
+ #!/bin/bash
2
+ # profile.sh — shared helper for hook strictness + disable logic
3
+ # Source at the top of every hook:
4
+ # source "$(dirname "$0")/lib/profile.sh"
5
+ # should_skip_hook "$(basename "$0" .sh)" && exit 0
6
+
7
+ should_skip_hook() {
8
+ local hook_name="$1"
9
+
10
+ # Explicit disable list takes precedence over everything
11
+ local disabled="${CLAUDE_DISABLED_HOOKS:-}"
12
+ if [ -n "$disabled" ]; then
13
+ local IFS=','
14
+ for item in $disabled; do
15
+ # Trim whitespace
16
+ item="${item## }"
17
+ item="${item%% }"
18
+ [ "$item" = "$hook_name" ] && return 0
19
+ done
20
+ fi
21
+
22
+ # fast profile: skip everything except critical safety hooks
23
+ local profile="${CLAUDE_HOOK_PROFILE:-standard}"
24
+ if [ "$profile" = "fast" ]; then
25
+ case "$hook_name" in
26
+ block-dangerous-git|security-patterns|audit-settings-source|doc-check-on-commit)
27
+ return 1
28
+ ;;
29
+ *)
30
+ return 0
31
+ ;;
32
+ esac
33
+ fi
34
+
35
+ return 1
36
+ }
37
+
38
+ # Keep the function available to sourcing scripts.
39
+ export -f should_skip_hook 2>/dev/null || true
40
+
41
+ # Canonical per-session key: prefer Claude Code session_id, then hook PID, then PPID.
42
+ # Use for any TMPDIR state file that must accumulate across hook invocations in a session.
43
+ superkit_session_key() {
44
+ printf '%s' "${SESSION_ID:-${CLAUDE_HOOK_PID:-$PPID}}"
45
+ }
46
+ export -f superkit_session_key 2>/dev/null || true
47
+
48
+ # superkit_advise <message> — emit a warn-only PreToolUse advisory as JSON
49
+ # `hookSpecificOutput.additionalContext` on stdout so it reaches the model.
50
+ # Claude Code can swallow non-blocking PreToolUse stderr; stdout JSON is the
51
+ # reliable channel for advisory context (ECC-inspired). Callers that also
52
+ # print to stderr (for human-readable transcript logs) should additionally
53
+ # call this so the model actually sees the reminder. Prefer jq (every hook in
54
+ # this kit already assumes jq is on PATH); fall back to a manually-escaped
55
+ # printf only if jq is unavailable, so the hook never emits invalid JSON.
56
+ superkit_advise() {
57
+ local msg="$1"
58
+ if command -v jq >/dev/null 2>&1; then
59
+ jq -cn --arg m "$msg" \
60
+ '{hookSpecificOutput:{hookEventName:"PreToolUse",additionalContext:$m}}'
61
+ else
62
+ # Minimal JSON string escaping: backslash, double-quote, then control chars.
63
+ local esc="$msg"
64
+ esc="${esc//\\/\\\\}"
65
+ esc="${esc//\"/\\\"}"
66
+ esc="${esc//$'\t'/\\t}"
67
+ esc="${esc//$'\r'/\\r}"
68
+ esc="${esc//$'\n'/\\n}"
69
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"%s"}}\n' "$esc"
70
+ fi
71
+ }
72
+ export -f superkit_advise 2>/dev/null || true
73
+
74
+ # superkit_should_emit_advisory <message> — per-session dedup/throttle for
75
+ # noisy ADVISORY hooks (Opus 4.8 self-flags, so repeated nudges are noise).
76
+ # returns 0 → emit (first time, or window elapsed)
77
+ # returns 1 → suppress (identical advisory already emitted within window)
78
+ # Keyed on superkit_session_key + a hash of the message, with a sliding
79
+ # N-minute window (CLAUDE_NUDGE_WINDOW_MIN, default 10). Setting the window
80
+ # to 0 disables throttling entirely (always emit). On success it records the
81
+ # emit time so the NEXT identical call within the window is suppressed.
82
+ #
83
+ # Scope note: this throttles advisory FREQUENCY only. It must never be used to
84
+ # suppress or filter reviewer findings — that is a separate layer. Use it only
85
+ # in nudge/advisory hooks (edit-streak, gateguard advisory, behavioral nudges).
86
+ superkit_should_emit_advisory() {
87
+ local msg="$1"
88
+ local window_min="${CLAUDE_NUDGE_WINDOW_MIN:-10}"
89
+
90
+ # Non-numeric window → fall back to default; 0 → throttling disabled.
91
+ case "$window_min" in (*[!0-9]*|"") window_min=10 ;; esac
92
+ [ "$window_min" = "0" ] && return 0
93
+
94
+ local window_sec=$((window_min * 60))
95
+ local now
96
+ now=$(date +%s)
97
+
98
+ # Hash the message for a compact, collision-resistant key.
99
+ local hash
100
+ if command -v shasum >/dev/null 2>&1; then
101
+ hash=$(printf '%s' "$msg" | shasum -a 256 | cut -d' ' -f1)
102
+ elif command -v sha256sum >/dev/null 2>&1; then
103
+ hash=$(printf '%s' "$msg" | sha256sum | cut -d' ' -f1)
104
+ else
105
+ # Last resort: cksum (weaker, but keeps the helper functional).
106
+ hash=$(printf '%s' "$msg" | cksum | tr -d ' ')
107
+ fi
108
+
109
+ local state_file="${SUPERKIT_NUDGE_STATE:-${TMPDIR:-/tmp}/superkit-nudge-$(superkit_session_key)}"
110
+
111
+ # Look up last emit time for this hash; suppress if still inside the window.
112
+ if [ -f "$state_file" ]; then
113
+ local last_epoch
114
+ last_epoch=$(grep -E "^${hash} " "$state_file" 2>/dev/null | tail -1 | cut -d' ' -f2)
115
+ case "$last_epoch" in (*[!0-9]*|"") last_epoch="" ;; esac
116
+ if [ -n "$last_epoch" ] && [ "$last_epoch" -le "$now" ] \
117
+ && [ "$((now - last_epoch))" -lt "$window_sec" ]; then
118
+ return 1
119
+ fi
120
+ fi
121
+
122
+ # Record this emit. Drop the prior line for this hash, append the fresh one,
123
+ # then atomically replace. Also prune entries older than the window so the
124
+ # file can't grow unbounded over a long session.
125
+ local tmp="${state_file}.$$.${now}"
126
+ {
127
+ if [ -f "$state_file" ]; then
128
+ while IFS=' ' read -r h e _; do
129
+ [ -z "$h" ] && continue
130
+ [ "$h" = "$hash" ] && continue
131
+ case "$e" in (*[!0-9]*|"") continue ;; esac
132
+ [ "$((now - e))" -ge "$window_sec" ] && continue
133
+ printf '%s %s\n' "$h" "$e"
134
+ done < "$state_file"
135
+ fi
136
+ printf '%s %s\n' "$hash" "$now"
137
+ } > "$tmp" 2>/dev/null && mv -f "$tmp" "$state_file" 2>/dev/null
138
+ # Fail-open: if the state write failed we still emit (return 0).
139
+ return 0
140
+ }
141
+ export -f superkit_should_emit_advisory 2>/dev/null || true
@@ -0,0 +1,75 @@
1
+ #!/bin/bash
2
+ # loop-guard.sh — detect and block repeated identical tool calls (anti-loop protection)
3
+ # Triggers on: PreToolUse(Bash)
4
+ # Profile: standard, strict
5
+
6
+ # Unified profile + disable check
7
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
8
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
9
+ # shellcheck source=/dev/null
10
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
11
+
12
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
13
+ if [ "$PROFILE" = "fast" ]; then
14
+ exit 0
15
+ fi
16
+
17
+ # Read tool input and create a fingerprint.
18
+ # Payload shape: .tool_input.{command,file_path}. See doc-check-on-commit.sh
19
+ # for the historical-bug context — same JSON schema change applied here.
20
+ INPUT=$(cat)
21
+ TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
22
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // .tool_input.file_path // .command // .input.command // empty' 2>/dev/null)
23
+
24
+ if [ -z "$TOOL_NAME" ] || [ -z "$COMMAND" ]; then
25
+ exit 0
26
+ fi
27
+
28
+ # Create a hash of the tool call for comparison
29
+ FINGERPRINT=$(echo "${TOOL_NAME}:${COMMAND}" | shasum -a 256 | cut -d' ' -f1)
30
+
31
+ # Log file for tracking recent calls (per-session)
32
+ SESSION_KEY=$(command -v superkit_session_key >/dev/null 2>&1 && superkit_session_key || printf '%s' "${SESSION_ID:-${CLAUDE_HOOK_PID:-$PPID}}")
33
+ LOG_FILE="${TMPDIR:-/tmp}/claude-loop-guard-${SESSION_KEY}.log"
34
+
35
+ # Append current fingerprint
36
+ echo "$FINGERPRINT" >> "$LOG_FILE"
37
+
38
+ # Keep only last 6 entries
39
+ tail -6 "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
40
+
41
+ # Read recent fingerprints
42
+ RECENT=$(tail -4 "$LOG_FILE" 2>/dev/null)
43
+ COUNT=$(echo "$RECENT" | grep -c "^${FINGERPRINT}$" 2>/dev/null)
44
+
45
+ # Block if 3+ identical consecutive calls
46
+ if [ "$COUNT" -ge 3 ]; then
47
+ echo "" >&2
48
+ echo "BLOCKED: Loop detected — same tool call repeated 3+ times" >&2
49
+ echo " Tool: $TOOL_NAME" >&2
50
+ echo " Command: $(echo "$COMMAND" | head -c 100)" >&2
51
+ echo "" >&2
52
+ echo " Try a different approach or ask the user for guidance." >&2
53
+ echo "" >&2
54
+ exit 2
55
+ fi
56
+
57
+ # Detect A→B→A→B pattern (sliding window)
58
+ if [ "$(wc -l < "$LOG_FILE" 2>/dev/null)" -ge 4 ]; then
59
+ LINE1=$(sed -n '1p' "$LOG_FILE")
60
+ LINE2=$(sed -n '2p' "$LOG_FILE")
61
+ LINE3=$(sed -n '3p' "$LOG_FILE")
62
+ LINE4=$(sed -n '4p' "$LOG_FILE")
63
+
64
+ if [ "$LINE1" = "$LINE3" ] && [ "$LINE2" = "$LINE4" ] && [ "$LINE1" != "$LINE2" ]; then
65
+ echo "" >&2
66
+ echo "BLOCKED: Alternating loop detected (A→B→A→B pattern)" >&2
67
+ echo " The last 4 tool calls alternate between two operations." >&2
68
+ echo "" >&2
69
+ echo " Try a different approach or ask the user for guidance." >&2
70
+ echo "" >&2
71
+ exit 2
72
+ fi
73
+ fi
74
+
75
+ exit 0
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+ # migration-safety.sh — PostToolUse hook for Edit/Write
3
+ # Validates SQL migration files: checks for matching down.sql, non-empty content,
4
+ # and correct naming convention (000NNN_description.{up,down}.sql).
5
+ # Works with any */migrations/*.sql path.
6
+ # Profile: standard, strict (skip on fast)
7
+
8
+ # Unified profile + disable check
9
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
10
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
11
+ # shellcheck source=/dev/null
12
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
13
+
14
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
15
+ if [ "$PROFILE" = "fast" ]; then
16
+ exit 0
17
+ fi
18
+
19
+ INPUT=$(cat)
20
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
21
+
22
+ if [ -z "$FILE_PATH" ]; then
23
+ exit 0
24
+ fi
25
+
26
+ # Only process SQL files inside any migrations/ directory
27
+ if [[ ! "$FILE_PATH" =~ /migrations/.*\.sql$ ]]; then
28
+ exit 0
29
+ fi
30
+
31
+ BASENAME=$(basename "$FILE_PATH")
32
+
33
+ # Check naming convention: 000NNN_description.{up,down}.sql
34
+ if [[ ! "$BASENAME" =~ ^[0-9]{6}_[a-z0-9_]+\.(up|down)\.sql$ ]]; then
35
+ echo "WARNING: Migration doesn't follow 000NNN_description.{up,down}.sql convention: $BASENAME" >&2
36
+ fi
37
+
38
+ # If writing up.sql, check matching down.sql exists
39
+ if [[ "$FILE_PATH" =~ \.up\.sql$ ]]; then
40
+ DOWN_FILE="${FILE_PATH%.up.sql}.down.sql"
41
+ if [ ! -f "$DOWN_FILE" ]; then
42
+ echo "WARNING: No matching DOWN migration: $(basename "$DOWN_FILE")" >&2
43
+ echo " Create the rollback migration before committing." >&2
44
+ fi
45
+ fi
46
+
47
+ # If writing down.sql, verify it has actual SQL content (not empty/comments-only)
48
+ if [[ "$FILE_PATH" =~ \.down\.sql$ ]] && [ -f "$FILE_PATH" ]; then
49
+ SQL_LINES=$(grep -cvE '^\s*$|^\s*--' "$FILE_PATH" 2>/dev/null)
50
+ if [ "${SQL_LINES:-0}" -eq 0 ]; then
51
+ echo "WARNING: DOWN migration has no SQL statements: $BASENAME" >&2
52
+ echo " Add rollback SQL (DROP/ALTER) to ensure reversibility." >&2
53
+ fi
54
+ fi
55
+
56
+ exit 0
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+ # plan-completion-gate.sh — mark a superpowers plan as "awaiting doc update"
3
+ # Triggers on: PostToolUse(Skill)
4
+ # Profile: standard, strict
5
+ #
6
+ # Superpowers plan skills (executing-plans, writing-plans) finish by
7
+ # printing "plan complete" / "✅ done" / "Final report" in the Skill
8
+ # output. If the session touched code without updating
9
+ # `docs/architecture/*`, we drop a marker the next `git commit` must
10
+ # clear — either by staging architecture docs OR by adding
11
+ # `[plan-docs-deferred: <plan-id>: <reason>]` to the commit message.
12
+ #
13
+ # Marker: ${TMPDIR:-/tmp}/claude-plan-docs-pending-<session>
14
+ # Opt-out: CLAUDE_DISABLE_PLAN_GATE=1
15
+
16
+ # Unified profile + disable check
17
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
18
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
19
+ # shellcheck source=/dev/null
20
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
21
+
22
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
23
+ if [ "$PROFILE" = "fast" ] || [ "${CLAUDE_DISABLE_PLAN_GATE:-}" = "1" ]; then
24
+ exit 0
25
+ fi
26
+
27
+ INPUT=$(cat 2>/dev/null || echo '{}')
28
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
29
+ [ "$TOOL" = "Skill" ] || exit 0
30
+
31
+ SKILL=$(echo "$INPUT" | jq -r '.tool_input.skill // empty' 2>/dev/null)
32
+ # Match executing-plans / writing-plans with optional namespace prefix
33
+ if ! printf '%s' "$SKILL" | grep -qE '(^|:)(executing|writing)-plans?$'; then
34
+ exit 0
35
+ fi
36
+
37
+ # Pull the skill output / last assistant message for completion markers
38
+ OUTPUT=$(echo "$INPUT" | jq -r '.tool_response.output // .tool_response // .last_assistant_message // empty' 2>/dev/null)
39
+ if ! printf '%s' "$OUTPUT" | grep -qiE 'plan complete|✅ done|final report|plan finished|marking.*complete'; then
40
+ exit 0
41
+ fi
42
+
43
+ SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
44
+ SESSION_KEY="${SESSION_ID:-${CLAUDE_HOOK_PID:-$PPID}}"
45
+ MARKER="${TMPDIR:-/tmp}/claude-plan-docs-pending-${SESSION_KEY}"
46
+
47
+ touch "$MARKER"
48
+
49
+ # Echo an advisory so Claude sees it inline (hook stdout under PostToolUse
50
+ # is surfaced; the commit gate further down handles enforcement).
51
+ cat <<EOF
52
+
53
+ Plan completion detected (skill: $SKILL).
54
+ A doc-sync marker was placed at:
55
+ $MARKER
56
+
57
+ Next commit touching code files must either stage docs/architecture/*
58
+ OR include [plan-docs-deferred: <plan-id>: <reason ≥15 chars>] in the
59
+ commit message.
60
+ EOF
61
+ exit 0
@@ -0,0 +1,89 @@
1
+ #!/bin/bash
2
+ # pre-compact-save.sh — PreCompact hook
3
+ # Saves current context summary before compaction
4
+ # Captures: git state, modified files, task state, architectural decisions, review findings
5
+ # Profile: always on
6
+
7
+ # Unified profile + disable check
8
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
9
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
10
+ # shellcheck source=/dev/null
11
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
12
+
13
+ CONTEXT_DIR="$HOME/.config/claude-superkit"
14
+ mkdir -p "$CONTEXT_DIR"
15
+
16
+ CONTEXT_FILE="$CONTEXT_DIR/last-context.md"
17
+
18
+ # Collect recent architectural decisions from git log
19
+ RECENT_DECISIONS=""
20
+ if git log --oneline -20 --format="%s" 2>/dev/null | grep -iE "(feat|refactor|arch|design|migrate)" | head -5 | grep -q .; then
21
+ RECENT_DECISIONS=$(git log --oneline -20 --format="- %s" 2>/dev/null | grep -iE "(feat|refactor|arch|design|migrate)" | head -5)
22
+ fi
23
+
24
+ # Collect active plan if exists
25
+ ACTIVE_PLAN=""
26
+ if [ -f ".claude/.active-plan.md" ]; then
27
+ ACTIVE_PLAN=$(head -50 ".claude/.active-plan.md" 2>/dev/null)
28
+ fi
29
+
30
+ # Collect review findings from last session
31
+ REVIEW_FINDINGS=""
32
+ if [ -f ".claude/.last-review.md" ]; then
33
+ REVIEW_FINDINGS=$(cat ".claude/.last-review.md" 2>/dev/null)
34
+ fi
35
+
36
+ # Collect discovered issues
37
+ DISCOVERED_ISSUES=""
38
+ if [ -f ".claude/.discovered-issues.md" ]; then
39
+ DISCOVERED_ISSUES=$(cat ".claude/.discovered-issues.md" 2>/dev/null)
40
+ fi
41
+
42
+ # Detect project stacks
43
+ STACKS=""
44
+ [ -f "go.mod" ] && STACKS="${STACKS}Go "
45
+ [ -f "Cargo.toml" ] && STACKS="${STACKS}Rust "
46
+ [ -f "pyproject.toml" ] && STACKS="${STACKS}Python "
47
+ [ -f "package.json" ] && [ -f "tsconfig.json" ] && STACKS="${STACKS}TypeScript "
48
+
49
+ cat > "$CONTEXT_FILE" << CTXEOF
50
+ # Claude Code — Last Context (auto-saved before compaction)
51
+ **Saved at:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
52
+ **Working directory:** $(pwd)
53
+ **Stacks:** ${STACKS:-unknown}
54
+ **Profile:** ${CLAUDE_HOOK_PROFILE:-standard}
55
+
56
+ ## Git State
57
+ **Branch:** $(git branch --show-current 2>/dev/null || echo "not a git repo")
58
+ **Recent commits:**
59
+ $(git log --oneline -5 2>/dev/null || echo "no commits")
60
+
61
+ ## Modified Files (unstaged)
62
+ $(git diff --name-only 2>/dev/null || echo "none")
63
+
64
+ ## Staged Files
65
+ $(git diff --cached --name-only 2>/dev/null || echo "none")
66
+
67
+ ## Task State
68
+ $(if [ -f ".claude/.task-state.json" ]; then cat .claude/.task-state.json; else echo "no active task"; fi)
69
+
70
+ ## Recent Architectural Decisions
71
+ $(if [ -n "$RECENT_DECISIONS" ]; then echo "$RECENT_DECISIONS"; else echo "none detected"; fi)
72
+
73
+ ## Active Plan
74
+ $(if [ -n "$ACTIVE_PLAN" ]; then echo "$ACTIVE_PLAN"; else echo "no active plan"; fi)
75
+
76
+ ## Review Findings (last session)
77
+ $(if [ -n "$REVIEW_FINDINGS" ]; then echo "$REVIEW_FINDINGS"; else echo "none"; fi)
78
+
79
+ ## Discovered Issues
80
+ $(if [ -n "$DISCOVERED_ISSUES" ]; then echo "$DISCOVERED_ISSUES"; else echo "none"; fi)
81
+ CTXEOF
82
+
83
+ # Validate saved context is not empty
84
+ if [ ! -s "$CONTEXT_FILE" ]; then
85
+ echo "WARNING: Context file is empty after save" >&2
86
+ fi
87
+
88
+ echo "Context saved to $CONTEXT_FILE" >&2
89
+ exit 0
@@ -0,0 +1,119 @@
1
+ #!/bin/bash
2
+ # security-patterns.sh — PostToolUse hook (Edit/Write)
3
+ # Detects dangerous code patterns in real-time during editing
4
+ # Profile: standard, strict
5
+ #
6
+ # Based on Anthropic official security-guidance plugin patterns.
7
+ # Warns (does not block) — security-scanner agent does deep analysis.
8
+ #
9
+ # EXIT CODES:
10
+ # 0 = allow (always — this hook only warns)
11
+
12
+ # Unified profile + disable check
13
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
14
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
15
+ # shellcheck source=/dev/null
16
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
17
+
18
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
19
+ if [ "$PROFILE" = "fast" ]; then
20
+ exit 0
21
+ fi
22
+
23
+ # Read tool input — PostToolUse payload: .tool_input.file_path.
24
+ # See doc-check-on-commit.sh for the historical-bug context — same JSON shape.
25
+ INPUT=$(cat)
26
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.filePath // .file_path // .filePath // empty' 2>/dev/null)
27
+
28
+ # Only check code files
29
+ case "$FILE_PATH" in
30
+ *.go|*.ts|*.tsx|*.js|*.jsx|*.py|*.rs|*.rb|*.java|*.kt) ;;
31
+ *) exit 0 ;;
32
+ esac
33
+
34
+ # Skip if file doesn't exist
35
+ if [ ! -f "$FILE_PATH" ]; then
36
+ exit 0
37
+ fi
38
+
39
+ WARNINGS=""
40
+
41
+ # JavaScript/TypeScript patterns
42
+ case "$FILE_PATH" in *.ts|*.tsx|*.js|*.jsx)
43
+ if grep -qn 'eval(' "$FILE_PATH" 2>/dev/null; then
44
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: eval() detected — potential code injection"
45
+ fi
46
+ if grep -qn 'new Function(' "$FILE_PATH" 2>/dev/null; then
47
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: new Function() — dynamic code execution"
48
+ fi
49
+ if grep -qn 'dangerouslySetInnerHTML' "$FILE_PATH" 2>/dev/null; then
50
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: dangerouslySetInnerHTML — XSS risk, use DOMPurify"
51
+ fi
52
+ if grep -qn 'document\.write' "$FILE_PATH" 2>/dev/null; then
53
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: document.write — DOM XSS vector"
54
+ fi
55
+ if grep -qn '\.innerHTML\s*=' "$FILE_PATH" 2>/dev/null; then
56
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: innerHTML assignment — XSS vector"
57
+ fi
58
+ ;;
59
+ esac
60
+
61
+ # Python patterns
62
+ case "$FILE_PATH" in *.py)
63
+ if grep -qn 'pickle\.loads\|pickle\.load(' "$FILE_PATH" 2>/dev/null; then
64
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: pickle deserialization — arbitrary code execution"
65
+ fi
66
+ if grep -qn 'os\.system(' "$FILE_PATH" 2>/dev/null; then
67
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: os.system() — command injection risk, use subprocess"
68
+ fi
69
+ if grep -qn '__import__(' "$FILE_PATH" 2>/dev/null; then
70
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: __import__() — dynamic import risk"
71
+ fi
72
+ if grep -qn '\bexec(' "$FILE_PATH" 2>/dev/null; then
73
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: exec() — arbitrary code execution"
74
+ fi
75
+ ;;
76
+ esac
77
+
78
+ # Go patterns
79
+ case "$FILE_PATH" in *.go)
80
+ if grep -qn 'fmt\.Sprintf.*SELECT\|fmt\.Sprintf.*INSERT\|fmt\.Sprintf.*UPDATE\|fmt\.Sprintf.*DELETE' "$FILE_PATH" 2>/dev/null; then
81
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: fmt.Sprintf in SQL — use parameterized queries"
82
+ fi
83
+ # Weak hash for passwords
84
+ if grep -qn 'crypto/md5\|crypto/sha1' "$FILE_PATH" 2>/dev/null; then
85
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: weak hash (md5/sha1) — use bcrypt or argon2 for passwords"
86
+ fi
87
+ # Command injection
88
+ if grep -qn 'exec\.Command.*+\|exec\.CommandContext.*+' "$FILE_PATH" 2>/dev/null; then
89
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: exec.Command with concatenation — potential command injection"
90
+ fi
91
+ # text/template in HTTP context (XSS)
92
+ if grep -qn '"text/template"' "$FILE_PATH" 2>/dev/null; then
93
+ if grep -q 'http\.\|Handler\|handler\|router\|chi\.\|gin\.\|echo\.' "$FILE_PATH" 2>/dev/null; then
94
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: text/template in HTTP context — use html/template for XSS safety"
95
+ fi
96
+ fi
97
+ # HTTP server without timeouts
98
+ if grep -qn 'http\.ListenAndServe\b' "$FILE_PATH" 2>/dev/null; then
99
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: http.ListenAndServe without explicit timeouts — slowloris risk. Use http.Server{ReadTimeout, WriteTimeout}"
100
+ fi
101
+ ;;
102
+ esac
103
+
104
+ # GitHub Actions injection
105
+ case "$FILE_PATH" in .github/workflows/*.yml|.github/workflows/*.yaml)
106
+ if grep -qn '\${{.*github\.event' "$FILE_PATH" 2>/dev/null; then
107
+ WARNINGS="${WARNINGS}\n [SECURITY] $FILE_PATH: GitHub Actions expression injection risk"
108
+ fi
109
+ ;;
110
+ esac
111
+
112
+ # Output warnings
113
+ if [ -n "$WARNINGS" ]; then
114
+ echo -e "\nSecurity patterns detected:${WARNINGS}"
115
+ echo " Run /security-scan for deep analysis."
116
+ echo ""
117
+ fi
118
+
119
+ exit 0
@@ -0,0 +1,76 @@
1
+ #!/bin/bash
2
+ # session-context-restore.sh — SessionStart hook
3
+ # Restores last saved context at session start
4
+ # Includes: git state, task state, architectural decisions, review findings, discovered issues
5
+ # Output to stdout is injected into Claude's context
6
+
7
+ # Unified profile + disable check
8
+ SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
9
+ [ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
10
+ # shellcheck source=/dev/null
11
+ [ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
12
+
13
+ CONTEXT_FILE="$HOME/.config/claude-superkit/last-context.md"
14
+
15
+ if [ -f "$CONTEXT_FILE" ]; then
16
+ if [ "$(uname)" = "Darwin" ]; then
17
+ FILE_AGE=$(( $(date +%s) - $(stat -f %m "$CONTEXT_FILE") ))
18
+ else
19
+ FILE_AGE=$(( $(date +%s) - $(stat -c %Y "$CONTEXT_FILE") ))
20
+ fi
21
+
22
+ if [ "$FILE_AGE" -lt 86400 ]; then
23
+ # Validate context file is readable
24
+ if [ ! -s "$CONTEXT_FILE" ]; then
25
+ echo "<previous-session-context>"
26
+ echo "WARNING: Previous context file is empty or corrupted. Starting fresh."
27
+ echo "</previous-session-context>"
28
+ else
29
+ echo "<previous-session-context>"
30
+ cat "$CONTEXT_FILE"
31
+ echo "</previous-session-context>"
32
+ fi
33
+
34
+ # Inject task state if present in project
35
+ if [ -f ".claude/.task-state.json" ]; then
36
+ # Validate JSON
37
+ if node -e "JSON.parse(require('fs').readFileSync('.claude/.task-state.json','utf8'))" 2>/dev/null; then
38
+ echo ""
39
+ echo "<task-state>"
40
+ cat .claude/.task-state.json
41
+ echo "</task-state>"
42
+ else
43
+ echo ""
44
+ echo "<task-state>"
45
+ echo "WARNING: .task-state.json is invalid JSON. Ignoring."
46
+ echo "</task-state>"
47
+ fi
48
+ fi
49
+
50
+ # Inject active plan if present
51
+ if [ -f ".claude/.active-plan.md" ]; then
52
+ echo ""
53
+ echo "<active-plan>"
54
+ head -50 ".claude/.active-plan.md" 2>/dev/null
55
+ echo "</active-plan>"
56
+ fi
57
+
58
+ # Inject discovered issues if present
59
+ if [ -f ".claude/.discovered-issues.md" ]; then
60
+ echo ""
61
+ echo "<discovered-issues>"
62
+ cat ".claude/.discovered-issues.md" 2>/dev/null
63
+ echo "</discovered-issues>"
64
+ fi
65
+
66
+ # Inject last review findings if present
67
+ if [ -f ".claude/.last-review.md" ]; then
68
+ echo ""
69
+ echo "<last-review-findings>"
70
+ cat ".claude/.last-review.md" 2>/dev/null
71
+ echo "</last-review-findings>"
72
+ fi
73
+ fi
74
+ fi
75
+
76
+ exit 0