contextdevkit 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/CHANGELOG.md +592 -0
  2. package/LICENSE +21 -0
  3. package/README.md +401 -0
  4. package/docs/AGENT-PACKAGE-FORMAT.md +140 -0
  5. package/docs/ARCHITECTURE.md +258 -0
  6. package/docs/CHANGELOG.md +559 -0
  7. package/docs/CUSTOMIZING.md +211 -0
  8. package/docs/LEVELS.md +151 -0
  9. package/docs/ROADMAP.md +385 -0
  10. package/docs/SQUAD-PIPELINE-FORMAT.md +258 -0
  11. package/docs/SQUADS/agent-forge.md +65 -0
  12. package/docs/SQUADS/design-team.md +161 -0
  13. package/docs/token-economy-plan.md +135 -0
  14. package/install.mjs +273 -0
  15. package/instrucoes.md +274 -0
  16. package/package.json +46 -0
  17. package/templates/CLAUDE.md.tpl +133 -0
  18. package/templates/claude/agents/_TEMPLATE.md +52 -0
  19. package/templates/claude/agents/accessibility.md +36 -0
  20. package/templates/claude/agents/agent-architect.md +37 -0
  21. package/templates/claude/agents/architect.md +39 -0
  22. package/templates/claude/agents/code-reviewer.md +43 -0
  23. package/templates/claude/agents/code-security.md +59 -0
  24. package/templates/claude/agents/context-keeper.md +40 -0
  25. package/templates/claude/agents/devops.md +40 -0
  26. package/templates/claude/agents/eval-designer.md +40 -0
  27. package/templates/claude/agents/forge-orchestrator.md +42 -0
  28. package/templates/claude/agents/governance-officer.md +45 -0
  29. package/templates/claude/agents/growth.md +92 -0
  30. package/templates/claude/agents/infra-security.md +53 -0
  31. package/templates/claude/agents/landing-architect.md +154 -0
  32. package/templates/claude/agents/model-router.md +34 -0
  33. package/templates/claude/agents/packager.md +38 -0
  34. package/templates/claude/agents/privacy-lgpd.md +64 -0
  35. package/templates/claude/agents/product-owner.md +51 -0
  36. package/templates/claude/agents/prompt-engineer.md +33 -0
  37. package/templates/claude/agents/qa-e2e.md +52 -0
  38. package/templates/claude/agents/qa-fuzzer.md +24 -0
  39. package/templates/claude/agents/qa-integration.md +21 -0
  40. package/templates/claude/agents/qa-orchestrator.md +40 -0
  41. package/templates/claude/agents/qa-perf.md +40 -0
  42. package/templates/claude/agents/qa-unit.md +39 -0
  43. package/templates/claude/agents/rag-designer.md +54 -0
  44. package/templates/claude/agents/retention.md +85 -0
  45. package/templates/claude/agents/security.md +48 -0
  46. package/templates/claude/agents/seo-specialist.md +106 -0
  47. package/templates/claude/agents/test-engineer.md +48 -0
  48. package/templates/claude/agents/tool-designer.md +32 -0
  49. package/templates/claude/agents/ui-designer.md +37 -0
  50. package/templates/claude/agents/ux-designer.md +38 -0
  51. package/templates/claude/commands/README.md +95 -0
  52. package/templates/claude/commands/advise.md +80 -0
  53. package/templates/claude/commands/audit/analyze-code-ia-practices.md +75 -0
  54. package/templates/claude/commands/audit/audit.md +35 -0
  55. package/templates/claude/commands/audit/contract-check.md +21 -0
  56. package/templates/claude/commands/audit/deep-analysis.md +48 -0
  57. package/templates/claude/commands/audit/deps-audit.md +49 -0
  58. package/templates/claude/commands/audit/security-setup.md +35 -0
  59. package/templates/claude/commands/audit/seo-audit.md +63 -0
  60. package/templates/claude/commands/audit/tech-debt-sweep.md +35 -0
  61. package/templates/claude/commands/bug-hunt.md +42 -0
  62. package/templates/claude/commands/claude-md.md +36 -0
  63. package/templates/claude/commands/close-version.md +25 -0
  64. package/templates/claude/commands/context-refresh.md +19 -0
  65. package/templates/claude/commands/context-stats.md +15 -0
  66. package/templates/claude/commands/dashboard.md +66 -0
  67. package/templates/claude/commands/distill-apply.md +19 -0
  68. package/templates/claude/commands/distill-sessions.md +26 -0
  69. package/templates/claude/commands/fleet.md +47 -0
  70. package/templates/claude/commands/forge/forge-audit.md +16 -0
  71. package/templates/claude/commands/forge/forge-budget.md +16 -0
  72. package/templates/claude/commands/forge/forge-deprecate.md +16 -0
  73. package/templates/claude/commands/forge/forge-doctor.md +17 -0
  74. package/templates/claude/commands/forge/forge-eval.md +16 -0
  75. package/templates/claude/commands/forge/forge-fallback-test.md +17 -0
  76. package/templates/claude/commands/forge/forge-killswitch.md +17 -0
  77. package/templates/claude/commands/forge/forge-list.md +17 -0
  78. package/templates/claude/commands/forge/forge-new.md +41 -0
  79. package/templates/claude/commands/forge/forge-policy.md +16 -0
  80. package/templates/claude/commands/forge/forge-redteam.md +17 -0
  81. package/templates/claude/commands/forge/forge-refresh-matrix.md +20 -0
  82. package/templates/claude/commands/forge/forge-route.md +17 -0
  83. package/templates/claude/commands/forge/forge-show.md +16 -0
  84. package/templates/claude/commands/landing-page.md +71 -0
  85. package/templates/claude/commands/log-session.md +59 -0
  86. package/templates/claude/commands/media-gen.md +93 -0
  87. package/templates/claude/commands/new-adr.md +30 -0
  88. package/templates/claude/commands/pipeline/dev-start.md +64 -0
  89. package/templates/claude/commands/pipeline/pipeline.md +36 -0
  90. package/templates/claude/commands/pipeline/resume.md +70 -0
  91. package/templates/claude/commands/pipeline/retro.md +34 -0
  92. package/templates/claude/commands/pipeline/runs.md +63 -0
  93. package/templates/claude/commands/pipeline/ship.md +54 -0
  94. package/templates/claude/commands/pipeline/workflow.md +85 -0
  95. package/templates/claude/commands/playbook.md +27 -0
  96. package/templates/claude/commands/predictions-review.md +28 -0
  97. package/templates/claude/commands/qa/qa-signoff.md +24 -0
  98. package/templates/claude/commands/qa/scaffold-tests.md +27 -0
  99. package/templates/claude/commands/qa/test-plan.md +26 -0
  100. package/templates/claude/commands/qa/visual-test.md +42 -0
  101. package/templates/claude/commands/roadmap.md +48 -0
  102. package/templates/claude/commands/setup/aidevtool-from0.md +104 -0
  103. package/templates/claude/commands/setup/context-config.md +25 -0
  104. package/templates/claude/commands/setup/context-doctor.md +21 -0
  105. package/templates/claude/commands/setup/context-level.md +17 -0
  106. package/templates/claude/commands/setup/setupcontextdevkit.md +121 -0
  107. package/templates/claude/commands/simulate-impact.md +32 -0
  108. package/templates/claude/commands/squad.md +44 -0
  109. package/templates/claude/commands/state.md +21 -0
  110. package/templates/claude/commands/token-report.md +29 -0
  111. package/templates/claude/commands/tune-agents.md +35 -0
  112. package/templates/claude/commands/vcs/claim.md +18 -0
  113. package/templates/claude/commands/vcs/git.md +83 -0
  114. package/templates/claude/commands/vcs/release.md +15 -0
  115. package/templates/claude/commands/vcs/worktree-new.md +18 -0
  116. package/templates/claude/commands/watch.md +47 -0
  117. package/templates/contextkit/.env.example +36 -0
  118. package/templates/contextkit/CLAUDE.child.md.tpl +38 -0
  119. package/templates/contextkit/README.md +74 -0
  120. package/templates/contextkit/behaviors-examples.md +183 -0
  121. package/templates/contextkit/behaviors.md +116 -0
  122. package/templates/contextkit/best-practices.md +323 -0
  123. package/templates/contextkit/config.json +66 -0
  124. package/templates/contextkit/detectors/README.md +45 -0
  125. package/templates/contextkit/detectors/example-detector.mjs.example +25 -0
  126. package/templates/contextkit/instrucoes.md +114 -0
  127. package/templates/contextkit/memory/GLOSSARY.md +13 -0
  128. package/templates/contextkit/memory/SESSIONS.md +9 -0
  129. package/templates/contextkit/memory/WORKSPACE.md +7 -0
  130. package/templates/contextkit/memory/business-rules/_TEMPLATE.md +33 -0
  131. package/templates/contextkit/memory/decisions/0000-record-architecture-decisions.md +34 -0
  132. package/templates/contextkit/memory/decisions/_TEMPLATE.md +25 -0
  133. package/templates/contextkit/memory/predictions/.gitkeep +0 -0
  134. package/templates/contextkit/memory/roadmap.md +28 -0
  135. package/templates/contextkit/memory/sessions/.gitkeep +0 -0
  136. package/templates/contextkit/memory/workflows/.gitkeep +0 -0
  137. package/templates/contextkit/pipeline/backlog/.gitkeep +0 -0
  138. package/templates/contextkit/pipeline/conclusion/.gitkeep +0 -0
  139. package/templates/contextkit/pipeline/devpipeline.md +9 -0
  140. package/templates/contextkit/pipeline/testing/.gitkeep +0 -0
  141. package/templates/contextkit/pipeline/working/.gitkeep +0 -0
  142. package/templates/contextkit/review-protocol.md +214 -0
  143. package/templates/contextkit/runtime/config/defaults.mjs +215 -0
  144. package/templates/contextkit/runtime/config/levels.mjs +42 -0
  145. package/templates/contextkit/runtime/config/load.mjs +105 -0
  146. package/templates/contextkit/runtime/config/paths.mjs +92 -0
  147. package/templates/contextkit/runtime/config/presets.mjs +47 -0
  148. package/templates/contextkit/runtime/config/schema.mjs +88 -0
  149. package/templates/contextkit/runtime/config/settings-compose.mjs +55 -0
  150. package/templates/contextkit/runtime/git-hooks/commit-msg.mjs +55 -0
  151. package/templates/contextkit/runtime/git-hooks/pre-commit.mjs +47 -0
  152. package/templates/contextkit/runtime/git-hooks/pre-push.mjs +102 -0
  153. package/templates/contextkit/runtime/hooks/boot-context-readers.mjs +111 -0
  154. package/templates/contextkit/runtime/hooks/boot-signals.mjs +135 -0
  155. package/templates/contextkit/runtime/hooks/check-registration.mjs +228 -0
  156. package/templates/contextkit/runtime/hooks/concurrency-guard.mjs +110 -0
  157. package/templates/contextkit/runtime/hooks/ledger.mjs +231 -0
  158. package/templates/contextkit/runtime/hooks/md-extract.mjs +65 -0
  159. package/templates/contextkit/runtime/hooks/path-classification.mjs +62 -0
  160. package/templates/contextkit/runtime/hooks/safe-io.mjs +84 -0
  161. package/templates/contextkit/runtime/hooks/session-digest-core.mjs +85 -0
  162. package/templates/contextkit/runtime/hooks/session-start.mjs +248 -0
  163. package/templates/contextkit/runtime/hooks/simulate-gate.mjs +108 -0
  164. package/templates/contextkit/runtime/hooks/track-edits.mjs +154 -0
  165. package/templates/contextkit/runtime/providers/media/_adapter.mjs +120 -0
  166. package/templates/contextkit/runtime/providers/media/nano-banana.mjs +110 -0
  167. package/templates/contextkit/runtime/providers/media/veo.mjs +162 -0
  168. package/templates/contextkit/runtime/providers/review/_adapter.mjs +71 -0
  169. package/templates/contextkit/runtime/providers/review/detect.mjs +115 -0
  170. package/templates/contextkit/runtime/providers/review/gh.mjs +103 -0
  171. package/templates/contextkit/runtime/state/state-io.mjs +172 -0
  172. package/templates/contextkit/runtime/statusline.mjs +51 -0
  173. package/templates/contextkit/squads/README.md +115 -0
  174. package/templates/contextkit/squads/_BRIEFING.md.tpl +27 -0
  175. package/templates/contextkit/squads/agent-forge/README.md +69 -0
  176. package/templates/contextkit/squads/agent-forge/ROADMAP.md +108 -0
  177. package/templates/contextkit/squads/agent-forge/best-practices.md +89 -0
  178. package/templates/contextkit/squads/agent-forge/cli/forge-admin.mjs +132 -0
  179. package/templates/contextkit/squads/agent-forge/cli/forge-eval-cli.mjs +163 -0
  180. package/templates/contextkit/squads/agent-forge/cli/forge-new.mjs +97 -0
  181. package/templates/contextkit/squads/agent-forge/cli/forge-ops.mjs +177 -0
  182. package/templates/contextkit/squads/agent-forge/lib/architect.mjs +112 -0
  183. package/templates/contextkit/squads/agent-forge/lib/eval-designer.mjs +133 -0
  184. package/templates/contextkit/squads/agent-forge/lib/eval-runner.mjs +167 -0
  185. package/templates/contextkit/squads/agent-forge/lib/governance-officer.mjs +178 -0
  186. package/templates/contextkit/squads/agent-forge/lib/package-ops.mjs +101 -0
  187. package/templates/contextkit/squads/agent-forge/lib/packager.mjs +219 -0
  188. package/templates/contextkit/squads/agent-forge/lib/prompt-gen.mjs +122 -0
  189. package/templates/contextkit/squads/agent-forge/lib/rag-designer.mjs +102 -0
  190. package/templates/contextkit/squads/agent-forge/lib/router.mjs +165 -0
  191. package/templates/contextkit/squads/agent-forge/lib/tool-gen.mjs +113 -0
  192. package/templates/contextkit/squads/agent-forge/lib/yaml.mjs +47 -0
  193. package/templates/contextkit/squads/agent-forge/pipeline.yaml +65 -0
  194. package/templates/contextkit/squads/agent-forge/router/capability-matrix.json +112 -0
  195. package/templates/contextkit/squads/agent-forge/router/decision-rules.json +120 -0
  196. package/templates/contextkit/squads/agent-forge/templates/agent-package/.agentforgerc +12 -0
  197. package/templates/contextkit/squads/agent-forge/templates/agent-package/CHANGELOG.md +13 -0
  198. package/templates/contextkit/squads/agent-forge/templates/agent-package/LICENSE +5 -0
  199. package/templates/contextkit/squads/agent-forge/templates/agent-package/README.md +39 -0
  200. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/README.md +10 -0
  201. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/agent.go +14 -0
  202. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/go/go.mod +3 -0
  203. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/README.md +11 -0
  204. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/index.js +53 -0
  205. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/node/package.json +9 -0
  206. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/README.md +10 -0
  207. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/agent.py +16 -0
  208. package/templates/contextkit/squads/agent-forge/templates/agent-package/adapters/python/pyproject.toml +10 -0
  209. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/golden.jsonl +1 -0
  210. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/red-team.jsonl +3 -0
  211. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/rubric.yaml +14 -0
  212. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/run-eval.md +17 -0
  213. package/templates/contextkit/squads/agent-forge/templates/agent-package/evals/thresholds.yaml +18 -0
  214. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/basic.node.md +17 -0
  215. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-fallback.node.md +24 -0
  216. package/templates/contextkit/squads/agent-forge/templates/agent-package/examples/with-rag.python.md +20 -0
  217. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/audit.schema.json +23 -0
  218. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/compliance.policy.yaml +43 -0
  219. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/cost.policy.yaml +36 -0
  220. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/fallback-chain.yaml +16 -0
  221. package/templates/contextkit/squads/agent-forge/templates/agent-package/governance/quality.policy.yaml +43 -0
  222. package/templates/contextkit/squads/agent-forge/templates/agent-package/manifest.yaml +91 -0
  223. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.anthropic.md +19 -0
  224. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.canonical.md +25 -0
  225. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.deepseek.md +21 -0
  226. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.google.md +19 -0
  227. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.ollama.md +21 -0
  228. package/templates/contextkit/squads/agent-forge/templates/agent-package/prompts/system.openai.md +20 -0
  229. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/config.yaml +17 -0
  230. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/index/.gitkeep +3 -0
  231. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/chunker.config.yaml +6 -0
  232. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/ingestion/sources.yaml +8 -0
  233. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/query-template.md +16 -0
  234. package/templates/contextkit/squads/agent-forge/templates/agent-package/rag/retrieval/rerank.config.yaml +6 -0
  235. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/anthropic.tools.json +11 -0
  236. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/deepseek.tools.json +14 -0
  237. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/google.tools.json +11 -0
  238. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/ollama.tools.json +14 -0
  239. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/adapters/openai.tools.json +14 -0
  240. package/templates/contextkit/squads/agent-forge/templates/agent-package/tools/schemas.canonical.json +25 -0
  241. package/templates/contextkit/starters/tanstack/README.md +86 -0
  242. package/templates/contextkit/starters/tanstack/index.html +12 -0
  243. package/templates/contextkit/starters/tanstack/package.json +25 -0
  244. package/templates/contextkit/starters/tanstack/src/main.tsx +40 -0
  245. package/templates/contextkit/starters/tanstack/src/router.tsx +12 -0
  246. package/templates/contextkit/starters/tanstack/src/routes/__root.tsx +10 -0
  247. package/templates/contextkit/starters/tanstack/src/routes/index.tsx +17 -0
  248. package/templates/contextkit/starters/tanstack/tsconfig.json +19 -0
  249. package/templates/contextkit/starters/tanstack/vite.config.ts +10 -0
  250. package/templates/contextkit/tools/scripts/adr-digest-core.mjs +42 -0
  251. package/templates/contextkit/tools/scripts/adr-digest.mjs +78 -0
  252. package/templates/contextkit/tools/scripts/agent-tuning.mjs +74 -0
  253. package/templates/contextkit/tools/scripts/aiso-audit.mjs +174 -0
  254. package/templates/contextkit/tools/scripts/audit-shared.mjs +129 -0
  255. package/templates/contextkit/tools/scripts/claim.mjs +133 -0
  256. package/templates/contextkit/tools/scripts/claude-md.mjs +123 -0
  257. package/templates/contextkit/tools/scripts/clean-drive.mjs +78 -0
  258. package/templates/contextkit/tools/scripts/context-config.mjs +111 -0
  259. package/templates/contextkit/tools/scripts/context-level.mjs +98 -0
  260. package/templates/contextkit/tools/scripts/context-pack.mjs +120 -0
  261. package/templates/contextkit/tools/scripts/contract-scan.mjs +186 -0
  262. package/templates/contextkit/tools/scripts/dashboard-data.mjs +198 -0
  263. package/templates/contextkit/tools/scripts/dashboard-html.mjs +215 -0
  264. package/templates/contextkit/tools/scripts/dashboard-server.mjs +129 -0
  265. package/templates/contextkit/tools/scripts/dashboard.mjs +107 -0
  266. package/templates/contextkit/tools/scripts/deep-analysis.mjs +62 -0
  267. package/templates/contextkit/tools/scripts/deps-audit.mjs +201 -0
  268. package/templates/contextkit/tools/scripts/detect-stack.mjs +164 -0
  269. package/templates/contextkit/tools/scripts/distill-detect.mjs +90 -0
  270. package/templates/contextkit/tools/scripts/doctor.mjs +165 -0
  271. package/templates/contextkit/tools/scripts/fleet.mjs +170 -0
  272. package/templates/contextkit/tools/scripts/generate-context.mjs +142 -0
  273. package/templates/contextkit/tools/scripts/gh-alerts.mjs +117 -0
  274. package/templates/contextkit/tools/scripts/git.mjs +97 -0
  275. package/templates/contextkit/tools/scripts/home.mjs +106 -0
  276. package/templates/contextkit/tools/scripts/mark-simulation.mjs +78 -0
  277. package/templates/contextkit/tools/scripts/media-gen.mjs +154 -0
  278. package/templates/contextkit/tools/scripts/pipeline-board.mjs +74 -0
  279. package/templates/contextkit/tools/scripts/pipeline-prioritize.mjs +68 -0
  280. package/templates/contextkit/tools/scripts/pipeline-session.mjs +99 -0
  281. package/templates/contextkit/tools/scripts/pipeline-validate.mjs +136 -0
  282. package/templates/contextkit/tools/scripts/pipeline.mjs +302 -0
  283. package/templates/contextkit/tools/scripts/playbook.mjs +123 -0
  284. package/templates/contextkit/tools/scripts/predictions-review.mjs +113 -0
  285. package/templates/contextkit/tools/scripts/release.mjs +60 -0
  286. package/templates/contextkit/tools/scripts/resume.mjs +114 -0
  287. package/templates/contextkit/tools/scripts/roadmap.mjs +86 -0
  288. package/templates/contextkit/tools/scripts/runs.mjs +116 -0
  289. package/templates/contextkit/tools/scripts/seo-audit.mjs +150 -0
  290. package/templates/contextkit/tools/scripts/session-digest.mjs +89 -0
  291. package/templates/contextkit/tools/scripts/session-reindex.mjs +91 -0
  292. package/templates/contextkit/tools/scripts/setup-complete.mjs +69 -0
  293. package/templates/contextkit/tools/scripts/squad-meta.mjs +23 -0
  294. package/templates/contextkit/tools/scripts/squad-pipeline-condition.mjs +192 -0
  295. package/templates/contextkit/tools/scripts/squad-pipeline.mjs +301 -0
  296. package/templates/contextkit/tools/scripts/squad.mjs +80 -0
  297. package/templates/contextkit/tools/scripts/stats.mjs +138 -0
  298. package/templates/contextkit/tools/scripts/sync-check.mjs +235 -0
  299. package/templates/contextkit/tools/scripts/tech-debt-detectors.mjs +76 -0
  300. package/templates/contextkit/tools/scripts/tech-debt-scan.mjs +164 -0
  301. package/templates/contextkit/tools/scripts/token-report.mjs +153 -0
  302. package/templates/contextkit/tools/scripts/visual-test.mjs +132 -0
  303. package/templates/contextkit/tools/scripts/watch.mjs +106 -0
  304. package/templates/contextkit/tools/scripts/workflow.mjs +136 -0
  305. package/templates/contextkit/tools/scripts/workspace-sync.mjs +220 -0
  306. package/templates/contextkit/tools/scripts/worktree-new.mjs +50 -0
  307. package/templates/contextkit/workflows/L1-static-loading.md +59 -0
  308. package/templates/contextkit/workflows/L2-session-ledger.md +86 -0
  309. package/templates/contextkit/workflows/L3-multi-session.md +80 -0
  310. package/templates/contextkit/workflows/L4-squads.md +68 -0
  311. package/templates/contextkit/workflows/L5-proactive.md +88 -0
  312. package/templates/contextkit/workflows/README.md +47 -0
  313. package/templates/contextkit/workflows/playbooks/distillation-cycle.md +74 -0
  314. package/templates/contextkit/workflows/playbooks/landing-page.md +197 -0
  315. package/templates/contextkit/workflows/playbooks/security-batch.md +68 -0
  316. package/templates/contextkit/workflows/playbooks/seo-aiso.md +288 -0
  317. package/templates/contextkit/workflows/playbooks/simulate-impact.md +83 -0
  318. package/templates/contextkit/workflows/playbooks/tanstack.md +164 -0
  319. package/templates/contextkit/workflows/playbooks/tech-debt-sweep.md +77 -0
  320. package/templates/docs/CHANGELOG.md.tpl +11 -0
  321. package/templates/gitattributes +3 -0
  322. package/templates/github/ISSUE_TEMPLATE/bug_report.md +30 -0
  323. package/templates/github/ISSUE_TEMPLATE/feature_request.md +22 -0
  324. package/templates/github/PULL_REQUEST_TEMPLATE.md +27 -0
  325. package/templates/github/dependabot.yml +27 -0
  326. package/templates/github/workflows/quality.yml +36 -0
  327. package/templates/github/workflows/security.yml +54 -0
  328. package/tools/install/cli.mjs +62 -0
  329. package/tools/install/fs.mjs +56 -0
  330. package/tools/install/git.mjs +114 -0
  331. package/tools/install/project.mjs +51 -0
  332. package/tools/install/uninstall.mjs +54 -0
  333. package/tools/integration-test-compozy.mjs +88 -0
  334. package/tools/integration-test-guards.mjs +269 -0
  335. package/tools/integration-test-tooling-agent-forge.mjs +189 -0
  336. package/tools/integration-test-tooling-pipeline.mjs +164 -0
  337. package/tools/integration-test-tooling.mjs +172 -0
  338. package/tools/integration-test.mjs +228 -0
  339. package/tools/it-helpers.mjs +60 -0
  340. package/tools/selfcheck-agent-forge-ops.mjs +107 -0
  341. package/tools/selfcheck-agent-forge.mjs +304 -0
  342. package/tools/selfcheck-config.mjs +80 -0
  343. package/tools/selfcheck-runtime.mjs +135 -0
  344. package/tools/selfcheck-source.mjs +326 -0
  345. package/tools/selfcheck.mjs +268 -0
@@ -0,0 +1,183 @@
1
+ # Behavioral Discipline — examples
2
+
3
+ > Concrete before/after diffs for the four guidelines in
4
+ > [`behaviors.md`](./behaviors.md). Each shows what an LLM commonly does wrong and
5
+ > the disciplined alternative. Examples are in Python for brevity; the *behavior*
6
+ > is language-agnostic.
7
+ >
8
+ > Adapted from the MIT-licensed `karpathy-guidelines` skill (Andrej Karpathy's
9
+ > observations on LLM coding pitfalls).
10
+
11
+ ---
12
+
13
+ ## 1. Think before coding
14
+
15
+ ### Hidden assumptions
16
+
17
+ **Request:** "Add a feature to export user data."
18
+
19
+ ❌ **What LLMs do** — implement `export_users(format='json')` that dumps *all*
20
+ users to a hardcoded file path with a guessed field list. Four silent
21
+ assumptions (scope, location, fields, privacy), any of which can be wrong.
22
+
23
+ ✅ **Disciplined** — surface the assumptions and ask before coding:
24
+
25
+ ```
26
+ Before implementing, I need to clarify:
27
+ 1. Scope: all users or a filtered subset? (privacy implications)
28
+ 2. Delivery: browser download, background job + email, or an API endpoint?
29
+ 3. Fields: which ones? (some may be sensitive)
30
+ 4. Volume: how many rows typically? (changes the approach)
31
+
32
+ Simplest path: a paginated JSON endpoint. File exports need more info — preference?
33
+ ```
34
+
35
+ ### Multiple interpretations
36
+
37
+ **Request:** "Make the search faster."
38
+
39
+ ❌ **What LLMs do** — silently add caching *and* indexes *and* async in one
40
+ 200-line diff, optimizing a dimension the user may not care about.
41
+
42
+ ✅ **Disciplined** — name the interpretations with rough cost, then let the user pick:
43
+ latency (indexes/cache, ~2h) · throughput (async/pooling, ~4h) · perceived speed
44
+ (progressive results, ~3h). "Current ~500ms typical — which matters most?"
45
+
46
+ ---
47
+
48
+ ## 2. Simplicity first
49
+
50
+ ### Over-abstraction
51
+
52
+ **Request:** "Add a function to calculate a discount."
53
+
54
+ ❌ **What LLMs do** — `DiscountStrategy(ABC)` + `PercentageDiscount` +
55
+ `FixedDiscount` + `DiscountConfig` + `DiscountCalculator`: 30+ lines of patterns
56
+ for one calculation.
57
+
58
+ ✅ **Disciplined:**
59
+
60
+ ```python
61
+ def calculate_discount(amount: float, percent: float) -> float:
62
+ """Discount amount. percent is 0-100."""
63
+ return amount * (percent / 100)
64
+ ```
65
+
66
+ > Add the strategy pattern **when a second discount type actually exists** —
67
+ > refactor then, not now.
68
+
69
+ ### Speculative features
70
+
71
+ **Request:** "Save user preferences to the database."
72
+
73
+ ❌ **What LLMs do** — a `PreferenceManager` with injected cache + validator and a
74
+ `save(..., merge=True, validate=True, notify=False)` signature: caching,
75
+ validation, merging, and notifications nobody asked for.
76
+
77
+ ✅ **Disciplined:**
78
+
79
+ ```python
80
+ def save_preferences(db, user_id: int, preferences: dict):
81
+ db.execute("UPDATE users SET preferences = ? WHERE id = ?",
82
+ (json.dumps(preferences), user_id))
83
+ ```
84
+
85
+ > Add caching when performance bites, validation when bad data appears, merging
86
+ > when the requirement emerges.
87
+
88
+ ---
89
+
90
+ ## 3. Surgical changes
91
+
92
+ ### Drive-by refactoring
93
+
94
+ **Request:** "Fix the bug where empty emails crash the validator."
95
+
96
+ ❌ **What LLMs do** — fix the empty-email check *and* "improve" email validation,
97
+ *and* add username length/alphanumeric rules, *and* add a docstring, *and* rewrite
98
+ the comments. The bug fix is buried in unrelated changes.
99
+
100
+ ✅ **Disciplined** — change only the lines that fix empty-email handling:
101
+
102
+ ```diff
103
+ def validate_user(user_data):
104
+ # Check email format
105
+ - if not user_data.get('email'):
106
+ + email = user_data.get('email', '')
107
+ + if not email or not email.strip():
108
+ raise ValueError("Email required")
109
+ ```
110
+
111
+ Username validation, docstrings, and comment rewrites are *not in this diff*.
112
+
113
+ ### Style drift
114
+
115
+ **Request:** "Add logging to the upload function."
116
+
117
+ ❌ **What LLMs do** — while adding logging, switch `'single'` to `"double"`
118
+ quotes, add type hints, insert a docstring, and reformat whitespace. Every one of
119
+ those is noise that hides the real change and fights the file's existing style.
120
+
121
+ ✅ **Disciplined** — add the logging lines and **nothing else**; match the file's
122
+ existing single quotes, no-type-hint, existing-boolean-pattern style. The diff
123
+ contains logging and only logging.
124
+
125
+ ---
126
+
127
+ ## 4. Goal-driven execution
128
+
129
+ ### Reproduce before fixing
130
+
131
+ **Request:** "The sorting breaks when there are duplicate scores."
132
+
133
+ ❌ **What LLMs do** — immediately rewrite the sort key without confirming the bug,
134
+ so there's no proof the fix addresses the real failure (or that it won't return).
135
+
136
+ ✅ **Disciplined** — write the failing test first, *then* fix:
137
+
138
+ ```python
139
+ def test_sort_with_duplicate_scores():
140
+ scores = [{'name':'Alice','score':100},{'name':'Bob','score':100},{'name':'Charlie','score':90}]
141
+ result = sort_scores(scores) # run repeatedly — order must be stable
142
+ assert [s['name'] for s in result] == ['Alice', 'Bob', 'Charlie']
143
+ # Verify it FAILS (reproduces the non-deterministic order), then:
144
+
145
+ def sort_scores(scores):
146
+ """Score desc, then name asc for ties (stable)."""
147
+ return sorted(scores, key=lambda s: (-s['score'], s['name']))
148
+ # Verify it now passes, consistently.
149
+ ```
150
+
151
+ ### Incremental with verification
152
+
153
+ **Request:** "Add rate limiting to the API."
154
+
155
+ ❌ **What LLMs do** — a 300-line Redis-backed, multi-strategy, configurable
156
+ system in one commit with no verification steps.
157
+
158
+ ✅ **Disciplined** — a plan where each step is independently verifiable:
159
+
160
+ ```
161
+ 1. In-memory limit, one endpoint → verify: 11th request gets 429
162
+ 2. Extract to middleware (all endpoints) → verify: applies to /users + /posts; old tests green
163
+ 3. Redis backend (multi-server) → verify: limit persists across restart; shared across instances
164
+ 4. Per-endpoint config → verify: /search 10/min, /users 100/min
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Anti-pattern summary
170
+
171
+ | Guideline | Anti-pattern | Fix |
172
+ |---|---|---|
173
+ | Think before coding | Silently assumes scope/format/fields | List assumptions, ask before coding |
174
+ | Simplicity first | Strategy pattern for one calculation | One function until a 2nd consumer is real |
175
+ | Surgical changes | Reformats + adds type hints while fixing a bug | Only the lines that fix the reported issue |
176
+ | Goal-driven | "I'll review and improve the code" | "Failing test for X → make it pass → no regressions" |
177
+
178
+ ## The key insight
179
+
180
+ The overcomplicated versions aren't obviously wrong — they follow real design
181
+ patterns. The problem is **timing**: complexity added *before it's needed* is
182
+ harder to read, more bug-prone, slower to ship, and harder to test. Good code
183
+ solves **today's** problem simply; it doesn't pre-solve tomorrow's.
@@ -0,0 +1,116 @@
1
+ # Behavioral Discipline — how the agent *acts* while coding
2
+
3
+ > The behavioral companion to [`best-practices.md`](./best-practices.md).
4
+ > `best-practices.md` says **what good code looks like** (structure, naming,
5
+ > errors); this file says **how to behave while producing it** (clarify before
6
+ > coding, stay surgical, loop to a verified goal). The constitution in `CLAUDE.md`
7
+ > has absolute priority; this file expands its behavioral clauses.
8
+ >
9
+ > **Source & credit.** Adapted from
10
+ > [Andrej Karpathy's observations on LLM coding pitfalls](https://x.com/karpathy/status/2015883857489522876)
11
+ > via the MIT-licensed `karpathy-guidelines` skill. Generalized to ContextDevKit's
12
+ > voice and reconciled with the constitution.
13
+ >
14
+ > **Tradeoff (stated honestly).** These guidelines bias toward **caution over
15
+ > raw speed**. For trivial, unambiguous tasks, use judgment — don't perform a
16
+ > ceremony the work doesn't need. The discipline is a guardrail, not a tax.
17
+
18
+ ---
19
+
20
+ ## 1. Think before coding
21
+
22
+ **Don't assume. Don't hide confusion. Surface tradeoffs — *before* the diff.**
23
+
24
+ - **State assumptions explicitly.** If the request has gaps (scope, format,
25
+ fields, volume, privacy), name what you're assuming. If an assumption is
26
+ load-bearing and you're unsure, **ask** instead of guessing.
27
+ - **Present interpretations; don't pick silently.** "Make the search faster" can
28
+ mean latency, throughput, or perceived speed — lay out the options with their
29
+ rough cost and let the user choose.
30
+ - **Push back when warranted.** If a simpler approach exists, say so. If the ask
31
+ conflicts with an immutable rule or an ADR, refuse and explain — silently
32
+ complying with a bad instruction is not service.
33
+ - **Stop on genuine confusion.** Name what's unclear and ask. One clarifying
34
+ question now beats a wrong 200-line diff later.
35
+
36
+ **Fits the kit.** This is the moment-to-moment companion to `/new-adr` (decide
37
+ the big call *before* implementing) and `/dev-start` (lock the objective). The
38
+ `architect` and `product-owner` agents exist precisely to resolve ambiguity —
39
+ route to them when the unknown is design or scope.
40
+
41
+ ## 2. Simplicity first
42
+
43
+ **The minimum code that solves the problem. Nothing speculative.**
44
+
45
+ - No features beyond what was asked. No flags, options, or "configurability"
46
+ nobody requested.
47
+ - **No abstraction for single-use code.** A strategy pattern / factory / base
48
+ class earns its place when a *second* real consumer appears — not before.
49
+ - No error handling for impossible scenarios; handle the failures that can
50
+ actually happen at the boundary (constitution §4).
51
+ - If you wrote 200 lines and 50 would do, rewrite it. Ask: *"Would a senior
52
+ engineer call this overcomplicated?"* If yes, simplify before showing it.
53
+
54
+ **Fits the kit.** This is constitution §9 ("build what is asked; defer the
55
+ rest") and §1 (line budget) as an *in-the-moment* habit. The trap is **timing**:
56
+ the over-engineered version isn't "wrong" — it adds complexity *before it's
57
+ needed*. Add it later, when the requirement is real.
58
+
59
+ ## 3. Surgical changes
60
+
61
+ **Touch only what the task requires. Clean up only your own mess.**
62
+
63
+ - **Don't "improve" adjacent code, comments, or formatting.** Don't refactor what
64
+ isn't broken on the way past.
65
+ - **Match the surrounding style — even if you'd do it differently.** Quote style,
66
+ type-hint usage, naming cadence, spacing: conform to the file you're in. A diff
67
+ that reformats is a diff that hides its real change.
68
+ - **Every changed line traces to the request.** If you can't explain a line by
69
+ the task, it shouldn't be in the diff.
70
+ - **Orphans:** remove imports/variables/functions *your* change made unused.
71
+ **Don't** delete pre-existing dead code unless asked — *mention* it instead.
72
+
73
+ **Fits the kit (the one real tension).** The constitution rewards refactoring by
74
+ responsibility (§1, §2) and the kit ships `/analyze-code-ia-practices`,
75
+ `/tech-debt-sweep`, and `/dev-start "refactor X"`. That is not a contradiction:
76
+ **refactoring is a deliberate, scoped task — never an opportunistic side effect
77
+ of an unrelated change.** When you spot a real structural smell mid-task, note it
78
+ and offer a focused follow-up; don't fold it into the current diff. `/dev-start`
79
+ already locks scope and blocks opportunistic refactors — this rule makes the same
80
+ discipline always-on, even without it.
81
+
82
+ ## 4. Goal-driven execution
83
+
84
+ **Define a verifiable success criterion. Loop until it's met.**
85
+
86
+ - **Turn vague tasks into checkable goals.** "Add validation" → "tests for the
87
+ invalid inputs, then make them pass." "Fix the bug" → "a test that reproduces
88
+ it, then make it green." "Refactor X" → "the suite is green before and after."
89
+ - **Reproduce before you fix.** Write the failing test that captures the bug
90
+ *first* — it proves you understood it and guards against its return (this is
91
+ `/bug-hunt`'s root-cause-first stance, and constitution-grade for any fix).
92
+ - **State a brief plan for multi-step work**, each step paired with its check:
93
+ ```
94
+ 1. <step> → verify: <check>
95
+ 2. <step> → verify: <check>
96
+ ```
97
+ - **Loop independently on strong criteria.** A clear success test lets you
98
+ iterate without pestering the user; a weak one ("make it work") guarantees
99
+ rework. Don't claim done until the check is green — report honestly if it isn't.
100
+
101
+ **Fits the kit.** This ties together what the kit already provides: `/bug-hunt`
102
+ (root cause first), the QA squad (`/test-plan`, `/scaffold-tests`, `/qa-signoff`),
103
+ `best-practices.md` §H7 (behavior tests that catch the bug), and the TodoWrite
104
+ plan. This rule is the thread that connects them on every task.
105
+
106
+ ---
107
+
108
+ ## These guidelines are working if…
109
+
110
+ - clarifying questions arrive **before** implementation, not after a wrong diff;
111
+ - diffs are smaller and every line traces to the request;
112
+ - fewer rewrites for overcomplication;
113
+ - fixes ship with a test that fails without them.
114
+
115
+ See [`behaviors-examples.md`](./behaviors-examples.md) for concrete before/after
116
+ diffs of each anti-pattern.
@@ -0,0 +1,323 @@
1
+ # AI-Assisted Coding Best Practices — The Rubric
2
+
3
+ > The principles `/analyze-code-ia-practices` checks against. Mirrors the
4
+ > constitution in `CLAUDE.md` — keep them in sync. Tune thresholds via
5
+ > `contextkit/config.json` (`l5.lineBudget`, etc.).
6
+ >
7
+ > **Paired with `review-protocol.md`** (severity vocabulary, scope, the
8
+ > protocol the auditor follows, and the scanner contract). This file says
9
+ > *what good looks like*; the protocol file says *how to apply it*.
10
+ >
11
+ > **Stack-agnostic by design.** ContextDevKit installs into any language and any
12
+ > stack — this rubric speaks in principles, not in framework names. If your
13
+ > project wants concrete stack-specific rules (e.g. ORM patterns, framework
14
+ > conventions, security controls particular to your stack), write them in a
15
+ > sibling `best-practices.local.md` your project owns. The kit will not
16
+ > invent domain content (constitution, rule 9).
17
+ >
18
+ > **Why this rubric exists.** AI-assisted code fails in predictable ways, and
19
+ > the *expensive* failures are not the ones a linter sees. Logic married to
20
+ > the database, authorization holes, duplicated domain rules, state with no
21
+ > single source of truth — that is what sinks a project. God files and bad
22
+ > names are real, but they are the *cheap* tier. The tiers below are ordered
23
+ > by what actually costs the project, not by what a regex can match.
24
+
25
+ ## Risk model
26
+
27
+ A finding's weight is not "which rule." It is:
28
+
29
+ > **severity ≈ likelihood × blast radius × cost-to-fix-later**
30
+
31
+ - **likelihood** — how often this bites in practice.
32
+ - **blast radius** — how much breaks, or how much data leaks, when it does.
33
+ - **cost-to-fix-later** — cheap now, expensive once it has spread or shipped.
34
+
35
+ That is why the rubric is reviewed **top-down by tier**:
36
+
37
+ 1. **System & architecture** — wrong here and everything downstream inherits it.
38
+ 2. **Module & function hygiene** — real, but local and cheap to fix.
39
+
40
+ **Security is deliberately *not* a tier here.** The kit already has a
41
+ dedicated security ecosystem (`code-security`, `security`, `infra-security`
42
+ agents; `/audit`, `/deps-audit`, `/security-setup` commands). Duplicating
43
+ those rules in this rubric would create two places to maintain them and
44
+ violate the rubric's own §H3 (separation of concerns). For security
45
+ findings, dispatch the security-team — see *Adjacent concerns* at the foot
46
+ of this file.
47
+
48
+ ## Rule shape
49
+
50
+ Every rule below has the same four blocks — **Principle / Smells / Fix /
51
+ Don't over-apply** — because an agent applies a rule well only when it knows
52
+ what triggers a look, what to propose, *and where to stay quiet.* The
53
+ over-apply clause is the calibration; a respected guardrail beats a flagged
54
+ false positive. (Severity, scope, and reporting format live in
55
+ `review-protocol.md`.)
56
+
57
+ ---
58
+
59
+ # TIER 1 — System & architecture
60
+
61
+ The highest-leverage tier, and the one a line-counting linter is blind to.
62
+ The scanner gives the agent almost nothing here — read the code.
63
+
64
+ ## S1 — Dependency direction
65
+
66
+ **Principle.** Dependencies point *inward*: UI and domain logic do not depend
67
+ on infrastructure. The persistence client, the HTTP transport, and the
68
+ framework live at the edges and depend on the core, not the reverse. The
69
+ domain should not know how it is stored or transported.
70
+
71
+ **Smells.** A `domain/` or business module importing the DB/ORM client, the
72
+ network library, the router, or generated persistence types. Generated row
73
+ types used as the domain model everywhere. "It's easier to just import the
74
+ client here."
75
+
76
+ **Fix.** Invert it: the core defines an interface (a repository/port); infra
77
+ implements it; the dependency is injected at the edge. The domain stays
78
+ ignorant of how things are persisted or transported.
79
+
80
+ **Don't over-apply.** A genuinely thin app — a CRUD admin panel with no real
81
+ domain — doesn't need a hexagonal cathedral. Match ceremony to complexity.
82
+ The *direction* rule still holds; the *depth* of layering is negotiable.
83
+
84
+ ## S2 — Boundaries & encapsulation
85
+
86
+ **Principle.** Each module has a deliberate public surface; everything else
87
+ is internal. Callers depend on the contract, not the guts. The shape of a
88
+ module's public API is a *decision*, not a side effect of which files happen
89
+ to be re-exported.
90
+
91
+ **Smells.** Deep imports into a module's internals
92
+ (`feature/x/internal/helpers`). A barrel that re-exports everything, so
93
+ nothing is actually private. Two modules reaching into each other's state.
94
+ A consumer mutating a value the producer hands back.
95
+
96
+ **Fix.** Export the contract from the module's entry point; keep the rest
97
+ unexported. If a caller genuinely needs an internal, that internal probably
98
+ wants promoting to the public API — on purpose, not by accident. Return
99
+ immutable values or copies across the boundary.
100
+
101
+ **Don't over-apply.** Don't add barrel/index ceremony to a two-file feature.
102
+ The point is intentional surface, not bureaucratic surface.
103
+
104
+ ## S3 — Coupling & cycles
105
+
106
+ **Principle.** Low coupling between modules; no import cycles. Watch
107
+ **fan-in** (many things depend on this — change it carefully) and
108
+ **fan-out** (this depends on many things — it's probably doing too much).
109
+
110
+ **Smells.** Circular imports. A "god module" everything imports. A change
111
+ here forcing edits in five unrelated places. A module that pulls in half the
112
+ codebase to do its job.
113
+
114
+ **Fix.** Break the cycle by extracting the shared piece both sides depend on,
115
+ or by inverting one direction with an interface. High fan-out usually means a
116
+ missing decomposition: the module is orchestrating *and* doing the work; pull
117
+ the work into focused collaborators it calls.
118
+
119
+ **Don't over-apply.** Shared kernel utilities (types, pure helpers) having
120
+ high fan-in is normal and fine — that's what they're *for*. The smell is
121
+ high fan-in on something that *changes often*, not high fan-in on a stable
122
+ primitive.
123
+
124
+ ## S4 — State location & single source of truth
125
+
126
+ **Principle.** Every piece of state has **one source of truth.** Server
127
+ state and client/UI state are different things and live in different places.
128
+ Domain rules live once. Derived data is computed, not stored.
129
+
130
+ **Smells.** The same server data fetched and cached in several places,
131
+ drifting out of sync. The same validation or business rule copy-pasted across
132
+ screens. Server data and UI-only state mashed into one blob. Two flags that
133
+ must always agree (and don't, on some path).
134
+
135
+ **Fix.** Server state → one query/cache layer (a query hook, a cache, a
136
+ loader, whatever your stack offers), read everywhere from that one place.
137
+ Client/UI state → local and minimal. A rule that appears twice → extract it
138
+ to one function. Derive, don't duplicate.
139
+
140
+ **Don't over-apply.** Not every local state is a sin. Genuinely ephemeral
141
+ UI state (a toggle, an input draft, a hover flag) belongs where it lives. The
142
+ target is *duplicated* and *drifting* state, not all state.
143
+
144
+ ---
145
+
146
+ # TIER 2 — Module & function hygiene
147
+
148
+ Real and worth fixing — but local, cheap, and lower-leverage than Tier 1.
149
+ This is where the deterministic scanner does most of its work.
150
+
151
+ ## H1 — Complexity & cohesion (line count is a trip-wire, not a verdict)
152
+
153
+ **Principle.** A unit is too big when it carries more than one reason to
154
+ change or exceeds what a reader can hold in their head. The constitution
155
+ sets a **280 useful lines** budget (tolerance ~308) — treat that line count
156
+ as a trip-wire that *starts* the conversation, not as the verdict.
157
+
158
+ **Smells.** Scanner trip-wire: yellow at **240+**, RED (`BLOCKER`) at
159
+ **> 308**. The real smells the agent has to spot beyond the line count: deep
160
+ nesting; a function doing two jobs; a name needing a conjunction
161
+ (`validateAndSave`, `fetchAndTransform`, or the Portuguese
162
+ `validarESalvar`, `buscarETransformar`); grab-bag modules (`utils.ts`,
163
+ `manager.ts`, `helpers.ts` that accrete unrelated functions); long parameter
164
+ lists; bodies that mix abstraction levels.
165
+
166
+ **Fix — refactor by responsibility, in order of preference:**
167
+
168
+ - **Extract a unit with one job** — a service/use-case, a pure helper
169
+ module, a custom hook (UI state/effects), a sub-component (a `renderX()`
170
+ becomes a real component), a validator/schema module, a mapper/adapter.
171
+ - **Promote inline render functions** (`renderHeader()`, `renderList()`) to
172
+ real components.
173
+ - **Lift complex state** (`> 2 useState + ≥ 1 effect`) into a custom hook.
174
+ - **Separate layers** — leaked business logic in a transport handler moves
175
+ to a service; *that's* the split, never an arbitrary line cut.
176
+ - **Name the orchestrator by its intent** (`processOrder`, not
177
+ `validateAndSaveOrder`).
178
+
179
+ **Don't over-apply.** A 300-line dumb DTO/constants/types file is fine —
180
+ flat, cohesive, no branching. Document the cohesion in a header comment and
181
+ move on. Conversely, a 90-line function with three responsibilities and five
182
+ levels of nesting is rotten *under* the limit. Judge complexity, not length.
183
+ An orchestrator that composes single-purpose units is doing one job
184
+ (coordinating) — don't shatter cohesive logic to chase a number.
185
+ **280 starts analysis; it is not a guillotine.**
186
+
187
+ ## H2 — Single Responsibility
188
+
189
+ **Principle.** Each function/module/component has **one reason to change.**
190
+
191
+ **Smells.** A name needing a conjunction signals two jobs. Grab-bag modules
192
+ that accrete unrelated functions. Bodies mixing abstraction levels (one line
193
+ of high-level intent followed by ten lines of low-level twiddling). Very
194
+ long parameter lists.
195
+
196
+ **Fix.** Extract the parts; give the caller an intention-revealing name. If
197
+ a module is a grab-bag, split it by domain. If a function takes 8
198
+ parameters, it probably wants an object — or it's actually two functions.
199
+
200
+ **Don't over-apply.** An orchestrator that *composes* single-purpose units
201
+ is doing one job — coordinating. SRP is about *reasons to change*, not
202
+ literal single statements. Don't shatter cohesive logic to chase the rule.
203
+
204
+ ## H3 — Separation of concerns (unit level)
205
+
206
+ **Principle.** Visual logic ≠ business logic ≠ data access. Components stay
207
+ "dumb"; logic lives in hooks/services/helpers. Transport dispatches and
208
+ never holds business rules. Side effects (IO, network, clock, randomness)
209
+ are isolated and injectable.
210
+
211
+ **Smells.** Network calls inside view code (`fetch()` in JSX). Business math
212
+ in a route handler or controller. `new Date()`, `Math.random()`, or direct
213
+ env reads buried in business code that pretends to be pure.
214
+
215
+ **Fix.** Push logic out of components into hooks/services. Make controllers
216
+ *call* a service rather than contain one. Inject the clock/random/IO so
217
+ they're swappable and testable. Leaked business logic in a controller →
218
+ move it to a service; that's the split, not an arbitrary line cut.
219
+
220
+ **Don't over-apply.** Don't stand up a DI container or a repository layer
221
+ for a three-file script. Match the ceremony to the size of the project.
222
+ This is the unit-level companion to **S1**; depth scales with complexity.
223
+
224
+ ## H4 — Errors
225
+
226
+ **Principle.** Validate at the boundary, fail fast with typed, descriptive
227
+ errors. Never swallow exceptions silently; never leak stack traces to end
228
+ users.
229
+
230
+ **Smells.** Empty `catch {}`. A `catch` that only `console.log`s and then
231
+ continues as if nothing happened. Returning `null`/`undefined` on failure
232
+ with no signal to the caller. Throwing bare strings. Rendering raw
233
+ `error.message` straight into the UI.
234
+
235
+ **Fix.** Validate inputs where they enter the system. Throw or return typed
236
+ errors with context. Log the technical detail with a correlation id, show
237
+ the user a clean generic message, and let unexpected errors propagate to a
238
+ boundary that handles them.
239
+
240
+ **Don't over-apply.** Deliberate best-effort handling is legitimate —
241
+ fire-and-forget analytics, optional cache warmups — *as long as the intent
242
+ is explicit and logged*. That's not swallowing.
243
+
244
+ ## H5 — Naming
245
+
246
+ **Principle.** Names reveal intent and domain. Readability beats clever or
247
+ compact code — a good name is the first layer of documentation.
248
+
249
+ **Smells.** Meaningful identifiers wearing meaningless names: `data`,
250
+ `temp`, `obj`, `val`, `result`, `arr`, `foo`, `thing` (and equivalents in
251
+ any language — e.g. Portuguese `dados`, `valor`, `resultado`).
252
+ `manager`/`helper`/`util` as the actual thing carrying meaning.
253
+
254
+ **Fix.** Rename to the domain concept (`invoices` not `data`, `retryCount`
255
+ not `x`); booleans as predicates (`isLoading`); carry units in the name
256
+ (`timeoutMs`).
257
+
258
+ **Don't over-apply.** Short names are fine in tight scope — `i`/`j` in
259
+ loops, `x`/`y` in math or coordinates, `err` in a catch, `_` for an unused
260
+ arg, single letters in a one-line lambda. The ban is for identifiers that
261
+ *carry meaning*, not throwaways.
262
+
263
+ ## H6 — Documentation
264
+
265
+ **Principle.** Doc-comment non-trivial business logic, hooks, and public
266
+ functions (`@param`/`@returns`/`@throws`). Comments explain the **why**,
267
+ not the obvious **what**.
268
+
269
+ **Smells.** Comments restating the code (`// increment i` above `i++`).
270
+ Stale comments contradicting the code. A public function that throws with
271
+ no `@throws`. A non-obvious workaround with no rationale.
272
+
273
+ **Fix.** Delete the redundant ones. Add the *why* for anything surprising.
274
+ Document the contract on public surfaces — what it promises, what it
275
+ guarantees, what it can throw.
276
+
277
+ **Don't over-apply.** Trivial one-liners and self-evident code don't need
278
+ JSDoc. Don't demand ceremony where the name already says it.
279
+
280
+ ## H7 — Tests
281
+
282
+ **Principle.** Critical paths and failure modes earn tests that would
283
+ **actually catch the bug** — tests of *behavior*, not implementation
284
+ details.
285
+
286
+ **Smells.** Happy-path-only suites. Tests asserting internal calls or
287
+ object shape instead of observable outcome. Snapshot-only coverage. No test
288
+ for the error/edge cases the code clearly handles.
289
+
290
+ **Fix.** Test contracts and behavior; cover the failure modes; write the
291
+ test that fails if the bug returns. See the QA squad (`/test-plan`,
292
+ `/scaffold-tests`, `/qa-signoff`) for the wider testing plan.
293
+
294
+ **Don't over-apply.** Coverage % is not the goal; risk is. Don't pad with
295
+ trivial tests to hit a number.
296
+
297
+ ---
298
+
299
+ # Adjacent concerns — what this rubric does *not* cover
300
+
301
+ The kit deliberately splits responsibilities across specialised
302
+ agents/commands. The rubric stays in its lane:
303
+
304
+ - **Security (AppSec, supply-chain, infra/cloud)** — `code-security`,
305
+ `security`, `infra-security` agents; `/audit`, `/deps-audit`,
306
+ `/security-setup`. Dispatch the security-team for findings of any of:
307
+ trust-boundary validation, server-side authorization, secret/PII
308
+ exposure, injection/unsafe sinks, dependency CVEs, IAM, IaC misconfig.
309
+ - **Accessibility** — `accessibility` agent (design-team).
310
+ - **Privacy (LGPD / regional)** — `privacy-lgpd` agent (compliance-team).
311
+ - **Architectural decisions (new designs, dependency adoption)** —
312
+ `architect` agent + `/new-adr` + `/simulate-impact`. The rubric audits
313
+ *existing* code's architecture (Tier 1); `architect` decides *new*
314
+ shape.
315
+ - **QA / test strategy** — `qa-orchestrator` and the qa-* squad;
316
+ `/test-plan`, `/scaffold-tests`, `/qa-signoff`. H7 in this rubric is a
317
+ code-quality lens on tests; QA owns the deeper test strategy.
318
+
319
+ ---
320
+
321
+ For severity vocabulary, scope (when Tier 2 is relaxed for spikes), the
322
+ review protocol the auditor follows, and the contract between scanner and
323
+ agent — see **[`review-protocol.md`](./review-protocol.md)**.
@@ -0,0 +1,66 @@
1
+ {
2
+ "level": 2,
3
+ "setup": { "completed": false },
4
+ "practices": { "active": false },
5
+ "ledger": {
6
+ "important": [
7
+ "src/",
8
+ "lib/",
9
+ "app/",
10
+ "apps/",
11
+ "packages/",
12
+ "components/",
13
+ "pages/",
14
+ "server/",
15
+ "contextkit/",
16
+ ".claude/",
17
+ ".github/",
18
+ "CLAUDE.md",
19
+ "package.json",
20
+ "tsconfig.json",
21
+ "pyproject.toml",
22
+ "go.mod",
23
+ "Cargo.toml"
24
+ ],
25
+ "irrelevant": [
26
+ "node_modules/",
27
+ "dist/",
28
+ "build/",
29
+ "out/",
30
+ ".next/",
31
+ ".turbo/",
32
+ ".expo/",
33
+ ".svelte-kit/",
34
+ "coverage/",
35
+ "__pycache__/",
36
+ "target/",
37
+ "vendor/",
38
+ ".context-snapshot.md",
39
+ ".claude/.sessions/",
40
+ ".claude/.workspace/"
41
+ ],
42
+ "registration": ["contextkit/memory/SESSIONS.md", "docs/CHANGELOG.md"]
43
+ },
44
+ "l3": { "mainBranch": "main" },
45
+ "qa": {
46
+ "criticalPaths": [],
47
+ "coverageTarget": { "lines": 80, "branches": 70 }
48
+ },
49
+ "l5": {
50
+ "highRiskPaths": [],
51
+ "lineBudget": { "yellow": 240, "red": 308 },
52
+ "contractGlobs": [],
53
+ "distill": {
54
+ "observeWindow": 10,
55
+ "proposeAfterSessions": 30,
56
+ "archiveLedgersOlderThanDays": 7
57
+ },
58
+ "techDebtSweep": {
59
+ "default": "full",
60
+ "profiles": {
61
+ "full": { "cadenceDays": 14, "scope": "all" },
62
+ "quick": { "cadenceDays": 3, "scope": "red-zone-only" }
63
+ }
64
+ }
65
+ }
66
+ }