@zigrivers/scaffold 2.28.1 → 2.38.1

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 (375) hide show
  1. package/README.md +309 -136
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +94 -14
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/build.test.js +30 -5
  6. package/dist/cli/commands/build.test.js.map +1 -1
  7. package/dist/cli/commands/check.d.ts +12 -0
  8. package/dist/cli/commands/check.d.ts.map +1 -0
  9. package/dist/cli/commands/check.js +311 -0
  10. package/dist/cli/commands/check.js.map +1 -0
  11. package/dist/cli/commands/check.test.d.ts +2 -0
  12. package/dist/cli/commands/check.test.d.ts.map +1 -0
  13. package/dist/cli/commands/check.test.js +412 -0
  14. package/dist/cli/commands/check.test.js.map +1 -0
  15. package/dist/cli/commands/complete.d.ts +12 -0
  16. package/dist/cli/commands/complete.d.ts.map +1 -0
  17. package/dist/cli/commands/complete.js +103 -0
  18. package/dist/cli/commands/complete.js.map +1 -0
  19. package/dist/cli/commands/complete.test.d.ts +2 -0
  20. package/dist/cli/commands/complete.test.d.ts.map +1 -0
  21. package/dist/cli/commands/complete.test.js +133 -0
  22. package/dist/cli/commands/complete.test.js.map +1 -0
  23. package/dist/cli/commands/dashboard.d.ts.map +1 -1
  24. package/dist/cli/commands/dashboard.js +12 -8
  25. package/dist/cli/commands/dashboard.js.map +1 -1
  26. package/dist/cli/commands/info.d.ts.map +1 -1
  27. package/dist/cli/commands/info.js +4 -0
  28. package/dist/cli/commands/info.js.map +1 -1
  29. package/dist/cli/commands/knowledge.d.ts.map +1 -1
  30. package/dist/cli/commands/knowledge.js +6 -2
  31. package/dist/cli/commands/knowledge.js.map +1 -1
  32. package/dist/cli/commands/knowledge.test.js +16 -11
  33. package/dist/cli/commands/knowledge.test.js.map +1 -1
  34. package/dist/cli/commands/next.d.ts.map +1 -1
  35. package/dist/cli/commands/next.js +41 -13
  36. package/dist/cli/commands/next.js.map +1 -1
  37. package/dist/cli/commands/next.test.js +3 -0
  38. package/dist/cli/commands/next.test.js.map +1 -1
  39. package/dist/cli/commands/reset.d.ts +1 -0
  40. package/dist/cli/commands/reset.d.ts.map +1 -1
  41. package/dist/cli/commands/reset.js +179 -67
  42. package/dist/cli/commands/reset.js.map +1 -1
  43. package/dist/cli/commands/reset.test.js +360 -0
  44. package/dist/cli/commands/reset.test.js.map +1 -1
  45. package/dist/cli/commands/rework.d.ts +20 -0
  46. package/dist/cli/commands/rework.d.ts.map +1 -0
  47. package/dist/cli/commands/rework.js +332 -0
  48. package/dist/cli/commands/rework.js.map +1 -0
  49. package/dist/cli/commands/rework.test.d.ts +2 -0
  50. package/dist/cli/commands/rework.test.d.ts.map +1 -0
  51. package/dist/cli/commands/rework.test.js +297 -0
  52. package/dist/cli/commands/rework.test.js.map +1 -0
  53. package/dist/cli/commands/run.d.ts.map +1 -1
  54. package/dist/cli/commands/run.js +59 -31
  55. package/dist/cli/commands/run.js.map +1 -1
  56. package/dist/cli/commands/run.test.js +288 -6
  57. package/dist/cli/commands/run.test.js.map +1 -1
  58. package/dist/cli/commands/skill.d.ts +12 -0
  59. package/dist/cli/commands/skill.d.ts.map +1 -0
  60. package/dist/cli/commands/skill.js +123 -0
  61. package/dist/cli/commands/skill.js.map +1 -0
  62. package/dist/cli/commands/skill.test.d.ts +2 -0
  63. package/dist/cli/commands/skill.test.d.ts.map +1 -0
  64. package/dist/cli/commands/skill.test.js +297 -0
  65. package/dist/cli/commands/skill.test.js.map +1 -0
  66. package/dist/cli/commands/skip.d.ts +1 -1
  67. package/dist/cli/commands/skip.d.ts.map +1 -1
  68. package/dist/cli/commands/skip.js +123 -57
  69. package/dist/cli/commands/skip.js.map +1 -1
  70. package/dist/cli/commands/skip.test.js +91 -0
  71. package/dist/cli/commands/skip.test.js.map +1 -1
  72. package/dist/cli/commands/status.d.ts +1 -0
  73. package/dist/cli/commands/status.d.ts.map +1 -1
  74. package/dist/cli/commands/status.js +57 -10
  75. package/dist/cli/commands/status.js.map +1 -1
  76. package/dist/cli/commands/status.test.js +81 -0
  77. package/dist/cli/commands/status.test.js.map +1 -1
  78. package/dist/cli/commands/update.test.js +252 -0
  79. package/dist/cli/commands/update.test.js.map +1 -1
  80. package/dist/cli/commands/version.test.js +171 -1
  81. package/dist/cli/commands/version.test.js.map +1 -1
  82. package/dist/cli/index.d.ts.map +1 -1
  83. package/dist/cli/index.js +8 -0
  84. package/dist/cli/index.js.map +1 -1
  85. package/dist/core/adapters/adapter.d.ts +14 -0
  86. package/dist/core/adapters/adapter.d.ts.map +1 -1
  87. package/dist/core/adapters/adapter.js.map +1 -1
  88. package/dist/core/adapters/adapter.test.js +10 -0
  89. package/dist/core/adapters/adapter.test.js.map +1 -1
  90. package/dist/core/adapters/claude-code.d.ts.map +1 -1
  91. package/dist/core/adapters/claude-code.js +47 -10
  92. package/dist/core/adapters/claude-code.js.map +1 -1
  93. package/dist/core/adapters/claude-code.test.js +41 -20
  94. package/dist/core/adapters/claude-code.test.js.map +1 -1
  95. package/dist/core/adapters/codex.d.ts.map +1 -1
  96. package/dist/core/adapters/codex.js +5 -1
  97. package/dist/core/adapters/codex.js.map +1 -1
  98. package/dist/core/adapters/codex.test.js +5 -0
  99. package/dist/core/adapters/codex.test.js.map +1 -1
  100. package/dist/core/adapters/universal.d.ts.map +1 -1
  101. package/dist/core/adapters/universal.js +0 -1
  102. package/dist/core/adapters/universal.js.map +1 -1
  103. package/dist/core/adapters/universal.test.js +5 -0
  104. package/dist/core/adapters/universal.test.js.map +1 -1
  105. package/dist/core/assembly/context-gatherer.d.ts.map +1 -1
  106. package/dist/core/assembly/context-gatherer.js +5 -2
  107. package/dist/core/assembly/context-gatherer.js.map +1 -1
  108. package/dist/core/assembly/engine.d.ts.map +1 -1
  109. package/dist/core/assembly/engine.js +10 -2
  110. package/dist/core/assembly/engine.js.map +1 -1
  111. package/dist/core/assembly/engine.test.js +19 -0
  112. package/dist/core/assembly/engine.test.js.map +1 -1
  113. package/dist/core/assembly/knowledge-loader.d.ts +25 -0
  114. package/dist/core/assembly/knowledge-loader.d.ts.map +1 -1
  115. package/dist/core/assembly/knowledge-loader.js +75 -2
  116. package/dist/core/assembly/knowledge-loader.js.map +1 -1
  117. package/dist/core/assembly/knowledge-loader.test.js +388 -1
  118. package/dist/core/assembly/knowledge-loader.test.js.map +1 -1
  119. package/dist/core/assembly/meta-prompt-loader.d.ts +6 -0
  120. package/dist/core/assembly/meta-prompt-loader.d.ts.map +1 -1
  121. package/dist/core/assembly/meta-prompt-loader.js +41 -25
  122. package/dist/core/assembly/meta-prompt-loader.js.map +1 -1
  123. package/dist/core/assembly/preset-loader.d.ts +10 -0
  124. package/dist/core/assembly/preset-loader.d.ts.map +1 -1
  125. package/dist/core/assembly/preset-loader.js +26 -1
  126. package/dist/core/assembly/preset-loader.js.map +1 -1
  127. package/dist/core/assembly/preset-loader.test.js +65 -1
  128. package/dist/core/assembly/preset-loader.test.js.map +1 -1
  129. package/dist/core/assembly/update-mode.d.ts.map +1 -1
  130. package/dist/core/assembly/update-mode.js +10 -4
  131. package/dist/core/assembly/update-mode.js.map +1 -1
  132. package/dist/core/assembly/update-mode.test.js +47 -0
  133. package/dist/core/assembly/update-mode.test.js.map +1 -1
  134. package/dist/core/dependency/dependency.d.ts.map +1 -1
  135. package/dist/core/dependency/dependency.js +3 -2
  136. package/dist/core/dependency/dependency.js.map +1 -1
  137. package/dist/core/dependency/dependency.test.js +2 -0
  138. package/dist/core/dependency/dependency.test.js.map +1 -1
  139. package/dist/core/dependency/eligibility.js +3 -3
  140. package/dist/core/dependency/eligibility.js.map +1 -1
  141. package/dist/core/dependency/eligibility.test.js +2 -0
  142. package/dist/core/dependency/eligibility.test.js.map +1 -1
  143. package/dist/core/dependency/graph.d.ts.map +1 -1
  144. package/dist/core/dependency/graph.js +4 -0
  145. package/dist/core/dependency/graph.js.map +1 -1
  146. package/dist/core/dependency/graph.test.d.ts +2 -0
  147. package/dist/core/dependency/graph.test.d.ts.map +1 -0
  148. package/dist/core/dependency/graph.test.js +262 -0
  149. package/dist/core/dependency/graph.test.js.map +1 -0
  150. package/dist/core/rework/phase-selector.d.ts +24 -0
  151. package/dist/core/rework/phase-selector.d.ts.map +1 -0
  152. package/dist/core/rework/phase-selector.js +98 -0
  153. package/dist/core/rework/phase-selector.js.map +1 -0
  154. package/dist/core/rework/phase-selector.test.d.ts +2 -0
  155. package/dist/core/rework/phase-selector.test.d.ts.map +1 -0
  156. package/dist/core/rework/phase-selector.test.js +138 -0
  157. package/dist/core/rework/phase-selector.test.js.map +1 -0
  158. package/dist/dashboard/generator.d.ts +48 -17
  159. package/dist/dashboard/generator.d.ts.map +1 -1
  160. package/dist/dashboard/generator.js +75 -5
  161. package/dist/dashboard/generator.js.map +1 -1
  162. package/dist/dashboard/generator.test.js +213 -5
  163. package/dist/dashboard/generator.test.js.map +1 -1
  164. package/dist/dashboard/template.d.ts +1 -1
  165. package/dist/dashboard/template.d.ts.map +1 -1
  166. package/dist/dashboard/template.js +755 -114
  167. package/dist/dashboard/template.js.map +1 -1
  168. package/dist/e2e/knowledge.test.js +4 -3
  169. package/dist/e2e/knowledge.test.js.map +1 -1
  170. package/dist/e2e/pipeline.test.js +2 -0
  171. package/dist/e2e/pipeline.test.js.map +1 -1
  172. package/dist/e2e/rework.test.d.ts +6 -0
  173. package/dist/e2e/rework.test.d.ts.map +1 -0
  174. package/dist/e2e/rework.test.js +226 -0
  175. package/dist/e2e/rework.test.js.map +1 -0
  176. package/dist/index.js +0 -0
  177. package/dist/project/adopt.test.js +2 -0
  178. package/dist/project/adopt.test.js.map +1 -1
  179. package/dist/project/claude-md.js +2 -2
  180. package/dist/project/claude-md.js.map +1 -1
  181. package/dist/project/claude-md.test.js +4 -4
  182. package/dist/project/claude-md.test.js.map +1 -1
  183. package/dist/project/detector.d.ts.map +1 -1
  184. package/dist/project/detector.js +4 -1
  185. package/dist/project/detector.js.map +1 -1
  186. package/dist/project/frontmatter.d.ts.map +1 -1
  187. package/dist/project/frontmatter.js +54 -15
  188. package/dist/project/frontmatter.js.map +1 -1
  189. package/dist/project/frontmatter.test.js +2 -2
  190. package/dist/project/frontmatter.test.js.map +1 -1
  191. package/dist/state/rework-manager.d.ts +16 -0
  192. package/dist/state/rework-manager.d.ts.map +1 -0
  193. package/dist/state/rework-manager.js +126 -0
  194. package/dist/state/rework-manager.js.map +1 -0
  195. package/dist/state/rework-manager.test.d.ts +2 -0
  196. package/dist/state/rework-manager.test.d.ts.map +1 -0
  197. package/dist/state/rework-manager.test.js +191 -0
  198. package/dist/state/rework-manager.test.js.map +1 -0
  199. package/dist/state/state-manager.d.ts +13 -0
  200. package/dist/state/state-manager.d.ts.map +1 -1
  201. package/dist/state/state-manager.js +39 -2
  202. package/dist/state/state-manager.js.map +1 -1
  203. package/dist/state/state-manager.test.js +74 -1
  204. package/dist/state/state-manager.test.js.map +1 -1
  205. package/dist/state/state-migration.d.ts +23 -0
  206. package/dist/state/state-migration.d.ts.map +1 -0
  207. package/dist/state/state-migration.js +144 -0
  208. package/dist/state/state-migration.js.map +1 -0
  209. package/dist/state/state-migration.test.d.ts +2 -0
  210. package/dist/state/state-migration.test.d.ts.map +1 -0
  211. package/dist/state/state-migration.test.js +451 -0
  212. package/dist/state/state-migration.test.js.map +1 -0
  213. package/dist/types/assembly.d.ts +2 -0
  214. package/dist/types/assembly.d.ts.map +1 -1
  215. package/dist/types/dependency.d.ts +2 -2
  216. package/dist/types/dependency.d.ts.map +1 -1
  217. package/dist/types/frontmatter.d.ts +100 -7
  218. package/dist/types/frontmatter.d.ts.map +1 -1
  219. package/dist/types/frontmatter.js +89 -1
  220. package/dist/types/frontmatter.js.map +1 -1
  221. package/dist/types/index.d.ts +1 -0
  222. package/dist/types/index.d.ts.map +1 -1
  223. package/dist/types/index.js +1 -0
  224. package/dist/types/index.js.map +1 -1
  225. package/dist/types/lock.d.ts +1 -1
  226. package/dist/types/lock.d.ts.map +1 -1
  227. package/dist/types/rework.d.ts +36 -0
  228. package/dist/types/rework.d.ts.map +1 -0
  229. package/dist/types/rework.js +2 -0
  230. package/dist/types/rework.js.map +1 -0
  231. package/dist/utils/errors.d.ts +1 -0
  232. package/dist/utils/errors.d.ts.map +1 -1
  233. package/dist/utils/errors.js +8 -0
  234. package/dist/utils/errors.js.map +1 -1
  235. package/dist/utils/fs.d.ts +6 -0
  236. package/dist/utils/fs.d.ts.map +1 -1
  237. package/dist/utils/fs.js +13 -0
  238. package/dist/utils/fs.js.map +1 -1
  239. package/dist/validation/config-validator.test.d.ts +2 -0
  240. package/dist/validation/config-validator.test.d.ts.map +1 -0
  241. package/dist/validation/config-validator.test.js +210 -0
  242. package/dist/validation/config-validator.test.js.map +1 -0
  243. package/dist/validation/dependency-validator.test.d.ts +2 -0
  244. package/dist/validation/dependency-validator.test.d.ts.map +1 -0
  245. package/dist/validation/dependency-validator.test.js +215 -0
  246. package/dist/validation/dependency-validator.test.js.map +1 -0
  247. package/dist/validation/frontmatter-validator.test.d.ts +2 -0
  248. package/dist/validation/frontmatter-validator.test.d.ts.map +1 -0
  249. package/dist/validation/frontmatter-validator.test.js +371 -0
  250. package/dist/validation/frontmatter-validator.test.js.map +1 -0
  251. package/dist/validation/state-validator.test.d.ts +2 -0
  252. package/dist/validation/state-validator.test.d.ts.map +1 -0
  253. package/dist/validation/state-validator.test.js +325 -0
  254. package/dist/validation/state-validator.test.js.map +1 -0
  255. package/dist/wizard/suggestion.test.d.ts +2 -0
  256. package/dist/wizard/suggestion.test.d.ts.map +1 -0
  257. package/dist/wizard/suggestion.test.js +115 -0
  258. package/dist/wizard/suggestion.test.js.map +1 -0
  259. package/dist/wizard/wizard.d.ts.map +1 -1
  260. package/dist/wizard/wizard.js +34 -1
  261. package/dist/wizard/wizard.js.map +1 -1
  262. package/knowledge/core/adr-craft.md +4 -0
  263. package/knowledge/core/api-design.md +4 -0
  264. package/knowledge/core/automated-review-tooling.md +203 -0
  265. package/knowledge/core/coding-conventions.md +1 -1
  266. package/knowledge/core/database-design.md +4 -0
  267. package/knowledge/core/design-system-tokens.md +4 -0
  268. package/knowledge/core/domain-modeling.md +4 -0
  269. package/knowledge/core/git-workflow-patterns.md +200 -0
  270. package/knowledge/core/operations-runbook.md +5 -1
  271. package/knowledge/core/security-best-practices.md +4 -0
  272. package/knowledge/core/system-architecture.md +5 -1
  273. package/knowledge/core/task-decomposition.md +118 -3
  274. package/knowledge/core/user-story-innovation.md +13 -0
  275. package/knowledge/core/ux-specification.md +13 -0
  276. package/knowledge/execution/enhancement-workflow.md +201 -0
  277. package/knowledge/execution/task-claiming-strategy.md +130 -0
  278. package/knowledge/execution/tdd-execution-loop.md +172 -0
  279. package/knowledge/execution/worktree-management.md +205 -0
  280. package/knowledge/finalization/apply-fixes-and-freeze.md +12 -0
  281. package/knowledge/finalization/developer-onboarding.md +4 -0
  282. package/knowledge/finalization/implementation-playbook.md +83 -5
  283. package/knowledge/product/gap-analysis.md +5 -1
  284. package/knowledge/product/prd-innovation.md +12 -0
  285. package/knowledge/product/vision-craft.md +213 -0
  286. package/knowledge/review/review-adr.md +12 -0
  287. package/knowledge/review/review-api-design.md +13 -0
  288. package/knowledge/review/review-database-design.md +13 -0
  289. package/knowledge/review/review-domain-modeling.md +5 -1
  290. package/knowledge/review/review-implementation-tasks.md +58 -1
  291. package/knowledge/review/review-methodology.md +11 -0
  292. package/knowledge/review/review-operations.md +12 -0
  293. package/knowledge/review/review-prd.md +13 -0
  294. package/knowledge/review/review-security.md +12 -0
  295. package/knowledge/review/review-system-architecture.md +4 -2
  296. package/knowledge/review/review-testing-strategy.md +11 -0
  297. package/knowledge/review/review-user-stories.md +11 -0
  298. package/knowledge/review/review-ux-specification.md +13 -1
  299. package/knowledge/review/review-vision.md +255 -0
  300. package/knowledge/tools/release-management.md +222 -0
  301. package/knowledge/tools/session-analysis.md +215 -0
  302. package/knowledge/tools/version-strategy.md +200 -0
  303. package/knowledge/validation/critical-path-analysis.md +1 -1
  304. package/knowledge/validation/cross-phase-consistency.md +12 -0
  305. package/knowledge/validation/decision-completeness.md +13 -1
  306. package/knowledge/validation/dependency-validation.md +12 -0
  307. package/knowledge/validation/scope-management.md +12 -0
  308. package/knowledge/validation/traceability.md +12 -0
  309. package/methodology/README.md +37 -0
  310. package/methodology/custom-defaults.yml +12 -1
  311. package/methodology/deep.yml +11 -0
  312. package/methodology/mvp.yml +11 -0
  313. package/package.json +3 -3
  314. package/pipeline/architecture/review-architecture.md +18 -7
  315. package/pipeline/architecture/system-architecture.md +11 -8
  316. package/pipeline/build/multi-agent-resume.md +245 -0
  317. package/pipeline/build/multi-agent-start.md +236 -0
  318. package/pipeline/build/new-enhancement.md +456 -0
  319. package/pipeline/build/quick-task.md +381 -0
  320. package/pipeline/build/single-agent-resume.md +210 -0
  321. package/pipeline/build/single-agent-start.md +207 -0
  322. package/pipeline/consolidation/claude-md-optimization.md +11 -8
  323. package/pipeline/consolidation/workflow-audit.md +15 -11
  324. package/pipeline/decisions/adrs.md +7 -5
  325. package/pipeline/decisions/review-adrs.md +14 -6
  326. package/pipeline/environment/ai-memory-setup.md +18 -12
  327. package/pipeline/environment/automated-pr-review.md +10 -4
  328. package/pipeline/environment/design-system.md +9 -7
  329. package/pipeline/environment/dev-env-setup.md +8 -5
  330. package/pipeline/environment/git-workflow.md +3 -1
  331. package/pipeline/finalization/apply-fixes-and-freeze.md +16 -5
  332. package/pipeline/finalization/developer-onboarding-guide.md +22 -8
  333. package/pipeline/finalization/implementation-playbook.md +40 -11
  334. package/pipeline/foundation/beads.md +10 -7
  335. package/pipeline/foundation/coding-standards.md +6 -3
  336. package/pipeline/foundation/project-structure.md +5 -1
  337. package/pipeline/foundation/tdd.md +10 -6
  338. package/pipeline/foundation/tech-stack.md +9 -9
  339. package/pipeline/integration/add-e2e-testing.md +21 -6
  340. package/pipeline/modeling/domain-modeling.md +10 -7
  341. package/pipeline/modeling/review-domain-modeling.md +17 -6
  342. package/pipeline/parity/platform-parity-review.md +31 -11
  343. package/pipeline/planning/implementation-plan-review.md +21 -10
  344. package/pipeline/planning/implementation-plan.md +52 -19
  345. package/pipeline/pre/create-prd.md +22 -7
  346. package/pipeline/pre/innovate-prd.md +10 -8
  347. package/pipeline/pre/innovate-user-stories.md +9 -7
  348. package/pipeline/pre/review-prd.md +11 -2
  349. package/pipeline/pre/review-user-stories.md +12 -3
  350. package/pipeline/pre/user-stories.md +12 -7
  351. package/pipeline/quality/create-evals.md +10 -6
  352. package/pipeline/quality/operations.md +16 -12
  353. package/pipeline/quality/review-operations.md +19 -10
  354. package/pipeline/quality/review-security.md +21 -11
  355. package/pipeline/quality/review-testing.md +23 -12
  356. package/pipeline/quality/security.md +17 -13
  357. package/pipeline/quality/story-tests.md +6 -4
  358. package/pipeline/specification/api-contracts.md +11 -6
  359. package/pipeline/specification/database-schema.md +12 -6
  360. package/pipeline/specification/review-api.md +18 -9
  361. package/pipeline/specification/review-database.md +18 -9
  362. package/pipeline/specification/review-ux.md +20 -10
  363. package/pipeline/specification/ux-spec.md +8 -5
  364. package/pipeline/validation/critical-path-walkthrough.md +14 -7
  365. package/pipeline/validation/cross-phase-consistency.md +14 -7
  366. package/pipeline/validation/decision-completeness.md +14 -7
  367. package/pipeline/validation/dependency-graph-validation.md +15 -7
  368. package/pipeline/validation/implementability-dry-run.md +15 -7
  369. package/pipeline/validation/scope-creep-check.md +15 -7
  370. package/pipeline/validation/traceability-matrix.md +20 -7
  371. package/pipeline/vision/create-vision.md +267 -0
  372. package/pipeline/vision/innovate-vision.md +157 -0
  373. package/pipeline/vision/review-vision.md +149 -0
  374. package/skills/scaffold-pipeline/SKILL.md +33 -18
  375. package/skills/scaffold-runner/SKILL.md +172 -18
@@ -0,0 +1,203 @@
1
+ ---
2
+ name: automated-review-tooling
3
+ description: Patterns for setting up automated PR code review using AI models (Codex, Gemini) via local CLI, including dual-model review, reconciliation, and CI integration
4
+ topics: [code-review, automation, codex, gemini, pull-requests, ci-cd, review-tooling]
5
+ ---
6
+
7
+ # Automated Review Tooling
8
+
9
+ Automated PR review leverages AI models to provide consistent, thorough code review without manual reviewer bottlenecks. This knowledge covers the local CLI approach (no GitHub Actions), dual-model review patterns, and integration with the PR workflow.
10
+
11
+ ## Summary
12
+
13
+ ### Architecture: Local CLI Review
14
+
15
+ The scaffold approach uses local CLI review rather than GitHub Actions:
16
+ - **No CI secrets required** — models run locally via CLI tools
17
+ - **Dual-model review** — run Codex and Gemini (when available) for independent perspectives
18
+ - **Agent-managed loop** — Claude orchestrates the review-fix cycle locally
19
+
20
+ Components:
21
+ - `AGENTS.md` — reviewer instructions with project-specific rules
22
+ - `docs/review-standards.md` — severity definitions (P0-P3) and criteria
23
+ - `scripts/cli-pr-review.sh` — dual-model review script
24
+ - `scripts/await-pr-review.sh` — polling script for external bot mode
25
+
26
+ ### Review Severity Levels
27
+
28
+ Consistent with the pipeline's review step severity:
29
+ - **P0 (blocking)** — must fix before merge (security, data loss, broken functionality)
30
+ - **P1 (important)** — should fix before merge (bugs, missing tests, performance)
31
+ - **P2 (suggestion)** — consider fixing (style, naming, documentation)
32
+ - **P3 (nit)** — optional (personal preference, minor optimization)
33
+
34
+ ### Dual-Model Review Pattern
35
+
36
+ When both Codex CLI and Gemini CLI are available:
37
+ 1. Run both reviewers independently on the PR diff
38
+ 2. Collect findings from each
39
+ 3. Reconcile: consensus findings get higher confidence
40
+ 4. Disagreements are flagged for the implementing agent to resolve
41
+
42
+ ### Integration with PR Workflow
43
+
44
+ The review step integrates into the standard PR flow:
45
+ 1. Agent creates PR
46
+ 2. Agent runs `scripts/cli-pr-review.sh` (or review runs automatically)
47
+ 3. Review findings are posted as PR comments or written to a local file
48
+ 4. Agent addresses P0/P1 findings, pushes fixes
49
+ 5. Re-review until no P0/P1 findings remain
50
+ 6. PR is ready for merge
51
+
52
+ ## Deep Guidance
53
+
54
+ ### AGENTS.md Structure
55
+
56
+ The `AGENTS.md` file provides reviewer instructions:
57
+
58
+ ```markdown
59
+ # Code Review Instructions
60
+
61
+ ## Project Context
62
+ [Brief description of what this project does]
63
+
64
+ ## Review Focus Areas
65
+ - Security: [project-specific security concerns]
66
+ - Performance: [known hot paths or constraints]
67
+ - Testing: [coverage requirements, test patterns]
68
+
69
+ ## Coding Standards Reference
70
+ See docs/coding-standards.md for:
71
+ - Naming conventions
72
+ - Error handling patterns
73
+ - Logging standards
74
+
75
+ ## Known Patterns
76
+ [Project-specific patterns reviewers should enforce]
77
+
78
+ ## Out of Scope
79
+ [Things reviewers should NOT flag]
80
+ ```
81
+
82
+ ### CLI Review Script Pattern
83
+
84
+ The `cli-pr-review.sh` script follows this structure:
85
+
86
+ ```bash
87
+ #!/usr/bin/env bash
88
+ set -euo pipefail
89
+
90
+ # 1. Get the PR diff
91
+ diff=$(gh pr diff "$PR_NUMBER")
92
+
93
+ # 2. Run Codex review (if available)
94
+ if command -v codex &>/dev/null; then
95
+ codex_findings=$(echo "$diff" | codex review --context AGENTS.md)
96
+ fi
97
+
98
+ # 3. Run Gemini review (if available)
99
+ if command -v gemini &>/dev/null; then
100
+ gemini_findings=$(echo "$diff" | gemini review --context AGENTS.md)
101
+ fi
102
+
103
+ # 4. Reconcile findings
104
+ # - Findings from both models: HIGH confidence
105
+ # - Findings from one model: MEDIUM confidence
106
+ # - Contradictions: flagged for human review
107
+ ```
108
+
109
+ ### Review Standards Document
110
+
111
+ `docs/review-standards.md` should define:
112
+ - Severity levels with concrete examples per project
113
+ - What constitutes a blocking review (P0/P1 threshold)
114
+ - Auto-approve criteria (when review can be skipped)
115
+ - Review SLA (how long before auto-approve kicks in)
116
+
117
+ ### Fallback When Models Unavailable
118
+
119
+ If neither Codex nor Gemini CLI is available:
120
+ 1. Claude performs an enhanced self-review of the diff
121
+ 2. Focus on the AGENTS.md review criteria
122
+ 3. Apply the same severity classification
123
+ 4. Document that the review was single-model
124
+
125
+ ### Updating Review Standards Over Time
126
+
127
+ As the project evolves:
128
+ - Add new review focus areas when new patterns emerge
129
+ - Remove rules that linters now enforce automatically
130
+ - Update AGENTS.md when architecture changes
131
+ - Track false-positive rates and adjust thresholds
132
+
133
+ ### Review Finding Reconciliation
134
+
135
+ When running dual-model review, reconcile findings systematically:
136
+
137
+ ```
138
+ Finding Classification:
139
+ ┌─────────────────┬──────────┬──────────┬───────────────────┐
140
+ │ │ Codex │ Gemini │ Action │
141
+ ├─────────────────┼──────────┼──────────┼───────────────────┤
142
+ │ Same issue │ Found │ Found │ HIGH confidence │
143
+ │ Unique finding │ Found │ - │ MEDIUM confidence │
144
+ │ Unique finding │ - │ Found │ MEDIUM confidence │
145
+ │ Contradiction │ Fix X │ Keep X │ Flag for agent │
146
+ └─────────────────┴──────────┴──────────┴───────────────────┘
147
+ ```
148
+
149
+ HIGH confidence findings are always addressed. MEDIUM confidence findings are addressed if P0/P1. Contradictions require the implementing agent to make a judgment call and document the reasoning.
150
+
151
+ ### Security-Focused Review Checklist
152
+
153
+ Every automated review should check:
154
+ - No secrets or credentials in the diff (API keys, passwords, tokens)
155
+ - No `eval()` or equivalent unsafe operations introduced
156
+ - SQL queries use parameterized queries (no string concatenation)
157
+ - User input is validated before use
158
+ - Authentication/authorization checks are present on new endpoints
159
+ - Dependencies added are from trusted sources with known versions
160
+
161
+ ### Performance Review Patterns
162
+
163
+ Look for these performance anti-patterns:
164
+ - N+1 queries (loop with individual DB calls)
165
+ - Missing pagination on list endpoints
166
+ - Synchronous operations that should be async
167
+ - Large objects passed by value instead of reference
168
+ - Missing caching for expensive computations
169
+ - Unbounded growth in arrays or maps
170
+
171
+ ### Integration with CLAUDE.md
172
+
173
+ The workflow-audit step should add review commands to CLAUDE.md:
174
+
175
+ ```markdown
176
+ ## Code Review
177
+ | Command | Purpose |
178
+ |---------|---------|
179
+ | `scripts/cli-pr-review.sh <PR#>` | Run dual-model review |
180
+ | `scripts/await-pr-review.sh <PR#>` | Poll for external review |
181
+ ```
182
+
183
+ This ensures agents always know how to trigger reviews without consulting separate docs.
184
+
185
+ ### Common False Positives
186
+
187
+ Track and suppress recurring false positives:
188
+ - Test files flagged for "hardcoded values" (test fixtures are intentional)
189
+ - Migration files flagged for "raw SQL" (migrations must use raw SQL)
190
+ - Generated files flagged for style issues (generated code has its own conventions)
191
+
192
+ Add suppressions to AGENTS.md under "Out of Scope" to prevent repeated false findings.
193
+
194
+ ### Review Metrics and Continuous Improvement
195
+
196
+ Track these metrics over time to improve review quality:
197
+ - **False positive rate** — findings that are dismissed without action
198
+ - **Escape rate** — bugs that reach production despite review
199
+ - **Time to resolve** — average time between finding and fix
200
+ - **Coverage** — percentage of PRs that receive automated review
201
+ - **Model agreement rate** — how often Codex and Gemini agree
202
+
203
+ Use these metrics to calibrate severity thresholds and update AGENTS.md focus areas.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: coding-conventions
3
3
  description: Universal coding standards patterns across languages and linter/formatter configuration
4
- topics: [coding-standards, linting, formatting, naming-conventions, error-handling, code-style]
4
+ topics: [coding-standards, linting, formatting, naming, error-handling, code-style]
5
5
  ---
6
6
 
7
7
  # Coding Conventions
@@ -4,6 +4,8 @@ description: Database schema design, normalization, indexing, and migration patt
4
4
  topics: [database, schema, sql, nosql, migrations, indexing, data-modeling]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## From Domain Models to Schema
8
10
 
9
11
  The domain model defines what the business cares about. The database schema defines how that information is stored. The mapping between them is deliberate, not automatic.
@@ -77,6 +79,8 @@ metadata JSONB NOT NULL DEFAULT '{}'
77
79
 
78
80
  **Lookup table** — Store value objects with limited valid values in a reference table. Best for enums with associated data (status codes with descriptions, country codes with names).
79
81
 
82
+ ## Deep Guidance
83
+
80
84
  ### Modeling Relationships
81
85
 
82
86
  **One-to-one:** Use a foreign key in either table (typically the dependent side). Consider: could this be columns in the same table instead?
@@ -4,6 +4,8 @@ description: Design token definitions, base component visual specs, dark mode pa
4
4
  topics: [design-system, tokens, colors, typography, spacing, components, dark-mode, pattern-library]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## Design Tokens
8
10
 
9
11
  Design tokens are the atomic values that define the visual language. They are variables, not hard-coded values. Every visual property in the application references a token.
@@ -66,6 +68,8 @@ Design tokens are the atomic values that define the visual language. They are va
66
68
  --color-focus-ring: rgba(37,99,235,0.5) // Focus indicator
67
69
  ```
68
70
 
71
+ ## Deep Guidance
72
+
69
73
  ### Typography Tokens
70
74
 
71
75
  **Font families:**
@@ -4,6 +4,8 @@ description: Domain-driven design patterns for identifying and modeling project
4
4
  topics: [ddd, domain-modeling, entities, aggregates, bounded-contexts, domain-events, value-objects]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## Strategic DDD Patterns
8
10
 
9
11
  Strategic DDD operates at the system level, answering where domain boundaries fall and how domains communicate.
@@ -54,6 +56,8 @@ Not all parts of a system are equally important or complex. Classify domains by
54
56
 
55
57
  **Classification decisions matter because they drive resource allocation.** Over-investing in a generic domain (building a custom auth system when Auth0 exists) wastes effort. Under-investing in a core domain (using a generic CRUD framework for your competitive advantage) produces mediocre software.
56
58
 
59
+ ## Deep Guidance
60
+
57
61
  ## Tactical DDD Patterns
58
62
 
59
63
  Tactical DDD patterns structure the code within a bounded context.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: git-workflow-patterns
3
+ description: Git branching strategies, commit conventions, PR workflows, merge policies, and CI integration patterns for AI-agent-driven development
4
+ topics: [git, branching, commits, pull-requests, ci-cd, merge-strategy, worktrees]
5
+ ---
6
+
7
+ # Git Workflow Patterns
8
+
9
+ Structured git workflows for AI-agent-driven projects ensure consistent branching, meaningful commit history, automated quality gates, and smooth multi-agent collaboration via worktrees.
10
+
11
+ ## Summary
12
+
13
+ ### Branching Strategy
14
+
15
+ The trunk-based development model works best for AI-agent workflows:
16
+
17
+ - **Main branch** (`main`) — always deployable, protected by CI
18
+ - **Feature branches** — short-lived, created per task or story (`feat/US-xxx-slug`, `fix/bug-description`)
19
+ - **Worktree branches** — parallel agent execution using git worktrees (`agent/<name>/<task>`)
20
+
21
+ Branch naming conventions:
22
+ ```
23
+ feat/US-001-user-registration # Feature work tied to a story
24
+ fix/login-timeout-handling # Bug fix
25
+ chore/update-dependencies # Maintenance
26
+ docs/api-contract-updates # Documentation only
27
+ ```
28
+
29
+ ### Commit Conventions
30
+
31
+ Use Conventional Commits format for machine-parseable history:
32
+
33
+ ```
34
+ <type>(<scope>): <description>
35
+
36
+ [optional body]
37
+
38
+ [optional footer(s)]
39
+ ```
40
+
41
+ Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `ci`
42
+
43
+ AI agent commits should include the Co-Authored-By trailer for attribution and auditability.
44
+
45
+ ### Pull Request Workflow
46
+
47
+ Standard PR lifecycle:
48
+ 1. Create branch from `main`
49
+ 2. Implement changes with passing tests
50
+ 3. Push branch, create PR with structured description
51
+ 4. CI runs all quality gates (`make check` or equivalent)
52
+ 5. Review (automated or manual)
53
+ 6. Squash-merge to maintain clean history
54
+ 7. Delete branch after merge
55
+
56
+ ## Deep Guidance
57
+
58
+ ### Merge Policies
59
+
60
+ - **Squash merge** for feature branches — keeps main history clean
61
+ - **Merge commit** for release branches — preserves the merge point
62
+ - **Never force-push** to main or shared branches
63
+ - **Delete branches** after merge to prevent clutter
64
+
65
+ ### CI Integration
66
+
67
+ Minimum CI pipeline for scaffold projects:
68
+ 1. **Lint** — ShellCheck, ESLint, or language-appropriate linter
69
+ 2. **Test** — Full test suite including evals
70
+ 3. **Build** — Verify compilation/bundling succeeds
71
+ 4. **Type check** — For typed languages (TypeScript, etc.)
72
+
73
+ ### Worktree Patterns for Multi-Agent Work
74
+
75
+ Git worktrees enable parallel agent execution on the same repository:
76
+
77
+ ```bash
78
+ # Create a worktree for an agent
79
+ scripts/setup-agent-worktree.sh agent-name
80
+
81
+ # Each worktree gets its own branch and working directory
82
+ # Agents can work simultaneously without conflicts
83
+ ```
84
+
85
+ Key rules:
86
+ - Each agent works in its own worktree with its own branch
87
+ - Agents coordinate via the implementation plan task assignments
88
+ - Merge conflicts are resolved by the agent whose branch is behind
89
+ - The main worktree is the coordination point
90
+
91
+ ### Branch Protection Rules
92
+
93
+ Configure branch protection for `main`:
94
+ - Require status checks to pass before merge
95
+ - Require branches to be up to date before merge
96
+ - Do not allow direct pushes
97
+ - Require squash merging for feature branches
98
+
99
+ ### Commit Message Quality
100
+
101
+ Good commit messages for AI agents:
102
+ ```
103
+ feat(auth): add JWT token refresh endpoint
104
+
105
+ Implements automatic token refresh when the access token expires
106
+ within 5 minutes. Refresh tokens are rotated on each use.
107
+
108
+ Closes US-015
109
+ ```
110
+
111
+ Bad commit messages to avoid:
112
+ - `fix stuff` — no context
113
+ - `WIP` — should never be pushed
114
+ - `update` — what was updated?
115
+
116
+ ### PR Description Template
117
+
118
+ ```
119
+ ### What changed
120
+ - [1-3 bullet points describing the change]
121
+
122
+ ### Files modified
123
+ - [Specific files/components modified]
124
+
125
+ ### How to test
126
+ - [How to verify the changes work]
127
+
128
+ ### Related
129
+ - [Story ID, issue link, or ADR reference]
130
+ ```
131
+
132
+ ### Conflict Resolution Strategy
133
+
134
+ When multiple agents work in parallel:
135
+ 1. Agent finishing first merges normally
136
+ 2. Agent finishing second rebases onto updated main
137
+ 3. If conflicts arise, the second agent resolves them
138
+ 4. Never force-push over another agent's work
139
+
140
+ Conflict resolution checklist:
141
+ - Pull latest main before starting any task
142
+ - Rebase frequently on long-running branches (every few commits)
143
+ - If a rebase produces conflicts in files you didn't modify, investigate — another agent may have refactored the same area
144
+ - After resolving conflicts, re-run the full test suite before pushing
145
+ - Document unusual conflict resolutions in the commit message body
146
+
147
+ ### Release Workflow
148
+
149
+ For version-tagged releases:
150
+ 1. Ensure all PRs are merged to main
151
+ 2. Run full quality gates on main
152
+ 3. Create a version tag (`v1.2.3`)
153
+ 4. Generate changelog from conventional commits
154
+ 5. Push tag to trigger release pipeline
155
+
156
+ ### Semantic Versioning
157
+
158
+ Follow semver for version tags:
159
+ - **MAJOR** (`X.0.0`) — breaking API changes, incompatible migrations
160
+ - **MINOR** (`0.X.0`) — new features, backward-compatible additions
161
+ - **PATCH** (`0.0.X`) — bug fixes, documentation, internal refactors
162
+
163
+ Pre-release versions for staging: `v1.2.3-rc.1`, `v1.2.3-beta.1`
164
+
165
+ ### Git Hooks
166
+
167
+ Pre-commit hooks for quality enforcement:
168
+ ```bash
169
+ # .husky/pre-commit or .git/hooks/pre-commit
170
+ #!/usr/bin/env bash
171
+ set -euo pipefail
172
+
173
+ # Run linter on staged files
174
+ make lint
175
+
176
+ # Validate frontmatter on changed command files
177
+ ./scripts/validate-frontmatter.sh $(git diff --cached --name-only -- 'commands/*.md')
178
+ ```
179
+
180
+ Pre-push hooks for broader validation:
181
+ ```bash
182
+ # .husky/pre-push or .git/hooks/pre-push
183
+ #!/usr/bin/env bash
184
+ set -euo pipefail
185
+
186
+ # Run full test suite before pushing
187
+ make test
188
+ ```
189
+
190
+ ### Common Anti-Patterns
191
+
192
+ Patterns to avoid in AI-agent git workflows:
193
+
194
+ 1. **Long-lived branches** — branches older than 1 day risk merge conflicts. Keep branches short-lived.
195
+ 2. **Giant PRs** — PRs with 500+ lines changed are hard to review. Split into smaller, focused PRs.
196
+ 3. **Skipping hooks** — `--no-verify` hides real issues. Fix the root cause instead.
197
+ 4. **Rebasing shared branches** — only rebase branches that only you use. Shared branches use merge commits.
198
+ 5. **Committing generated files** — lock files yes, build output no. Use `.gitignore` aggressively.
199
+ 6. **Force-pushing to main** — this is never acceptable. Even if CI is broken, create a fix branch.
200
+ 7. **Mixing concerns in one commit** — each commit should be atomic and focused on one change.
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  name: operations-runbook
3
3
  description: Deployment pipeline, deployment strategies, monitoring, alerting, and incident response
4
- topics: [operations, cicd, deployment, monitoring, incident-response, alerting, rollback]
4
+ topics: [operations, ci-cd, deployment, monitoring, incident-response, alerting, rollback]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## Dev Environment Reference
8
10
 
9
11
  Local development setup (prerequisites, env vars, one-command setup, database, hot reload, common commands, troubleshooting) is defined in `docs/dev-setup.md`, created by the Dev Setup prompt. The operations runbook should reference it rather than redefine it.
@@ -73,6 +75,8 @@ Operations adds (main branch only):
73
75
  - Tag artifacts with the git SHA for traceability
74
76
  - Set retention policies (keep last 30 days, keep releases forever)
75
77
 
78
+ ## Deep Guidance
79
+
76
80
  ## Deployment Strategies
77
81
 
78
82
  ### Blue-Green Deployment
@@ -4,6 +4,8 @@ description: OWASP Top 10, authentication, authorization, data protection, and t
4
4
  topics: [security, owasp, authentication, authorization, threat-modeling, secrets-management, dependency-auditing]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## OWASP Top 10
8
10
 
9
11
  The OWASP Top 10 represents the most critical security risks to web applications. Every project should evaluate each risk and implement appropriate mitigations.
@@ -55,6 +57,8 @@ Sensitive data exposed due to weak or missing encryption.
55
57
  - Hash passwords with bcrypt, scrypt, or Argon2 (NEVER MD5 or SHA-256 for passwords)
56
58
  - Don't store sensitive data you don't need — the safest data is data you don't have
57
59
 
60
+ ## Deep Guidance
61
+
58
62
  ### A03: Injection
59
63
 
60
64
  Untrusted data sent to an interpreter as part of a command or query, causing unintended execution.
@@ -1,9 +1,11 @@
1
1
  ---
2
2
  name: system-architecture
3
3
  description: Architecture patterns, component design, and project structure
4
- topics: [architecture, components, modules, data-flows, project-structure, state-management]
4
+ topics: [architecture, components, modules, data-flow, project-structure, state-management]
5
5
  ---
6
6
 
7
+ ## Summary
8
+
7
9
  ## Architecture Patterns
8
10
 
9
11
  ### Layered Architecture
@@ -81,6 +83,8 @@ For most scaffold pipeline projects:
81
83
  4. Use **microservices** only if you have multiple teams that need independent deployment, or specific services with dramatically different scaling needs.
82
84
  5. Avoid **layered** unless the application is genuinely simple (CRUD with minimal business logic).
83
85
 
86
+ ## Deep Guidance
87
+
84
88
  ## Component Design
85
89
 
86
90
  ### Identifying Components from Domain Models
@@ -16,7 +16,14 @@ User stories bridge PRD features and implementation tasks. Each story decomposes
16
16
 
17
17
  ### Task Sizing
18
18
 
19
- Each task should be completable in a single AI agent session (30-90 minutes of agent time). A well-sized task has a clear title (usable as commit message), touches 1-5 files, produces a testable result, and has no ambiguity about "done."
19
+ Each task should be completable in a single AI agent session (30-90 minutes of agent time). A well-sized task has a clear title (usable as commit message), touches 1-3 application files (hard limit; justify exceptions), produces ~150 lines of net-new application code (excluding tests and generated files), and has no ambiguity about "done."
20
+
21
+ Five rules govern agent-friendly task sizing:
22
+ 1. **Three-File Rule** — Max 3 application files modified (test files excluded)
23
+ 2. **150-Line Budget** — Max ~150 lines of net-new application code per task
24
+ 3. **Single-Concern Rule** — One task does one thing (no "and" connecting unrelated work)
25
+ 4. **Decision-Free Execution** — All design decisions resolved in the task description; agents implement, they don't architect
26
+ 5. **Test Co-location** — Tests live in the same task as the code they test; no deferred testing
20
27
 
21
28
  Split large tasks by layer (API, UI, DB, tests), by feature slice (happy path, validation, edge cases), or by entity. Combine tiny tasks that touch the same file and have no independent value.
22
29
 
@@ -157,8 +164,11 @@ Each task should be completable in a single AI agent session (typically 30-90 mi
157
164
 
158
165
  **A well-sized task:**
159
166
  - Has a clear, specific title that could be a commit message
160
- - Touches 1-5 files (not counting test files)
161
- - Produces a testable, verifiable result
167
+ - Touches 1-3 application files (hard limit; test files excluded from count)
168
+ - Produces ~150 lines of net-new application code (excluding tests and generated files)
169
+ - Does exactly one thing (passes the single-concern test: describable without "and")
170
+ - Requires no design decisions from the agent (all choices resolved in the description)
171
+ - Includes co-located tests (the task isn't done until tests pass)
162
172
  - Has no ambiguity about what "done" means
163
173
  - Can be code-reviewed independently
164
174
 
@@ -376,6 +386,111 @@ Does NOT assume:
376
386
  - Any auth endpoints exist (this is the first)
377
387
  ```
378
388
 
389
+ ### Agent Executability Heuristics
390
+
391
+ Five formalized rules for ensuring tasks are the right size for AI agent execution. These are hard rules with an escape hatch — tasks exceeding limits must be split unless the author provides explicit justification via `<!-- agent-size-exception: reason -->`.
392
+
393
+ #### Rule 1: Three-File Rule
394
+
395
+ A task modifies at most 3 application files (test files don't count toward this limit). If it would touch more, split by layer or concern.
396
+
397
+ **Why 3:** Reading 3 files plus their context (imports, types, interfaces) consumes roughly 40-60% of a standard agent context window, leaving room for the task description, test code, and reasoning. At 5+ files, context pressure causes agents to lose track of cross-file consistency.
398
+
399
+ **Splitting when exceeded:**
400
+ - 4 files across 2 layers → split into one task per layer
401
+ - 5 files in the same layer → split by entity or concern within the layer
402
+ - Config files touched alongside application files → separate config task if non-trivial
403
+
404
+ #### Rule 2: 150-Line Budget
405
+
406
+ A task produces at most ~150 lines of net-new application code (excluding tests, generated files, and config). This keeps the entire change reviewable in one screen and within agent context budgets.
407
+
408
+ **Why 150:** Agent output quality degrades measurably after ~200 lines of new code in a single session. At 150 lines, the agent can hold the entire change in context while writing tests and verifying correctness.
409
+
410
+ **Estimating line count from task descriptions:**
411
+ - A CRUD endpoint with validation: ~80-120 lines
412
+ - A UI component with state management: ~100-150 lines
413
+ - A database migration with seed data: ~50-80 lines
414
+ - A full feature slice (API + UI + tests): ~300+ lines — MUST split
415
+
416
+ #### Rule 3: Single-Concern Rule
417
+
418
+ A task does exactly one thing. The test: can you describe what this task does in one sentence without "and"?
419
+
420
+ **Passes the test:**
421
+ - "Implement the user registration endpoint with input validation" (validation is part of the endpoint)
422
+ - "Create the order model with database migration" (migration is part of model creation)
423
+
424
+ **Fails the test:**
425
+ - "Add the API endpoint AND update the dashboard" — two tasks
426
+ - "Implement authentication AND set up the database" — two tasks
427
+ - "Build the payment form AND integrate with Stripe AND add webhook handling" — three tasks
428
+
429
+ **Splitting signals:**
430
+ - Task description contains "and" connecting unrelated work
431
+ - Task spans multiple architectural layers (API + frontend + database in one task)
432
+ - Task affects multiple bounded contexts or feature domains
433
+ - Task has acceptance criteria for two distinct user-facing behaviors
434
+
435
+ #### Rule 4: Decision-Free Execution
436
+
437
+ The task description must resolve all design decisions upfront. The agent implements, it doesn't architect. No task should require the agent to:
438
+
439
+ - Choose between patterns (repository vs active record, REST vs GraphQL)
440
+ - Select libraries or tools
441
+ - Decide module structure or file organization
442
+ - Determine API contract shapes (these come from upstream specs)
443
+
444
+ **Red flags in task descriptions:**
445
+ - "Choose the best approach for..."
446
+ - "Determine whether to use X or Y"
447
+ - "Decide how to structure..."
448
+ - "Evaluate options for..."
449
+ - "Select the most appropriate..."
450
+ - "Figure out the best way to..."
451
+
452
+ If a task contains any of these, the decision belongs in the task description — resolved by the plan author — not left to agent judgment. Local implementation choices (variable names, loop style, internal helper structure) are fine.
453
+
454
+ #### Rule 5: Test Co-location
455
+
456
+ Tests live in the same task as the code they test. The task follows TDD: write the failing test, then the implementation, then verify. The task isn't done until tests pass.
457
+
458
+ **Anti-pattern:** "Tasks 1-8: implement features. Task 9: write tests for everything." This produces untestable code, violates TDD, and creates a single massive testing task that exceeds all size limits.
459
+
460
+ **What co-location looks like:**
461
+ ```
462
+ Task: Implement user registration endpoint
463
+ 1. Write failing integration test (POST /register with valid data → 201)
464
+ 2. Implement endpoint to make test pass
465
+ 3. Write failing validation test (invalid email → 400)
466
+ 4. Add validation to make test pass
467
+ 5. Commit
468
+ ```
469
+
470
+ #### Escape Hatch
471
+
472
+ If a task genuinely can't be split further without creating tasks that have no independent value, add an explicit annotation in the task description: `<!-- agent-size-exception: [reason] -->`. The review pass flags unjustified exceptions but accepts reasoned ones.
473
+
474
+ **Valid exception reasons:**
475
+ - "Migration task touches 4 files but they're all trivial one-line renames"
476
+ - "Config file changes across 4 files are mechanical and identical in structure"
477
+ - "Test setup file is large but generated from a template"
478
+
479
+ **Invalid exception reasons:**
480
+ - "It's easier to do it all at once" (convenience is not a justification)
481
+ - "The files are related" (related files can still be separate tasks)
482
+ - "It would create too many tasks" (more small tasks > fewer large tasks)
483
+
484
+ #### Concrete "Too Big" Examples
485
+
486
+ | Task (Too Big) | Violations | Split Into |
487
+ |---------------|-----------|------------|
488
+ | "Implement user authentication" (8+ files, registration + login + reset + middleware) | Three-File, Single-Concern | 4 tasks: registration endpoint, login endpoint, password reset flow, auth middleware |
489
+ | "Build the settings page with all preferences" (6 files, multiple forms + APIs) | Three-File, 150-Line, Single-Concern | Per-group: profile settings, notification settings, security settings |
490
+ | "Set up database with all migrations and seed data" (10+ files, every entity) | Three-File, 150-Line | Per-entity: users table, orders table, products table, then seed data task |
491
+ | "Create API client with retry, caching, and auth" (4 concerns in one module) | Single-Concern, Decision-Free | 3 tasks: base client with auth, retry middleware, cache layer |
492
+ | "Implement the dashboard with charts, filters, and real-time updates" (5+ files, 300+ lines) | All five rules | 4 tasks: dashboard layout + routing, chart components, filter system, WebSocket integration |
493
+
379
494
  ### Common Pitfalls
380
495
 
381
496
  **Tasks too vague.** "Implement backend" or "Set up auth" with no acceptance criteria, no file paths, and no test requirements. An agent receiving this task will guess wrong about scope, structure, and conventions. Fix: every task must specify exact files to create/modify, acceptance criteria, and test requirements.