@hassangameryt/freeflow 0.8.0 → 0.9.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 (290) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +2 -2
  4. package/.codex-plugin/plugin.json +3 -3
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/README.md +96 -149
  7. package/capabilities/cognitive-routing/SKILL.md +21 -129
  8. package/capabilities/cognitive-routing/references/coordinator.md +163 -0
  9. package/capabilities/cognitive-routing/references/worker.md +38 -0
  10. package/capabilities/compaction/SKILL.md +3 -3
  11. package/capabilities/compaction/references/summary-format.md +26 -15
  12. package/capabilities/messaging/SKILL.md +49 -0
  13. package/capabilities/task-memory/SKILL.md +87 -0
  14. package/command-surface.json +6 -54
  15. package/gemini-extension.json +1 -1
  16. package/hooks/claude/hooks.json +13 -3
  17. package/hooks/codex/hooks.json +2 -1
  18. package/hooks/shared/runtime-context.mjs +69 -77
  19. package/package.json +25 -8
  20. package/pi-extension/dist/ask-user/ask.js +108 -0
  21. package/pi-extension/dist/ask-user/form.js +250 -0
  22. package/pi-extension/dist/ask-user/questions.js +66 -0
  23. package/pi-extension/dist/ask-user/tool.js +124 -0
  24. package/pi-extension/dist/cognitive-routing/assembler.js +35 -11
  25. package/pi-extension/dist/cognitive-routing/bootstrap.js +90 -0
  26. package/pi-extension/dist/cognitive-routing/config.js +3 -4
  27. package/pi-extension/dist/cognitive-routing/event-store.js +4 -1
  28. package/pi-extension/dist/cognitive-routing/gate.js +20 -5
  29. package/pi-extension/dist/cognitive-routing/handlers.js +15 -13
  30. package/pi-extension/dist/cognitive-routing/model-control.js +17 -8
  31. package/pi-extension/dist/cognitive-routing/projection.js +23 -6
  32. package/pi-extension/dist/cognitive-routing/provenance.js +3 -1
  33. package/pi-extension/dist/cognitive-routing/render.js +15 -15
  34. package/pi-extension/dist/cognitive-routing/runtime.js +4 -2
  35. package/pi-extension/dist/cognitive-routing/schemas.js +4 -4
  36. package/pi-extension/dist/cognitive-routing/session.js +3 -1
  37. package/pi-extension/dist/cognitive-routing/sources.js +29 -4
  38. package/pi-extension/dist/cognitive-routing/state.js +18 -8
  39. package/pi-extension/dist/cognitive-routing/status.js +4 -3
  40. package/pi-extension/dist/cognitive-routing/tools.js +29 -15
  41. package/pi-extension/dist/cognitive-routing/types.js +10 -1
  42. package/pi-extension/dist/compaction/carry.js +36 -22
  43. package/pi-extension/dist/compaction/config.js +4 -2
  44. package/pi-extension/dist/compaction/controller.js +52 -29
  45. package/pi-extension/dist/compaction/harness.js +19 -3
  46. package/pi-extension/dist/compaction/results.js +14 -13
  47. package/pi-extension/dist/compaction/tool.js +6 -6
  48. package/pi-extension/dist/host/catalog.js +20 -35
  49. package/pi-extension/dist/host/config-validation.js +233 -0
  50. package/pi-extension/dist/host/config.js +78 -91
  51. package/pi-extension/dist/host/inbound.js +142 -0
  52. package/pi-extension/dist/host/projection-tags.js +1 -1
  53. package/pi-extension/dist/host/prompts.js +24 -13
  54. package/pi-extension/dist/host/read-only-session.js +6 -1
  55. package/pi-extension/dist/host/request-history.js +7 -3
  56. package/pi-extension/dist/host/rows.js +25 -0
  57. package/pi-extension/dist/host/runtime-state.js +17 -2
  58. package/pi-extension/dist/host/section-keeper.js +85 -0
  59. package/pi-extension/dist/host/settings/freeflow-command.js +846 -93
  60. package/pi-extension/dist/host/settings/settings-view.js +27 -8
  61. package/pi-extension/dist/host/status.js +19 -5
  62. package/pi-extension/dist/index.js +638 -72
  63. package/pi-extension/dist/messaging/config.js +27 -0
  64. package/pi-extension/dist/messaging/messaging.js +398 -0
  65. package/pi-extension/dist/messaging/registry.js +57 -0
  66. package/pi-extension/dist/messaging/render.js +90 -0
  67. package/pi-extension/dist/messaging/tools.js +109 -0
  68. package/pi-extension/dist/messaging/transport.js +101 -0
  69. package/pi-extension/dist/provider-support/cache/keepalive.js +16 -4
  70. package/pi-extension/dist/task-memory/config.js +49 -0
  71. package/pi-extension/dist/task-memory/registry.js +119 -0
  72. package/pi-extension/dist/task-memory/render.js +107 -0
  73. package/pi-extension/dist/task-memory/runtime.js +994 -0
  74. package/pi-extension/dist/task-memory/tool.js +233 -0
  75. package/pi-extension/dist/tool-execution/apply-patch/tool.js +1 -1
  76. package/pi-extension/dist/tool-execution/background.js +220 -28
  77. package/pi-extension/dist/tool-execution/config.js +14 -3
  78. package/pi-extension/dist/tool-execution/file-tracking.js +24 -4
  79. package/pi-extension/dist/tool-execution/guidance-notices.js +124 -0
  80. package/pi-extension/dist/tool-execution/skill-reads.js +143 -0
  81. package/pi-extension/dist/tool-execution/tools.js +2 -2
  82. package/runtime/prompts/cognitive-routing.md +4 -4
  83. package/runtime/prompts/core.md +24 -14
  84. package/runtime/prompts/interaction-contract.md +7 -4
  85. package/runtime/prompts/tool-execution.md +3 -16
  86. package/runtime/prompts/working-method.md +16 -99
  87. package/skills/deliver-work/SKILL.md +76 -0
  88. package/skills/deliver-work/references/branch-closeout.md +134 -0
  89. package/skills/deliver-work/references/commit.md +83 -0
  90. package/skills/deliver-work/references/launch.md +94 -0
  91. package/skills/deliver-work/references/release.md +85 -0
  92. package/skills/deliver-work/scripts/commit-state.mjs +139 -0
  93. package/skills/deliver-work/scripts/delivery-state.mjs +107 -0
  94. package/skills/deliver-work/scripts/lib/git-state.mjs +178 -0
  95. package/skills/deliver-work/scripts/push-route.mjs +122 -0
  96. package/skills/deliver-work/scripts/release-preflight.mjs +177 -0
  97. package/skills/discuss-work/SKILL.md +148 -0
  98. package/skills/{discuss → discuss-work}/references/discussion-continuity.md +10 -27
  99. package/skills/discuss-work/references/learning-action.md +36 -0
  100. package/skills/discuss-work/scripts/choices.mjs +101 -0
  101. package/skills/discuss-work/scripts/lib/choices.mjs +159 -0
  102. package/skills/evaluate-behavior/SKILL.md +107 -0
  103. package/skills/evaluate-behavior/references/authoring.md +381 -0
  104. package/skills/evaluate-behavior/references/coding-tasks.md +145 -0
  105. package/skills/evaluate-behavior/references/conversations-pipelines-judges.md +177 -0
  106. package/skills/evaluate-behavior/references/design-and-measurement.md +273 -0
  107. package/skills/evaluate-behavior/references/running-and-evidence.md +245 -0
  108. package/skills/evaluate-behavior/scripts/claude-guard.mjs +76 -0
  109. package/skills/evaluate-behavior/scripts/guard-rules.mjs +309 -0
  110. package/skills/evaluate-behavior/scripts/lib/agreement.mjs +90 -0
  111. package/skills/evaluate-behavior/scripts/lib/arms.mjs +55 -0
  112. package/skills/evaluate-behavior/scripts/lib/budget.mjs +87 -0
  113. package/skills/evaluate-behavior/scripts/lib/build-source.mjs +287 -0
  114. package/skills/evaluate-behavior/scripts/lib/clear.mjs +74 -0
  115. package/skills/evaluate-behavior/scripts/lib/container.mjs +395 -0
  116. package/skills/evaluate-behavior/scripts/lib/decision.mjs +418 -0
  117. package/skills/evaluate-behavior/scripts/lib/definitions.mjs +1072 -0
  118. package/skills/evaluate-behavior/scripts/lib/freeflow.mjs +103 -0
  119. package/skills/evaluate-behavior/scripts/lib/grade-command.mjs +591 -0
  120. package/skills/evaluate-behavior/scripts/lib/grade-comparison.mjs +90 -0
  121. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-interaction.mjs +19 -18
  122. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-support.mjs +32 -5
  123. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/grade-workspace.mjs +28 -12
  124. package/skills/evaluate-behavior/scripts/lib/grade.mjs +101 -0
  125. package/skills/evaluate-behavior/scripts/lib/hooks.mjs +98 -0
  126. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/confinement.mjs +196 -0
  127. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/constraints.mjs +111 -0
  128. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/index.mjs +48 -0
  129. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/isolation.mjs +74 -0
  130. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/launch.mjs +123 -0
  131. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/model-call.mjs +73 -0
  132. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/recorder.mjs +178 -0
  133. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/session.mjs +494 -0
  134. package/skills/evaluate-behavior/scripts/lib/hosts/claude-code/skills.mjs +81 -0
  135. package/skills/evaluate-behavior/scripts/lib/hosts/index.mjs +31 -0
  136. package/skills/evaluate-behavior/scripts/lib/hosts/names.mjs +3 -0
  137. package/skills/evaluate-behavior/scripts/lib/hosts/pi/confinement.mjs +173 -0
  138. package/skills/evaluate-behavior/scripts/lib/hosts/pi/host.mjs +148 -0
  139. package/skills/evaluate-behavior/scripts/lib/hosts/pi/index.mjs +70 -0
  140. package/skills/evaluate-behavior/scripts/lib/hosts/pi/isolation.mjs +81 -0
  141. package/skills/evaluate-behavior/scripts/lib/hosts/pi/model-call.mjs +79 -0
  142. package/skills/evaluate-behavior/scripts/lib/hosts/pi/process.mjs +241 -0
  143. package/skills/{evaluate-skill/scripts/lib → evaluate-behavior/scripts/lib/hosts/pi}/rpc.mjs +144 -26
  144. package/skills/evaluate-behavior/scripts/lib/identity.mjs +82 -0
  145. package/skills/evaluate-behavior/scripts/lib/judge.mjs +688 -0
  146. package/skills/evaluate-behavior/scripts/lib/metrics.mjs +332 -0
  147. package/skills/evaluate-behavior/scripts/lib/model-call.mjs +17 -0
  148. package/skills/evaluate-behavior/scripts/lib/participants.mjs +616 -0
  149. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/process.mjs +22 -0
  150. package/skills/evaluate-behavior/scripts/lib/queue.mjs +54 -0
  151. package/skills/evaluate-behavior/scripts/lib/reference.mjs +343 -0
  152. package/skills/evaluate-behavior/scripts/lib/reuse.mjs +277 -0
  153. package/skills/evaluate-behavior/scripts/lib/review.mjs +933 -0
  154. package/skills/evaluate-behavior/scripts/lib/runner.mjs +732 -0
  155. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/sandbox.mjs +119 -14
  156. package/skills/evaluate-behavior/scripts/lib/scan-shell.mjs +457 -0
  157. package/skills/evaluate-behavior/scripts/lib/scan.mjs +479 -0
  158. package/skills/evaluate-behavior/scripts/lib/seal.mjs +91 -0
  159. package/skills/evaluate-behavior/scripts/lib/shell.mjs +560 -0
  160. package/skills/evaluate-behavior/scripts/lib/source-override.mjs +64 -0
  161. package/skills/evaluate-behavior/scripts/lib/subject-file.mjs +88 -0
  162. package/skills/{evaluate-skill/scripts/lib/pi.mjs → evaluate-behavior/scripts/lib/subject.mjs} +235 -265
  163. package/skills/evaluate-behavior/scripts/lib/task-copy.mjs +124 -0
  164. package/skills/evaluate-behavior/scripts/lib/trials.mjs +524 -0
  165. package/skills/evaluate-behavior/scripts/lib/validity.mjs +68 -0
  166. package/skills/evaluate-behavior/scripts/lib/view-html.mjs +454 -0
  167. package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/view.mjs +159 -18
  168. package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-command-tool.mjs +21 -6
  169. package/skills/evaluate-behavior/scripts/pi-container-route.mjs +23 -0
  170. package/skills/evaluate-behavior/scripts/pi-guard.mjs +77 -0
  171. package/skills/evaluate-behavior/scripts/pi-login-refresh.mjs +31 -0
  172. package/skills/evaluate-behavior/scripts/skill-eval.mjs +586 -0
  173. package/skills/execute-work/SKILL.md +96 -104
  174. package/skills/execute-work/references/code-practices.md +27 -51
  175. package/skills/execute-work/references/design.md +271 -0
  176. package/skills/execute-work/references/diagnose.md +117 -0
  177. package/skills/execute-work/references/migration.md +108 -0
  178. package/skills/execute-work/references/simplify.md +65 -0
  179. package/skills/execute-work/scripts/self-review.mjs +422 -0
  180. package/skills/execute-work/scripts/touch-map.mjs +290 -0
  181. package/skills/review-work/SKILL.md +89 -65
  182. package/skills/review-work/references/adjudication.md +94 -0
  183. package/skills/review-work/references/artifact.md +198 -0
  184. package/skills/review-work/references/evals-and-judges.md +66 -0
  185. package/skills/review-work/references/work.md +177 -0
  186. package/skills/review-work/scripts/check-brief.mjs +128 -0
  187. package/skills/review-work/scripts/review-packet.mjs +233 -0
  188. package/skills/setup-freeflow/SKILL.md +68 -17
  189. package/skills/track-work/SKILL.md +52 -20
  190. package/skills/track-work/references/handoff.md +190 -0
  191. package/skills/track-work/references/projects.md +51 -0
  192. package/skills/track-work/references/working-record-format.md +36 -18
  193. package/skills/track-work/scripts/lib/document.mjs +17 -13
  194. package/skills/track-work/scripts/lib/format.mjs +2 -0
  195. package/skills/track-work/scripts/lib/recover.mjs +254 -0
  196. package/skills/track-work/scripts/lib/registry.mjs +656 -0
  197. package/skills/track-work/scripts/lib/search.mjs +40 -0
  198. package/skills/track-work/scripts/lib/store.mjs +46 -15
  199. package/skills/track-work/scripts/lib/views.mjs +50 -1
  200. package/skills/track-work/scripts/working-record.mjs +232 -13
  201. package/skills/verify-work/SKILL.md +45 -37
  202. package/skills/verify-work/references/feature-map.md +120 -0
  203. package/skills/verify-work/references/runtime-evidence.md +203 -0
  204. package/skills/verify-work/references/test-design.md +25 -6
  205. package/skills/verify-work/scripts/test-changes.mjs +246 -0
  206. package/skills/write-docs/SKILL.md +113 -25
  207. package/skills/write-docs/references/documentation-shapes.md +68 -3
  208. package/skills/write-docs/references/spec-and-plan-shapes.md +308 -0
  209. package/skills/write-docs/scripts/artifact-check.mjs +148 -0
  210. package/skills/write-docs/scripts/docs-check.mjs +96 -6
  211. package/skills/write-docs/scripts/plan-lint.mjs +123 -0
  212. package/skills/write-skill/SKILL.md +92 -52
  213. package/skills/write-skill/references/activation-and-wording.md +143 -0
  214. package/skills/write-skill/references/placement-and-dependencies.md +154 -0
  215. package/skills/write-skill/scripts/lib/compare.mjs +701 -0
  216. package/skills/write-skill/scripts/lib/skill-author.mjs +197 -3
  217. package/skills/write-skill/scripts/skill-author.mjs +51 -8
  218. package/capabilities/cognitive-routing/references/both-mode.md +0 -36
  219. package/capabilities/cognitive-routing/references/executor-mode.md +0 -48
  220. package/capabilities/cognitive-routing/references/helper-mode.md +0 -47
  221. package/plugin.json +0 -33
  222. package/skills/action-selection/SKILL.md +0 -92
  223. package/skills/action-selection/references/trajectory-stalls.md +0 -73
  224. package/skills/bypass/SKILL.md +0 -153
  225. package/skills/commit-work/SKILL.md +0 -93
  226. package/skills/commit-work/references/git-state-edges.md +0 -94
  227. package/skills/commit-work/references/simple-push.md +0 -94
  228. package/skills/commit-work/references/staging-decisions.md +0 -106
  229. package/skills/decision-gate/SKILL.md +0 -87
  230. package/skills/design-for-depth/SKILL.md +0 -108
  231. package/skills/design-for-depth/references/design-pressure-signals.md +0 -84
  232. package/skills/design-for-depth/references/implementation-decisions.md +0 -76
  233. package/skills/design-for-depth/references/interface-design-loop.md +0 -105
  234. package/skills/design-for-depth/references/module-and-dependency-design.md +0 -117
  235. package/skills/design-for-depth/references/state-and-failure-boundaries.md +0 -125
  236. package/skills/diagnose-failure/SKILL.md +0 -140
  237. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +0 -50
  238. package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +0 -51
  239. package/skills/discuss/SKILL.md +0 -140
  240. package/skills/evaluate-skill/SKILL.md +0 -188
  241. package/skills/evaluate-skill/references/evaluation-definition-schema.md +0 -415
  242. package/skills/evaluate-skill/references/evaluation-design.md +0 -112
  243. package/skills/evaluate-skill/references/execution-and-evidence.md +0 -111
  244. package/skills/evaluate-skill/references/review-and-revision.md +0 -94
  245. package/skills/evaluate-skill/scripts/lib/definitions.mjs +0 -448
  246. package/skills/evaluate-skill/scripts/lib/grade-comparison.mjs +0 -60
  247. package/skills/evaluate-skill/scripts/lib/grade.mjs +0 -64
  248. package/skills/evaluate-skill/scripts/lib/review.mjs +0 -196
  249. package/skills/evaluate-skill/scripts/lib/runner.mjs +0 -405
  250. package/skills/evaluate-skill/scripts/lib/trials.mjs +0 -103
  251. package/skills/evaluate-skill/scripts/pi-guard.mjs +0 -181
  252. package/skills/evaluate-skill/scripts/skill-eval.mjs +0 -182
  253. package/skills/execute-work/references/execute-work-edges.md +0 -78
  254. package/skills/finish-branch/SKILL.md +0 -117
  255. package/skills/finish-branch/references/integration-options.md +0 -80
  256. package/skills/handoff/SKILL.md +0 -82
  257. package/skills/handoff/references/handoff-templates.md +0 -150
  258. package/skills/launch-work/SKILL.md +0 -116
  259. package/skills/launch-work/references/launch-readiness.md +0 -85
  260. package/skills/migration-work/SKILL.md +0 -115
  261. package/skills/migration-work/references/migration-lifecycle.md +0 -82
  262. package/skills/release-work/SKILL.md +0 -118
  263. package/skills/release-work/references/release-evidence.md +0 -78
  264. package/skills/review-artifact/SKILL.md +0 -143
  265. package/skills/review-artifact/references/adjudicate-artifact-review.md +0 -101
  266. package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +0 -159
  267. package/skills/review-work/references/adjudicate-work-review.md +0 -97
  268. package/skills/review-work/references/independent-work-reviewer-contract.md +0 -139
  269. package/skills/review-work/references/security-risk-lens.md +0 -67
  270. package/skills/setup-freeflow/references/activation-contract.md +0 -103
  271. package/skills/setup-freeflow/references/host-setup.md +0 -67
  272. package/skills/simplify-code/SKILL.md +0 -85
  273. package/skills/simplify-code/references/simplification-patterns.md +0 -70
  274. package/skills/verify-work/references/browser-runtime-evidence.md +0 -51
  275. package/skills/verify-work/references/integration-evidence.md +0 -49
  276. package/skills/verify-work/references/performance-evidence.md +0 -59
  277. package/skills/workflow/SKILL.md +0 -171
  278. package/skills/workflow/references/domain-skill-composition.md +0 -45
  279. package/skills/write-plan/SKILL.md +0 -92
  280. package/skills/write-plan/references/plan-shapes.md +0 -156
  281. package/skills/write-skill/references/activation-boundaries.md +0 -106
  282. package/skills/write-skill/references/agent-first-instructions.md +0 -133
  283. package/skills/write-skill/references/progressive-disclosure.md +0 -129
  284. package/skills/write-skill/references/skill-dependency-graphs.md +0 -192
  285. package/skills/write-spec/SKILL.md +0 -85
  286. package/skills/write-spec/references/artifact-standards.md +0 -86
  287. package/skills/write-spec/references/decision-records.md +0 -80
  288. package/skills/write-spec/references/spec-shapes.md +0 -143
  289. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/lib/evidence.mjs +0 -0
  290. /package/skills/{evaluate-skill → evaluate-behavior}/scripts/pi-observer.mjs +0 -0
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env node
2
+ // Lists every existing test file, fixture, snapshot and shared test setup file that changed, moved or was deleted
3
+ // between a base and a head, with the changed hunks. It only lists; whether a change is justified is a judgment for
4
+ // the agent and the user (references/test-design.md). A file that does not exist at the base is a new test, not a
5
+ // changed one, and is not listed; --new lists those instead (added, copied, or untracked in the working tree).
6
+ // Usage: test-changes.mjs --base <ref> [--head <ref>] [--root <repository>] [--pattern <glob>]... [--only]
7
+ // [--exclude <glob>]... [--new] [--json]
8
+ // Without --head, the head is the working tree, staged and unstaged. Exit code 0 when it lists (even nothing),
9
+ // 2 on a usage or Git error.
10
+ import { execFileSync } from "node:child_process";
11
+ import { resolve } from "node:path";
12
+ import { parseArgs } from "node:util";
13
+
14
+ const USAGE =
15
+ "Usage: test-changes.mjs --base <ref> [--head <ref>] [--root <repository>] [--pattern <glob>]... [--only] [--exclude <glob>]... [--new] [--json]";
16
+
17
+ // Common layouts for JavaScript, TypeScript, Python, Go, Ruby, Java, Kotlin, C#, Swift, C and C++, PHP, Elixir and
18
+ // Dart. Matching is case-sensitive, so capitalised folders such as Swift's Tests/ are listed separately. --pattern adds
19
+ // to these; --only replaces them.
20
+ const DEFAULT_PATTERNS = [
21
+ "**/*.{test,spec}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}",
22
+ "**/{test,tests,__tests__,spec,e2e,Tests}/**",
23
+ "**/*.{Tests,UnitTests,IntegrationTests}/**",
24
+ "**/src/*Test/**",
25
+ "**/*_test.{go,dart,exs}",
26
+ "**/*_{test,unittest}.{c,cc,cpp,cxx}",
27
+ "**/*_spec.rb",
28
+ "**/*{Test,Tests}.{java,kt,cs,swift,php}",
29
+ "**/test_*.py",
30
+ "**/*_test.py",
31
+ "**/conftest.py",
32
+ "**/{fixtures,__fixtures__,testdata,__mocks__}/**",
33
+ "**/__snapshots__/**",
34
+ "**/*.snap",
35
+ "**/{jest,vitest,playwright,cypress,karma}.config.*",
36
+ "**/vitest.workspace.*",
37
+ "**/{jest.setup,setupTests,setup-tests,test-setup,vitest.setup}.*",
38
+ "**/*.setup.{js,mjs,cjs,ts,mts,cts}",
39
+ "**/.mocharc*",
40
+ "**/{pytest.ini,tox.ini,noxfile.py}",
41
+ "**/{spec_helper,rails_helper}.rb",
42
+ "**/.rspec",
43
+ "**/phpunit.xml*",
44
+ "**/test_helper.exs",
45
+ ];
46
+
47
+ // The first matching kind wins, so a snapshot under tests/ is a snapshot and a fixture under tests/ is a fixture.
48
+ const KINDS = [
49
+ ["snapshot", ["**/__snapshots__/**", "**/*.snap"]],
50
+ [
51
+ "setup",
52
+ [
53
+ "**/conftest.py",
54
+ "**/{jest,vitest,playwright,cypress,karma}.config.*",
55
+ "**/vitest.workspace.*",
56
+ "**/{jest.setup,setupTests,setup-tests,test-setup,vitest.setup}.*",
57
+ "**/.mocharc*",
58
+ "**/{pytest.ini,tox.ini,noxfile.py}",
59
+ "**/*.setup.{js,mjs,cjs,ts,mts,cts}",
60
+ "**/{spec_helper,rails_helper}.rb",
61
+ "**/.rspec",
62
+ "**/phpunit.xml*",
63
+ "**/test_helper.exs",
64
+ ],
65
+ ],
66
+ ["fixture", ["**/{fixtures,__fixtures__,testdata,__mocks__}/**"]],
67
+ ];
68
+
69
+ const STATUS = { M: "modified", D: "deleted", R: "renamed", T: "type-changed" };
70
+
71
+ function fail(message) {
72
+ console.error(message);
73
+ process.exit(2);
74
+ }
75
+
76
+ let parsed;
77
+ try {
78
+ parsed = parseArgs({
79
+ options: {
80
+ base: { type: "string" },
81
+ head: { type: "string" },
82
+ root: { type: "string" },
83
+ pattern: { type: "string", multiple: true, default: [] },
84
+ only: { type: "boolean", default: false },
85
+ exclude: { type: "string", multiple: true, default: [] },
86
+ new: { type: "boolean", default: false },
87
+ json: { type: "boolean", default: false },
88
+ },
89
+ });
90
+ } catch (error) {
91
+ fail(`${error.message}\n${USAGE}`);
92
+ }
93
+ const { values } = parsed;
94
+ if (!values.base) fail(USAGE);
95
+ if (values.only && !values.pattern.length) fail(`--only needs at least one --pattern\n${USAGE}`);
96
+
97
+ // Glob to RegExp over repository-relative paths with "/" separators: "**/" is zero or more directories, "**" anything,
98
+ // "*" anything within one segment, "?" one character, and "{a,b}" either alternative.
99
+ function globToRegExp(glob) {
100
+ let source = "";
101
+ for (let index = 0; index < glob.length; index += 1) {
102
+ const char = glob[index];
103
+ if (char === "*" && glob[index + 1] === "*") {
104
+ const slash = glob[index + 2] === "/";
105
+ source += slash ? "(?:.*/)?" : ".*";
106
+ index += slash ? 2 : 1;
107
+ } else if (char === "*") source += "[^/]*";
108
+ else if (char === "?") source += "[^/]";
109
+ else if (char === "{") {
110
+ const end = glob.indexOf("}", index);
111
+ if (end === -1) source += "\\{";
112
+ else {
113
+ source += `(?:${glob
114
+ .slice(index + 1, end)
115
+ .split(",")
116
+ .map((part) => globToRegExp(part).source.slice(1, -1))
117
+ .join("|")})`;
118
+ index = end;
119
+ }
120
+ } else source += /[.+^$()|[\]\\]/.test(char) ? `\\${char}` : char;
121
+ }
122
+ return new RegExp(`^${source}$`);
123
+ }
124
+ const matcher = (globs) => {
125
+ const expressions = globs.map(globToRegExp);
126
+ return (path) => expressions.some((expression) => expression.test(path));
127
+ };
128
+
129
+ const patterns = values.only ? values.pattern : [...DEFAULT_PATTERNS, ...values.pattern];
130
+ const included = matcher(patterns);
131
+ const excluded = matcher(values.exclude);
132
+ const kindMatchers = KINDS.map(([kind, globs]) => [kind, matcher(globs)]);
133
+ const kindOf = (path) => kindMatchers.find(([, matches]) => matches(path))?.[0] ?? "test";
134
+
135
+ const git = (cwd, args) =>
136
+ execFileSync("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
137
+ const gitOrFail = (cwd, args, what) => {
138
+ try {
139
+ return git(cwd, args);
140
+ } catch (error) {
141
+ fail(`${what}: ${String(error.stderr || error.message).trim()}`);
142
+ }
143
+ };
144
+
145
+ const root = resolve(
146
+ gitOrFail(resolve(values.root ?? "."), ["rev-parse", "--show-toplevel"], "not inside a Git repository").trim(),
147
+ );
148
+ const commitOf = (ref) => {
149
+ try {
150
+ return git(root, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]).trim();
151
+ } catch {
152
+ fail(`no such commit: ${ref}`);
153
+ }
154
+ };
155
+ const base = { ref: values.base, commit: commitOf(values.base) };
156
+ const head = values.head ? { ref: values.head, commit: commitOf(values.head) } : { ref: "working tree", commit: null };
157
+
158
+ // Fixed flags so the user's Git configuration (colour, external diff tools, prefixes, rename limits) cannot change
159
+ // what is listed or how hunks read.
160
+ const DIFF = [
161
+ "-c",
162
+ "core.quotePath=false",
163
+ "diff",
164
+ "--no-color",
165
+ "--no-ext-diff",
166
+ "--no-textconv",
167
+ "--no-relative",
168
+ "-M",
169
+ ];
170
+ const range = head.commit ? [base.commit, head.commit] : [base.commit];
171
+
172
+ const fields = gitOrFail(root, [...DIFF, "--name-status", "-z", ...range], "git diff failed").split("\0");
173
+ const changes = [];
174
+ const added = [];
175
+ for (let index = 0; index < fields.length - 1;) {
176
+ const code = fields[index][0];
177
+ const paths = code === "R" || code === "C" ? [fields[index + 1], fields[index + 2]] : [fields[index + 1]];
178
+ index += 1 + paths.length;
179
+ const status = STATUS[code];
180
+ const [path] = paths;
181
+ if ((code === "A" || code === "C") && included(paths.at(-1)) && !excluded(paths.at(-1))) added.push(paths.at(-1));
182
+ // Only files that existed at the base: added and copied files are new.
183
+ if (!status || !included(path) || excluded(path)) continue;
184
+ const diff = gitOrFail(
185
+ root,
186
+ [...DIFF, "--unified=3", "--src-prefix=a/", "--dst-prefix=b/", ...range, "--", ...paths],
187
+ `git diff failed for ${path}`,
188
+ );
189
+ const lines = diff.split("\n");
190
+ const start = lines.findIndex((line) => line.startsWith("@@") || line.startsWith("Binary files"));
191
+ const body = start === -1 ? [] : lines.slice(start);
192
+ changes.push({
193
+ status,
194
+ path,
195
+ ...(status === "renamed" ? { to: paths[1] } : {}),
196
+ kind: kindOf(path),
197
+ added: body.filter((line) => line.startsWith("+")).length,
198
+ removed: body.filter((line) => line.startsWith("-")).length,
199
+ binary: body[0]?.startsWith("Binary files") ?? false,
200
+ // A deleted file's hunks are its whole content; the path and line count say what went.
201
+ hunks: status === "deleted" ? null : body.join("\n").trimEnd(),
202
+ });
203
+ }
204
+
205
+ // New test files, for a check that each one fails on the base: committed additions, plus untracked files when the head
206
+ // is the working tree.
207
+ if (values.new) {
208
+ if (!head.commit)
209
+ for (const path of gitOrFail(root, ["ls-files", "-z", "--others", "--exclude-standard"], "git ls-files failed")
210
+ .split("\0")
211
+ .filter(Boolean))
212
+ if (included(path) && !excluded(path)) added.push(path);
213
+ const tests = [...new Set(added)].sort().map((path) => ({ status: "added", path, kind: kindOf(path) }));
214
+ if (values.json)
215
+ console.log(
216
+ JSON.stringify(
217
+ { command: "test-changes", mode: "new", root, base, head, patterns, exclude: values.exclude, tests },
218
+ null,
219
+ 2,
220
+ ),
221
+ );
222
+ else if (!tests.length) console.log(`No new test, fixture, snapshot or test setup file since ${base.ref}.`);
223
+ else {
224
+ console.log(`${tests.length} new test, fixture, snapshot or test setup file(s) since ${base.ref}:`);
225
+ for (const each of tests) console.log(`added ${each.kind} ${each.path}`);
226
+ }
227
+ } else if (values.json) {
228
+ console.log(
229
+ JSON.stringify({ command: "test-changes", root, base, head, patterns, exclude: values.exclude, changes }, null, 2),
230
+ );
231
+ } else {
232
+ const against = `${base.ref} (${base.commit.slice(0, 12)})`;
233
+ const to = head.commit ? `${head.ref} (${head.commit.slice(0, 12)})` : head.ref;
234
+ if (!changes.length)
235
+ console.log(`No existing test, fixture, snapshot or test setup file changed between ${against} and ${to}.`);
236
+ else {
237
+ console.log(
238
+ `${changes.length} existing test, fixture, snapshot or test setup file${changes.length === 1 ? "" : "s"} changed between ${against} and ${to}:\n`,
239
+ );
240
+ for (const change of changes) {
241
+ const name = change.to ? `${change.path} -> ${change.to}` : change.path;
242
+ console.log(`${change.status} ${change.kind} ${name} (+${change.added} -${change.removed})`);
243
+ if (change.hunks) console.log(`${change.hunks}\n`);
244
+ }
245
+ }
246
+ }
@@ -1,25 +1,112 @@
1
1
  ---
2
2
  name: write-docs
3
- description: "Use when writing, updating, or reviewing documentation of how existing software works and why: architecture or subsystem docs, folder READMEs, and user guides, or when a change makes existing documentation wrong."
3
+ description: "Use when writing, updating or reviewing a document someone will act on: a spec, PRD, issue, requirements, API or interface contract, technical design, decision record or ADR; an implementation, remediation, migration or operations plan; a README, user guide, developer docs, subsystem doc, overview, folder README or feature file; or when a code change makes existing docs wrong, or a project has no developer docs yet. It covers where a document goes, its header and status, and the checks to run after writing it."
4
4
  ---
5
5
 
6
6
  # Write Docs
7
7
 
8
- Documentation tells a reader how a system works now and why it works that way, so they can use or change it without rebuilding the design from the code. It differs from a spec or a plan: those decide work before it happens and can be left behind once it is done ([Write Spec](../write-spec/SKILL.md), [Write Plan](../write-plan/SKILL.md)). Documentation describes what exists and stays true only if it changes with the code. If the document you are asked for decides work that is not done yet, use Write Spec or Write Plan instead.
8
+ Write a document a reader will act on: true to its sources, no more certain than they are, and holding only what its use needs.
9
9
 
10
- Its readers include agents. An agent that reads code sees what it does but not why; without the why, it may treat a deliberate choice as a bug, rebuild a design that was rejected for a reason, or break a rule nobody wrote down. Documentation is where that knowledge outlives the task that produced it.
10
+ Documents come in two kinds, with different lives:
11
+
12
+ - **Specs and Plans decide work before it happens.** A Spec defines what to build or decide: a PRD, issue, requirements, technical design, API or migration contract. A Plan orders how to carry out agreed work. They are task artifacts, kept beside the task's Working Record (`specs/`, `plans/`) unless the repository keeps them elsewhere; they are drafted, accepted by the user, and left behind once the work is done. A decision record is written the same way and can outlive the task.
13
+ - **Documentation describes software that exists:** how it works and why, for the people and agents who use or change it. It lives in the repository and stays true only if it changes with the code; its header names the code it `Covers` and the commit it was `Verified at`. A document that decides work not yet done is a Spec or a Plan, not documentation.
14
+
15
+ Readers include agents. An agent that reads code sees what it does but not why; without the why, it may treat a deliberate choice as a bug, rebuild a design that was rejected for a reason, or break a rule nobody wrote down.
11
16
 
12
17
  The **Rules** below are binding; if one cannot be met, stop and say why. Everything else is **judgment**: follow its stated goal, and adapt when a different choice serves that goal better.
13
18
 
19
+ ## Routes
20
+
21
+ | Situation | Read |
22
+ | --- | --- |
23
+ | A spec, PRD, issue, requirements, technical design, API or interface contract, or migration contract; an ordered plan for implementation, remediation, migration or operations | [spec and plan shapes](references/spec-and-plan-shapes.md) |
24
+ | Preserving a decision and its rationale: a decision note or ADR | [spec and plan shapes: Decision Records](references/spec-and-plan-shapes.md#decision-records) |
25
+ | Where a Spec, Plan or decision record goes, its header, status and source trail | Header, Status And Sources, below |
26
+ | Finding a project's developer docs or proposing them; the structure of an overview, subsystem doc, folder README, feature file or live-verification guide; a new or rewritten subsystem doc or overview | [documentation shapes](references/documentation-shapes.md) |
27
+ | After writing or revising a Spec, Plan or decision record | Run [artifact-check](scripts/artifact-check.mjs), and [plan-lint](scripts/plan-lint.mjs) for a Plan, as Specs And Plans says |
28
+ | After writing or changing documentation, or to find the docs and feature files covering a changed file | Run the [docs check](scripts/docs-check.mjs), as Check It says |
29
+ | A design whose open representation, identity, ownership, algorithm or failure choices could invalidate dependent work | Execute Work's [design](../execute-work/references/design.md) |
30
+ | Direction or alternatives still open, a user-owned choice, or conflicting sources | [Discuss Work](../discuss-work/SKILL.md) |
31
+ | Planning a fix whose cause is not supported | Execute Work's [diagnose](../execute-work/references/diagnose.md) |
32
+
14
33
  ## Rules
15
34
 
16
- - Write what is true now. Plans, task progress, and open work belong in the task's record, spec, or plan, not in documentation; history appears only as a short list of major changes.
17
- - Check each claim against the code, its tests, or an observed run before writing it as fact. State what you could not check as unverified, or leave it out.
18
- - When your change makes a document wrong, correct the document in the same change. Writing new documentation, or rewriting more than your change made wrong, needs a request or the repository's documentation rules.
19
- - Follow the repository's documentation rules (`AGENTS.md` or its equivalent): where documentation lives, which parts need the user's approval to change, and what is public.
20
- - Keep secrets, credentials, private task notes, and personal data out of documentation others can read.
35
+ - A document grants no permission. Accepting a Spec or Plan is not permission to execute it, and review establishes fitness, not acceptance or authority. Writing or revising one does not trigger independent review; never label author self-review as independent review, or give a document an accepted status without its source.
36
+ - Never add an obligation without an accepted source or a reason the stated outcome needs it. Never infer requirements from nearby code, existing tests or available machinery, invent a user-owned choice or scale, retry, recovery or extension machinery, or reduce agreed scope into an unapproved MVP, roadmap or later-version split.
37
+ - Label proposed design as proposed. Never write an assumption, a reviewer's suggestion or your own preference as an accepted decision, or a hoped-for answer or unsettled owner choice as a planning assumption. Authorization to investigate or draft an option does not accept its undisclosed production consequences.
38
+ - Stop the affected writing when it would silently settle a user-owned choice, as [Discuss Work](../discuss-work/SKILL.md) defines it, or a hard-to-reverse design; never settle such a choice through normative prose, an unexplained assumption or a polished placeholder. Return the concrete effect and supported alternatives to the owner through Discuss Work.
39
+ - Never rewrite source truth to suit implementation, let available tests redefine acceptance, or rewrite a historical decision as though it always contained the new choice.
40
+ - Check each factual claim against its source (the code, its tests, an observed run, or the accepted source) before writing it as fact; state what you could not check as unverified, or leave it out. Never claim whole-system completion from a narrow observer.
41
+ - Documentation says what is true now. Plans, task progress and open work belong in the task's record, Spec or Plan; history appears only as a short list of major changes.
42
+ - When your change makes a document wrong, correct it in the same change. Writing new documentation, or rewriting more than your change made wrong, needs a request or the repository's documentation rules.
43
+ - Follow the repository's documentation rules (`AGENTS.md` or its equivalent): where documents live, which parts need the user's approval to change, and what is public.
44
+ - Keep secrets, credentials, private task notes and personal data out of documents others can read.
45
+
46
+ ## Write The Document
47
+
48
+ Goal: a reader with only the document and its sources can act correctly, and can tell what is required, what is fact, and what is still open.
49
+
50
+ **Know the reader and the use.** Identify the document type, who reads it and for what later action, the accepted scope, the destination, and the open questions it must keep. Answer a question about a document without editing it unless revision is requested. Use Discuss Work when direction or alternatives are still materially open; do not repeat discussion that already settled the document's purpose. An agreement to implement accepted work may include documenting its supported contract; do not manufacture another approval because a document was produced.
51
+
52
+ **Ground it in current sources:** current user direction and accepted discussion, including later amendments; the Specs, issues, decisions and contracts it revises or consumes; live code, tests, policy and ADRs; current primary sources when an external version or interface constrains it; and the Working Record through [Track Work](../track-work/SKILL.md) when one exists. For documentation, start from the code and its tests, then read what explains them: specs, task records, decision records, commit messages, review threads. A reason that exists only in a task record or a conversation is the one most worth writing down, because it disappears with them.
53
+
54
+ A record or summary cannot override contradictory current intent or accepted source truth. Distinguish what was requested, proposed, accepted and observed, and know which accepted version or amendment the document follows; an earlier reviewed baseline does not excuse ignoring a later accepted change. An experiment produces evidence, not a requirement: carry its consequences only where they were selected for this outcome. A test can faithfully protect an unnecessary mechanism.
55
+
56
+ **Write only what the use needs**, in the shape the routes above name. Give the depth the reader needs, including architecture and ownership where the use requires it; do not cut necessary detail just to shorten the document, and leave out a section with nothing true to say. Keep distinguishable: required behavior and accepted decisions; supported facts and their limits; proposed mechanisms; assumptions and open questions; deferrals and superseded direction. Use the repository's vocabulary, and put a consequential uncertainty where the reader makes the affected decision, not in a distant caveat. A limitation of one technique does not establish a need for stronger guarantees, host changes, new persistence, retries or a subsystem. Open questions need not stop unrelated content; a document can be fit for discussion while unfit to guide production, so say which. Give each fact one home and link shared rationale instead of copying it.
57
+
58
+ **Self-review once before anyone relies on it.** After checking factual claims, use [Review Work](../review-work/SKILL.md) for one silent author self-review of the complete document against its use: it keeps accepted intent and amendments, separates requirements from proposals, has the evidence and acceptance conditions it needs, and keeps dependent documents coherent; for a Plan, also that the ordered work can achieve the outcome, its dependencies hold, later uncertainty is honest, final checks match acceptance, and selected checkpoints are proportionate. Correct clear defects and recheck what they affect; return an unresolved owner decision instead of inventing an answer to make the document consistent. Independent review applies only when selected and authorized to protect a concrete boundary: give the reviewer the complete document, its sources, dependencies and limits through Review Work, and adjudicate the report before revision or use. Respect a selected approval checkpoint, but do not create one for every document.
59
+
60
+ ## Specs And Plans
61
+
62
+ A Spec describes content, behavior, constraints and uncertainty for its use; it is not an implementation sequence, a Working Record, a transcript or a permission grant. Useful technical depth is welcome; hypothetical completeness is not required. A Plan describes intended execution; the Working Record keeps actual work, evolving state and the next useful action. Keep ordered execution in a Plan and live progress in the record. After writing or revising a Plan, run [plan-lint](scripts/plan-lint.mjs) (`node <write-docs-directory>/scripts/plan-lint.mjs <plan.md>`): it lists each step that names no check.
63
+
64
+ When a Working Record exists and the Spec or Plan is accepted for its task, list it under the record's `What defines this task` through Track Work, so every recovery reads it.
65
+
66
+ Revise for a change in the contract or strategy, not for progress. Preserve accepted content that still holds, change only what new intent or evidence affects, update the status honestly, and keep consequential prior rationale recoverable through a change note, decision record, supersession link or version control; a change note explains current intent or keeps rejected work from being repeated, never execution status or a transcript, and a first version needs none unless repository policy requires it. When an accepted amendment or learning result changes the contract, find the affected Plan, acceptance check or implementation assumption: reconcile it when authorized, otherwise mark it contingent and return the needed revision before dependent use. Learning does not enter the contract by itself: keep findings selected for implementation apart from observations kept as evidence. Do not keep an older baseline after the user accepted a change, synchronize unrelated documents, or repair consistency by silently changing the required outcome.
67
+
68
+ ### Header, Status And Sources
21
69
 
22
- ## Choose The Document
70
+ These apply to Specs, Plans and decision records; documentation uses the header in [documentation shapes](references/documentation-shapes.md#header) instead.
71
+
72
+ **Destination.** A task-local Spec or Plan goes in the task folder Track Work owns (`specs/`, `plans/`). Use an established product, design, API, issue, migration, policy or architecture location instead when the document should be canonical there, and the repository's issue tracker for an issue when it is available and intended. Ask before choosing between task-local memory and canonical repository documentation when the choice changes authority, review or longevity. Do not start a new top-level docs convention for one document.
73
+
74
+ **Header.** Use the repository's required metadata. Otherwise, when identity helps future readers, give a title and a compact header with only useful fields:
75
+
76
+ ```md
77
+ # Team Invitations API
78
+
79
+ > **Doc ID:** SPEC-001-team-invitations-api
80
+ > **Type:** API Contract
81
+ > **Status:** Draft
82
+ > **Owner:** User
83
+ > **Source:** Working Record task-004 and accepted product decisions
84
+ ```
85
+
86
+ **Doc ID** when links, review history or supersession need one; **Type** the document's actual job, such as PRD, Issue, Technical Design, API Contract, Migration Contract, Implementation Plan or Decision; **Owner** the person or role with authority over its intent; **Source** compact pointers to accepted context and evidence; a date, or **Supersedes** / **Superseded by**, only when reliable and needed. Never invent an owner, approval, date or authority to complete a header.
87
+
88
+ **Status.** Use the repository's statuses when it has them. Otherwise give one current status from this vocabulary, the same for every Spec, Plan and decision record, using only the states its life reaches:
89
+
90
+ | Status | Means |
91
+ | --- | --- |
92
+ | `Draft` | Being written, or proposed and not yet accepted. |
93
+ | `Reviewed` | Reviewed and not yet accepted; say whether by author self-review or selected independent review. |
94
+ | `Accepted` | The owner accepted it; `Source` names where. |
95
+ | `Rejected` | The owner declined it. |
96
+ | `Superseded` | Replaced; link the replacement both ways. |
97
+ | `Retired` | Dropped with nothing replacing it, with the date and the reason. |
98
+
99
+ Writing or reviewing a document never makes it `Accepted`, and `Accepted` is not permission to execute it. Status reports the document's state; it does not replace review evidence or user authority.
100
+
101
+ **Source trail.** Link stable sources that actually exist, such as `file:<path>#<section>`, `working-record:<task>/record.md#<section>`, `commit:<sha>`, `issue:<id>`, `output:<output-id>` or `session:<session-id>/turn:<turn-id>`, with concise quotations rather than copied inventories, logs, diffs or transcripts. The trail lets a later reader recover why the document says what it says, without preserving every turn: for a consequential choice, keep the proposal, its disclosed consequences and the acceptance source together rather than an isolated "proceed" or an agent's summary of approval, and keep accepted amendments apart from unselected experimental findings.
102
+
103
+ Then run [artifact-check](scripts/artifact-check.mjs) (`node <write-docs-directory>/scripts/artifact-check.mjs <document.md> [--statuses <the repository's own>]`): it refuses a missing title or status, a status outside this vocabulary, an `Accepted` document with no Source, a `Superseded` one with no replacement, and a `file:` or `commit:` pointer that does not resolve.
104
+
105
+ A Spec or Plan stays identifiable, source-backed and understandable without the original conversation, holding no information a Working Record, handoff or another canonical document owns.
106
+
107
+ ## Documentation
108
+
109
+ ### Choose The Document
23
110
 
24
111
  Goal: each fact lives in one place, written for the reader who needs it.
25
112
 
@@ -29,28 +116,28 @@ Goal: each fact lives in one place, written for the reader who needs it.
29
116
  | Someone finding their way around the code | Overview (an `ARCHITECTURE.md`, or the index of the developer docs) | The problem the software solves, its parts and how they relate, a map of where things are, and the rules that hold across parts. Short and slow to change. |
30
117
  | Someone changing one subsystem | Subsystem doc | How the subsystem works and why: its surface, state, invariants, decisions, failure behavior, code map, and tests. |
31
118
  | Someone editing files in one folder | Folder `README.md` | What each file owns, local rules, and a pointer to its subsystem doc. |
32
- | Anyone revisiting a hard-to-reverse choice | Decision record | The context, the decision, and its consequences. |
119
+ | Someone checking a feature in the running software | Feature file, plus a shared live-verification guide | What the user sees and the exact steps that show it works. |
120
+ | Anyone revisiting a hard-to-reverse choice | Decision record | The decision and why, in the [Decision Records](references/spec-and-plan-shapes.md#decision-records) shape. |
33
121
 
34
122
  Prefer extending an existing document to creating a new one: a small set of current documents serves readers better than many partly current ones. A subsystem earns its own doc when the reasons behind it cannot be read from the code and readers keep needing them: agents re-derive the same design, or mistake a deliberate behavior for a bug. A user guide and a subsystem doc about the same feature are different documents for different readers; link them rather than merging them.
35
123
 
36
- Write documentation where the repository keeps it. If it keeps none and you are asked to start, propose where it should live and confirm with the user before creating it.
124
+ Each kind of knowledge has one home. How the code works and why, its decisions, and behavior that looks wrong but is intended: developer docs, with hard-to-reverse choices in decision records and what the user sees in feature files. Rules for agents working in the repository: its instruction files. Task progress and decisions in flight: the task's record, until settled decisions move to the docs. The user's own preferences: the host's memory.
37
125
 
38
- ## Write The Document
126
+ Write documentation where the repository keeps it; [documentation shapes](references/documentation-shapes.md#starting-developer-docs) says where to look, and what to propose when there is none. If the repository keeps none and you are asked to start, propose a location and confirm with the user before creating it. When a project has code and no developer docs, propose creating them and wait for the user's yes; keep that knowledge out of `AGENTS.md`, `CLAUDE.md` and other always-loaded instruction files, which every request pays for.
39
127
 
40
- Read [Documentation Shapes](references/documentation-shapes.md) before choosing the structure of an overview, a subsystem doc, or a folder README, or before restructuring one. Its shapes are judgment to adapt to the software and to the repository's own conventions; only its header, which the docs check reads, is binding where used.
128
+ ### Write It For The Next Change
41
129
 
42
130
  Goal: a reader with only the document and the code can make a correct change, and can tell what is deliberate.
43
131
 
44
- - **Start from the code and its tests**, then read what explains them: specs, task records, decision records, commit messages, review threads. A reason that exists only in a task record or a conversation is the one most worth writing down, because it disappears with that record.
45
132
  - **Name, do not link to lines.** Write paths, functions, types, configuration keys, and messages exactly, in backticks, so readers and search tools find them. Line numbers go stale with the next edit.
46
133
  - **Write invariants, including absences.** "Nothing outside `config.ts` reads the config file" or "the request path never reads session files" cannot be seen by reading any one file, so state it.
47
134
  - **Say what looks wrong but is intended.** For behavior a careful reader would take for a bug, state the behavior, the reason, and what would break if it changed.
48
135
  - **Keep explanation apart from reference.** Explanation (purpose, how it works, why) is read once to understand; reference (surface, state, invariants, code map, tests) is consulted while working. Put them in separate sections so a reader looking up a fact does not wade through reasoning.
49
136
  - **Prefer present-tense facts to narrative.** "Compaction runs at the end of a turn" rather than "We changed compaction so that it now runs at the end of a turn". History gets one short section of major changes, with commits.
50
137
 
51
- Depth follows the reader's risk. A subsystem with many hidden reasons needs most of the shape; a small one may need only purpose, surface, and code map. Leave out a section with nothing true to say rather than filling it.
138
+ Depth follows the reader's risk. A subsystem with many hidden reasons needs most of the shape; a small one may need only purpose, surface, and code map.
52
139
 
53
- ## Keep Documentation Current
140
+ ### Keep It Current
54
141
 
55
142
  Goal: documentation stays true as the code changes, without anyone remembering to check.
56
143
 
@@ -60,24 +147,25 @@ Goal: documentation stays true as the code changes, without anyone remembering t
60
147
  - Delete or correct documentation that is no longer true. A wrong document misleads more than a missing one.
61
148
  - After checking a document against the code, update the commit it records as verified.
62
149
 
63
- ## Check The Documentation
64
-
65
- Goal: evidence that the document is accurate and that a reader without your context understands it.
150
+ ### Check It
66
151
 
67
152
  Run the bundled [docs check](scripts/docs-check.mjs) after writing or changing documentation:
68
153
 
69
154
  ```text
70
- node <write-docs-directory>/scripts/docs-check.mjs <docs-file-or-directory>... [--root <repository>] [--strict] [--json]
155
+ node <write-docs-directory>/scripts/docs-check.mjs <docs-file-or-directory>... [--root <repository>] [--strict] [--driven] [--json]
156
+ node <write-docs-directory>/scripts/docs-check.mjs [<docs-file-or-directory>...] --covering <path>... [--root <repository>] [--json]
71
157
  ```
72
158
 
73
- It reports paths a document names that do not exist and, for documents with the header, those whose covered code changed since the commit they record as verified. A change made together with the document, in the same commit or both uncommitted, counts as reviewed with it. Missing paths are errors (exit code 1). Changed code is a warning, since many changes leave a document true; `--strict` makes it an error. Read the changes it lists and update the document or its verified commit.
159
+ It reports paths a document names that do not exist and, for documents with the header, those whose covered code changed since the commit they record as verified. A change made together with the document, in the same commit or both uncommitted, counts as reviewed with it. Missing paths are errors (exit code 1). Changed code is a warning, since many changes leave a document true; `--strict` makes it an error. Read the changes it lists and update the document or its verified commit. `--driven` counts a change made together with the document too: use it for feature files, whose verified commit is the last live drive, so editing the text does not count as driving it.
74
160
 
75
- For a new subsystem doc or overview, or one you substantially rewrote, test it on a reader without your context. Write five to ten questions a newcomer would ask: where is the code that does X, why does it do Y, is Z a bug, what breaks if W changes, which test proves V. Give a fresh agent only the document and the questions (a subagent where the host has one; otherwise ask the user to run it in a new session). Compare each answer with the code. Where an answer is wrong or unsure, fix the document and ask again. The check passes when the answers are right without new gaps.
161
+ `--covering` instead lists the documents that cover each path and whether each is current: the ones a change should reread or update.
76
162
 
77
- A passing check shows the named paths exist and the reader understood the document; it does not prove every claim is current. Report what was checked.
163
+ A passing check shows that the named paths exist; it does not prove every claim is current. A new or substantially rewritten subsystem doc or overview also gets the reader test in [documentation shapes](references/documentation-shapes.md#test-it-on-a-new-reader). Report what was checked.
78
164
 
79
165
  ## Stop
80
166
 
81
- Stop when the document says only what is true now, each claim is checked or marked unverified, the docs check passes, and, for a new or rewritten subsystem doc or overview, the reader test answers correctly. Then return to the activity that asked for the documentation.
167
+ Report the document's path, type and intended use, its source basis, what is unresolved, contingent or unverified, and what was checked. For a Spec or Plan, also report a Plan's invalidation conditions and selected checkpoints, and the actual review, acceptance and execution-authority status.
168
+
169
+ Stop when the document is fit for its use, or its blocking decision or evidence limit is explicit; for documentation, when it says only what is true now, each claim is checked or marked unverified, and the docs check passes. Then return to the activity that asked for it: if the agreement covers implementation, continue through the normal route; if it asks for a Plan first, stop there. Do not begin work outside that agreement or call an unresolved strategy ready.
82
170
 
83
- Stop and ask when where documentation lives, who may change it, or whether a disputed behavior is intended cannot be settled from the code, its tests, and its sources.
171
+ Stop and ask when where a document lives, who may change it, or whether a disputed behavior is intended cannot be settled from the code, its tests and its sources.
@@ -1,14 +1,29 @@
1
1
  # Documentation Shapes
2
2
 
3
- Read this before choosing the structure of an overview, a subsystem doc, or a folder README, or before restructuring one.
4
-
5
3
  This reference is judgment except for the header: these are shapes to adapt, not mandatory templates. Where the repository already has documentation conventions, follow them and borrow from these shapes only what they lack. Use the sections a document's readers need, in the order that serves them, and leave out a section with nothing true to say.
6
4
 
7
5
  The header is binding when you use it, because the [docs check](../scripts/docs-check.mjs) reads it. Use it on a document whose code the check should watch for staleness.
8
6
 
7
+ ## Starting Developer Docs
8
+
9
+ First look for the project's own docs index, in this order: `dev-docs/README.md`, `ARCHITECTURE.md`, a `README.md` in `docs/`, then a docs folder the root `README.md` names. The first one found is the index. A project that has one keeps its home and its conventions: map these shapes onto what is there, never start a second tree, and never move existing docs without the user's yes.
10
+
11
+ Only when the project has no developer docs, propose this layout:
12
+
13
+ ```text
14
+ dev-docs/
15
+ README.md overview: purpose, parts, code map, rules across the code, review rules, index of docs
16
+ subsystems/ how each part works and why
17
+ features/ what the user sees, and how to drive it live
18
+ guides/ recurring maintainer jobs, such as a release or live verification
19
+ adr/ hard-to-reverse decisions
20
+ ```
21
+
22
+ Grow it on demand: start with `README.md` alone, and add a folder when its first document is needed. A small project may never need more than the overview and `features/`. The proposal names what the first change writes (the overview only, from the code), roughly what it costs, and what it gains.
23
+
9
24
  ## Header
10
25
 
11
- An overview and a subsystem doc start with a title and a header block:
26
+ An overview, a subsystem doc, a feature file, and a live-verification guide start with a title and a header block:
12
27
 
13
28
  ```markdown
14
29
  # Compaction
@@ -104,6 +119,52 @@ Tests: `<path to the folder's tests>`.
104
119
 
105
120
  Keep it to what someone editing the folder needs first. Explanation belongs in the subsystem doc it points to.
106
121
 
122
+ ## Feature File
123
+
124
+ Subsystem docs describe the software the way the code is built; a feature map describes it the way a user meets it, with the exact steps that show each feature working in the running software. Features cut across subsystems, so the map is its own folder beside them (`features/` in the developer docs): a `README.md` index and one file per user-facing feature. Software with nothing to run, such as a pure library, has no feature map; its tests are the live check.
125
+
126
+ A feature file uses the header. **Covers** names the code behind what the user sees, so the docs check flags the steps when that code changes. **Verified at** is the commit at which every step not marked unverified was last driven, not only read. Then:
127
+
128
+ ```markdown
129
+ # <Feature name>
130
+
131
+ <One paragraph: what the user sees and does.>
132
+
133
+ ## Sub-features
134
+ ## How to get to it (user POV)
135
+ ## Driving it
136
+ ## Gotchas
137
+ ```
138
+
139
+ - **Sub-features:** one line each, led by a short ID (`settings-open`) that evidence names reuse.
140
+ - **How to get to it (user POV):** every entry point a user has: a command, a key, a menu, a URL.
141
+ - **Driving it:** `Preconditions:` first, then one labeled bullet per user action, with the exact command and the observable result, including side effects such as files written. Mark a step that calls a paid service, such as a model, and say what it needs before it runs.
142
+ - **Gotchas:** traps that waste or invalidate a run, entry points not driven yet, and steps left unverified, with the reason.
143
+
144
+ Name only user paths, stable handles, required state, commands, and observable results; a source path appears only when it is the only stable handle. Link the subsystem docs the feature touches. A step that could not be driven stays marked unverified. A product bug the steps expose is reported to the user, never written into the steps as expected behavior.
145
+
146
+ The index `README.md` holds what every file shares: baseline preconditions, driving conventions, how proof and skipped steps are reported, and one line per feature file.
147
+
148
+ ## Live-Verification Guide
149
+
150
+ One guide shared by every feature file (for example `guides/verify-live.md` in the developer docs), with the helper script it documents kept in the repository. It uses the header, covering the helper.
151
+
152
+ ```markdown
153
+ ## Launch
154
+ ## Health Check
155
+ ## Drive
156
+ ## Evidence
157
+ ## Clean Up
158
+ ## Paid Calls
159
+ ```
160
+
161
+ - **Launch:** the exact command that starts an isolated instance from empty state, and the signal that it is usable, not merely running.
162
+ - **Health Check:** one read-only command that says whether this instance is worth driving: it is the one the run started, on the right build, with isolated state. Run it before the first step and after anything surprising.
163
+ - **Drive:** the helper's commands and the stable handles they rely on (prompts, labels, on-screen text), not coordinates or tab order.
164
+ - **Evidence:** what each step saves and where (an ignored folder), and the proof standards: drive the real user path, capture the action and the resulting state, and check side effects from a second view.
165
+ - **Clean Up:** stop only what the run started, never by process name; remove scratch state; keep the evidence.
166
+ - **Paid Calls:** which inputs call a model or another paid service, the guard that refuses them by default, and what a step needs before it may run one, such as a pinned cheap model and the user's yes.
167
+
107
168
  ## Adapting To The Software
108
169
 
109
170
  Shape the sections around what readers of this software need to know before changing it. For example:
@@ -114,6 +175,10 @@ Shape the sections around what readers of this software need to know before chan
114
175
  - **A data pipeline:** add data shapes at each stage, ordering and idempotency guarantees, and what reprocessing does.
115
176
  - **A small module:** purpose, surface, and a few invariants may be the whole document, or a folder README may be enough.
116
177
 
178
+ ## Test It On A New Reader
179
+
180
+ For a new subsystem doc or overview, or one you substantially rewrote, test it on a reader without your context. Write five to ten questions a newcomer would ask: where is the code that does X, why does it do Y, is Z a bug, what breaks if W changes, which test proves V. Give a fresh agent only the document and the questions (a subagent where the host has one; otherwise ask the user to run it in a new session). Compare each answer with the code. Where an answer is wrong or unsure, fix the document and ask again. The test passes when the answers are right without new gaps; it shows the reader understood the document, not that every claim is current.
181
+
117
182
  ## User Guide
118
183
 
119
184
  A user guide is task-oriented: what the user can do, the settings and commands involved, and what they will see. Keep internals out unless the user must understand them to use the feature correctly, and link the subsystem doc for readers who want more.