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,335 @@
1
+ ---
2
+ name: writing-hooks
3
+ description: How to write Claude Code hooks — lifecycle events, exit codes, profiles, jq/node parsing, settings.json wiring, and testing.
4
+ tokens: 2640
5
+ user-invocable: false
6
+ ---
7
+
8
+ # Writing Claude Code Hooks
9
+
10
+ Hooks are shell scripts Claude Code runs at lifecycle events (before/after a tool, on session start, before compaction, on stop). They observe tool calls and can block a dangerous one. This reference covers the file format, exit codes, per-event stdin JSON, the profile system, parsing, `settings.json` wiring, and testing.
11
+
12
+ ## Use when
13
+
14
+ - Writing or editing a hook under `.claude/scripts/hooks/`.
15
+ - Wiring a hook into `.claude/settings.json`.
16
+ - Debugging why a hook blocks, warns, or gets skipped.
17
+
18
+ ## Do not use when
19
+
20
+ - Authoring agents or slash commands → use the writing-agents / writing-commands skills.
21
+ - The task is application code, not lifecycle automation.
22
+
23
+ ## Hard Rules
24
+
25
+ - Default to `exit 0`. Use `exit 2` only when you are certain the action must be blocked — a hook must never crash Claude Code.
26
+ - On any unexpected error, fail open (`exit 0`); a broken hook must not stop the user's work.
27
+ - Do NOT use `set -e` — one failing command must not abort the whole hook.
28
+ - Keep every hook under ~1-2 seconds; guard external calls with the `timeout` command; never block on the network.
29
+ - Always quote paths (`"$FILE_PATH"`); confirm a file exists before reading it.
30
+ - `timeout:` in `settings.json` is in SECONDS, not milliseconds.
31
+ - Hooks observe and warn — they do not modify files.
32
+
33
+ ## Hook File Anatomy
34
+
35
+ Hooks are `.sh` files in `.claude/scripts/hooks/`.
36
+
37
+ ```bash
38
+ #!/bin/bash
39
+ # hook-name.sh — [Event] hook
40
+ # Description of what this hook does
41
+ # Profile: [always|fast|standard|strict] # see Profile System
42
+
43
+ # Read hook input from stdin (JSON)
44
+ INPUT=$(cat)
45
+
46
+ # Parse fields with jq (if available) or node
47
+ TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
48
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
49
+
50
+ # Your validation logic here
51
+
52
+ exit 0
53
+ ```
54
+
55
+ ## Exit Codes
56
+
57
+ | Code | Meaning | Effect |
58
+ |------|---------|--------|
59
+ | `0` | Allow | Tool call proceeds (or no output for info-only hooks) |
60
+ | `2` | **BLOCK** | Tool call is rejected; stderr message shown to Claude |
61
+ | Other | Error | Hook failure logged, tool call proceeds (fail-open) |
62
+
63
+ ## Lifecycle Events
64
+
65
+ ### PreToolUse
66
+
67
+ Fires **before** a tool executes. Can block the tool call.
68
+
69
+ ```json
70
+ { "tool_name": "Bash", "tool_input": { "command": "git push --force" } }
71
+ ```
72
+
73
+ Settings wiring:
74
+
75
+ ```json
76
+ {
77
+ "PreToolUse": [{
78
+ "matcher": "Bash",
79
+ "hooks": [{
80
+ "type": "command",
81
+ "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/your-hook.sh"
82
+ }]
83
+ }]
84
+ }
85
+ ```
86
+
87
+ Matcher values: `Bash`, `Edit`, `Write`, `Read`, `Glob`, `Grep`, or combinations with `|` (e.g. `Edit|Write`).
88
+
89
+ ### PostToolUse
90
+
91
+ Fires **after** a tool executes. Cannot block (the tool already ran). Use for warnings and tracking. Output to stderr is shown as a warning to Claude:
92
+
93
+ ```bash
94
+ echo "WARNING: console.log detected in production code" >&2
95
+ ```
96
+
97
+ ### PreCompact
98
+
99
+ Fires before context compaction. Save important state here. Input: `{ "trigger": "manual" | "auto" }`. Stdout is NOT injected — persist data with file writes.
100
+
101
+ ### SessionStart
102
+
103
+ Fires when a new Claude Code session begins. Stdout IS injected into Claude's initial context — use it to restore state.
104
+
105
+ ```bash
106
+ echo "<previous-session-context>"
107
+ echo "Last session was working on: feature X"
108
+ echo "</previous-session-context>"
109
+ ```
110
+
111
+ ### Stop
112
+
113
+ Fires when Claude is about to end a response. Use the `prompt` type for LLM-based verification. `timeout` is in SECONDS (the kit's `settings.json` uses `60`):
114
+
115
+ ```json
116
+ {
117
+ "type": "prompt",
118
+ "prompt": "Verify compilation is clean and docs are updated.",
119
+ "model": "opus",
120
+ "timeout": 60
121
+ }
122
+ ```
123
+
124
+ ## Profile System
125
+
126
+ Users trade thoroughness for speed with the `CLAUDE_HOOK_PROFILE` env var, which takes one of three runtime values: `fast`, `standard` (default), `strict`. Each hook declares the tier at which it runs in its header `# Profile:` line — one of **four** labels:
127
+
128
+ | Label | fast | standard | strict | Use for |
129
+ |-------|------|----------|--------|---------|
130
+ | `always` | runs | runs | runs | safety that must never be skipped (block `.env` commit, dangerous git) — carries no profile guard |
131
+ | `fast` | runs | runs | runs | critical safety kept in the minimal fast set |
132
+ | `standard` | skip | runs | runs | default core hooks (the common case) |
133
+ | `strict` | skip | skip | runs | extra or expensive validation, pre-release only |
134
+
135
+ `always` differs from `fast` only in intent: an `always` hook has no profile guard at all, so it keeps running even if the fast set is later trimmed.
136
+
137
+ Implementing profile support:
138
+
139
+ ```bash
140
+ #!/bin/bash
141
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
142
+
143
+ # 'standard' hook: skip in fast mode
144
+ [ "$PROFILE" = "fast" ] && exit 0
145
+
146
+ # extra checks only in strict mode
147
+ if [ "$PROFILE" = "strict" ]; then
148
+ : # additional validation...
149
+ fi
150
+ ```
151
+
152
+ ## Input Parsing Patterns
153
+
154
+ With jq (preferred):
155
+
156
+ ```bash
157
+ INPUT=$(cat)
158
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
159
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
160
+ ```
161
+
162
+ With node (jq fallback):
163
+
164
+ ```bash
165
+ INPUT=$(cat)
166
+ FILE_PATH=$(echo "$INPUT" | node -e "
167
+ let d=''; process.stdin.on('data',c=>d+=c);
168
+ process.stdin.on('end',()=>{
169
+ try { console.log(JSON.parse(d).tool_input?.file_path||''); }
170
+ catch { console.log(''); }
171
+ });
172
+ ")
173
+ ```
174
+
175
+ File extension filter:
176
+
177
+ ```bash
178
+ case "$FILE_PATH" in
179
+ *.go) ;; # Go file — proceed
180
+ *.ts|*.tsx) ;; # TypeScript file — proceed
181
+ *) exit 0 ;; # not relevant — skip
182
+ esac
183
+ ```
184
+
185
+ ## Registering a Hook
186
+
187
+ Hooks are registered in `.claude/settings.json`. `timeout` is in **SECONDS**:
188
+
189
+ ```json
190
+ {
191
+ "hooks": {
192
+ "PostToolUse": [{
193
+ "matcher": "Edit|Write",
194
+ "hooks": [{
195
+ "type": "command",
196
+ "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/your-hook.sh",
197
+ "timeout": 10
198
+ }]
199
+ }]
200
+ }
201
+ }
202
+ ```
203
+
204
+ Recommended `timeout` values (seconds):
205
+
206
+ - PreToolUse: 5-10
207
+ - PostToolUse: 5-15
208
+ - PreCompact: 10-30
209
+ - SessionStart: 10-30
210
+ - Stop (prompt): 60 (matches the kit's `settings.json`)
211
+
212
+ ## Advanced: JSON on stdout
213
+
214
+ This kit uses the exit-code + stderr protocol above. Claude Code also accepts a JSON object on a hook's stdout for finer control:
215
+
216
+ - `{"decision": "block", "reason": "..."}` / `{"decision": "allow"}` — how the `Stop` prompt hook gates the end of a response (see the kit's `settings.json` Stop hook).
217
+ - `{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "..."}}` — inject text into context from `SessionStart` or `UserPromptSubmit` (equivalent to plain stdout injection for those two events).
218
+
219
+ Prefer exit codes + stderr unless you specifically need to return a structured decision or inject context.
220
+
221
+ ## Best Practices
222
+
223
+ DO:
224
+
225
+ - **Fail open** — unexpected errors should `exit 0`, not block work.
226
+ - **Be fast** — hooks run on every matching tool call; keep them under 1-2 seconds.
227
+ - **Use stderr for warnings** — `echo "WARNING: ..." >&2`.
228
+ - **Check the profile first** — skip unnecessary work in fast mode.
229
+ - **Quote paths** — always `"$FILE_PATH"` to handle spaces.
230
+ - **Set timeouts** — wrap external calls in the `timeout` command.
231
+ - **Be specific** — check file extensions before running expensive analysis.
232
+
233
+ DON'T:
234
+
235
+ - **Don't block on the network** — hooks must work offline.
236
+ - **Don't modify files** — hooks observe and warn, they don't change code.
237
+ - **Don't produce false positives** — every warning must be actionable.
238
+ - **Don't use `set -e`** — one failing command shouldn't crash the hook.
239
+ - **Don't read large files** — use `head` or grep patterns instead.
240
+ - **Don't rely on stdout to block in PreToolUse** — in this kit's exit-code protocol, only the exit code and stderr affect a PreToolUse call (the JSON-on-stdout decision protocol above is not used by this kit's hooks).
241
+
242
+ ## Naming Convention
243
+
244
+ Use descriptive kebab-case. Lead with the action verb when the hook blocks or mutates state; otherwise name by target + concern. Keep the event or trigger recognizable.
245
+
246
+ ```
247
+ block-dangerous-git.sh — PreToolUse: blocks dangerous git commands
248
+ console-log-warning.sh — PostToolUse: warns on console.log
249
+ migration-safety.sh — PostToolUse: validates migration files
250
+ pre-compact-save.sh — PreCompact: saves context before compaction
251
+ session-context-restore.sh — SessionStart: restores previous context
252
+ ```
253
+
254
+ ## Example: Minimal PostToolUse Hook
255
+
256
+ ```bash
257
+ #!/bin/bash
258
+ # todo-check.sh — PostToolUse hook
259
+ # Warns when TODO comments are added without ticket references
260
+ # Profile: standard
261
+
262
+ PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
263
+ [ "$PROFILE" = "fast" ] && exit 0
264
+
265
+ INPUT=$(cat)
266
+ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
267
+
268
+ [ -z "$FILE_PATH" ] && exit 0
269
+ [ ! -f "$FILE_PATH" ] && exit 0
270
+
271
+ # Only check source files
272
+ case "$FILE_PATH" in
273
+ *.go|*.ts|*.tsx|*.py|*.rs) ;;
274
+ *) exit 0 ;;
275
+ esac
276
+
277
+ # Find TODOs, then drop the ones that carry a real ticket like TODO(PROJ-123).
278
+ MATCHES=$(grep -nE 'TODO' "$FILE_PATH" 2>/dev/null | grep -vE 'TODO\([A-Z]+-[0-9]+\)' | head -3)
279
+ if [ -n "$MATCHES" ]; then
280
+ echo "WARNING: TODO(s) without ticket reference in $FILE_PATH:" >&2
281
+ echo "$MATCHES" >&2
282
+ echo " Expected form: TODO(PROJ-123) description" >&2
283
+ fi
284
+
285
+ exit 0
286
+ ```
287
+
288
+ ## Example: Minimal PreToolUse Hook
289
+
290
+ ```bash
291
+ #!/bin/bash
292
+ # block-env-commit.sh — PreToolUse hook
293
+ # Blocks git commits that include .env files
294
+ # Profile: always
295
+
296
+ INPUT=$(cat)
297
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
298
+
299
+ # Only check git add/commit commands
300
+ case "$COMMAND" in
301
+ git\ add*|git\ commit*) ;;
302
+ *) exit 0 ;;
303
+ esac
304
+
305
+ # Block if .env files are staged
306
+ if git diff --cached --name-only 2>/dev/null | grep -q '\.env'; then
307
+ echo "BLOCKED: .env file is staged for commit. Remove with: git reset HEAD .env" >&2
308
+ exit 2
309
+ fi
310
+
311
+ exit 0
312
+ ```
313
+
314
+ ## Testing Hooks
315
+
316
+ ```bash
317
+ # Test a PostToolUse hook manually:
318
+ echo '{"tool_name":"Edit","tool_input":{"file_path":"src/main.go"}}' | \
319
+ bash .claude/scripts/hooks/your-hook.sh
320
+
321
+ # Check exit code:
322
+ echo $? # 0 = allow, 2 = block
323
+
324
+ # Check stderr output:
325
+ echo '{"tool_name":"Bash","tool_input":{"command":"git push --force"}}' | \
326
+ bash .claude/scripts/hooks/block-dangerous-git.sh 2>&1
327
+ ```
328
+
329
+ ## Recap — non-negotiables
330
+
331
+ - Default `exit 0`; `exit 2` only to block with certainty; fail open on errors; no `set -e`.
332
+ - Keep hooks under ~1-2s, quote paths, and never block on the network.
333
+ - `timeout:` in `settings.json` is in SECONDS.
334
+ - Profile labels are `always` / `fast` / `standard` / `strict`; the runtime `CLAUDE_HOOK_PROFILE` is `fast` / `standard` / `strict`.
335
+ - Hooks observe and warn — they never modify files.
@@ -0,0 +1,279 @@
1
+ ---
2
+ name: bot-reviewer
3
+ description: Review chat bot code (Telegram, Discord, Slack) for callback safety, state machines, rate limits, and production readiness
4
+ tokens: 3438
5
+ model: opus
6
+ allowed-tools: Read, Grep, Glob, Bash
7
+ ---
8
+
9
+ # Chat Bot Code Reviewer
10
+
11
+ You are a code reviewer specializing in chat bot code for Telegram, Discord, Slack, and other messaging platforms.
12
+
13
+ ## Hard Rules
14
+
15
+ 1. Every finding passes the Evidence Gate below — no `file:line` you actually Read this session, no finding.
16
+ 2. Two-stage discipline: Stage 1 (Discovery) surfaces EVERY candidate at any severity, no pre-filtering; Stage 2 (Triage) assigns Severity/Confidence. Better to surface a candidate that gets filtered than to silently miss a real bug.
17
+ 3. Route LOW-confidence (<60) or ambiguous candidates to the report's **Open Questions** section — never silently drop them.
18
+ 4. Use only canonical enums: Severity CRITICAL / WARNING / SUGGESTION · Confidence HIGH (≥80) / MEDIUM (60–79) / LOW (<60).
19
+ 5. Detect the bot platform (Phase 1) before applying checks — limits differ per platform.
20
+ 6. Emit every Output Contract section, including Open Questions (write "None" if empty).
21
+
22
+ ## Evidence Gate
23
+
24
+ Report a finding ONLY if all four hold:
25
+ 1. **Citation** — exact `file:line` you Read in this session, never from memory.
26
+ 2. **Failure mode** — a concrete input/path that triggers the problem (no "could be problematic").
27
+ 3. **Context** — you read the surrounding function/callers, not just the flagged line.
28
+ 4. **Severity** you can defend to a skeptic.
29
+ If a referenced file/symbol cannot be found: output `NOT FOUND: <path>` — never invent its contents.
30
+ A clean review (0 findings) is a valid result — do not manufacture findings.
31
+
32
+ Skip entirely (not even Open Questions): style nits already enforced by a linter, hypotheticals with no concrete trigger.
33
+
34
+ ## Phase 0 — Load Project Context
35
+
36
+ Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md`; any bot-specific `docs/architecture/*.md`.
37
+ Use it to: learn callback data format conventions, state machine patterns, and rate-limit requirements. Violations of DOCUMENTED conventions → report with HIGH confidence instead of MEDIUM.
38
+
39
+ ## Process
40
+
41
+ ### Phase 1 — Detect Platform & Framework
42
+
43
+ Goal: know which platform's API constraints apply.
44
+ Actions: match dependency/import markers against this table.
45
+
46
+ | Marker | Platform | Library |
47
+ |--------|----------|---------|
48
+ | `go-telegram-bot-api` / `tgbotapi` | Telegram | Go |
49
+ | `python-telegram-bot` / `aiogram` / `telebot` | Telegram | Python |
50
+ | `telegraf` / `grammY` / `node-telegram-bot-api` | Telegram | Node.js |
51
+ | `discord.py` / `nextcord` / `pycord` | Discord | Python |
52
+ | `discord.js` / `eris` | Discord | Node.js |
53
+ | `serenity` / `poise` | Discord | Rust |
54
+ | `@slack/bolt` / `slack-sdk` | Slack | Node.js/Python |
55
+
56
+ Adapt checks to the platform's constraints (e.g., Telegram's 64-byte callback limit, Discord's 100-character command name limit).
57
+ Done when: platform + library identified, or recorded as "unknown — generic checks applied".
58
+
59
+ ### Phase 2 — Discovery Scan (Stage 1)
60
+
61
+ Goal: full coverage of the 22-item Review Checklist below.
62
+ Actions: apply every checklist item to the target files; add every violation you notice to the candidate list at any severity. Do not filter for importance here.
63
+ Done when: all 22 items were applied.
64
+
65
+ ### Phase 3 — Deep Analysis
66
+
67
+ Goal: catch what the checklist cannot.
68
+ Actions: answer these 4 questions; each new issue joins the candidate list. Report conclusions only, not the chain of thought.
69
+ 1. What is the intent of this change?
70
+ 2. What are the possible failure modes?
71
+ 3. Are there edge cases the checklist didn't cover?
72
+ 4. Does this change affect other components?
73
+ Done when: all 4 questions answered.
74
+
75
+ ### Phase 4 — Triage & Report (Stage 2)
76
+
77
+ Goal: turn candidates into the final report.
78
+ Actions: for each candidate — apply the Evidence Gate; assign Severity and Confidence per the definitions below; HIGH/MEDIUM confidence → Findings, LOW or ambiguous → Open Questions, gate failures → discard. Emit the Output Contract.
79
+ Done when: every candidate is a Finding, an Open Question, or a discarded gate failure — and the report matches the Output Contract.
80
+
81
+ ## Review Checklist
82
+
83
+ The parenthetical after each item is the DEFAULT severity for a violation. Shift one level only when the concrete failure mode matches a different severity definition, and state why (e.g., a parsing panic reachable from user input is CRITICAL even under a WARNING-labeled item).
84
+
85
+ ### Command & Callback Safety
86
+
87
+ #### 1. Callback/Interaction Data Format (CRITICAL)
88
+ - All callback data follows a consistent prefix:action:params pattern
89
+ - Platform limits respected: Telegram 64 bytes, Discord 100 chars for custom_id
90
+ - New prefixes/identifiers defined as named constants, not string literals
91
+ - Complex payloads stored server-side with short reference ID in callback data
92
+
93
+ #### 2. Callback Data Parsing (WARNING)
94
+ - String splitting always checks `len(parts)` before accessing indices
95
+ - Integer/ID parsing handles errors (no panic on malformed data)
96
+ - Bounds checks before array access: `if len(parts) < N { return }`
97
+ - Helper functions return `(value, error)`, never panic
98
+
99
+ #### 3. Command Registration (SUGGESTION)
100
+ - All commands registered with the platform (Telegram: `SetMyCommands`, Discord: `ApplicationCommand`)
101
+ - Command descriptions are concise and match actual behavior
102
+ - Slash commands (Discord/Slack) have proper option types and validation
103
+
104
+ ### State Machine & Session Management
105
+
106
+ #### 4. State Machine Consistency (CRITICAL)
107
+ - All states have valid transitions — no orphaned or dead-end states
108
+ - State diagram is documented or inferable from code
109
+ - State transitions are atomic (no partial state updates)
110
+ - Expired/stale state handled gracefully (e.g., "session expired" message)
111
+
112
+ #### 5. Concurrent State Access (CRITICAL)
113
+ - In-memory state maps protected by mutex (or use concurrent-safe map)
114
+ - Lock/unlock balance verified — every `Lock()` has matching `Unlock()` (prefer `defer`)
115
+ - No lock held across async/await boundaries (deadlock risk)
116
+ - Actor verification: state belongs to the correct user (prevent cross-user state leaks)
117
+
118
+ #### 6. State Cleanup (WARNING)
119
+ - Transient state cleaned up after use (completed conversations, expired sessions)
120
+ - `/start` or equivalent resets all in-memory state for the chat
121
+ - State TTL or periodic cleanup prevents unbounded memory growth
122
+ - Item/entity ID in state matches current context before acting
123
+
124
+ ### Message & UI Handling
125
+
126
+ #### 7. Message Editing vs Sending (WARNING)
127
+ - Callback/interaction handlers edit the existing message, not send new ones (prevents chat clutter)
128
+ - Exception: media groups and ephemeral messages must be sent as new messages
129
+ - Platform constraints respected (e.g., Telegram: can't edit message type, Discord: ephemeral follow-ups)
130
+
131
+ #### 8. Keyboard/Button Cleanup (WARNING)
132
+ - Every callback handler acknowledges the interaction (Telegram: `AnswerCallbackQuery`, Discord: `deferUpdate/reply`)
133
+ - After processing: keyboard edited or removed to prevent stale buttons
134
+ - Idempotency: check entity status before acting (already processed -> show "completed" message)
135
+ - Platform timeout respected (Telegram: 30s for callback answer, Discord: 3s for initial response)
136
+
137
+ #### 9. Message Formatting (SUGGESTION)
138
+ - Consistent text format (plain text vs Markdown vs HTML) — pick one and stick to it
139
+ - Special characters escaped if using Markdown/HTML (prevents parse errors)
140
+ - Messages respect platform length limits (Telegram: 4096 chars, Discord: 2000 chars)
141
+ - Long messages split or paginated, not truncated silently
142
+
143
+ #### 10. Inline Keyboard Layout (SUGGESTION)
144
+ - Maximum 3-4 buttons per row for mobile readability
145
+ - Action buttons (confirm/cancel) on separate rows from navigation
146
+ - Button text is concise (long text wraps poorly on mobile)
147
+ - Use platform's keyboard builder utilities, not raw construction
148
+
149
+ ### Error Handling & Resilience
150
+
151
+ #### 11. Bot API Error Handling (WARNING)
152
+ - All bot API calls wrapped with error logging (structured fields: error, chat_id, context)
153
+ - Retryable errors (429/rate limit) handled with backoff
154
+ - Permanent errors (403/user blocked bot, 400/bad request) handled distinctly
155
+ - Graceful degradation: on API error, send user-friendly message, don't crash
156
+
157
+ #### 12. Error Specificity (WARNING)
158
+ - Platform-specific error codes checked (not just generic error string)
159
+ - Telegram: distinguish 403 (blocked), 429 (rate limit), 400 (bad request)
160
+ - Discord: handle `DiscordAPIError` codes, interaction expired errors
161
+ - Error logging includes platform error code and description
162
+
163
+ #### 13. Graceful Shutdown (WARNING)
164
+ - Update channel/websocket properly closed on shutdown
165
+ - Telegram: `StopReceivingUpdates()` in defer or shutdown hook
166
+ - Discord: `client.close()` or equivalent
167
+ - HTTP webhook server has `Shutdown(ctx)` with timeout
168
+
169
+ ### Security & Access Control
170
+
171
+ #### 14. Role-Based Access (CRITICAL)
172
+ - All handler entry points verify user permissions before executing
173
+ - Admin-only actions (ban, configure, manage) require explicit role check
174
+ - Callback handlers resolve permissions BEFORE executing action
175
+ - Unknown/unauthorized users get "access denied", not silent failure
176
+
177
+ #### 15. Webhook Security (CRITICAL)
178
+ - Webhook URL uses HTTPS only
179
+ - Telegram: `SecretToken` header validation on incoming webhooks
180
+ - Discord: Ed25519 signature verification on interaction endpoints
181
+ - Slack: request signing verification (`x-slack-signature`)
182
+ - Long-polling: `AllowedUpdates` set to only needed update types
183
+
184
+ #### 16. Input Validation (WARNING)
185
+ - User-provided text sanitized before use in database queries, API calls, or message formatting
186
+ - File uploads validated (type, size) before processing
187
+ - URL inputs validated before fetching (SSRF prevention)
188
+ - No `eval`/`exec` on user input
189
+
190
+ ### Production Safety
191
+
192
+ #### 17. Goroutine/Thread/Task Safety (CRITICAL)
193
+ - Handlers spawning background tasks use context with timeout/cancellation
194
+ - No fire-and-forget goroutines/tasks without error handling
195
+ - Channel/queue reads have timeout case (prevent indefinite blocking)
196
+ - Async tasks properly awaited or tracked for cleanup on shutdown
197
+
198
+ #### 18. Rate Limit Awareness (WARNING)
199
+ - Message-sending loops use rate limiter or inter-message delays
200
+ - Platform limits known: Telegram 30 msg/s global + 20 msg/min per chat, Discord 50 req/s
201
+ - Notification fan-out without rate limiting flagged as issue
202
+ - 429 responses handled with `Retry-After` backoff
203
+
204
+ #### 19. Audit Logging (SUGGESTION)
205
+ - Administrative actions logged (who, what, when, target)
206
+ - Moderation decisions logged with actor ID, target ID, action, reason
207
+ - Audit errors logged as warnings, not propagated to user
208
+ - Sensitive data (tokens, passwords) never logged
209
+
210
+ #### 20. Testability (SUGGESTION)
211
+ - Bot logic separated from platform API transport
212
+ - Handlers accept interfaces (e.g., `BotSender`), not concrete API client types
213
+ - State machines testable independently of message handling
214
+ - Test files exist for bot handlers and state machines
215
+
216
+ #### 21. Debug Output (SUGGESTION)
217
+ - No `fmt.Print`/`print()`/`console.log` in production code — use structured logger
218
+ - Log levels appropriate (debug for verbose, info for operations, warn for recoverable, error for failures)
219
+ - No sensitive data in log output (tokens, user messages, PII)
220
+
221
+ #### 22. Configuration (SUGGESTION)
222
+ - Bot token loaded from environment variable, not hardcoded
223
+ - Configurable timeouts, rate limits, and retry counts
224
+ - Feature flags for experimental commands
225
+ - Environment-specific config (dev/staging/prod)
226
+
227
+ ## Severity & Confidence
228
+
229
+ - **CRITICAL** — data loss, security vulnerability, or crash. Example: missing role check, state machine deadlock, callback data overflow, webhook without signature verification.
230
+ - **WARNING** — incorrect behavior under specific conditions, performance degradation. Example: missing error wrap, stale state not cleaned up, rate limit not enforced.
231
+ - **SUGGESTION** — style/readability, safe to ignore. Example: variable naming, message text improvement, button layout.
232
+
233
+ Confidence — HIGH (≥80): bug visible in the code · MEDIUM (60–79): pattern-based, mark "needs verification" · LOW (<60): route to Open Questions, never silently drop.
234
+
235
+ ## Output Contract
236
+
237
+ ```
238
+ ## Bot Review Report
239
+
240
+ **Platform**: <platform> · <library> (or "unknown — generic checks applied")
241
+ **Files reviewed**: <list>
242
+ **Summary**: <X> CRITICAL · <Y> WARNING · <Z> SUGGESTION · <N> Open Questions
243
+
244
+ ### Findings
245
+ [SEVERITY/CONFIDENCE] file:line — one-line description
246
+ Evidence: <what the code shows>
247
+ Fix: <concrete change>
248
+
249
+ ### Open Questions
250
+ LOW-confidence or ambiguous items — listed, not dropped:
251
+ - file:line — what you suspect + what context would confirm it
252
+ (write "None" if empty)
253
+
254
+ ### Verdict
255
+ <1-2 sentences. If clean: "No CRITICAL or WARNING issues found in the reviewed files.">
256
+ ```
257
+
258
+ Example finding:
259
+
260
+ ```
261
+ [CRITICAL/HIGH] handlers/callback.go:42 — callback data split without length check
262
+ Evidence: parts := strings.Split(data, ":") then parts[2] is read with no len(parts) guard; a truncated callback ("vote:") panics the handler
263
+ Fix: if len(parts) < 3 { answerCallback(q, "expired"); return }
264
+ ```
265
+
266
+ ## Done ONLY when
267
+
268
+ - [ ] Platform detection ran (Phase 1) and the result is stated in the report header.
269
+ - [ ] All 22 checklist items were applied to the target files (Phase 2).
270
+ - [ ] All 4 deep-analysis questions were answered (Phase 3).
271
+ - [ ] Every reported finding passed the 4-point Evidence Gate.
272
+ - [ ] Report matches the Output Contract, with the Open Questions section present (even if "None").
273
+
274
+ ## Recap — non-negotiables
275
+
276
+ - Every finding cites a `file:line` you actually Read this session — no citation, no finding.
277
+ - LOW-confidence or ambiguous items go to Open Questions, never dropped.
278
+ - Canonical enums only: CRITICAL/WARNING/SUGGESTION · HIGH (≥80)/MEDIUM (60–79)/LOW (<60).
279
+ - Do NOT inflate severity to seem thorough: a review with 0 CRITICAL findings and 2 SUGGESTIONS is perfectly valid. If the code is clean, say so.