devrites 1.19.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 (232) hide show
  1. package/.claude-plugin/marketplace.json +24 -0
  2. package/.claude-plugin/plugin.json +43 -0
  3. package/CHANGELOG.md +391 -0
  4. package/LICENSE +56 -0
  5. package/NOTICE.md +18 -0
  6. package/README.md +582 -0
  7. package/SECURITY.md +193 -0
  8. package/bin/devrites.mjs +100 -0
  9. package/docs/architecture.md +272 -0
  10. package/docs/cli-mcp.md +57 -0
  11. package/docs/command-map.md +143 -0
  12. package/docs/flow.md +360 -0
  13. package/docs/release.md +29 -0
  14. package/docs/skills.md +214 -0
  15. package/docs/usage.md +325 -0
  16. package/install.sh +359 -0
  17. package/mcp/devrites-mcp.mjs +103 -0
  18. package/pack/.claude/agents/devrites-code-reviewer.md +50 -0
  19. package/pack/.claude/agents/devrites-doubt-reviewer.md +55 -0
  20. package/pack/.claude/agents/devrites-frontend-reviewer.md +52 -0
  21. package/pack/.claude/agents/devrites-performance-reviewer.md +47 -0
  22. package/pack/.claude/agents/devrites-plan-reviewer.md +79 -0
  23. package/pack/.claude/agents/devrites-security-auditor.md +53 -0
  24. package/pack/.claude/agents/devrites-simplifier-reviewer.md +75 -0
  25. package/pack/.claude/agents/devrites-slice-wright.md +181 -0
  26. package/pack/.claude/agents/devrites-spec-reviewer.md +72 -0
  27. package/pack/.claude/agents/devrites-strategy-reviewer.md +62 -0
  28. package/pack/.claude/agents/devrites-test-analyst.md +47 -0
  29. package/pack/.claude/hooks/devrites-a1-guard.sh +81 -0
  30. package/pack/.claude/hooks/devrites-allow.sh +44 -0
  31. package/pack/.claude/hooks/devrites-cursor.sh +28 -0
  32. package/pack/.claude/hooks/devrites-orient.sh +53 -0
  33. package/pack/.claude/hooks/devrites-redwatch.sh +39 -0
  34. package/pack/.claude/hooks/devrites-refresh-indexes.sh +127 -0
  35. package/pack/.claude/hooks/devrites-reviewer-readonly.sh +28 -0
  36. package/pack/.claude/hooks/devrites-statusline.sh +18 -0
  37. package/pack/.claude/hooks/devrites-stop-gate.sh +45 -0
  38. package/pack/.claude/hooks/devrites-wright-scope.sh +35 -0
  39. package/pack/.claude/hooks/hooks.json +52 -0
  40. package/pack/.claude/rules/README.md +48 -0
  41. package/pack/.claude/rules/afk-hitl.md +245 -0
  42. package/pack/.claude/rules/agents.md +98 -0
  43. package/pack/.claude/rules/anti-patterns.md +48 -0
  44. package/pack/.claude/rules/code-review.md +38 -0
  45. package/pack/.claude/rules/coding-style.md +55 -0
  46. package/pack/.claude/rules/context-hygiene.md +97 -0
  47. package/pack/.claude/rules/core.md +119 -0
  48. package/pack/.claude/rules/development-workflow.md +40 -0
  49. package/pack/.claude/rules/documentation.md +27 -0
  50. package/pack/.claude/rules/error-handling.md +33 -0
  51. package/pack/.claude/rules/git-workflow.md +35 -0
  52. package/pack/.claude/rules/hooks.md +38 -0
  53. package/pack/.claude/rules/patterns.md +45 -0
  54. package/pack/.claude/rules/performance.md +27 -0
  55. package/pack/.claude/rules/prose-style.md +101 -0
  56. package/pack/.claude/rules/security.md +63 -0
  57. package/pack/.claude/rules/testing.md +88 -0
  58. package/pack/.claude/rules/tooling.md +72 -0
  59. package/pack/.claude/settings.json +53 -0
  60. package/pack/.claude/skills/devrites-api-interface/SKILL.md +45 -0
  61. package/pack/.claude/skills/devrites-audit/SKILL.md +73 -0
  62. package/pack/.claude/skills/devrites-browser-proof/SKILL.md +38 -0
  63. package/pack/.claude/skills/devrites-debug-recovery/SKILL.md +50 -0
  64. package/pack/.claude/skills/devrites-debug-recovery/reference/build-the-loop.md +47 -0
  65. package/pack/.claude/skills/devrites-debug-recovery/reference/cleanup-and-classify.md +17 -0
  66. package/pack/.claude/skills/devrites-debug-recovery/reference/hypotheses.md +17 -0
  67. package/pack/.claude/skills/devrites-debug-recovery/reference/instrumentation.md +21 -0
  68. package/pack/.claude/skills/devrites-debug-recovery/reference/regression-test.md +31 -0
  69. package/pack/.claude/skills/devrites-doubt/SKILL.md +75 -0
  70. package/pack/.claude/skills/devrites-frontend-craft/SKILL.md +96 -0
  71. package/pack/.claude/skills/devrites-frontend-craft/reference/craft.md +59 -0
  72. package/pack/.claude/skills/devrites-frontend-craft/reference/design-references.md +116 -0
  73. package/pack/.claude/skills/devrites-frontend-craft/reference/fullstack.md +45 -0
  74. package/pack/.claude/skills/devrites-frontend-craft/reference/quality-standards.md +215 -0
  75. package/pack/.claude/skills/devrites-frontend-craft/reference/reuse-first.md +59 -0
  76. package/pack/.claude/skills/devrites-frontend-craft/reference/shape.md +60 -0
  77. package/pack/.claude/skills/devrites-interview/SKILL.md +81 -0
  78. package/pack/.claude/skills/devrites-lib/SKILL.md +76 -0
  79. package/pack/.claude/skills/devrites-lib/scripts/analyze.sh +78 -0
  80. package/pack/.claude/skills/devrites-lib/scripts/check-acceptance.sh +75 -0
  81. package/pack/.claude/skills/devrites-lib/scripts/close-out.sh +47 -0
  82. package/pack/.claude/skills/devrites-lib/scripts/conventions.py +273 -0
  83. package/pack/.claude/skills/devrites-lib/scripts/coverage.sh +51 -0
  84. package/pack/.claude/skills/devrites-lib/scripts/devrites.sh +69 -0
  85. package/pack/.claude/skills/devrites-lib/scripts/doctor.sh +92 -0
  86. package/pack/.claude/skills/devrites-lib/scripts/evidence-fresh.sh +63 -0
  87. package/pack/.claude/skills/devrites-lib/scripts/footprint.sh +45 -0
  88. package/pack/.claude/skills/devrites-lib/scripts/learnings.sh +74 -0
  89. package/pack/.claude/skills/devrites-lib/scripts/mutation-gate.sh +52 -0
  90. package/pack/.claude/skills/devrites-lib/scripts/package-existence.sh +68 -0
  91. package/pack/.claude/skills/devrites-lib/scripts/preamble.sh +76 -0
  92. package/pack/.claude/skills/devrites-lib/scripts/progress.sh +103 -0
  93. package/pack/.claude/skills/devrites-lib/scripts/readiness.sh +62 -0
  94. package/pack/.claude/skills/devrites-lib/scripts/reconcile.sh +123 -0
  95. package/pack/.claude/skills/devrites-lib/scripts/resolve.sh +279 -0
  96. package/pack/.claude/skills/devrites-lib/scripts/stuck.sh +67 -0
  97. package/pack/.claude/skills/devrites-lib/scripts/test-integrity.sh +87 -0
  98. package/pack/.claude/skills/devrites-lib/scripts/tick-afk.sh +52 -0
  99. package/pack/.claude/skills/devrites-prose-craft/SKILL.md +105 -0
  100. package/pack/.claude/skills/devrites-prose-craft/reference/banned-phrases.md +95 -0
  101. package/pack/.claude/skills/devrites-prose-craft/reference/examples.md +88 -0
  102. package/pack/.claude/skills/devrites-prose-craft/reference/structures.md +134 -0
  103. package/pack/.claude/skills/devrites-refresh-indexes/SKILL.md +54 -0
  104. package/pack/.claude/skills/devrites-source-driven/SKILL.md +36 -0
  105. package/pack/.claude/skills/devrites-ux-shape/SKILL.md +121 -0
  106. package/pack/.claude/skills/devrites-ux-shape/reference/brief-template.md +93 -0
  107. package/pack/.claude/skills/devrites-ux-shape/reference/visual-direction-probe.md +48 -0
  108. package/pack/.claude/skills/rite/SKILL.md +135 -0
  109. package/pack/.claude/skills/rite/reference/menu.md +32 -0
  110. package/pack/.claude/skills/rite-adopt/SKILL.md +83 -0
  111. package/pack/.claude/skills/rite-adopt/reference/adoption.md +58 -0
  112. package/pack/.claude/skills/rite-adopt/reference/anti-patterns.md +19 -0
  113. package/pack/.claude/skills/rite-autocomplete/SKILL.md +96 -0
  114. package/pack/.claude/skills/rite-autocomplete/reference/decision-policy.md +35 -0
  115. package/pack/.claude/skills/rite-autocomplete/reference/loop.md +54 -0
  116. package/pack/.claude/skills/rite-autocomplete/reference/stop-conditions.md +59 -0
  117. package/pack/.claude/skills/rite-build/SKILL.md +261 -0
  118. package/pack/.claude/skills/rite-build/reference/afk-discipline.md +145 -0
  119. package/pack/.claude/skills/rite-build/reference/anti-patterns.md +25 -0
  120. package/pack/.claude/skills/rite-build/reference/checkpoint-protocol.md +149 -0
  121. package/pack/.claude/skills/rite-build/reference/evidence-standard.md +32 -0
  122. package/pack/.claude/skills/rite-build/reference/frontend-trigger.md +39 -0
  123. package/pack/.claude/skills/rite-build/reference/one-slice-cycle.md +38 -0
  124. package/pack/.claude/skills/rite-build/reference/spec-drift-guard.md +43 -0
  125. package/pack/.claude/skills/rite-build/reference/tdd.md +26 -0
  126. package/pack/.claude/skills/rite-build/reference/wright-dispatch.md +115 -0
  127. package/pack/.claude/skills/rite-define/SKILL.md +157 -0
  128. package/pack/.claude/skills/rite-define/reference/anti-patterns.md +25 -0
  129. package/pack/.claude/skills/rite-define/reference/gates.md +152 -0
  130. package/pack/.claude/skills/rite-define/reference/plan-template.md +65 -0
  131. package/pack/.claude/skills/rite-doctor/SKILL.md +50 -0
  132. package/pack/.claude/skills/rite-frame/SKILL.md +116 -0
  133. package/pack/.claude/skills/rite-frame/reference/failure-modes.md +68 -0
  134. package/pack/.claude/skills/rite-handoff/SKILL.md +95 -0
  135. package/pack/.claude/skills/rite-handoff/reference/handoff-template.md +34 -0
  136. package/pack/.claude/skills/rite-learn/SKILL.md +82 -0
  137. package/pack/.claude/skills/rite-plan/SKILL.md +82 -0
  138. package/pack/.claude/skills/rite-plan/reference/anti-patterns.md +24 -0
  139. package/pack/.claude/skills/rite-plan/reference/dependency-graph.md +33 -0
  140. package/pack/.claude/skills/rite-plan/reference/replan-and-repair.md +42 -0
  141. package/pack/.claude/skills/rite-plan/reference/slicing.md +52 -0
  142. package/pack/.claude/skills/rite-plan/reference/task-breakdown.md +34 -0
  143. package/pack/.claude/skills/rite-polish/SKILL.md +90 -0
  144. package/pack/.claude/skills/rite-polish/reference/anti-ai-slop.md +177 -0
  145. package/pack/.claude/skills/rite-polish/reference/anti-patterns.md +27 -0
  146. package/pack/.claude/skills/rite-polish/reference/backend-polish.md +80 -0
  147. package/pack/.claude/skills/rite-polish/reference/browser-polish-evidence.md +31 -0
  148. package/pack/.claude/skills/rite-polish/reference/code.md +85 -0
  149. package/pack/.claude/skills/rite-polish/reference/design-system-discovery.md +35 -0
  150. package/pack/.claude/skills/rite-polish/reference/harden-checklist.md +109 -0
  151. package/pack/.claude/skills/rite-polish/reference/ui.md +136 -0
  152. package/pack/.claude/skills/rite-pressure-test/SKILL.md +43 -0
  153. package/pack/.claude/skills/rite-prototype/SKILL.md +87 -0
  154. package/pack/.claude/skills/rite-prove/SKILL.md +120 -0
  155. package/pack/.claude/skills/rite-prove/reference/anti-patterns.md +25 -0
  156. package/pack/.claude/skills/rite-prove/reference/browser-proof.md +26 -0
  157. package/pack/.claude/skills/rite-prove/reference/failure-triage.md +25 -0
  158. package/pack/.claude/skills/rite-prove/reference/proof-ladder.md +26 -0
  159. package/pack/.claude/skills/rite-prove/reference/test-command-discovery.md +30 -0
  160. package/pack/.claude/skills/rite-quick/SKILL.md +81 -0
  161. package/pack/.claude/skills/rite-resolve/SKILL.md +113 -0
  162. package/pack/.claude/skills/rite-resolve/reference/answer-protocol.md +114 -0
  163. package/pack/.claude/skills/rite-review/SKILL.md +170 -0
  164. package/pack/.claude/skills/rite-review/reference/anti-patterns.md +32 -0
  165. package/pack/.claude/skills/rite-review/reference/cognitive-load.md +90 -0
  166. package/pack/.claude/skills/rite-review/reference/feature-scoped-review.md +26 -0
  167. package/pack/.claude/skills/rite-review/reference/five-axis-review.md +46 -0
  168. package/pack/.claude/skills/rite-review/reference/nielsen-heuristics.md +130 -0
  169. package/pack/.claude/skills/rite-review/reference/parallel-dispatch.md +62 -0
  170. package/pack/.claude/skills/rite-review/reference/performance-review.md +28 -0
  171. package/pack/.claude/skills/rite-review/reference/security-review.md +32 -0
  172. package/pack/.claude/skills/rite-seal/SKILL.md +183 -0
  173. package/pack/.claude/skills/rite-seal/reference/anti-patterns.md +27 -0
  174. package/pack/.claude/skills/rite-seal/reference/conventions-ledger.md +63 -0
  175. package/pack/.claude/skills/rite-seal/reference/final-evidence.md +72 -0
  176. package/pack/.claude/skills/rite-seal/reference/go-no-go.md +37 -0
  177. package/pack/.claude/skills/rite-seal/reference/parallel-dispatch.md +69 -0
  178. package/pack/.claude/skills/rite-seal/reference/risk-and-rollback.md +30 -0
  179. package/pack/.claude/skills/rite-seal/reference/seal-template.md +36 -0
  180. package/pack/.claude/skills/rite-ship/SKILL.md +120 -0
  181. package/pack/.claude/skills/rite-ship/reference/anti-patterns.md +25 -0
  182. package/pack/.claude/skills/rite-ship/reference/close-out.md +31 -0
  183. package/pack/.claude/skills/rite-ship/reference/design-memory.md +120 -0
  184. package/pack/.claude/skills/rite-ship/reference/git-ship.md +42 -0
  185. package/pack/.claude/skills/rite-ship/reference/ship-template.md +33 -0
  186. package/pack/.claude/skills/rite-spec/SKILL.md +126 -0
  187. package/pack/.claude/skills/rite-spec/reference/acceptance-criteria.md +31 -0
  188. package/pack/.claude/skills/rite-spec/reference/anti-patterns.md +25 -0
  189. package/pack/.claude/skills/rite-spec/reference/interview-patterns.md +56 -0
  190. package/pack/.claude/skills/rite-spec/reference/investigation.md +64 -0
  191. package/pack/.claude/skills/rite-spec/reference/question-protocol.md +61 -0
  192. package/pack/.claude/skills/rite-spec/reference/references-intake.md +57 -0
  193. package/pack/.claude/skills/rite-spec/reference/spec-checklists.md +73 -0
  194. package/pack/.claude/skills/rite-spec/reference/spec-template.md +124 -0
  195. package/pack/.claude/skills/rite-spec/reference/state-workspace.md +159 -0
  196. package/pack/.claude/skills/rite-status/SKILL.md +101 -0
  197. package/pack/.claude/skills/rite-temper/SKILL.md +119 -0
  198. package/pack/.claude/skills/rite-temper/reference/anti-patterns.md +29 -0
  199. package/pack/.claude/skills/rite-temper/reference/review-dimensions.md +65 -0
  200. package/pack/.claude/skills/rite-temper/reference/scope-modes.md +53 -0
  201. package/pack/.claude/skills/rite-temper/reference/significance.md +46 -0
  202. package/pack/.claude/skills/rite-temper/reference/strategy-template.md +90 -0
  203. package/pack/.claude/skills/rite-vet/SKILL.md +155 -0
  204. package/pack/.claude/skills/rite-vet/reference/anti-patterns.md +29 -0
  205. package/pack/.claude/skills/rite-vet/reference/artifacts.md +135 -0
  206. package/pack/.claude/skills/rite-vet/reference/cross-model.md +41 -0
  207. package/pack/.claude/skills/rite-vet/reference/depth.md +53 -0
  208. package/pack/.claude/skills/rite-vet/reference/eng-lenses.md +48 -0
  209. package/pack/.claude/skills/rite-vet/reference/review-axes.md +167 -0
  210. package/pack/.claude/skills/rite-zoom-out/SKILL.md +75 -0
  211. package/package.json +68 -0
  212. package/scripts/build-release-tarball.sh +74 -0
  213. package/scripts/check-cross-refs.py +121 -0
  214. package/scripts/check-no-global-writes.sh +44 -0
  215. package/scripts/check-rule-uniqueness.sh +73 -0
  216. package/scripts/devrites-detect.sh +175 -0
  217. package/scripts/eval-runner.py +273 -0
  218. package/scripts/grade-feature.sh +104 -0
  219. package/scripts/install-lib.sh +83 -0
  220. package/scripts/pin.sh +166 -0
  221. package/scripts/render-eval-summary.py +48 -0
  222. package/scripts/run-evals.sh +149 -0
  223. package/scripts/run-outcome-evals.sh +49 -0
  224. package/scripts/scan-pack-security.py +209 -0
  225. package/scripts/scan-supply-chain-iocs.py +127 -0
  226. package/scripts/supply-chain-iocs.json +11 -0
  227. package/scripts/sync-version.sh +56 -0
  228. package/scripts/validate-frontmatter.py +149 -0
  229. package/scripts/validate-workflow-security.py +86 -0
  230. package/scripts/validate.sh +234 -0
  231. package/uninstall.sh +137 -0
  232. package/update.sh +196 -0
@@ -0,0 +1,245 @@
1
+ # AFK & HITL — the pause/resume contract
2
+
3
+ The rule layer for DevRites's two run modes. Every `rite-*` and `devrites-*` skill that
4
+ might pause for a human reads from this contract; `/rite-build`, `/rite-status`,
5
+ `/rite-resolve`, and `devrites-doubt` are the primary callers.
6
+
7
+ The contract is intentionally small: one sentinel, one queue, one verb.
8
+
9
+ ## Run modes
10
+
11
+ - **HITL (default)** — human is present. At a gap/checkpoint the skill **asks inline** via
12
+ the harness `AskUserQuestion` tool — a ranked **option set** (recommended first, each with
13
+ dimension-tagged rationale; see [Option set](#option-set--how-every-gap-is-presented)). The
14
+ human picks; the skill records the pick to `questions.md` (`answered`) + `decisions.md` and
15
+ **continues in place — no `/rite-resolve` round-trip**. `/rite-resolve` is only for answering
16
+ **async** (a pause that already stopped the session) or in **batch**.
17
+ - **AFK** — `.devrites/AFK` is present. For any gate AFK may auto-handle (severity in
18
+ `allow_gates`), the skill **auto-picks the recommended option** (option 1 of the set), records
19
+ it (`gate: advisory` + a `decisions.md` ADR), and continues unattended. Gates above the
20
+ ceiling — and every irreversible-risk item — pause and queue a `questions.md` entry for
21
+ `/rite-resolve`, **unless `allow_irreversible: true`** is set (see [Maximal
22
+ autonomy](#irreversible-risk-list-always-pause)).
23
+
24
+ `.devrites/AFK` presence is authoritative for run mode; gate-deciding skills re-read the
25
+ sentinel at decision time (the shared preamble derives the mode from it). There is no
26
+ `state.md` run-mode field to drift out of sync.
27
+
28
+ ## The sentinel — `.devrites/AFK`
29
+
30
+ Presence = AFK active. The file body is optional YAML:
31
+
32
+ ```yaml
33
+ max_slices: 10 # read-only INITIAL budget; seeds state.md `AFK slices remaining`
34
+ notify: "ntfy.sh/my-topic" # shell command run on awaiting_human transition
35
+ allow_gates: [advisory, validating] # gate severities AFK auto-handles (auto-picks the recommended option)
36
+ allow_irreversible: false # DANGER, opt-in. true → auto-pick the recommended option even on
37
+ # irreversible gates (drop-table, auth, public-API break, data-loss).
38
+ # Lifts the safety floor; destructive changes ship unattended. Default false.
39
+ ```
40
+
41
+ The file is **read-only config** — never rewritten in place. `max_slices` is the initial
42
+ budget; the mutable remaining count lives in `state.md` as `AFK slices remaining: <n>`,
43
+ seeded from `max_slices` on the first AFK build and decremented by `tick-afk.sh` (which
44
+ exits non-zero at 0, forcing a HITL stop). The cap is enforced by the script, not prose.
45
+
46
+ Missing keys fall back to defaults:
47
+
48
+ | Key | Default | Meaning |
49
+ |---|---|---|
50
+ | `max_slices` | unlimited | a missing cap is unsafe; recommend setting one explicitly |
51
+ | `notify` | none | no notification fires |
52
+ | `allow_gates` | `[advisory]` | AFK auto-handles advisory only by default (auto-picks the recommended option) |
53
+ | `allow_irreversible` | `false` | when `true`, AFK auto-picks even irreversible-risk gates — the safety floor is lifted (see [Maximal autonomy](#irreversible-risk-list-always-pause)) |
54
+
55
+ To leave AFK, delete the file. The next skill invocation reverts to HITL.
56
+
57
+ ## The four gates
58
+
59
+ Every `Mode: HITL` slice declares a `Gate:` and an `SLA:`. See
60
+ [`.claude/skills/rite-define/reference/gates.md`](../skills/rite-define/reference/gates.md)
61
+ for the full taxonomy. Summary:
62
+
63
+ | Gate | Stakes | Pause? | SLA | AFK auto-handle when in `allow_gates`? |
64
+ |---|---|---|---|---|
65
+ | advisory | low | no | none | yes (log + proceed) |
66
+ | validating | medium | async | 4h | yes (build + queue, no merge until resolved) |
67
+ | blocking | high | sync | 15m | **no** — always pauses |
68
+ | escalating | novel pattern | sync to specialist | 24h | **no** — always pauses |
69
+
70
+ `blocking` and `escalating` always pause regardless of `allow_gates`. They are the
71
+ "AFK never silently accepts" guarantees in protocol form.
72
+
73
+ An open `gate: validating` entry is **merge-blocking by definition**: at `/rite-seal` any
74
+ `questions.md` entry with `gate: validating` and `status: open` is a NO-GO, regardless of
75
+ its behavior impact. A slice marked `built (pending review)` is **not done** until that
76
+ validating gate resolves.
77
+
78
+ ## Option set — how every gap is presented
79
+
80
+ Wherever a gap, checkpoint, or non-trivial decision surfaces (`/rite-spec`, `/rite-define`,
81
+ `/rite-build`, `/rite-temper`, `/rite-vet`, `devrites-doubt`, `devrites-interview`), present a
82
+ **ranked option set**, never a single bare guess:
83
+
84
+ - **2–4 concrete options**, the **recommended one first**, labelled `(Recommended)`.
85
+ - Each option carries a **one-line rationale tagged by the dimensions that matter** —
86
+ `logic · infra · business · architecture` (add `security` / `UX` / `risk` when in scope).
87
+ Name the trade-off, not just the choice.
88
+ - Always include an escape hatch (`Something else — I'll describe it`).
89
+ - The recommendation reflects what's best for *this* project (its conventions, stack, scale,
90
+ domain) — not a generic default.
91
+
92
+ **HITL** renders the set via `AskUserQuestion` (recommended option first; rationale in each
93
+ option's description); the human's pick resolves the gate **in place**. **AFK** auto-picks
94
+ option 1 (the recommendation) for gates it may auto-handle. Either way the chosen option is
95
+ recorded verbatim and the **rejected options stay in `questions.md`** as the considered-alternatives
96
+ trail — the audit shows what was weighed, not just what was decided.
97
+
98
+ ## Irreversible-risk list (always pause)
99
+
100
+ The following always invoke the checkpoint protocol, regardless of `Mode`, `Gate`, or
101
+ `allow_gates`:
102
+
103
+ - Destructive data migration (drop column, drop table, irreversible backfill).
104
+ - Auth / authz boundary change.
105
+ - Public API break (response shape, removed endpoint, changed status code semantics).
106
+ - External-service contract change.
107
+ - Filesystem destruction outside the workspace.
108
+ - Red tests / types / lint on slice completion (fail-on-red).
109
+
110
+ By default, AFK widens what's *automatic*; it never widens what's *irreversible*.
111
+
112
+ **Maximal autonomy (`allow_irreversible: true` — opt-in, dangerous).** Setting this key in
113
+ `.devrites/AFK` lifts the floor: AFK then **auto-picks the recommended option on irreversible
114
+ gates too, with no pause**. This ships destructive migrations / auth changes / public-API
115
+ breaks / data-loss paths **unattended, with zero human review** — recommended *only* on a
116
+ throwaway or sandboxed target you can roll back wholesale. Default is `false`; a missing key
117
+ keeps the floor. The floor is the deliberate safety default — `allow_irreversible` is the user
118
+ pulling the trigger themselves, not something a stray sentinel can do silently.
119
+
120
+ ## `questions.md` schema
121
+
122
+ Append-only. One entry per qid. Format:
123
+
124
+ ```markdown
125
+ ## q-YYYY-MM-DD-NNN
126
+ status: open | answered | dropped
127
+ slice: <slice id, e.g. 03-list-endpoint, or "spec" / "plan">
128
+ gate: advisory | validating | blocking | escalating
129
+ question: <one crisp sentence>
130
+ options: | # ranked option set; recommended FIRST (see "Option set")
131
+ 1. <recommended> (Recommended) — logic: … · infra: … · business: … · architecture: …
132
+ 2. <alternative> — <dimension-tagged rationale + trade-off>
133
+ 3. Something else — describe it
134
+ proposed: <the recommended option restated — the HITL default + the AFK auto-pick>
135
+ raised_at: <iso>
136
+ answered_at: <iso, when status flips off "open">
137
+ answer: <chosen option (or human's verbatim reply / drop reason)>
138
+ ```
139
+
140
+ Rules:
141
+ - `NNN` is sequential per date — the next-available 3-digit integer.
142
+ - `status: open` is the only state `/rite-resolve` can mutate; `answered` and `dropped`
143
+ are terminal.
144
+ - The file is the audit trail. Don't edit answered/dropped entries — open a new qid that
145
+ references the old one (`supersedes: q-...-OLD`) and resolve it.
146
+
147
+ ## `state.md` `Awaiting human` block
148
+
149
+ When a HITL gate fires, `/rite-build` writes:
150
+
151
+ ```markdown
152
+ - Status: awaiting_human
153
+ - Next step: /rite-resolve <qid> "<answer>"
154
+
155
+ ## Awaiting human
156
+ - qid: <q-...>
157
+ - gate: <gate>
158
+ - question: <crisp text>
159
+ - proposed: <agent's tentative answer>
160
+ - raised_at: <iso>
161
+ - blocking_slices: [<slice ids that cannot advance>]
162
+ ```
163
+
164
+ `/rite-resolve` removes the block on success and flips `Status: running`.
165
+
166
+ ## The resume verb — `/rite-resolve`
167
+
168
+ Three shapes:
169
+
170
+ ```
171
+ /rite-resolve <qid> "<answer>"
172
+ /rite-resolve --drop <qid> ["<reason>"]
173
+ /rite-resolve --batch <path-to-yaml>
174
+ ```
175
+
176
+ `/rite-resolve` is the canonical writer for **async** resume — a gate that already paused and
177
+ stopped the session (an AFK blocking/escalating/irreversible queue, or a HITL pause the human
178
+ walked away from), plus `--batch`. In an **interactive HITL** session the skill resolves the
179
+ `AskUserQuestion` pick **in place** (the same `questions.md` `answered` write + `state.md`
180
+ clear), so you don't type `/rite-resolve` for gaps you answer live. Both paths flip
181
+ `status: open → answered` and clear `Awaiting human` through the **same `resolve.sh` writer** —
182
+ one source of truth, two entry points (live pick vs typed verb). Manual edits work but the
183
+ script is the contract — use it.
184
+
185
+ When `/rite-resolve` does resume a stopped session, the skill does **not** auto-run the next
186
+ `/rite-build`. The user types the next command explicitly so:
187
+ - A `/rite-plan repair` can land first if the answer changes scope.
188
+ - The user sees the workspace state before resuming.
189
+ - Each verb has one mutation; chaining is a hidden side-effect.
190
+
191
+ ## AFK exception for discretionary pauses
192
+
193
+ `devrites-doubt` and similar skills that "ask the user" follow this rule when
194
+ `.devrites/AFK` exists:
195
+
196
+ - Finding severity ≤ slice's gate ceiling (slice's `Gate:` plus `.devrites/AFK`
197
+ `allow_gates`) → log to `questions.md` as `gate: advisory`, record the trade-off in
198
+ `decisions.md`, proceed.
199
+ - Finding severity > gate ceiling, OR finding touches the irreversible-risk list →
200
+ log to `questions.md` as `gate: blocking`, set `state.md` `Status: awaiting_human`,
201
+ fire `notify:`, STOP.
202
+
203
+ The loop limits of the calling skill still apply — after the limit, the unresolved
204
+ doubt becomes a blocking question regardless of AFK config.
205
+
206
+ ## Retry cap, stuck loops, and self-resolve
207
+
208
+ - **Cap retries.** At most **3 attempts** on the same failing check (test, lint, type, build).
209
+ On the third failure, stop guessing and convert it to a `gate: blocking` question — a fourth
210
+ identical attempt is thrash, not progress.
211
+ - **Stuck loops pause even in AFK.** A detected loop — the same action repeating, or an
212
+ action↔error ping-pong — pauses regardless of `allow_gates` (`stuck.sh`), the same standing as
213
+ the irreversible-risk list. AFK widens what's automatic, never what's looping.
214
+ - **Bias to self-resolve.** Before raising a question, try to answer it from the code, the docs,
215
+ or `decisions.md`. Communicate only for a blocked environment, a deliverable to hand over,
216
+ critical info you genuinely can't access, or a credential / permission you lack. This narrows
217
+ needless pauses and never weakens the blocking / escalating / irreversible gates.
218
+ - **Human time is for human-only work.** A `human_intervention` pause is for what the agent
219
+ literally cannot do (create a cloud account, click a console button) — never for writing code,
220
+ writing tests, or reviewing. Punting the agent's own job to the human is not a valid gate.
221
+
222
+ ## What the rule does NOT cover
223
+
224
+ This contract is about **human pauses**. It does not weaken or replace:
225
+
226
+ - `/rite-prove`, `/rite-review`, `/rite-seal` — feature-scoped gates that always run.
227
+ - Spec Drift Guard — answer that changes acceptance criteria routes through
228
+ `/rite-plan repair`, not silently into the slice.
229
+ - `evidence.md` writes — every AFK iteration still records evidence; un-recorded passes
230
+ are unproven at `/rite-prove`.
231
+ - `/clear` / `/compact` advice — context-hygiene rules are unchanged.
232
+
233
+ AFK shifts the boundary between automatic and "ask"; nothing else.
234
+
235
+ ## Cross-reference
236
+
237
+ - Skill: `/rite-resolve` (`.claude/skills/rite-resolve/SKILL.md`).
238
+ - Workflow integration: `/rite-build` (`.claude/skills/rite-build/SKILL.md`),
239
+ workflow steps 0 + 2a (readiness / HITL pre-flight) and steps 4–6 (doubt / fail-on-red /
240
+ record) on the wright's return.
241
+ - Render contract: `.claude/skills/rite-build/reference/checkpoint-protocol.md`.
242
+ - Loop discipline: `.claude/skills/rite-build/reference/afk-discipline.md`.
243
+ - Gate taxonomy: `.claude/skills/rite-define/reference/gates.md`.
244
+ - Schema: `.claude/skills/rite-spec/reference/state-workspace.md`.
245
+ - Doubt's AFK exception: `.claude/skills/devrites-doubt/SKILL.md` (AFK exception section).
@@ -0,0 +1,98 @@
1
+ # Agent orchestration
2
+
3
+ DevRites uses **project-local** agents under `.claude/agents/` (never a global location).
4
+ It separates three roles: **specialist skills** (model-invoked disciplines that run inline),
5
+ **review subagents** (fresh-context, **read-only** reviewers spawned for independent judgment),
6
+ and the **executor subagent** (`devrites-slice-wright` — fresh-context but **write-capable**,
7
+ the one agent that produces code).
8
+
9
+ ## Review subagents — `.claude/agents/`
10
+ Fresh-context, read-only reviewers. Each is given the active feature workspace path
11
+ (`.devrites/work/<slug>/`) + the diff, and returns findings — they do **not** edit code.
12
+
13
+ | Agent | Purpose | When |
14
+ |-------|---------|------|
15
+ | `devrites-spec-reviewer` | Does the diff implement the spec? Missing / partial / wrong criteria; scope creep | `/rite-review` (Spec axis); `/rite-seal` |
16
+ | `devrites-code-reviewer` | Correctness / readability / architecture / maintainability | `/rite-seal`; after a slice |
17
+ | `devrites-test-analyst` | Do the tests actually prove the acceptance criteria? | `/rite-seal` |
18
+ | `devrites-frontend-reviewer` | UX flow, a11y, responsive, design-system, anti-AI-slop | `/rite-seal` on UI features |
19
+ | `devrites-security-auditor` | Untrusted input, trust boundaries, secrets, deps | `/rite-seal` when input/auth/data in scope |
20
+ | `devrites-performance-reviewer` | Measure-first perf (N+1, hot paths, payload size) | `/rite-seal` when perf relevant |
21
+ | `devrites-simplifier-reviewer` | Behavior-preserving simplification (Chesterton's Fence, deletion test) — Suggestion-only by design | `/rite-polish` Phase 1; `devrites-audit simplify` |
22
+ | `devrites-doubt-reviewer` | Adversarial check of a single claim/decision | `devrites-doubt` loop; risky decisions |
23
+ | `devrites-strategy-reviewer` | Spec-vs-rubric strategic review (ambition / scope / premise / pre-mortem / YAGNI / testability / irreversibility / cross-cutting / convention) — **before** any plan or code | `/rite-temper` loop (pre-plan) |
24
+ | `devrites-plan-reviewer` | Plan-vs-rubric engineering review (architecture / scope-reuse / plan code-quality / test-coverage design / performance / reversibility / failure-mode coverage), confidence-banded with a quote-the-source verification gate — **after define, before build** | `/rite-vet` loop (pre-build) |
25
+
26
+ ## The executor subagent — `.claude/agents/devrites-slice-wright.md`
27
+
28
+ The system's one **write-capable** agent, and the mirror of the reviewers: where a reviewer
29
+ reads a finished diff in a fresh context, the wright **writes** one slice in a fresh context.
30
+
31
+ | Agent | Purpose | When |
32
+ |-------|---------|------|
33
+ | `devrites-slice-wright` | Turn ONE fully-specified slice contract into the smallest complete, idiomatic, proven implementation — orient → TDD → verify, anti-AI-slop, feature scope only | `/rite-build` — the build-core dispatch step |
34
+
35
+ `/rite-build` is the orchestrator: it owns the gates and the workspace, dispatches the wright
36
+ for the implementation, then doubts, gates, and records the return. Tools:
37
+ `Read, Edit, Write, Bash, Glob, Grep` (+ a code-intelligence index when present). It writes
38
+ **code and tests only** — never the `.devrites/` bookkeeping files; it returns that data and
39
+ the orchestrator persists it, so there is exactly one canonical writer of workspace state and
40
+ the HITL/AFK contract stays intact. **Single-threaded: one wright per slice, never a parallel
41
+ fan-out of writers** (concurrent writers make conflicting implicit decisions). Contract + return
42
+ shape + fallback: `.claude/skills/rite-build/reference/wright-dispatch.md`.
43
+
44
+ ## Namespaces — `rite-*` is the user surface; `devrites-*` is internal
45
+
46
+ The prefix mirrors visibility:
47
+
48
+ - **`rite-*`** = user-invocable (`user-invocable: true`). The public slash-command
49
+ surface — lifecycle phases plus utilities. `rite`, `rite-spec`, `rite-temper`,
50
+ `rite-define`, `rite-vet`,
51
+ `rite-plan`, `rite-build`, `rite-prove`, `rite-polish`, `rite-review`, `rite-seal`,
52
+ `rite-ship`, `rite-autocomplete`, `rite-status`, `rite-resolve`, `rite-prototype`,
53
+ `rite-handoff`, `rite-zoom-out`, `rite-pressure-test`. `/rite-seal` **decides**
54
+ GO/NO-GO and writes the verdict; `/rite-ship` **executes** the irreversible git
55
+ ladder and **closes** the task (archives the workspace, clears `.devrites/ACTIVE`).
56
+ `/rite-autocomplete` drives the whole lifecycle unattended.
57
+ - **`devrites-*`** = model-invoked (`user-invocable: false`, no slash command).
58
+ Internal specialists that fire on trigger from the `rite-*` skills or auto-select.
59
+ `devrites-interview`, `devrites-source-driven`, `devrites-doubt`,
60
+ `devrites-ux-shape` (plans UX/UI into `design-brief.md` at `/rite-spec` when UI is
61
+ detected — the build target), `devrites-frontend-craft`, `devrites-prose-craft`
62
+ (human-voice prose for artifacts + replies; the catch pass in `/rite-polish`),
63
+ `devrites-browser-proof`,
64
+ `devrites-debug-recovery`, `devrites-api-interface`, `devrites-audit` (dispatches the
65
+ security / perf / simplify reviewer subagent on an axis argument).
66
+ The `devrites-` prefix avoids collisions with bundled Claude Code skill
67
+ names (`prototype`, `handoff`, `diagnose`, etc.) — peer skill packs may
68
+ collide on the bare names internally even though these never appear in the
69
+ user's slash menu. Parallel reviewer fan-out at `/rite-seal` is no longer
70
+ a skill — it lives as a reference file
71
+ (`.claude/skills/rite-seal/reference/parallel-dispatch.md`).
72
+
73
+ The `/rite` menu carries the routing previously held by `devrites-selector`, which
74
+ has been removed. `user-invocable:` in each `SKILL.md` is the source of truth; the
75
+ prefix is a naming convention that matches it.
76
+
77
+ ## When to bring in a reviewer (no prompt needed)
78
+ 1. Standing a non-trivial decision (boundary, data model, auth, public API, migration) →
79
+ `devrites-doubt` → `devrites-doubt-reviewer`.
80
+ 2. Sealing a feature → fan out to the relevant reviewers above.
81
+ 3. A UI feature at seal → include `devrites-frontend-reviewer`.
82
+ 4. Input/auth/data/integration in scope → include `devrites-security-auditor`.
83
+
84
+ ## Rules
85
+ - Run independent reviewers **in parallel** at the seal, then reconcile; surface
86
+ disagreements explicitly rather than averaging them away.
87
+ - Reviewer read-only is **enforced at the tool layer**, not just promised: each reviewer
88
+ carries a shared deny-mutating-Bash frontmatter hook (`devrites-reviewer-readonly.sh`). A
89
+ fresh-context reviewer reads untrusted source — a silent write path would be a prompt-injection
90
+ surface.
91
+ - **Reviewer** agents are **read-only** and return labeled findings (Critical / Important /
92
+ Suggestion / Nit / FYI). Keep review **feature-scoped**.
93
+ - The **executor** agent (`devrites-slice-wright`) is the one **write-capable** agent: it writes
94
+ code + tests for a single slice and returns a structured artifact, but it never writes the
95
+ `.devrites/` workspace files (the orchestrator does) and never runs in parallel with another
96
+ writer.
97
+ - Give each agent the contract (workspace + diff for a reviewer; the slice contract for the
98
+ wright) without the author's reasoning — fresh, undirected context is the point.
@@ -0,0 +1,48 @@
1
+ # DevRites — universal anti-patterns
2
+
3
+ The pack-wide rationalizations the agent reaches for when discipline gets in
4
+ the way. Apply at every phase. Each `rite-*/reference/anti-patterns.md`
5
+ extends this with phase-specific items.
6
+
7
+ This file is the **single source** of the universal anti-rationalization table.
8
+ `core.md` carries only a minimal 5-row subset (its first five rows are
9
+ byte-identical to the matching rows below); read this file for the full set.
10
+
11
+ ## Universal rationalizations
12
+
13
+ | Excuse | Rebuttal |
14
+ |---|---|
15
+ | "I'll add the tests later." | Tests written after the fact don't drive design and miss the boundary cases the act of writing exposes. Test now or the tests you eventually write are worse. |
16
+ | "Lint and build pass — that proves quality." | Automation proves syntax and style, not design or correctness. Never cite clean automation as evidence of good design. |
17
+ | "It's only a small refactor while I'm in here." | Feature scope only — drive-by cleanup balloons the diff, hides intent, and gets rejected at seal. Record as an FYI follow-up. |
18
+ | "This is a special case, the pattern doesn't apply." | Special cases multiply silently. Either they really are special (record *why* in `decisions.md`) or they're not (and the pattern wins). |
19
+ | "The user will tell me if something is wrong." | Drift detection is the workflow's job, not the user's QA. Surface assumptions; route material questions through the Spec Drift Guard. |
20
+ | "Generic name (`processData`, `handleItem`) is fine — the code is self-evident." | Generic AI naming is slop. Match the project's idiom; one concept gets one word across the codebase. |
21
+ | "Better safe than sorry — add the defensive null/length check." | Over-defensive guarding is slop. Validate at boundaries; trust the core. A check inside trusted code hides bugs in the boundary. |
22
+ | "It's faster to skip the small step." | Process shortcuts pay back later as drift, missed criteria, or unrecorded decisions. The step is the point. |
23
+ | "I observed it pass; recording is bureaucracy." | Un-recorded pass = unproven. The next phase reads `evidence.md`, not your memory. |
24
+ | "User clearly wants this, so I'll bypass the gate." | Gates exist for the failure modes asks miss. Honor the gate; the gate exists *because* of the ask. |
25
+ | "The test is failing — I'll just skip it / loosen the assertion to get green." | Faking green is reward-hacking, not progress. Never delete / skip / `xfail` / `.only` / loosen a failing test — a red test means fix the code or agree the change. A weakened test is a Critical finding (`test-integrity.sh`). |
26
+
27
+ ## Pack-wide red flags
28
+
29
+ These show up at any phase and are equally damning regardless:
30
+
31
+ - Touching files that aren't in `touched-files.md` "while I'm here".
32
+ - A finding / decision / assumption recorded only in chat, not in the workspace files (it dies on `/clear`).
33
+ - Catching the broadest possible error and continuing past it.
34
+ - A test that asserts the implementation, not the behavior.
35
+ - A failing test deleted, skipped, `xfail`-ed, `.only`-narrowed, or loosened to make the suite pass.
36
+ - Commenting out code instead of deleting it.
37
+ - A `// TODO` left in shipped code.
38
+ - Adding a dependency or a second design system without rationale in `decisions.md`.
39
+ - "I'll fix it in a follow-up PR" with no follow-up actually opened.
40
+
41
+ ## Where this gets loaded
42
+
43
+ Each `rite-*/reference/anti-patterns.md` opens with a pointer back here
44
+ (written as a relative link in the form `../../../rules/anti-patterns.md`
45
+ from the per-phase reference file), then lists only the **phase-specific**
46
+ rationalizations + red flags that don't fit here. When the agent is
47
+ reluctant, it reads the phase file first, then this file if the reluctance
48
+ is broader than the phase.
@@ -0,0 +1,38 @@
1
+ # Code review
2
+
3
+ The reviewer's one question: **does this change make the codebase healthier** — clearer
4
+ design, cleaner logic, better tests, fewer risks? If not, it doesn't merge yet.
5
+
6
+ ## Keep changes small
7
+ - One concern per change (a fix, an endpoint, a refactor) — not three at once.
8
+ - Aim for small diffs: under ~200 lines reviews well and merges fast; treat ~400 as a
9
+ soft ceiling and self-split beyond it. Large diffs hide defects and get rubber-stamped.
10
+
11
+ ## What to check (tests first)
12
+ 1. **Tests** — do they exist and prove the behavior + failure modes (empty, error,
13
+ boundary, concurrency)? Would they fail if the code were wrong?
14
+ 2. **Correctness** — logic, edge cases, error paths, race conditions, wrong assumptions.
15
+ 3. **Readability** — names, function size, control flow, intent obvious without the author.
16
+ 4. **Architecture** — right seam, coupling/cohesion, fits existing patterns, no premature
17
+ abstraction. How does it fit the bigger system, not just what it does?
18
+ 5. **Security** — trust boundaries, input validation, authz, secrets.
19
+ 6. **Risk** — migrations, destructive changes, rollback.
20
+
21
+ ## Give actionable feedback
22
+ - Label severity so the author knows what blocks: **Critical / Important / Suggestion /
23
+ Nit / FYI**.
24
+ - Be specific: point at the line, name the problem, propose the fix. Frame non-blocking
25
+ ideas as questions ("what about a map here for readability?").
26
+ - Let automation (linters, formatters, CI) catch the trivial stuff so review focuses on
27
+ design and correctness.
28
+
29
+ ## Scope discipline
30
+ Review the change, not the whole project. Out-of-scope problems become follow-ups, not
31
+ drive-by edits that balloon the diff.
32
+
33
+ ## Charter & conventions are a pass/fail gate
34
+ The anti-slop charter and the project conventions ledger (`.devrites/conventions.md`) are not
35
+ advisory at review time — they are evaluated as explicit pass/fail at `/rite-vet` and re-checked
36
+ after design lands. A change that violates a stated convention or trips the charter is a
37
+ **Critical** finding, not a Nit; record it with `file:line` and block on it the same as any
38
+ correctness defect.
@@ -0,0 +1,55 @@
1
+ # Coding style
2
+
3
+ Write code the next engineer can read without you in the room. Match the project's
4
+ existing idiom first; these rules fill the gaps.
5
+
6
+ ## Names reveal intent
7
+ - A name should answer *what is this and why*. `daysSinceLastModification`, not `d`.
8
+ - Avoid generic verbs that hide intent: `process()`, `handle()`, `doWork()`, `manage()`.
9
+ - Be consistent: the same concept gets the same word across the codebase. Don't alias
10
+ `user` / `account` / `member` for one thing.
11
+
12
+ ## Functions do one thing
13
+ - One responsibility per function; if you need "and" to describe it, split it.
14
+ - Keep functions short enough to hold in your head. Long functions hide bugs.
15
+ - Limit parameters; a long parameter list usually wants a struct/object or a split.
16
+ - Make edge cases explicit rather than implicit in clever control flow.
17
+
18
+ ## Guard clauses over nested pyramids
19
+ Handle the unwanted cases up front and return early; keep the success path flat.
20
+ ```
21
+ # instead of nesting the whole body in if/else, exit early:
22
+ if (!user) return Unauthorized
23
+ if (!user.active) return Forbidden
24
+ # ...happy path here, un-nested
25
+ ```
26
+
27
+ ## Comments explain *why*, not *what*
28
+ - Self-explanatory code beats a comment restating it. Rename before you comment.
29
+ - Reserve comments for intent, trade-offs, non-obvious constraints, and "here be
30
+ dragons" warnings. Delete commented-out code — that's what version control is for.
31
+
32
+ ## Simplicity
33
+ - Prefer the simplest thing that works. Don't add abstraction before you have two real
34
+ callers; premature generalization is a cost, not a saving.
35
+ - Don't be clever at the expense of clear. Shorter-but-cryptic is not simpler.
36
+ - Delete dead code you created; don't leave TODOs or stray debug logs in shipped code.
37
+
38
+ ## Reuse before you write
39
+ Before adding a new util, helper, hook, type, component, or formatter, **search** for an
40
+ existing one. **Reuse → extend → build new**, in that order. Don't re-implement what the
41
+ project (or stdlib) already provides. If forcing reuse would distort the existing thing's
42
+ shape, build a sibling and consolidate later — duplication is cheaper than the wrong
43
+ abstraction (AHA).
44
+
45
+ ## Edit reliably, change only what's asked
46
+ - **No elision.** Never write `// ... rest unchanged` / `# ... existing code` in place of an
47
+ edit — emit the whole coherent function. Don't anchor an edit on line numbers; match on the
48
+ surrounding code. If an edit fails to apply, **re-read the file before retrying** — it may
49
+ have changed under you.
50
+ - **Do what's asked, no more — and no less.** Don't improve, comment, or refactor code unrelated
51
+ to the task while you're in the file (feature scope). And never leave a comment describing code
52
+ you didn't write — implement it.
53
+ - **Never hand-edit a manifest or lockfile.** Add / update / remove dependencies through the
54
+ package manager (`npm install`, `pip install`, `go get`, `cargo add`) so the lockfile stays
55
+ consistent — don't paste a version into `package.json` / `requirements.txt` by hand.
@@ -0,0 +1,97 @@
1
+ # Context hygiene
2
+
3
+ Long conversations degrade an agent's reasoning quality. The fix is operational, not
4
+ mystical: end phases cleanly, persist what matters to disk, and start the next phase
5
+ in a fresh context.
6
+
7
+ DevRites is uniquely well-suited to this because its workspace
8
+ (`.devrites/work/<slug>/`) already stores everything the next session needs —
9
+ `spec.md`, `plan.md`, `tasks.md`, `state.md`, `decisions.md`, `evidence.md`,
10
+ `questions.md`, `assumptions.md`, `drift.md`, `touched-files.md`, `review.md`. None
11
+ of those live in chat memory.
12
+
13
+ ## Why long contexts hurt (research-backed)
14
+
15
+ - **Lost-in-the-middle** (Liu et al. 2023). Models attend strongly to the start and
16
+ end of their context and **systematically under-attend the middle**. Performance
17
+ drops by ~30% on retrieval and reasoning tasks when load-bearing information shifts
18
+ from the edges to the centre.
19
+ - **Context rot.** Even on simple tasks, accuracy degrades as input length grows. The
20
+ effect compounds for agent workflows: every tool call, file read, and failed attempt
21
+ pushes earlier load-bearing context toward the middle of the window.
22
+ - **Failed-attempt amplification.** When an agentic task goes wrong and is corrected
23
+ in the same session, the failed attempt stays in context — doubling the token cost
24
+ and dragging the model toward the same kinds of mistake.
25
+ - **The 50–70% threshold.** Published Claude Code guidance + community evidence
26
+ consistently land at the same number: **act on context at 50–70% used, not 95%.**
27
+ By 95% the model is already operating in the dump-zone.
28
+
29
+ The summary the model can carry is *not* a substitute for the workspace; the workspace
30
+ is the source of truth.
31
+
32
+ **Compaction-preservation directive.** When the harness summarizes or compacts mid-feature,
33
+ always preserve these four — they are the cursor, and losing them to a summary forces the next
34
+ agent to re-derive state the workspace already holds: the `.devrites/ACTIVE` slug, `state.md`'s
35
+ `Next step`, every open `questions.md` gate, and `decisions.md`'s `Dead ends`. (The SessionStart
36
+ orientation and the UserPromptSubmit cursor re-inject this each session and turn; this directive
37
+ is the fallback for involuntary mid-session compaction, where no hook fires.)
38
+
39
+ ## `/clear` vs `/compact`
40
+
41
+ | Use `/clear` (default) when | Use `/compact` when |
42
+ |---|---|
43
+ | The current phase is done and its outputs are on disk (the common DevRites case). | You need to keep mid-flight reasoning that hasn't yet been written to the workspace. |
44
+ | Next phase reads workspace files anyway (every `rite-*` does). | The remaining work is small and continuation beats restart. |
45
+ | The chat is dominated by tool outputs (file reads, diffs, test logs, browser snapshots). | A drift or doubt loop is mid-flight and the trade-off discussion isn't yet recorded. |
46
+ | You hit a wrong path that needs unwinding — fresh start beats arguing with stale context. | A user clarification just landed that materially changes the next phase. |
47
+
48
+ **Default to `/clear`.** Reach for `/compact` only when continuity has real load-bearing
49
+ value that the workspace doesn't capture. When in doubt, write the missing decision /
50
+ assumption / question to the canonical file (`/rite-handoff` does this in one step),
51
+ then `/clear`.
52
+
53
+ ## Phase-aware recommendation (DevRites lifecycle)
54
+
55
+ | Phase | Typical context cost | After-phase recommendation |
56
+ |---|---|---|
57
+ | `/rite-spec` | HIGH — reads codebase, references, design assets. | **Strong `/clear`.** `spec.md`, `references/`, `decisions.md`, `assumptions.md`, `questions.md`, `brief.md` all captured. |
58
+ | `/rite-define` | MED — reads spec + decides architecture. | **`/clear`.** `plan.md`, `tasks.md`, `decisions.md`, `state.md` captured. |
59
+ | `/rite-plan` | MED — reshape / repair. | **`/clear`** if reshape was big; **keep** if only a small reorder. |
60
+ | `/rite-build` | HIGH — reads files, writes code + tests, runs checks, often retries. | **Strong `/clear` between slices.** `state.md` cursor, `touched-files.md`, `evidence.md` carry the cursor forward. |
61
+ | `/rite-prove` | HIGH — full test suite output, build logs, browser snapshots. | **Strong `/clear`.** `evidence.md`, `browser-evidence.md` captured. |
62
+ | `/rite-polish` | MED-HIGH — diffs + design-system reads + per-target polish. | **`/clear` between targets.** `polish-report.md`, `browser-evidence.md` captured. |
63
+ | `/rite-review` | HIGH — diff + parallel sub-agent reports + multi-axis review. | **`/compact`** if Criticals must be fixed in flow (review context informs the fix); **`/clear`** if review is clean. `review.md` captured. |
64
+ | `/rite-seal` | MED — read-only fan-out + GO/NO-GO. | Usually session-end. **`/clear` after a GO**; `/compact` if NO-GO and the seal's findings drive immediate fixes. |
65
+ | `/rite-status` | LOW (read-only). | **No recommendation** — cheap. |
66
+ | `/rite` (menu) | LOW. | **No recommendation.** |
67
+
68
+ ## The "Session hygiene" footer (every rite-* output)
69
+
70
+ Every `rite-*` skill ends its output with a one-line **Session hygiene** advisory, plus
71
+ the **single command** that resumes work next session:
72
+
73
+ ```
74
+ Session hygiene: /clear (recommended) — <one-line why, anchored to what just got persisted>
75
+ Resume next session with: <single command, e.g. /rite-build slice 2>
76
+ ```
77
+
78
+ The advisory is advisory, not a gate. The user can ignore it. But it surfaces the
79
+ trade-off the model itself can't reliably introspect (no API for "how full is my
80
+ context") at the exact moment the next decision is cheap.
81
+
82
+ ## When NOT to recommend `/clear` or `/compact`
83
+
84
+ - The current phase is read-only and cheap (`/rite-status`, `/rite` menu) — no
85
+ recommendation; let the user keep their flow.
86
+ - The user just landed material clarification that changes the next phase — write the
87
+ clarification to the workspace (`decisions.md` / `assumptions.md`) before suggesting
88
+ any session reset, otherwise the clarification dies in chat.
89
+ - A drift / doubt loop is mid-flight — finish the loop and record the verdict first.
90
+
91
+ ## The handoff bridge
92
+
93
+ When the user is leaving for a long break (not just between phases), `/rite-handoff`
94
+ is the stronger move than `/clear` alone: it syncs chat-only context into the canonical
95
+ workspace files **before** the reset, then the user can `/clear` (or even close the
96
+ session) without losing anything. The session-hygiene footer points at `/rite-handoff`
97
+ when the gap to the next session is likely > a few hours.