@nurix/etna 0.18.9 → 0.18.11

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 (108) hide show
  1. package/README.md +6 -5
  2. package/bin/etna.js +35 -0
  3. package/data/harness-index.json +9 -1
  4. package/data/harnesses/code/CLAUDE.md +8 -9
  5. package/data/harnesses/code/agents/change-review.md +1 -1
  6. package/data/harnesses/code/agents/harness-manager.md +15 -12
  7. package/data/harnesses/code/agents/maintenance.md +12 -12
  8. package/data/harnesses/code/agents/spec-mode.md +3 -3
  9. package/data/harnesses/code/harness.json +2 -2
  10. package/data/harnesses/code/skills/distiller/references/docs-mode.md +7 -7
  11. package/data/harnesses/code/skills/documentation/SKILL.md +25 -31
  12. package/data/harnesses/code/skills/documentation/references/templates.md +61 -24
  13. package/data/harnesses/etna/.prettierignore +12 -0
  14. package/data/harnesses/etna/.prettierrc.json +3 -0
  15. package/data/harnesses/etna/.vscode/settings.json +10 -0
  16. package/data/harnesses/etna/CLAUDE.md +160 -0
  17. package/data/harnesses/etna/agents/brainstorm.md +35 -0
  18. package/data/harnesses/etna/agents/change-review.md +251 -0
  19. package/data/harnesses/etna/agents/harness-manager.md +184 -0
  20. package/data/harnesses/etna/agents/maintenance.md +122 -0
  21. package/data/harnesses/etna/agents/performance-review.md +223 -0
  22. package/data/harnesses/etna/agents/spec-mode.md +56 -0
  23. package/data/harnesses/etna/harness.json +11 -0
  24. package/data/harnesses/etna/hooks/hooks.json +27 -0
  25. package/data/harnesses/etna/hooks/lib/redact.mjs +35 -0
  26. package/data/harnesses/etna/hooks/prompt-recall.mjs +155 -0
  27. package/data/harnesses/etna/hooks/session-reflect.mjs +285 -0
  28. package/data/harnesses/etna/rules/general.md +86 -0
  29. package/data/harnesses/etna/rules/kb.md +13 -0
  30. package/data/harnesses/etna/rules/nomenclature.md +41 -0
  31. package/data/harnesses/etna/skills/boundary/SKILL.md +49 -0
  32. package/data/harnesses/etna/skills/boundary/references/boundary-taxonomy.md +796 -0
  33. package/data/harnesses/etna/skills/brainstorm/README.md +136 -0
  34. package/data/harnesses/etna/skills/brainstorm/SKILL.md +135 -0
  35. package/data/harnesses/etna/skills/brainstorm/harvest.md +26 -0
  36. package/data/harnesses/etna/skills/brainstorm/templates/backlog.md +39 -0
  37. package/data/harnesses/etna/skills/brainstorm/templates/build.md +37 -0
  38. package/data/harnesses/etna/skills/brainstorm/templates/decisions.md +29 -0
  39. package/data/harnesses/etna/skills/brainstorm/templates/doctrine.md +31 -0
  40. package/data/harnesses/etna/skills/brainstorm/templates/domain-model.md +25 -0
  41. package/data/harnesses/etna/skills/brainstorm/templates/glossary.md +20 -0
  42. package/data/harnesses/etna/skills/brainstorm/templates/milestones.md +43 -0
  43. package/data/harnesses/etna/skills/brainstorm/templates/non-goals.md +17 -0
  44. package/data/harnesses/etna/skills/brainstorm/templates/plan-doc.md +61 -0
  45. package/data/harnesses/etna/skills/brainstorm/templates/questions.md +36 -0
  46. package/data/harnesses/etna/skills/brainstorm/templates/references.md +28 -0
  47. package/data/harnesses/etna/skills/brainstorm/templates/rejected.md +29 -0
  48. package/data/harnesses/etna/skills/brainstorm/templates/state.md +1 -0
  49. package/data/harnesses/etna/skills/brainstorm/templates/tech.md +23 -0
  50. package/data/harnesses/etna/skills/brainstorm/templates/thesis.md +21 -0
  51. package/data/harnesses/etna/skills/distiller/SKILL.md +90 -0
  52. package/data/harnesses/etna/skills/distiller/references/docs-mode.md +299 -0
  53. package/data/harnesses/etna/skills/distiller/references/method.md +94 -0
  54. package/data/harnesses/etna/skills/documentation/SKILL.md +124 -0
  55. package/data/harnesses/etna/skills/documentation/references/examples.md +162 -0
  56. package/data/harnesses/etna/skills/documentation/references/style-guide.md +308 -0
  57. package/data/harnesses/etna/skills/documentation/references/templates.md +894 -0
  58. package/data/harnesses/etna/skills/workflow-mapper/SKILL.md +451 -0
  59. package/data/harnesses/etna/skills/workflow-mapper/references/patterns.md +214 -0
  60. package/data/harnesses/mobile/.prettierignore +12 -0
  61. package/data/harnesses/mobile/.prettierrc.json +3 -0
  62. package/data/harnesses/mobile/.vscode/settings.json +10 -0
  63. package/data/harnesses/mobile/CLAUDE.md +129 -0
  64. package/data/harnesses/mobile/agents/brainstorm.md +35 -0
  65. package/data/harnesses/mobile/agents/change-review.md +251 -0
  66. package/data/harnesses/mobile/agents/harness-manager.md +184 -0
  67. package/data/harnesses/mobile/agents/maintenance.md +122 -0
  68. package/data/harnesses/mobile/agents/performance-review.md +223 -0
  69. package/data/harnesses/mobile/agents/spec-mode.md +56 -0
  70. package/data/harnesses/mobile/harness.json +11 -0
  71. package/data/harnesses/mobile/hooks/hooks.json +27 -0
  72. package/data/harnesses/mobile/hooks/lib/redact.mjs +35 -0
  73. package/data/harnesses/mobile/hooks/prompt-recall.mjs +155 -0
  74. package/data/harnesses/mobile/hooks/session-reflect.mjs +285 -0
  75. package/data/harnesses/mobile/rules/general.md +86 -0
  76. package/data/harnesses/mobile/rules/nomenclature.md +41 -0
  77. package/data/harnesses/mobile/rules/react-native.md +132 -0
  78. package/data/harnesses/mobile/rules/typescript.md +40 -0
  79. package/data/harnesses/mobile/skills/boundary/SKILL.md +49 -0
  80. package/data/harnesses/mobile/skills/boundary/references/boundary-taxonomy.md +796 -0
  81. package/data/harnesses/mobile/skills/brainstorm/README.md +136 -0
  82. package/data/harnesses/mobile/skills/brainstorm/SKILL.md +135 -0
  83. package/data/harnesses/mobile/skills/brainstorm/harvest.md +26 -0
  84. package/data/harnesses/mobile/skills/brainstorm/templates/backlog.md +39 -0
  85. package/data/harnesses/mobile/skills/brainstorm/templates/build.md +37 -0
  86. package/data/harnesses/mobile/skills/brainstorm/templates/decisions.md +29 -0
  87. package/data/harnesses/mobile/skills/brainstorm/templates/doctrine.md +31 -0
  88. package/data/harnesses/mobile/skills/brainstorm/templates/domain-model.md +25 -0
  89. package/data/harnesses/mobile/skills/brainstorm/templates/glossary.md +20 -0
  90. package/data/harnesses/mobile/skills/brainstorm/templates/milestones.md +43 -0
  91. package/data/harnesses/mobile/skills/brainstorm/templates/non-goals.md +17 -0
  92. package/data/harnesses/mobile/skills/brainstorm/templates/plan-doc.md +61 -0
  93. package/data/harnesses/mobile/skills/brainstorm/templates/questions.md +36 -0
  94. package/data/harnesses/mobile/skills/brainstorm/templates/references.md +28 -0
  95. package/data/harnesses/mobile/skills/brainstorm/templates/rejected.md +29 -0
  96. package/data/harnesses/mobile/skills/brainstorm/templates/state.md +1 -0
  97. package/data/harnesses/mobile/skills/brainstorm/templates/tech.md +23 -0
  98. package/data/harnesses/mobile/skills/brainstorm/templates/thesis.md +21 -0
  99. package/data/harnesses/mobile/skills/distiller/SKILL.md +90 -0
  100. package/data/harnesses/mobile/skills/distiller/references/docs-mode.md +299 -0
  101. package/data/harnesses/mobile/skills/distiller/references/method.md +94 -0
  102. package/data/harnesses/mobile/skills/documentation/SKILL.md +124 -0
  103. package/data/harnesses/mobile/skills/documentation/references/examples.md +162 -0
  104. package/data/harnesses/mobile/skills/documentation/references/style-guide.md +308 -0
  105. package/data/harnesses/mobile/skills/documentation/references/templates.md +894 -0
  106. package/data/harnesses/mobile/skills/workflow-mapper/SKILL.md +451 -0
  107. package/data/harnesses/mobile/skills/workflow-mapper/references/patterns.md +214 -0
  108. package/package.json +1 -1
@@ -0,0 +1,894 @@
1
+ # Documentation Templates
2
+
3
+ Templates for all documentation needs.
4
+
5
+ ---
6
+
7
+ ## 1. docs/README.md (Documentation Root)
8
+
9
+ Use for: the entry point for all documentation in a repo. Created during baseline audit.
10
+
11
+ ```
12
+ # {Project Name} Documentation
13
+
14
+ Technical documentation for {project description}.
15
+
16
+ > For documentation organization, authority map, and folder rules, see **[structure.md](structure.md)**.
17
+
18
+ ---
19
+
20
+ ## Quick Links
21
+
22
+ | Document | Description |
23
+ | --------------------------------- | ------------------------------------ |
24
+ | [Structure](structure.md) | Documentation entry point and rules |
25
+ | [Setup](operations/setup.md) | Installation and configuration guide |
26
+
27
+ ---
28
+
29
+ ## Architecture
30
+
31
+ System design, patterns, and technical decisions.
32
+
33
+ - [system-design.md](architecture/system-design.md) - High-level system architecture
34
+ {list all architecture docs}
35
+
36
+ ---
37
+
38
+ ## Features
39
+
40
+ Living reference docs for implemented features (how things currently work).
41
+
42
+ - [feature-name.md](features/feature-name.md) - Feature description
43
+ {list all feature docs}
44
+
45
+ ---
46
+
47
+ ## Operations
48
+
49
+ How to run, develop, and deploy.
50
+
51
+ - [setup.md](operations/setup.md) - Installation and configuration guide
52
+ {list all operations docs}
53
+
54
+ ---
55
+
56
+ ## History
57
+
58
+ Everything frozen or append-only.
59
+
60
+ - [CHANGELOG.md](history/CHANGELOG.md) - Master changelog index
61
+ - [changelog/](history/changelog/) - Individual changelog entries
62
+ - [plans/](history/plans/) - Historical implementation plans
63
+ - [research/](history/research/) - Deep-research artifacts (one folder per topic)
64
+ - [backlog.md](history/backlog.md) - Tracked work items and technical debt
65
+
66
+ ---
67
+
68
+ ## Contributing
69
+
70
+ See [CLAUDE.md](../CLAUDE.md) for documentation guidelines.
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 2. docs/structure.md (Authority Map)
76
+
77
+ Use for: defining which folder owns which topic and how docs are maintained.
78
+
79
+ ```
80
+ ---
81
+ harness-version: 1.0.0
82
+ ---
83
+
84
+ # Documentation Structure
85
+
86
+ > This file is the entry point for understanding the docs folder.
87
+ > `harness-version` above is the repo's single baseline/version sentinel — the `harness-manager` agent owns it and stamps the installed harness version (semver) on every reconcile.
88
+
89
+ ## Authority Map
90
+
91
+ Each topic has one canonical location. Read from here, not from plans or changelogs.
92
+
93
+ | Topic | Authority | Key Files |
94
+ | ----- | --------- | --------- |
95
+ | Code-path ownership (path → doc + module) | `docs/routing.md` | File-Pattern Routes |
96
+ | System architecture + steering | `docs/architecture/` | domain-model, glossary, non-goals, references, adr/ |
97
+ | Feature behavior | `docs/features/` (or `docs/modules/{m}/features/`) | {key files} |
98
+ | Declared modules (bounded contexts) | `docs/modules/{m}/` | `features/` + `pillars/` |
99
+ | Setup & development | `docs/operations/` | {key files} |
100
+ | Historical plans | `docs/history/plans/` | YYYY-MM-DD-name.md |
101
+ | Change records | `docs/history/changelog/` | Individual entries |
102
+ | Deep-research artifacts | `docs/history/research/{topic}/` | README.md + findings.md + sources.md |
103
+ | Backlog | `docs/history/` | backlog.md |
104
+
105
+ ## Document Lifecycle
106
+
107
+ Plan (Status: Draft) → Implementation → Feature Doc or Architecture Update → Changelog Entry
108
+
109
+ - Plans freeze at completion — never updated to reflect current code
110
+ - Changelogs summarize + link to feature docs — no duplicated schemas
111
+ - Feature docs are the living reference — updated when code changes
112
+
113
+ ## Folder Rules
114
+
115
+ - `docs/routing.md`: The single hand-maintained map from code paths (and keywords) to the canonical doc and module for each. Code ownership lives here, not in feature-doc frontmatter. Update it whenever you add/move/delete a doc or move/rename owned source.
116
+ - `docs/features/`: Living reference for implemented features. Carry **no** ownership frontmatter — a feature doc's code paths are declared by its row(s) in `docs/routing.md`. (An optional `anchors:` block — a qmd drift tripwire, see §3 — is the only frontmatter a doc may carry.)
117
+ - `docs/architecture/`: System-wide patterns and the cross-module steering layer (domain model, glossary, non-goals, references, ADRs). Update when cross-cutting concerns change.
118
+ - `docs/modules/{m}/`: Vertical bounded contexts, **declared** (not inferred from layout) and tied to code by their `docs/routing.md` patterns (the Module column groups routes into modules). Each owns `features/` + module-local `pillars/` (doctrine, lazy). There is no repo-wide `docs/pillars/`. Worth declaring at ≥2 genuine bounded contexts; a single-context app stays flat under `docs/features/`.
119
+ - `docs/operations/`: How-to procedures for setup, development, and deployment. Update when workflows change.
120
+ - `docs/history/plans/`: Historical. Must have `Status:` field. Never modify after completion.
121
+ - `docs/history/changelog/`: Historical. Append-only.
122
+ - `docs/history/research/{topic}/`: Deep-research artifacts — the dumped output of a research pass, one folder per topic (conventionally `README.md` synthesis + `findings.md` verified claims & citations + `sources.md`). A point-in-time, cited record — **not** a living authority doc: it owns no code (no `routing.md` row, no frontmatter) and is never edited to "stay current." A spec/plan links to it for grounding; a new question gets a new topic folder.
123
+ - `docs/history/backlog.md`: Tracked work items. Append new items under appropriate priority.
124
+
125
+ ## Health Log
126
+
127
+ <!-- Updated by maintenance agent -->
128
+ | Date | Review Summary |
129
+ | ---- | -------------- |
130
+ | {today} | Initial baseline — v{harness-version} structure established |
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 2.5 docs/routing.md (Code-Path Ownership Map)
136
+
137
+ Use for: the single hand-maintained map from code paths (and keywords) to the canonical doc + module. This is the source of truth for code ownership — feature docs carry no ownership frontmatter. Scaffold it once any feature doc owns code.
138
+
139
+ ```
140
+ # Routing
141
+
142
+ The single map from code paths (and keywords) to the doc that is canonical for them, and the module each belongs to. The source of truth for code-path ownership — feature docs carry no ownership frontmatter. Read this before touching unfamiliar code, then read the mapped doc.
143
+
144
+ > **One canonical doc per path.** When two patterns match the same path, the **narrower** pattern wins; an equal-specificity overlap is a conflict — resolve it before merging. Hand-maintained — there is no generator. Keep it in sync when you add/move/delete a doc or move/rename owned source.
145
+
146
+ ## File-Pattern Routes
147
+
148
+ | Pattern | Module | Canonical Doc | Memory |
149
+ | ------- | ------ | ------------- | ------ |
150
+ | `src/auth/**` | auth | features/login.md | memory/main.md |
151
+ | `src/billing/**` | billing | modules/billing/features/invoicing.md | — |
152
+
153
+ - **Pattern** — the narrowest glob covering the files the doc is canonical for. A doc may have several rows.
154
+ - **Module** — the declared module the pattern belongs to, or `—` if the repo is flat (no module declared). Grouping rows by this column is how a module is tied to code.
155
+ - **Canonical Doc** — the one doc to read before changing matching files (`features/…` when flat, `modules/{m}/features/…` when the module is declared).
156
+ - **Memory** — the `docs/memory/` file with domain knowledge for this area, or `—`.
157
+
158
+ ## Keyword Routes
159
+
160
+ | Keyword / topic | Canonical Doc |
161
+ | --------------- | ------------- |
162
+ | auth, login, SSO, refresh | features/login.md |
163
+
164
+ ## Top-Level Folders
165
+
166
+ | Folder | Purpose | Doc |
167
+ | ------ | ------- | --- |
168
+ | `src/` | {what lives here} | {doc} |
169
+
170
+ ## How to Add a Route
171
+
172
+ 1. Add/extend a **File-Pattern Routes** row — narrowest pattern that doesn't overlap an existing row at equal specificity; set its Module (or `—`).
173
+ 2. Add keyword row(s) for discoverability.
174
+ 3. When you move/rename owned source, update the matching pattern(s) here — this map is hand-maintained.
175
+ ```
176
+
177
+ ---
178
+
179
+ ## 3. Code-Path Ownership & Anchors
180
+
181
+ **Ownership.** A feature doc is the canonical reference for the code paths mapped to it in `docs/routing.md` (File-Pattern Routes). Feature docs declare ownership through their routing row(s), **not** through frontmatter. To find what a doc owns, read its rows in `routing.md`; to find the doc for a path, match the path against the patterns there (narrower wins). See the **routing-map derivation** in `SKILL.md` for turning code into routing rows.
182
+
183
+ **Anchors (optional — the only frontmatter a living doc may carry).** A doc may carry an `anchors:` block — a qmd drift tripwire, orthogonal to ownership:
184
+
185
+ ```yaml
186
+ ---
187
+ anchors:
188
+ - "qmd query: feature-name persistence shape"
189
+ ---
190
+ ```
191
+
192
+ `anchors` is a list of qmd queries (or `#docid`s) that re-resolve to the code/facts this doc abstracts as they move; anchors are retrieval context plus a drift tripwire, never a contract — an anchor that returns nothing IS the drift signal, nothing auto-rewrites from an anchor result, and the doc's prose stays the human-owned abstraction. They detect **doc-area drift** (the subject moving or vanishing from the corpus), not a pure code rename — the query also matches the doc's own prose, so a rename that leaves the text unchanged won't shift the result; code-symbol drift is the maintenance named-referent check's job, and anchors complement it rather than replace it. Resolved via `qmd query --format json -c <collection>` against this repo's collections; absent qmd ⇒ anchors are inert (no error). Never required on any doc. `anchors:` may appear on any living doc the maintenance anchor-drift check globs — `docs/features/`, `docs/architecture/`, and `docs/operations/`.
193
+
194
+ ---
195
+
196
+ ## 4. Scaffold Files (create if missing)
197
+
198
+ These standard files must exist after every baseline. Create them with these scaffolds if the repo doesn't already have them.
199
+
200
+ ### docs/history/CHANGELOG.md
201
+
202
+ ```
203
+ # Changelog
204
+
205
+ All notable changes to {Project Name} will be documented in this file.
206
+
207
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
208
+
209
+ ---
210
+
211
+ ## [Unreleased]
212
+
213
+ {entries added here as work proceeds}
214
+
215
+ ---
216
+
217
+ ## Links
218
+
219
+ - [Setup Guide](../operations/setup.md)
220
+ - [Architecture](../architecture/)
221
+
222
+ ---
223
+
224
+ ## How to Update This Changelog
225
+
226
+ 1. Create a dated change file in `docs/history/changelog/`:
227
+ `docs/history/changelog/YYYY-MM-DD-feature-name.md`
228
+
229
+ 2. Update this CHANGELOG.md with a high-level summary linking to the detail file
230
+
231
+ 3. Follow Keep a Changelog categories:
232
+ - **Added** for new features
233
+ - **Changed** for changes in existing functionality
234
+ - **Deprecated** for soon-to-be removed features
235
+ - **Removed** for now removed features
236
+ - **Fixed** for bug fixes
237
+ - **Security** for security improvements
238
+ ```
239
+
240
+ ### docs/history/backlog.md
241
+
242
+ ```
243
+ # Backlog
244
+
245
+ Tracked work items, technical debt, and planned improvements. Append new items under the appropriate priority.
246
+
247
+ ---
248
+
249
+ ## Format
250
+
251
+ - **[P0]** Description — discovered by [plan-name or agent-name]
252
+
253
+ ---
254
+
255
+ ## P0 — Critical
256
+
257
+ {items here}
258
+
259
+ ## P1 — High
260
+
261
+ {items here}
262
+
263
+ ## P2 — Medium
264
+
265
+ {items here}
266
+
267
+ ## P3 — Low
268
+
269
+ {items here}
270
+ ```
271
+
272
+ ### docs/memory/index.md
273
+
274
+ ```
275
+ ---
276
+ type: cross-session-learnings
277
+ description: Shared knowledge accumulated across agent sessions. All agents should consult and update this file.
278
+ ---
279
+
280
+ # Cross-Session Learnings
281
+
282
+ ## Documentation Baseline
283
+
284
+ - **Baselined:** {today}
285
+ - **Structure:** v{harness-version} (architecture, features, operations, history, memory; + modules/, tests/ when present)
286
+ - **Spec version:** v{harness-version}
287
+ <!-- v{harness-version} resolves to the installed harness version — read it from `.claude/harness.json` (`version`) / `docs/structure.md` frontmatter (`harness-version`); never hardcode a literal version here. -->
288
+
289
+ ## Knowledge Tiers
290
+
291
+ Memory is a gradient — volume falls, signal rises, one hop down each tier. Tiers describe themselves here even before they fill:
292
+
293
+ - **Inbox** (`docs/memory/inbox/`) — per-actor queue of session lessons, written by the `session-reflect` hook at session end and consumed by the distiller on digestion. Transient by design, rarely read directly.
294
+ - **Fact-cards** (`docs/memory/facts/`) — distilled, provenance-linked atomic facts, written by the distiller (`facts` mode) from inbox entries and resurfaced at prompt time by the `prompt-recall` hook.
295
+ - **This index** — the curated read tier: the learnings list below, distilled from the colder tiers and hand-appended.
296
+
297
+ ## Learnings
298
+
299
+ {Agents append learnings here as they discover gotchas, patterns, and architecture notes}
300
+ ```
301
+
302
+ ### docs/memory/main.md
303
+
304
+ ```
305
+ ---
306
+ type: project-memory
307
+ owner: main-agent
308
+ description: Project-wide patterns and conventions confirmed in this codebase. Project facts only — user-centric facts go in ~/.claude/.
309
+ ---
310
+
311
+ # Main Agent — Project Memory
312
+
313
+ Append entries below, oldest at bottom. Format:
314
+
315
+ ## YYYY-MM-DD — {topic}
316
+
317
+ {1-3 line fact, with file paths or references where relevant}
318
+
319
+ ---
320
+
321
+ ## {today} — Baseline
322
+
323
+ Memory file initialized during documentation baseline.
324
+ ```
325
+
326
+ > The per-actor memory **inbox** (`docs/memory/inbox/`) is _not_ a baseline scaffold — the `session-reflect` hook creates it mechanically on the first reflected session. See **§11 Memory inbox entry** for its format.
327
+
328
+ ---
329
+
330
+ ## 5. Feature Documentation (docs/features/{feature}.md)
331
+
332
+ Use for: every feature in `docs/features/`. The same file persists from design (Status: Draft) through implementation to live reference (Status: Active). Sections fill in as the feature matures — no template swap.
333
+
334
+ The four research-derived sections (**Affected Modules**, **Conventions to Follow**, **Current Behavior**, **Ownership Conflicts**) map 1:1 to spec-mode's return shape. The orchestrator drops spec-mode's findings into those slots without restructuring.
335
+
336
+ ```yaml
337
+ ---
338
+ anchors: # optional — the only frontmatter a feature doc may carry; see §3
339
+ - "qmd query: wire envelope invariants"
340
+ ---
341
+ ```
342
+
343
+ > This doc carries **no** ownership frontmatter. Declare the code paths it owns as File-Pattern Routes row(s) in `docs/routing.md` (§2.5) — projected at Draft, confirmed at Active.
344
+
345
+ ```
346
+ # {Feature Name}
347
+
348
+ **Status:** Draft | Active <!-- Draft: in design or in flight. Active: implemented and maintained. -->
349
+ **Plan:** [history/plans/YYYY-MM-DD-feature-name.md](../history/plans/YYYY-MM-DD-feature-name.md) <!-- added once a plan exists -->
350
+
351
+ ## Goal
352
+
353
+ One sentence. What this feature accomplishes, in user-facing terms.
354
+
355
+ ## Goals & Non-Goals
356
+
357
+ **In scope**
358
+ - Bullet 1
359
+ - Bullet 2
360
+
361
+ **Out of scope**
362
+ - Bullet 1
363
+
364
+ ## Background
365
+
366
+ Why this feature exists. The user need, the business trigger, the constraint that pushed it above the line. One paragraph.
367
+
368
+ (For Product-level work, also include: problem statement, key hypotheses, open questions.)
369
+
370
+ ## Approach
371
+
372
+ High-level shape of the solution. ASCII diagram if it helps. Implementation specifics belong in the plan.
373
+
374
+ ## Affected Modules
375
+
376
+ (From spec-mode research) Files, routes, components, slices this feature involves. Group by module.
377
+
378
+ | Module | Path | Role in this feature |
379
+ |--------|------|----------------------|
380
+
381
+ ## Conventions to Follow
382
+
383
+ (From spec-mode research) Naming patterns, structural patterns, doc-fit heuristics confirmed for the area being touched. Cite the source file(s) where the convention is established.
384
+
385
+ ## Current Behavior
386
+
387
+ (From spec-mode research) How the relevant part of the system works *today*, before this feature lands. Without this baseline the design intent is hard to evaluate.
388
+
389
+ ## Ownership Conflicts
390
+
391
+ (From spec-mode research) Existing feature docs whose `docs/routing.md` patterns overlap with the projected scope. Resolve per row before the plan starts — leave nothing unresolved.
392
+
393
+ | Conflicting doc | Overlapping path(s) | Resolution |
394
+ |-----------------|---------------------|------------|
395
+
396
+ ## Architecture
397
+
398
+ [ASCII diagram. Fill once implementation lands. See style-guide.md for box-drawing patterns.]
399
+
400
+ ## Key Functions
401
+
402
+ ### `functionName(param1, param2)`
403
+ **Goal:** What it accomplishes
404
+ **Input:**
405
+ - `param1` (type) - Description
406
+ - `param2` (type) - Description
407
+ **Output:** Return type and shape
408
+ **Side Effects:** DB writes, API calls, state updates
409
+
410
+ ### `hookName(config)`
411
+ **Goal:** What it provides
412
+ **Returns:** `{ data, loading, error }`
413
+ **Triggers:** On mount, on change, manual
414
+
415
+ ## State
416
+
417
+ **Frontend (at persistence):**
418
+ {
419
+ "data": [],
420
+ "changes": { "added": [], "updated": [], "removed": [] }
421
+ // "cache": {} // UNUSED: Deprecated
422
+ }
423
+
424
+ **Storage:** localStorage `app_state`
425
+
426
+ **Backend:**
427
+ model Resource {
428
+ id String @id
429
+ data Json
430
+ // oldField String? // UNUSED: Legacy
431
+ }
432
+
433
+ **API Shape:**
434
+ { "status": 1, "data": {...} }
435
+
436
+ ## Redux (if applicable)
437
+
438
+ **Slice:** `sliceName`
439
+
440
+ **Actions:**
441
+ - `setData(payload)` - Replace all data
442
+ - `upsertItem(item)` - Add or update single item
443
+
444
+ **Selectors:**
445
+ - `selectAll(state)` → `Array<Item>`
446
+ - `selectById(state, id)` → `Item | undefined`
447
+
448
+ ## Files
449
+
450
+ - `src/path/to/main.js` - Core logic
451
+ - `src/path/to/hooks.js` - React hooks
452
+
453
+ ## Open Questions
454
+
455
+ - Question — who decides, by when
456
+ - (Resolved questions: fold the resolution into Background.)
457
+
458
+ ## Risks
459
+
460
+ - Risk — likelihood / impact / mitigation
461
+ ```
462
+
463
+ ### Section evolution
464
+
465
+ Sections fill in across the feature's lifecycle. No template swap — they accumulate in place.
466
+
467
+ | When | Sections written | Source |
468
+ | --- | --- | --- |
469
+ | Status: Draft (design) | Goal, Goals & Non-Goals, Background, Approach, Open Questions, Risks | User interview |
470
+ | Status: Draft (research) | Affected Modules, Conventions to Follow, Current Behavior, Ownership Conflicts | spec-mode agent |
471
+ | Status: Draft → Active (implementation lands) | Architecture, Key Functions, State, Redux, Files; `docs/routing.md` row(s) confirmed against real code | Main agent (from actual code) |
472
+
473
+ Resolved Open Questions can be summarized into Background; unresolved ones stay visible.
474
+
475
+ ---
476
+
477
+ ## 6. Changelog
478
+
479
+ Use for: recording code changes with function-level detail.
480
+
481
+ ```
482
+ # YYYY-MM-DD - [Title]
483
+
484
+ ## Summary
485
+
486
+ Brief description of what changed and why.
487
+
488
+ ## Changes
489
+
490
+ ### Added
491
+ - `newFunction(params)` in `path/to/file.js`
492
+ - Purpose: What it does
493
+ - Used by: Where it's called
494
+
495
+ ### Modified
496
+ - `existingFunction()` in `path/to/file.js`
497
+ - Changed: What's different
498
+ - Reason: Why it changed
499
+ - Migration: What callers must do
500
+
501
+ ### Removed
502
+ - `oldFunction()` from `path/to/file.js`
503
+ - Replaced by: `newFunction()`
504
+
505
+ ## Breaking Changes
506
+
507
+ ⚠️ **[Change description]**
508
+ - Old: Previous behavior
509
+ - New: Current behavior
510
+ - Impact: What breaks
511
+ - Migration: How to fix
512
+
513
+ ## Migration Steps
514
+
515
+ - [ ] Step 1
516
+ - [ ] Step 2
517
+
518
+ ## Files Changed
519
+
520
+ - `src/path/file1.js` - Core changes
521
+ - `src/path/file2.js` - Supporting updates
522
+ ```
523
+
524
+ ---
525
+
526
+ ## 7. Plan (docs/history/plans/YYYY-MM-DD-feature-name.md)
527
+
528
+ Use for: every implementation plan. Plans are created here directly with `Status: Draft`, flip to `Status: In Progress` when work starts, and freeze at `Status: Complete` or `Status: Abandoned`. Once frozen, never edit — write a new dated plan if scope changes.
529
+
530
+ The `boundary` skill parses the **Proposed Changes** sections to check boundary impact before execution. Keep that structure stable — section headings and bullet shape are load-bearing for the parser.
531
+
532
+ ```
533
+ # {Feature Name}
534
+
535
+ **Status:** Draft | In Progress | Complete | Abandoned
536
+ **Spec:** [docs/features/{feature}.md](../../features/{feature}.md)
537
+ **Started:** YYYY-MM-DD
538
+ **Completed:** YYYY-MM-DD <!-- fill when status flips to Complete -->
539
+
540
+ ## Background
541
+
542
+ Why this work is happening *now*. Link to the spec for *what* we're building; this section is the motivation and the trigger. One paragraph.
543
+
544
+ ## Proposed Changes
545
+
546
+ ### New Files
547
+
548
+ - `src/path/new-file.js` — purpose
549
+
550
+ ### Modified Files
551
+
552
+ - `src/path/existing.js` — what changes and why
553
+
554
+ ### New Entities / State
555
+
556
+ - `entities.foo` — new Redux slice / DB table / persisted shape
557
+ - Persisted state addition: `state.bar.baz` (default `null` for existing users on rehydrate)
558
+
559
+ ### API Changes
560
+
561
+ - `POST /api/foo` — new route, request `{...}`, response `{status, data}`
562
+ - `PUT /api/bar` — request shape changes; see Migration
563
+
564
+ ### Cross-Module Contracts Affected
565
+
566
+ - List which cross-cutting contracts this plan touches (db schema, wire envelope, auth, events, env/config, …)
567
+ - "None" is a valid answer and means the `boundary` check will pass cleanly
568
+
569
+ ## Implementation Steps
570
+
571
+ 1. Concrete, ordered, testable
572
+ 2. Each step ends with something verifiable
573
+ 3. ...
574
+
575
+ ## Done Criteria
576
+
577
+ - [ ] Implementation complete and verified
578
+ - [ ] Affected docs updated (use `docs/routing.md` to find them)
579
+ - [ ] Changelog entry created in `docs/history/changelog/`
580
+ - [ ] Plan marked `Status: Complete`, **Completed:** date filled
581
+
582
+ ## Open Questions
583
+
584
+ - Question — who decides, by when
585
+
586
+ ## Risks
587
+
588
+ - Risk — likelihood / impact / mitigation
589
+ ```
590
+
591
+ ---
592
+
593
+ ## 8. Protected Files
594
+
595
+ Use for: documenting critical files that need approval before modification.
596
+
597
+ ```
598
+ # Protected Files
599
+
600
+ Critical files requiring approval before modification.
601
+
602
+ ## File List
603
+
604
+ # Category 1 - Description
605
+ path/to/critical/file1.js
606
+ path/to/critical/file2.js
607
+
608
+ # Category 2 - Description
609
+ path/to/another/file.js
610
+
611
+ ## Risk Summary
612
+
613
+ | Category | Risk if Broken |
614
+ |------------|-----------------|
615
+ | Category 1 | Specific impact |
616
+ | Category 2 | Specific impact |
617
+
618
+ ## Critical Logic
619
+
620
+ ### Category 1: [Name]
621
+
622
+ **Purpose:** What these files do
623
+
624
+ **Key Functions:**
625
+
626
+ | Function | Input | Output | Purpose |
627
+ |------------|-------|--------|----------------|
628
+ | `func1()` | Type | Type | What it does |
629
+ | `func2()` | Type | Type | What it does |
630
+
631
+ **Critical Behavior:**
632
+ - Important point 1
633
+ - Important point 2
634
+ ```
635
+
636
+ ---
637
+
638
+ ## 9. Architecture Decision Record (ADR)
639
+
640
+ Use for: capturing a single, point-in-time architectural decision with its context, alternatives considered, and consequences. Lives in `docs/history/adr/` — an ADR is a **historical decision record**, not the deployed-design source of truth (which lives in `docs/architecture/`). When the design later changes, update `docs/architecture/` and write a new superseding ADR; never rewrite a shipped ADR.
641
+
642
+ ### When to write an ADR
643
+
644
+ Write an ADR when **all three** apply:
645
+
646
+ 1. The decision is architectural — affects system shape, contracts, or substrate choice, not internal implementation
647
+ 2. Alternatives were genuinely considered and rejected
648
+ 3. Future maintainers will ask "why did we do it this way?"
649
+
650
+ Don't write an ADR for:
651
+
652
+ - Standing principles or style preferences (those are stances, not decisions — put them in `docs/architecture/`)
653
+ - Routine implementation choices with no rejected alternatives
654
+ - Anything you'd be happy reversing without ceremony
655
+
656
+ ### Lifecycle
657
+
658
+ `Proposed` → `Accepted` → `Deprecated` → `Superseded by ADR-NNN`
659
+
660
+ ADRs are **immutable after acceptance**. If the decision changes, write a new ADR that supersedes it. Update only the old ADR's `status` frontmatter field — never its body.
661
+
662
+ ### Naming
663
+
664
+ `ADR-NNN-short-title.md` — three-digit zero-padded number, kebab-case title. Numbers are assigned sequentially across the project and never reused.
665
+
666
+ ### Structure
667
+
668
+ Three sections are required: **Decision**, **Context**, **Consequences**. Everything else is optional — include only when warranted. Decision-first: readers should see the answer in the first paragraph.
669
+
670
+ ### Template
671
+
672
+ ```markdown
673
+ ---
674
+ title: "ADR-NNN: Short title in sentence case"
675
+ status: Accepted # Proposed | Accepted | Deprecated | Superseded by ADR-NNN
676
+ date: YYYY-MM-DD
677
+ decision-owner: Name
678
+ reviewers: [] # optional
679
+ supersedes: # optional, e.g., ADR-005
680
+ tags: [adr]
681
+ ---
682
+
683
+ # ADR-NNN: Short Title
684
+
685
+ ## Decision
686
+
687
+ [One paragraph, active voice. "We will…" Lead with the answer.]
688
+
689
+ ## Context
690
+
691
+ [The forces in play. What is the problem? Why does it need a decision now? Technical, political, social, and project-local pressures.]
692
+
693
+ ## Consequences
694
+
695
+ **Positive:**
696
+
697
+ - [What becomes easier]
698
+
699
+ **Negative:**
700
+
701
+ - [What becomes harder, what we accept reluctantly]
702
+
703
+ **Risks:**
704
+
705
+ - [Second-order effects you can already see, with mitigations if known]
706
+
707
+ <!-- Optional sections below. Include only when warranted by the decision's weight. -->
708
+
709
+ ## Decision Drivers
710
+
711
+ [Hard non-negotiables vs. strong levers. Include when alternatives exist and the criteria aren't self-evident from Context.]
712
+
713
+ ## Options Considered
714
+
715
+ | Option | Pros | Cons | Outcome |
716
+ | ------------ | ---- | ---- | --------------------- |
717
+ | **Option A** | … | … | **CHOSEN** |
718
+ | Option B | … | … | Eliminated — [reason] |
719
+
720
+ ## Deep Comparison
721
+
722
+ [Honest framing of the strongest alternative(s). Include when the table doesn't make the reasoning obvious. State the *real* reason each was rejected — not a strawman.]
723
+
724
+ ## Architecture in Detail
725
+
726
+ [Diagrams, code shape, layer responsibilities. Include when the decision implies non-trivial structure that readers need to understand alongside the *why*.]
727
+
728
+ ## Implementation Plan
729
+
730
+ | Phase | Scope | Duration |
731
+ | ----- | ----- | -------- |
732
+ | 1 | … | … |
733
+
734
+ ## Open Questions
735
+
736
+ 1. **[Question]** — _Default_: [stated default until resolved].
737
+
738
+ ## Acknowledgements
739
+
740
+ [Credit reviewers; name what they corrected. Include when reviewers materially shaped the doc.]
741
+
742
+ ## References
743
+
744
+ - [External link or cross-reference]
745
+ ```
746
+
747
+ ### Rules
748
+
749
+ - One decision per ADR. If you find yourself describing two decisions, split into two ADRs.
750
+ - Decision-first. The first paragraph after the heading is the answer; readers should not need to scroll.
751
+ - No section numbering (`§5.1.1`). Use markdown headings only — inserting a section shouldn't renumber everything.
752
+ - Frontmatter `status` is the single source of truth for lifecycle. Don't also write "Status: Accepted" in the body.
753
+ - When superseding, set the old ADR's `status: "Superseded by ADR-NNN"` and the new ADR's `supersedes: ADR-OLD`.
754
+ - The body is frozen at `Accepted`. Corrections to facts that were wrong at the time get a new ADR; typos and formatting fixes are fine.
755
+
756
+ ---
757
+
758
+ ## 10. Project Root README
759
+
760
+ Use for: the human-facing entry point at the repository root (`/README.md`) — what visitors and new contributors land on. Distinct from `docs/README.md` (the agent/doc index — see §1). The two coexist; don't merge them.
761
+
762
+ ### Strategy
763
+
764
+ The root README answers, in order:
765
+
766
+ 1. **What is this?** — one to two sentences, no marketing claims
767
+ 2. **What do I get if I install it?** — capability families
768
+ 3. **What's it built on?** — terse stack list with versions
769
+ 4. **How do I run it?** — the three or four scripts that matter
770
+ 5. **How is it laid out?** — directory tree, one-liner per significant folder
771
+ 6. **How do I extend it?** — numbered contribution checklist
772
+ 7. **What state is it in?** — pre-publish, beta, stable, internal
773
+
774
+ Skip any section that doesn't apply. Don't pad to fill the template.
775
+
776
+ ### Writing rules
777
+
778
+ - **Sentence-case headings.** "Getting started", not "Getting Started".
779
+ - **Concrete over abstract.** Real versions, real paths, real commands. No "leverages cutting-edge…".
780
+ - **The tagline answers "what is this?"** — not "why is it great?". Two sentences max.
781
+ - **Tables for enumeration** (routes, commands, endpoints). **Bullets for families and categories.**
782
+ - **Directory tree as a code block**, not a nested markdown list.
783
+ - **Numbered checklist** for "how to add a thing" — readers should be able to follow it top-to-bottom without re-reading.
784
+ - **Point to `docs/` for depth.** The root README links into deep docs; it doesn't host them.
785
+ - **Detect the package manager from the lockfile** (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, otherwise npm) and write commands accordingly. Don't hardcode `npm` if the repo uses pnpm.
786
+
787
+ ### Template
788
+
789
+ ```markdown
790
+ # {package-name}
791
+
792
+ {One- to two-sentence positioning. What it is and what scope it covers. No superlatives, no value claims.}
793
+
794
+ ## What's in the box
795
+
796
+ - **{Family 1}** — {what's in it; a few specific items, comma-listed.}
797
+ - **{Family 2}** — {what's in it.}
798
+ - **{Family 3}** — {what's in it.}
799
+
800
+ The full surface lives in [`{path/to/public-index}`]({path/to/public-index}). ← optional pointer for libraries
801
+
802
+ ## Stack
803
+
804
+ - {Framework} {version} · {Language} {version}
805
+ - {Build tool} {version}
806
+ - {Other load-bearing deps}
807
+
808
+ ## Getting started
809
+
810
+ \`\`\`bash {pm} install {pm} run dev # what it does (port, URL) {pm} run build # what it does {pm} run preview # what it does (omit if not applicable) \`\`\`
811
+
812
+ {Optional one-liner about first-run behavior — e.g., "Dev server lands on /playground."}
813
+
814
+ ## {Runtime entry point} ← optional; e.g., "The playground", "CLI", "API endpoints"
815
+
816
+ {Brief description of the dev/runtime surface.}
817
+
818
+ | {Thing} | {What it shows / does} |
819
+ | -------------------- | ---------------------- |
820
+ | `{route or command}` | {description} |
821
+
822
+ ## Layout
823
+
824
+ \`\`\` src/ ├── {entry-file} # {purpose} ├── {folder}/ # {purpose} │ └── ... └── {folder}/ # {purpose} \`\`\`
825
+
826
+ ## Adding a {primary unit}
827
+
828
+ 1. {Drop the source under the right family/folder.}
829
+ 2. {Re-export from the public surface.}
830
+ 3. {Wire into the playground / example app / test harness so reviewers can see it render.}
831
+ 4. {Document any divergence from upstream in `docs/{...}`.}
832
+
833
+ ## Styling ← optional; replace with whichever cross-cutting concern matters most
834
+
835
+ {Configuration notes that affect every consumer — design tokens, conventions, opt-outs.}
836
+
837
+ ## Status
838
+
839
+ {Pre-publish, beta, stable, internal-only. State what's stable and what's still moving — readers should know whether the API can be relied on.}
840
+
841
+ ## License
842
+
843
+ {License name — scope. e.g., "UNLICENSED — internal use only", "MIT".}
844
+ ```
845
+
846
+ ### Baseline scaffolding behavior
847
+
848
+ The baseline audit **does** scaffold the project root README when missing. The risk this template guards against — template-shaped placeholders that look abandoned — is mitigated by the writing rules above: fill every section with concrete details from the repo (real package manager from the lockfile, real scripts, real layout, real status). Skip sections that genuinely don't apply rather than leaving stubs.
849
+
850
+ **Never overwrite an existing root README** during a baseline. If one is present — even sparse or outdated — leave it untouched. Treat updates to a pre-existing root README as a separate, explicit request.
851
+
852
+ ---
853
+
854
+ ## 11. Memory inbox entry (docs/memory/inbox/{actor}.md)
855
+
856
+ Use for: the capture tier of the knowledge gradient — the durable lessons of each session (corrections, root-caused failures, decisions with rationale, discovered constraints), reflected by the `session-reflect` hook at session end. It is the raw input to distillation: `distiller facts` digests entries into fact-cards and **consumes** them, so the file holds exactly what is undigested.
857
+
858
+ ### File grain
859
+
860
+ One file **per actor**: `docs/memory/inbox/{actor}.md`. `actor` is `git config user.name` lowercased and kebab-slugged; fall back to `$USER`, then `agent`. Two actors write to different files, so the inbox is **append-only without merge conflicts** — no shared file to contend over, no lock, no last-writer-wins.
861
+
862
+ ### File header
863
+
864
+ Written once, on the first entry:
865
+
866
+ ```
867
+ # Memory inbox — {actor}
868
+ Session lessons awaiting distillation — appended by the session-reflect hook, consumed by `distiller facts`.
869
+ ```
870
+
871
+ ### Entry shape
872
+
873
+ One block per reflected session, at most 6 bullets. Each bullet is one complete, self-contained sentence tagged `[project]` (true of the repo or its tooling) or `[user]` (true of the user) — the tag routes it at distillation: project facts → `docs/memory/facts/`, user facts → user-level memory.
874
+
875
+ ```
876
+ ## YYYY-MM-DD HH:MM · session <id> · {repo}@{branch}
877
+ - [project] <one self-contained sentence, names and identifiers spelled out>
878
+ - [user] <one self-contained sentence>
879
+ ```
880
+
881
+ ### Examples
882
+
883
+ ```
884
+ ## 2026-06-08 22:26 · session bc06c4fc · etna@dev
885
+ - [project] The read_network_requests Chrome CDP tool only captures after its first call — arm it, trigger traffic, then read.
886
+ - [user] jane-doe prefers minimal fixes over defensive machinery; fail loudly instead of engineering around a problem.
887
+ ```
888
+
889
+ ### Rules
890
+
891
+ - **Hooks append, the distiller consumes.** A digested entry block is deleted by `distiller facts`; nothing else edits or reorders the file. A human may hand-append a lesson in the same shape — it rides the same queue.
892
+ - **Sessions are deduped by id.** The reflect hook skips a session whose id already appears in the file (SessionEnd re-fires on resume).
893
+ - **Secrets are redacted on write.** The privacy filter replaces secret shapes with `[redacted:{kind}]` (e.g. `[redacted:api-key]`, `[redacted:bearer]`, `[redacted:pem]`) before any line is appended — never paste a raw token in by hand either.
894
+ - **Don't curate here.** Promotion to fact-cards and `docs/memory/main.md` happens at distillation; the inbox stays a transient queue.