@kiwidata/grimoire 0.1.4 → 0.1.5

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 (81) hide show
  1. package/README.md +79 -58
  2. package/dist/cli/index.js +5 -7
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/core/check.d.ts.map +1 -1
  5. package/dist/core/check.js +54 -11
  6. package/dist/core/check.js.map +1 -1
  7. package/dist/core/doc-style.d.ts.map +1 -1
  8. package/dist/core/doc-style.js +76 -0
  9. package/dist/core/doc-style.js.map +1 -1
  10. package/dist/core/docs.js +96 -70
  11. package/dist/core/docs.js.map +1 -1
  12. package/dist/core/health.d.ts +6 -0
  13. package/dist/core/health.d.ts.map +1 -1
  14. package/dist/core/health.js +78 -19
  15. package/dist/core/health.js.map +1 -1
  16. package/dist/core/hooks.js +11 -5
  17. package/dist/core/hooks.js.map +1 -1
  18. package/dist/core/risk-register.d.ts +17 -0
  19. package/dist/core/risk-register.d.ts.map +1 -0
  20. package/dist/core/risk-register.js +73 -0
  21. package/dist/core/risk-register.js.map +1 -0
  22. package/dist/core/shared-setup.d.ts.map +1 -1
  23. package/dist/core/shared-setup.js +5 -4
  24. package/dist/core/shared-setup.js.map +1 -1
  25. package/dist/core/trace.d.ts.map +1 -1
  26. package/dist/core/trace.js +37 -35
  27. package/dist/core/trace.js.map +1 -1
  28. package/dist/index.d.ts +0 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -3
  31. package/dist/index.js.map +1 -1
  32. package/package.json +1 -1
  33. package/skills/grimoire-apply/SKILL.md +35 -39
  34. package/skills/grimoire-commit/SKILL.md +1 -1
  35. package/skills/grimoire-design/SKILL.md +3 -3
  36. package/skills/grimoire-discover/SKILL.md +77 -110
  37. package/skills/grimoire-draft/SKILL.md +51 -18
  38. package/skills/grimoire-plan/SKILL.md +62 -32
  39. package/skills/grimoire-pr/SKILL.md +7 -8
  40. package/skills/grimoire-pr-review/SKILL.md +1 -1
  41. package/skills/grimoire-refactor/SKILL.md +2 -2
  42. package/skills/grimoire-review/SKILL.md +12 -0
  43. package/skills/grimoire-verify/SKILL.md +7 -7
  44. package/skills/grimoire-vuln-remediate/SKILL.md +107 -0
  45. package/skills/grimoire-vuln-triage/SKILL.md +109 -0
  46. package/skills/references/code-quality.md +41 -9
  47. package/skills/references/container-scan-triage.md +102 -0
  48. package/skills/references/dependency-vuln-triage.md +236 -0
  49. package/skills/references/principles.md +82 -0
  50. package/skills/references/refactor-scan-categories.md +2 -2
  51. package/skills/references/review-personas.md +4 -3
  52. package/skills/references/testing-contracts.md +1 -1
  53. package/templates/accepted-risks.yml +47 -0
  54. package/templates/constraints.md +25 -0
  55. package/dist/commands/archive.d.ts +0 -3
  56. package/dist/commands/archive.d.ts.map +0 -1
  57. package/dist/commands/archive.js +0 -22
  58. package/dist/commands/archive.js.map +0 -1
  59. package/dist/commands/log.d.ts +0 -3
  60. package/dist/commands/log.d.ts.map +0 -1
  61. package/dist/commands/log.js +0 -15
  62. package/dist/commands/log.js.map +0 -1
  63. package/dist/commands/map.d.ts +0 -3
  64. package/dist/commands/map.d.ts.map +0 -1
  65. package/dist/commands/map.js +0 -16
  66. package/dist/commands/map.js.map +0 -1
  67. package/dist/core/archive.d.ts +0 -9
  68. package/dist/core/archive.d.ts.map +0 -1
  69. package/dist/core/archive.js +0 -81
  70. package/dist/core/archive.js.map +0 -1
  71. package/dist/core/log.d.ts +0 -8
  72. package/dist/core/log.d.ts.map +0 -1
  73. package/dist/core/log.js +0 -140
  74. package/dist/core/log.js.map +0 -1
  75. package/dist/core/map.d.ts +0 -22
  76. package/dist/core/map.d.ts.map +0 -1
  77. package/dist/core/map.js +0 -365
  78. package/dist/core/map.js.map +0 -1
  79. package/templates/dupignore +0 -93
  80. package/templates/mapignore +0 -58
  81. package/templates/mapkeys +0 -65
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: grimoire-apply
3
- description: Implement tasks from a planned grimoire change with strict red-green BDD. Use when tasks.md exists and is ready for implementation.
3
+ description: Implement tasks from a planned grimoire change, test-first at the right level (BDD scenario, unit-invariant, or characterization). Use when tasks.md exists and is ready for implementation.
4
4
  compatibility: Designed for Claude Code (or similar products)
5
5
  metadata:
6
6
  author: kiwi-data
@@ -9,7 +9,19 @@ metadata:
9
9
 
10
10
  # grimoire-apply
11
11
 
12
- Implement tasks from a planned grimoire change using strict red-green BDD: write the failing test first, then the production code that makes it pass. A task is not complete until its scenarios pass.
12
+ Implement tasks from a planned grimoire change using **test-first discipline at the right level**: write the failing test first, then the production code that makes it pass. A task is not complete until its test passes.
13
+
14
+ **Red-green is the discipline; the test vehicle matches the artifact the task came from** (set by `grimoire-plan` as each task's `verify:` tag):
15
+
16
+ | `verify:` | Task came from | Test vehicle |
17
+ |-----------|----------------|--------------|
18
+ | `scenario` | a `.feature` (actor-observable behavior) | Gherkin scenario + step definitions |
19
+ | `unit-invariant` | the constraints register (security/NFR/observability) | unit/integration test asserting the invariant |
20
+ | `characterization` | internal change / refactor (no spec) | unit / characterization test |
21
+
22
+ Do NOT write a `.feature` scenario for a `unit-invariant` or `characterization` task — forcing Gherkin where a unit test is correct is the antipattern that fills feature files with slop. One right way: behavior → scenario, everything else → unit test.
23
+
24
+ **Artifacts are edited live on the feature branch.** Features, decisions, constraints, and schema are real files in `features/`, `.grimoire/decisions/`, `.grimoire/docs/`. There is no copy-into-change-folder and no promote step — `git diff` is the staging area. The change folder holds only ephemeral process scaffolding (`manifest.md`, `tasks.md`).
13
25
 
14
26
  ## CRITICAL: Two Rules That Must Not Be Broken
15
27
 
@@ -41,8 +53,8 @@ This applies to all LLMs: Claude, Codex, Cursor, Copilot, etc. The task list is
41
53
  ## Prerequisites
42
54
  - A change exists in `.grimoire/changes/<change-id>/` with:
43
55
  - `manifest.md`
44
- - `tasks.md` (from plan stage)
45
- - At least one `.feature` file or decision record
56
+ - `tasks.md` (from plan stage, each task carrying a `verify:` tag)
57
+ - The change's live artifacts exist on the branch — at least one `.feature` (in `features/`), constraint (in `.grimoire/docs/constraints.md`), or decision record (in `.grimoire/decisions/`)
46
58
 
47
59
  ## Workflow
48
60
 
@@ -185,26 +197,11 @@ Before writing any code, ensure you're on a feature branch for this change:
185
197
  git checkout -b <type>/<change-id>
186
198
  ```
187
199
 
188
- Where `<type>` is `feat`, `fix`, `refactor`, or `chore` based on the change. If a branch already exists (resuming work), switch to it. Update the manifest's `branch:` field with the branch name.
189
-
190
- This links the git history to the grimoire change — `grimoire trace` and `grimoire log` depend on it.
191
-
192
- ### 3b. Promote Feature Files
193
-
194
- Before writing any code, copy the proposed feature files from the change directory into the live `features/` tree:
195
-
196
- ```
197
- cp -r .grimoire/changes/<change-id>/features/* features/
198
- ```
199
-
200
- For extended files (scenarios added to an existing feature), overwrite — the change copy already contains the baseline scenarios plus the new ones. For new files, place them at the correct path under `features/`.
200
+ Where `<type>` is `feat`, `fix`, `refactor`, or `chore` based on the change. If a branch already exists (`grimoire-branch-guard` or `grimoire-draft` usually created it), switch to it. Update the manifest's `branch:` field with the branch name.
201
201
 
202
- **Why this comes first:** BDD test runners discover scenarios from `features/`. Scenarios that only exist in `.grimoire/changes/` are invisible to the test runner, so the red-green cycle cannot work. On a feature branch, `features/` is branch-local promoting here has no effect on `main` until the PR merges.
202
+ The branch links the git history to the change via the `Change: <change-id>` commit trailer. The branch IS the isolation and `git diff` IS the staging there is no separate promote step.
203
203
 
204
- Commit the promoted files before writing any step definitions:
205
- ```
206
- git add features/ && git commit -m "feat(<change-id>): promote feature specs to features/"
207
- ```
204
+ > **No promote.** Feature files, decisions, and constraints were drafted directly into their live locations (`features/`, `.grimoire/decisions/`, `.grimoire/docs/constraints.md`) on this branch. BDD runners already discover the scenarios from `features/`. Do not copy anything out of `.grimoire/changes/` — that folder holds only `manifest.md` and `tasks.md`.
208
205
 
209
206
  ### 4. Load Context
210
207
 
@@ -222,14 +219,15 @@ git add features/ && git commit -m "feat(<change-id>): promote feature specs to
222
219
  3. Tell the user: "Context is getting large. I've updated tasks.md with progress. A fresh session can resume from here."
223
220
 
224
221
  ### 5. Implement Tasks
225
- Work through `tasks.md` sequentially. **Every task follows the same cycle: test → red → code → green → next.**
222
+ Work through `tasks.md` sequentially. **Every task follows the same cycle: test → red → code → green → next.** The cycle is identical at every level; only the *test vehicle* changes per the task's `verify:` tag (`scenario` → step definitions; `unit-invariant` / `characterization` → unit/integration test). "Step definitions" below means *the failing test at the task's level* — for non-`scenario` tasks, write a unit test, not a `.feature`.
226
223
 
227
224
  **For each task:**
228
225
  1. Announce which task you're working on
226
+ - Read the task's `verify:` tag — it decides the test vehicle. `scenario` → write/extend step definitions for the named scenario. `unit-invariant` → write a unit/integration test asserting the constraint. `characterization` → write a unit test pinning current/intended behavior. If a `unit-invariant` task has no matching constraint in `.grimoire/docs/constraints.md`, STOP and flag — don't invent a scenario to fill the gap.
229
227
  - **Pattern brief** (before writing anything): classify code type → `search_graph` for 3–5 peers (excluding last 60 days) → `get_code_snippet` → extract modal pattern across the four critical seams (error handling, dependency access, abstraction depth, return shape) → write a 5–8 rule brief. Skip if graph not indexed or < 3 peers. Full instructions in `../references/pattern-guard.md`.
230
- 2. Write the step definitions FIRST (the test that will verify this task)
231
- 3. Run the step definitions — **they MUST FAIL (red)**
232
- 4. If the test passes immediately, STOP. The test is broken — it's not actually testing anything. Fix the step definition so it makes a real assertion that fails without production code. Common causes:
228
+ 2. Write the test FIRST, at the task's level (step definitions for `scenario`; unit/integration test for `unit-invariant`/`characterization`)
229
+ 3. Run the test — **it MUST FAIL (red)**
230
+ 4. If the test passes immediately, STOP. The test is broken — it's not actually testing anything. Fix it so it makes a real assertion that fails without production code. Common causes:
233
231
  - Empty step definition body (passes by default)
234
232
  - Assertion against a mock/fixture that already satisfies the condition
235
233
  - Step wired to wrong function or missing the actual check
@@ -241,7 +239,7 @@ Work through `tasks.md` sequentially. **Every task follows the same cycle: test
241
239
  - **Branching budget ~7.** If a function has more `if` / `else` / `case` / `&&` than that, split or drop dead guards.
242
240
  - **Function size ~30 lines.** One job per function. If the name needs "and", split.
243
241
  - **No premature abstraction.** Three near-identical copies is fine. No new `BaseX` / factory / strategy / config object for a single caller.
244
- - **Comments: zero by default.** Do not add a comment unless you can state the non-obvious *why* in one sentence. No function docstrings unless the project's `comment_style` requires them. No inline comments restating what the code does (`# loop over users`, `# return result`). No block comments describing a section. No comments naming the task, PR, or ticket. If removing the comment would not confuse a future reader, do not write it.
242
+ - **Comments: terse, self-contained, no essays** (`../references/code-quality.md` §7). Default to none; add only a one-line non-obvious *why*. Terse voice drop "this function", filler, restated types. **Self-contained:** never name an external artifact that moves independently — no feature/scenario/`.feature`, MADR/ADR number, change-id, ticket/PR, test name, or tag code (`LOG-OBS-003`) in a comment; describe the behavior, not where it's specced. **No paragraphs:** summary is 1–2 lines, then the `comment_style` params if the project requires them no prose block before them. No comments restating the code (`# loop over users`). If removing it wouldn't confuse a future reader, don't write it.
245
243
  6. Run the step definitions again — they should PASS (green)
246
244
  7. If still red, fix the production code (not the test)
247
245
  8. **Hallucination check:** Before running tests, verify every external function/method your new code calls actually exists in the graph: `search_graph(name_pattern="<name>")` for each. If not found: find the correct function or stop and flag to user. Do not run tests against calls to non-existent functions. (Full instructions in `../references/pattern-guard.md` Step 6.)
@@ -280,23 +278,21 @@ When all implementation tasks are complete:
280
278
  **The verify step is not optional. Do not proceed to finalize with failing tests.**
281
279
 
282
280
  ### 7. Finalize
283
- When all tests are green:
284
- 1. Move new decision records to `.grimoire/decisions/` with proper sequential numbering
285
- 2. Update MADR status from `proposed` to `accepted` and set the date
286
- 3. If `data.yml` exists, merge the changes into `.grimoire/docs/data/schema.yml` apply adds/modifies/removes so the baseline schema stays current
287
- 4. Move `manifest.md` to `.grimoire/archive/YYYY-MM-DD-<change-id>/`
288
- 5. Remove the change directory from `.grimoire/changes/`
289
-
290
- Feature files were already promoted to `features/` in step 3b — no copy needed here.
281
+ When all tests are green. Features, decisions, and constraints were edited live on the branch — finalize flips states, applies the schema delta, and clears the ephemeral scaffolding:
282
+ 1. Decision records already live in `.grimoire/decisions/` (drafted there, numbered at draft time). Flip MADR status from `proposed` to `accepted` and set the date.
283
+ 2. Constraints (`.grimoire/docs/constraints.md`) were edited in place nothing to move.
284
+ 3. If the change has a `data.yml` (schema delta), apply its `add`/`modify`/`remove` entries to the live `.grimoire/docs/data/schema.yml` so the baseline schema stays current. `data.yml` is a migration-delta spec (ephemeral scaffolding carrying nullability/safety/ordering intent a raw diff wouldn't), not a copy of the schema — `schema.yml` is the live target; the delta is discarded with the change folder.
285
+ 4. Refresh the project overview: run `grimoire docs`. It regenerates `.grimoire/docs/OVERVIEW.md` (the human entry point) from the now-current features, constraints, decisions, and schema — superseded decisions drop out automatically. This is the existing `docs` command, not a new one.
286
+ 5. Remove the change directory `.grimoire/changes/<change-id>/`. Its `manifest.md` + `tasks.md` (+ any `data.yml`) are ephemeral process scaffolding. The durable record is the branch, the PR, and `git log` — linked by the `Change: <change-id>` trailer. **There is no archive tree** (don't reinvent git history).
291
287
 
292
288
  ### 8. Commit
293
289
 
294
- Finalize must be complete before committing — the commit captures the finished state including archived manifest and promoted decisions, not mid-flight change artefacts.
290
+ Finalize must be complete before committing — the commit captures the finished state (accepted decisions, cleared scaffolding), not mid-flight change artefacts.
295
291
 
296
- Stage everything:
292
+ Stage the live artifacts and the scaffolding removal:
297
293
  ```
298
- git add features/ .grimoire/decisions/ .grimoire/archive/ .grimoire/docs/ src/ tests/
299
- git add -u # picks up any deleted files (removed change directory)
294
+ git add features/ .grimoire/decisions/ .grimoire/docs/ src/ tests/
295
+ git add -u # picks up the removed change directory
300
296
  ```
301
297
 
302
298
  Then commit using `/grimoire:commit` (reads change context for the message) or write a manual message following `AGENTS.md` commit trailer conventions:
@@ -66,7 +66,7 @@ If `commit_style` in config is anything else, read it as a format hint and adapt
66
66
  - If multiple logical changes are staged, suggest splitting into separate commits
67
67
 
68
68
  ### 5. Git Trailers (mandatory for audit trail)
69
- When a grimoire change is active, the commit **MUST** include `Change:` as a git trailer. This is what makes `grimoire trace` and `grimoire log` work without it, the commit is invisible to the audit trail.
69
+ When a grimoire change is active, the commit **MUST** include `Change:` as a git trailer. This git-native anchor links the commit to its change — `grimoire trace` and `git log --grep "Change: <id>"` both rely on it. Without it, the commit is invisible to the audit trail.
70
70
 
71
71
  ```
72
72
  Change: add-2fa-login
@@ -128,7 +128,7 @@ For HTML output, write a single `.grimoire/changes/<change-id>/designs/preview.h
128
128
  Skip preview rendering when output is Figma (the Figma file IS the preview) or ASCII (the markdown table IS the preview).
129
129
 
130
130
  ### 9. Derive Gherkin
131
- Propose draft `.feature` files at `.grimoire/changes/<change-id>/features/<capability>/`. One Scenario per (component × state). Each Scenario has Given / When / Then steps grounded in the design.
131
+ Propose draft scenarios as a **design artifact** at `.grimoire/changes/<change-id>/designs/scenarios.feature` (a proposal, not the live baseline). One Scenario per (component × state), Given / When / Then grounded in the design. `grimoire-draft` writes the user-approved scenarios live into `features/` — design does not edit the live baseline directly. Every proposed scenario must still pass draft's feature admission test (external actor, observable, domain language).
132
132
 
133
133
  Apply surface-conditional adversarial scenarios per `../references/adversarial-personas.md`:
134
134
 
@@ -210,7 +210,7 @@ Brand-drift lint cross-references hardcoded values in code against `.grimoire/br
210
210
 
211
211
  ### Scope
212
212
  - Default: scan **staged files** (`git diff --cached --name-only`) — fast, dev-loop-friendly
213
- - `--all` / "scan all" → scan all tracked files (slower; honor `.grimoire/mapignore`)
213
+ - `--all` / "scan all" → scan all tracked files (slower; honor `.gitignore`)
214
214
  - File types: `.css`, `.scss`, `.less`, `.html`, `.jsx`, `.tsx`, `.vue`, `.svelte` (configurable per project conventions)
215
215
 
216
216
  ### What it looks for
@@ -249,7 +249,7 @@ Do not error — absence is a valid state for projects that haven't onboarded br
249
249
  ## Important
250
250
  - **Pure markdown.** This skill is interpreted by an LLM per ADR-0010. Do not generate executable code or shell scripts to satisfy any step. The variant HTML files are output artifacts; the workflow itself is prose the AI follows.
251
251
  - **Ask before scanning large codebases.** Component-inventory scans (step 4) and `--lint --all` scans can be expensive on monorepos. Confirm with the user before scanning more than ~500 files.
252
- - **Honor `.grimoire/mapignore`.** Any scan (component inventory, brand lint) must respect mapignore patterns. Reuse the same exclusion logic as `grimoire map`.
252
+ - **Honor `.gitignore`.** Any scan (component inventory, brand lint) must skip vendored, generated, and version-control-ignored paths.
253
253
  - **Do not create `.grimoire/brand/` unprompted.** The directory only appears when the user opts in via onboarding or `--capture-brand`. Reading from a missing brand directory is a valid state — fall back to neutral defaults.
254
254
  - **Never log Figma access tokens.** The token lives in `FIGMA_ACCESS_TOKEN` env var, read by the MCP server. Never write it to config, never echo it in transcripts, never include it in artifacts.
255
255
  - **Soft gates are warnings, not blockers.** The problem-statement gate (step 2) and the state-enumeration gate (step 7) warn aggressively but accept user override. Record overrides as assumptions so they surface in review.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: grimoire-discover
3
- description: Generate area docs and data schema from a codebase snapshot. Use when initializing grimoire on an existing project or when codebase structure has changed significantly.
3
+ description: Generate intent-focused area docs and data schema by querying the codebase graph. Use when initializing grimoire on an existing project or when an area's intent/boundaries have changed.
4
4
  compatibility: Designed for Claude Code (or similar products)
5
5
  metadata:
6
6
  author: kiwi-data
@@ -9,13 +9,15 @@ metadata:
9
9
 
10
10
  # grimoire-discover
11
11
 
12
- Generate a structured project map in `.grimoire/docs/` from a codebase snapshot. This map helps LLMs understand the codebase layout, find reusable code, and follow existing patterns preventing duplicate code and misplaced files.
12
+ Generate **intent-focused** area docs and a data schema in `.grimoire/docs/`. Area docs capture what the graph can't know an area's *purpose, boundaries, and conventions* — and point at the codebase-memory-mcp graph for everything structural (symbols, key files, call graphs, reusable code). The graph is the live source of structure; discover does not freeze it into a doc that drifts.
13
13
 
14
14
  ## Triggers
15
- - User wants to document or map the codebase structure
16
- - User asks about coding standards, patterns, or conventions
17
- - User wants to prevent duplicate code or find existing utilities
18
- - Loose match: "discover", "map", "standards", "conventions", "DRY", "utilities", "codebase layout"
15
+ - User wants to document an area's purpose, boundaries, or conventions
16
+ - User asks about coding standards or where new code of a type should go
17
+ - User is onboarding an existing project to grimoire
18
+ - Loose match: "discover", "standards", "conventions", "boundaries", "onboard codebase"
19
+
20
+ Note: "find existing utilities", "what calls what", "codebase layout/structure" are **graph** queries, not discover — use codebase-memory-mcp (`search_graph`, `get_architecture`, `trace_path`) directly.
19
21
 
20
22
  ## Routing
21
23
  - Want to document existing behavior as Gherkin features → `grimoire-audit`
@@ -24,85 +26,63 @@ Generate a structured project map in `.grimoire/docs/` from a codebase snapshot.
24
26
 
25
27
  ## Prerequisites
26
28
 
27
- **Structural snapshot:** Run `grimoire map` first. This produces `.grimoire/docs/.snapshot.json` a structural scan of the directory tree, key files, and file extension counts. The snapshot is the input for directory structure; this skill adds the semantic layer.
28
-
29
- If `.snapshot.json` doesn't exist or is stale, tell the user to run `grimoire map` (or `grimoire map --refresh` to diff against existing docs).
30
-
31
- **Symbol intelligence (recommended):** If `codebase-memory-mcp` is available as an MCP server, use its graph tools (`search_graph`, `get_architecture`, `query_graph`) to query symbols, call graphs, and architecture instead of reading source files manually. This provides AST-parsed symbols across 66 languages, call-path tracing, and dead code detection — far more accurate than regex extraction.
29
+ **The codebase graph is the structure source.** `codebase-memory-mcp` should be indexed for this project discover reads directory layout, symbols, key files, and call graphs from it (`get_architecture`, `search_graph`, `trace_path`), not from a filesystem snapshot. There is no `grimoire map` step and no `.snapshot.json` (both retired).
32
30
 
33
- If `codebase-memory-mcp` is not available, fall back to reading source files directly to identify symbols and patterns.
31
+ If `codebase-memory-mcp` is not indexed, run `index_repository` first. Only if the graph is genuinely unavailable, fall back to reading source files directly to identify boundaries and conventions.
34
32
 
35
33
  ## What It Produces
36
34
 
37
35
  `.grimoire/docs/` with:
38
- - **`index.yml`** — master index of all documented areas with descriptions and directory mappings
39
- - **Area docs** — one markdown file per area of the codebase, each covering:
40
- - Purpose and boundaries of the module/area
41
- - Key files and their responsibilities
42
- - Reusable utilities, helpers, and shared functions (the "reuse inventory")
43
- - Naming conventions and patterns in use
36
+ - **`index.yml`** — registry of documented areas (descriptions + directory mappings) and the functional-story map that groups capabilities in the OVERVIEW
37
+ - **Area docs** — one markdown file per significant area, **intent only**:
38
+ - Purpose of the area
39
+ - Boundaries (what belongs here, what doesn't, where related code lives)
40
+ - Conventions (naming + structural patterns, with example file references)
44
41
  - Where new code of this type should go
45
- - Example references (point to specific files as exemplars, don't duplicate code)
46
-
47
- ## Workflow
48
-
49
- ### 1. Load Snapshot and Graph
50
- Read `.grimoire/docs/.snapshot.json`. This gives you:
51
- - **directories** — every directory with file counts, extensions, key files, and subdirectories
52
- - **keyFiles** — significant files (entry points, configs, route files, etc.) with their detected type
53
- - **undocumented** — directories not yet covered by existing docs (only present on `--refresh`)
54
- - **removed** — directories that have docs but no longer exist (only present on `--refresh`)
55
42
 
56
- Use this as your roadmap. The snapshot tells you WHERE to look; you add WHAT it means.
43
+ Area docs do NOT contain Key Files, a reusable-code inventory, or duplicate listings — those are structure, and the graph regenerates them live on demand (and would drift if frozen here). When a reader needs symbols or reuse candidates, they query the graph, not the doc.
57
44
 
58
- If the snapshot includes a `duplicates` section (from `grimoire map --duplicates`), use it to populate "Known Duplicates" sections in area docs. This tells the plan skill where code is already duplicated so it can consolidate rather than add more.
45
+ ## Workflow
59
46
 
60
- **If `codebase-memory-mcp` is available**, also query the graph for each area:
61
- - `search_graph` find all symbols (functions, classes, types) in a directory
62
- - `trace_call_path` — understand how modules connect (inbound/outbound calls)
63
- - `get_architecture` — get a high-level module/dependency overview
64
- - `query_graph` — Cypher-like queries for specific relationships (e.g., `MATCH (f:Function)-[:CALLS]->(g) WHERE f.file STARTS WITH 'src/api/' RETURN f.name, g.name`)
47
+ ### 1. Load the Graph
48
+ Query `codebase-memory-mcp` to understand the codebase live:
49
+ - `get_architecture` — high-level module/dependency overview and directory layout (your roadmap of WHERE the areas are)
50
+ - `search_graph` — symbols (functions, classes, types) in a directory, with signatures
51
+ - `trace_path` — how modules connect (inbound/outbound calls)
52
+ - `query_graph` — specific relationships (e.g., `MATCH (f:Function)-[:CALLS]->(g) WHERE f.file STARTS WITH 'src/api/' RETURN f.name, g.name`)
65
53
 
66
- This replaces the need to manually read every source file to extract symbols. The graph gives you AST-accurate function signatures, call relationships, and dead code detection across 66 languages.
54
+ The graph gives AST-accurate structure across many languages. You use it to *understand* each area so you can write its intent doc — you do NOT copy its output into the doc (that's what regenerating live avoids).
67
55
 
68
56
  ### 2. Determine Scope
69
57
  Ask the user what to document (or accept the scope passed in by a calling skill):
70
- - **Full scan** — document all areas from the snapshot (default for first run)
58
+ - **Full scan** — document all significant areas (default for first run); use `get_architecture` to enumerate them
71
59
  - **Area scan** — document specific directories (e.g., "just the API layer")
72
- - **Gap fill** — only document areas flagged as `undocumented` in the snapshot
73
- - **Targeted refresh** — a list of directories is passed in (from `grimoire-precommit-review` doc freshness check or `grimoire-plan` staleness gate). Skip the full snapshot walk. Go directly to step 3 for each named directory, regenerate only those area docs, and update their `last_updated` entries in `index.yml`. This is the fast-path mode for post-change maintenance — it does not touch areas outside the passed list.
60
+ - **Targeted refresh** — a list of directories is passed in (e.g. from `grimoire-plan`'s staleness gate). Regenerate only those area docs and update their `last_updated` entries in `index.yml`. Fast-path for when an area's *intent* changed; does not touch areas outside the passed list.
74
61
 
75
- Check `.grimoire/docs/index.yml` if it exists — don't redo work unless refreshing.
62
+ Check `.grimoire/docs/index.yml` if it exists — don't redo work unless refreshing. Remember discover runs when **intent** changes (new area, shifted boundary), not on every code change — structure is always live from the graph.
76
63
 
77
64
  ### 3. Analyze Each Area
78
- For each directory cluster in the snapshot, read the actual code to understand:
79
-
80
- **From the snapshot (already known):**
81
- - Directory path and file counts
82
- - File extensions (tells you the language/type mix)
83
- - Key files (tells you what framework patterns are in use)
84
-
85
- **From `codebase-memory-mcp` graph (if available):**
86
- - All symbols in the area: functions, classes, types, constants with signatures
87
- - Call graph: what calls what, both inbound and outbound
88
- - Dead code: functions with zero callers
89
- - Cross-service HTTP links: REST routes and their callers
90
-
91
- **From reading the code (your job — or to supplement the graph):**
92
- - What the module/area is responsible for
93
- - Reusable functions, classes, utilities that other code should import
94
- - Naming conventions and structural patterns
95
- - Where new code of this type should be created
96
- - Import relationships with other areas
97
- - **Data models and schemas** in or owned by this area (see Data Layer below)
65
+ For each area, use the graph to understand it, then distill the **intent** a reader can't get from the graph:
66
+
67
+ **From the graph (read, don't transcribe):**
68
+ - Symbols, signatures, call relationships, dead code — context for understanding what the area does
69
+ - Cross-area import/HTTP links informs the Boundaries section
70
+
71
+ **What you write down (the graph can't infer this):**
72
+ - What the area is *responsible for* (Purpose)
73
+ - What belongs here vs. where related code lives (Boundaries)
74
+ - Naming and structural conventions in use, with an exemplar file reference
75
+ - Where new code of this type should go
76
+ - **Data models and schemas** owned by this area (see Data Layer below)
98
77
 
99
78
  ### 4. Generate Area Docs
100
79
  For each significant area, create a doc file in `.grimoire/docs/`.
101
80
 
102
- **Area doc format:**
81
+ **Area doc format (intent only — no structure tables):**
103
82
 
104
83
  ```markdown
105
84
  # <Area Name>
85
+ > Last updated: YYYY-MM-DD
106
86
 
107
87
  ## Purpose
108
88
  <1-2 sentences: what this area of the codebase is responsible for>
@@ -110,41 +90,28 @@ For each significant area, create a doc file in `.grimoire/docs/`.
110
90
  ## Boundaries
111
91
  <What belongs here and what doesn't. Where related code lives instead.>
112
92
 
113
- ## Key Files
114
- | File | Responsibility |
115
- |------|---------------|
116
- | `path/to/file.py` | <what it does> |
117
- | `path/to/other.py` | <what it does> |
118
-
119
- ## Reusable Code
120
- Utilities and helpers in this area that MUST be reused (not re-implemented):
121
-
122
- | Function/Class | Location | What It Does |
123
- |----------------|----------|-------------|
124
- | `format_currency()` | `utils/formatters.py:42` | Formats decimal as currency string |
125
- | `BaseAPIView` | `api/base.py:15` | Base view with auth, pagination, error handling |
126
-
127
- ## Patterns
128
- <How things are done in this area. Reference specific files as exemplars.>
93
+ ## Conventions
94
+ <How things are done in this area. Reference specific files as exemplars — don't list every file.>
129
95
 
130
96
  ### Naming
131
- - <naming convention with example>
97
+ - <naming convention with one example file>
132
98
 
133
99
  ### Structure
134
- - <structural pattern with example file>
100
+ - <structural pattern with one exemplar file>
135
101
 
136
102
  ## Where New Code Goes
137
103
  - New <type> → `path/to/directory/`
138
104
  - New <type> → `path/to/other/`
139
105
 
140
- ## Known Duplicates
141
- <Only if duplicates data exists in snapshot. List clones that touch this area.>
142
-
143
- | Files | Lines | What's Duplicated |
144
- |-------|-------|------------------|
145
- | `views.py:42-68` ↔ `api/views.py:15-41` | 26 | Request validation logic |
106
+ ## Structure (live)
107
+ For key files, symbols, reusable utilities, call graphs, and duplicates in this area,
108
+ query the graph — it is always current:
109
+ - `get_architecture(area="<dir>")` · `search_graph(qn_pattern="<dir>.*")`
110
+ - duplicates: `grimoire health` (config-driven `duplicates` metric)
146
111
  ```
147
112
 
113
+ Do not hand-list files, functions, or "reusable code" — that's the graph's job, and a frozen copy drifts. The single pointer above replaces the old Key Files / Reusable Code / Known Duplicates tables.
114
+
148
115
  ### 5. Generate Data Schema
149
116
 
150
117
  Scan the codebase for data models, ORM definitions, migration files, and schema declarations. Produce `.grimoire/docs/data/schema.yml` documenting the current data layer.
@@ -290,9 +257,22 @@ areas:
290
257
  path: .grimoire/docs/utils.md
291
258
  directory: src/utils
292
259
  description: Shared utilities, helpers, formatters
260
+
261
+ # Functional stories — how capabilities group for a human reader.
262
+ # `grimoire docs` uses this to group the OVERVIEW's Capabilities section.
263
+ # `features` lists feature-file basenames (no .feature extension).
264
+ stories:
265
+ chat-qa:
266
+ title: Chat & Q&A
267
+ features: [ai-chat, a2ui-integration, search]
268
+ extraction:
269
+ title: Document extraction
270
+ features: [document-pipeline, bbd-validation-rules]
293
271
  ```
294
272
 
295
- The `directory` field links each doc back to the source directory — this is what `grimoire map --refresh` uses to detect gaps.
273
+ The `directory` field links each doc back to the source directory — it's how a targeted refresh maps a changed directory to the area doc that describes it.
274
+
275
+ **Generate the `stories:` map.** Walk `features/`, then group the feature files by *functional story* — the user-facing capability area they serve, not the source directory. Propose the grouping to the user and let them rename/merge stories before writing. A feature not yet assigned to a story falls back to its feature-directory group in the OVERVIEW, so partial maps are fine. `stories` is the one place that grouping lives (DRY) — `grimoire docs` reads it, nothing else defines it.
296
276
 
297
277
  ### Freshness Tracking
298
278
 
@@ -323,38 +303,25 @@ areas:
323
303
  ### 8. Present Summary
324
304
  After generating, show the user:
325
305
  - How many areas documented
326
- - How many reusable utilities inventoried
327
- - Any areas that seem under-organized or have pattern inconsistencies
306
+ - Any areas whose boundaries seem unclear or whose conventions are inconsistent
328
307
  - Suggest which area docs are most critical for the plan skill to read
329
308
 
330
- ## Config Files
331
-
332
- Users can customize what gets scanned by editing files in `.grimoire/`:
333
-
334
- - **`.grimoire/mapignore`** — directories/patterns to skip during scanning (like .gitignore). Edit to exclude vendor code, generated files, etc.
335
- - **`.grimoire/mapkeys`** — key file definitions (format: `filename = type`). Edit to add project-specific indicators like `factories.py = test-factories` or `signals.py = django-signals`.
336
-
337
- These are read by `grimoire map` and affect the snapshot this skill consumes.
338
-
339
309
  ## Integration with Other Skills
340
310
 
341
- - The **plan** skill should read `.grimoire/docs/` before generating tasks look for existing utilities in the reuse inventory, follow documented patterns
342
- - The **verify** skill can check new code against documented patterns
311
+ - The **plan** skill reads `.grimoire/docs/` for Purpose/Boundaries/Conventions before generating tasks, and queries the **graph** for symbols and reusable utilities
312
+ - The **verify** skill can check new code against documented conventions
343
313
  - The **audit** skill can trigger a discover pass as part of onboarding
344
314
  - The **design** skill reads `.grimoire/docs/components.md` first to avoid generating duplicate components
345
- - The **precommit-review** skill checks area doc freshness on every commit and invokes discover in targeted refresh mode for stale dirs this is the primary maintenance trigger, not a periodic manual task
346
- - The **plan** skill gates on staleness for level 3-4 changes and directs the user to run targeted refresh before planning
315
+ - The **plan** skill gates on staleness for level 3-4 changes (when an area's *intent* doc lags its directory) and directs the user to run a targeted refresh before planning
347
316
 
348
317
  ## Important
349
- - **Start from the snapshot.** Don't scan the filesystem yourself — `grimoire map` already did that. Read `.snapshot.json` for structure, then use `codebase-memory-mcp` graph queries for symbols and call graphs (if available), and read actual code files for meaning.
350
- - **Prefer graph queries over file reads.** If `codebase-memory-mcp` is available, use `search_graph` and `query_graph` to find symbols, call paths, and architecture rather than reading every source file. This is faster, more accurate (AST-parsed), and uses fewer tokens.
351
- - **Document what IS, not what should be.** This is a map of the actual codebase, not aspirational standards. If the code is inconsistent, note it — don't paper over it.
352
- - **Point, don't copy.** Reference files and line numbers as exemplars. Don't duplicate code into the docs — it goes stale.
353
- - **Focus on what helps LLMs.** The goal is preventing duplicate code and misplaced files. Prioritize: reusable utilities > file placement > naming conventions > architectural patterns.
354
- - **Keep docs lean.** Each area doc should be scannable in 30 seconds. If it's too long, split it.
355
- - **The reuse inventory is the most valuable output.** An LLM that knows `format_currency()` exists in `utils/formatters.py` won't write a new one.
356
- - **Don't document the obvious.** Skip areas that are self-explanatory from file names alone. Focus on areas where an LLM would make mistakes.
357
- - **Update, don't accumulate.** When refreshing, replace stale docs rather than appending. The docs should reflect the current codebase, not its history.
318
+ - **Start from the graph.** Use `get_architecture` to enumerate areas and `search_graph`/`trace_path` to understand each one. Read source files only to pin down intent the graph can't express.
319
+ - **Intent only never transcribe structure.** Do not write Key Files lists, reusable-code inventories, or symbol tables into area docs. Those are derivable from the graph and would drift. The doc captures purpose, boundaries, and conventions; the doc points at the graph for everything else (DRY one home per fact).
320
+ - **Document what IS, not what should be.** This describes the actual codebase, not aspirational standards. If the code is inconsistent, note it — don't paper over it.
321
+ - **Point, don't copy.** Reference one exemplar file per convention. Don't duplicate code into the docs.
322
+ - **Keep docs lean.** Each area doc should be scannable in 30 seconds. If it's too long, it's probably transcribing structure cut it back to intent.
323
+ - **Don't document the obvious.** Skip areas self-explanatory from file names. Focus on areas where intent or boundaries are non-obvious.
324
+ - **Update, don't accumulate.** When refreshing, replace stale docs rather than appending.
358
325
 
359
326
  ## Done
360
327
  When area docs, schema, context, and index are generated, the workflow is complete. Suggest `grimoire-audit` to document existing features and decisions as Gherkin specs and ADRs.
@@ -21,21 +21,37 @@ Draft or update Gherkin features and MADR architecture decisions collaboratively
21
21
  - Bug report ("something is broken") → `grimoire-bug` or `grimoire-bug-report`
22
22
  - Pure refactoring (no behavior change) → no grimoire artifact needed. Suggest an ADR only if architecturally significant.
23
23
  - Config, deps, formatting → not grimoire territory. Just do it.
24
- - If unclear after one clarifying question, default to drafting a feature.
24
+ - If unclear, apply the jurisdiction table + admission test in step 1. Do NOT default to drafting a feature — default to finding the fact's correct home, and ask one clarifying question if the test is inconclusive.
25
25
 
26
26
  ## Workflow
27
27
 
28
- ### 1. Qualify the Request
29
- Before doing anything, determine what kind of change this is:
28
+ ### 1. Qualify the Request — Jurisdiction
30
29
 
31
- - **Behavioral** (Given/When/Then expressible) draft `.feature` files
32
- - **Architectural** (trade-off, choice, structural) → draft MADR decision record
33
- - **Both** → draft features AND decision records
34
- - **Bug fix** → STOP. Tell the user: "The feature file already describes the correct behavior. Let's just fix the code."
35
- - **Refactoring** → STOP. No behavior change = no grimoire artifact. Suggest an ADR only if it's a significant architectural shift.
36
- - **Config/deps/formatting** → STOP. Not grimoire territory.
30
+ Before doing anything, route the change to the **one** artifact type that owns it. Each fact has exactly one home (see `../references/principles.md` — one right way, DRY). **The default is NOT "draft a feature."** The default is: figure out which home this fact belongs in.
37
31
 
38
- If unclear, ask the user one clarifying question to route correctly. **Do not guess the routing and proceed.** A wrong routing wastes both your context and the user's time — one question costs less.
32
+ | What the change is | Home | Not |
33
+ |--------------------|------|-----|
34
+ | **Actor-observable behavior** — an external actor does something and observes a result | `.feature` (Gherkin) | — |
35
+ | **Constraint** — security control, NFR, performance budget, observability/logging guarantee, compliance rule | `.grimoire/docs/constraints.md` (assertion + rationale + how-verified) | NOT a `.feature` |
36
+ | **Architecture decision** — a trade-off or structural choice | MADR in `.grimoire/decisions/` | NOT a `.feature` |
37
+ | **Data model / external API contract** | data schema | NOT a `.feature` |
38
+ | **Both behavior + decision** | features AND a MADR | — |
39
+ | **Bug fix** | STOP → `grimoire-bug`. "The spec already describes correct behavior; just fix the code." | — |
40
+ | **Refactoring** (no behavior change) | STOP. No artifact. Suggest an ADR only if architecturally significant. | — |
41
+ | **Config / deps / formatting** | STOP. Not grimoire territory. | — |
42
+
43
+ #### The feature-file admission test
44
+
45
+ A scenario may be written **only if it passes all four gates.** If it fails any, it is not a feature — route it to the home above.
46
+
47
+ 1. **External actor** — a user, operator, or external system does the thing. "As a developer, I want structured logs" / "the system retries" → fails. The actor is internal → it's a constraint or a decision, not a feature.
48
+ 2. **Observable** — the actor can see the outcome without reading code or logs. "logs are scrubbed of PII", "request completes in <200ms" → fails (not observable by an actor) → constraint.
49
+ 3. **Domain language** — the scenario uses domain nouns, zero implementation detail. If a step names a library, log level, function, table, or framework (`loguru`, `INFO`, `bcrypt`, `users` table) → fails → it's leaking implementation; rewrite declaratively or move to a constraint/MADR.
50
+ 4. **Survives reimplementation** — if the internals were rewritten from scratch, would the scenario still read the same? If it would change, it's pinned to implementation → not a feature.
51
+
52
+ Common slop this catches (all belong in `constraints.md`, not `.feature`): "PII is scrubbed from logs", "all endpoints require auth", "responses are gzipped", "errors are logged with a trace id". These are invariants, not behaviors.
53
+
54
+ If unclear after applying the test, ask the user one clarifying question to route correctly. **Do not guess the routing and proceed.** A wrong routing wastes both your context and the user's time — one question costs less.
39
55
 
40
56
  ### 2. Score Complexity
41
57
 
@@ -117,7 +133,8 @@ Present a Requirements Summary (template in the reference) and wait for user con
117
133
 
118
134
  ### 6. Scaffold the Change
119
135
  - Choose a `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`)
120
- - Create `.grimoire/changes/<change-id>/`
136
+ - Ensure you're on a feature branch for this change (`grimoire-branch-guard` usually created it). The branch is where all artifacts are edited live.
137
+ - Create `.grimoire/changes/<change-id>/` — this folder holds **only ephemeral process scaffolding**: `manifest.md` (and later `tasks.md`). It does NOT hold copies of features, decisions, or constraints — those are edited live in their real locations and tracked by `git diff`. The folder is deleted at finalize; the branch + PR + git log are the durable record.
121
138
 
122
139
  ### 7. Draft Artifacts
123
140
  **For behavioral changes:**
@@ -151,15 +168,17 @@ Scenario triage:
151
168
 
152
169
  Do not proceed to writing until this table is complete. If unsure about a match, default to extend.
153
170
 
154
- **Step 3 — Execute**
171
+ **Step 3 — Execute (edit live on the branch)**
155
172
 
156
- - **Extend:** copy the matching baseline file to `.grimoire/changes/<change-id>/features/<same-relative-path>/` and add scenarios there.
157
- - **New file (requires justification):** state which existing files were considered and why none fit. Then create `.grimoire/changes/<change-id>/features/<capability>/<name>.feature`.
173
+ Artifacts are edited **directly in their real locations** on the feature branch. The branch is the isolation; `git diff` is the staging area. There is no copy into `.grimoire/changes/` and no promote step (see `../references/principles.md` — don't reinvent git).
174
+
175
+ - **Extend:** add scenarios directly to the live `features/<same-relative-path>` file.
176
+ - **New file (requires justification):** state which existing files were considered and why none fit. Then create `features/<capability>/<name>.feature` directly.
158
177
 
159
178
  Signals a scenario belongs in an existing file: same actor, same domain object, same entry point, same HTTP resource or screen.
160
179
  Signals a genuinely new file: new actor type with no existing file, entirely new domain object, or existing file's Feature title would need "and" to cover both.
161
180
 
162
- - If modifying an existing feature, copy the current baseline first, then modify
181
+ - Every scenario must have passed the **admission test** in step 1. If you catch yourself writing a step that names a library/log-level/table, stop — that fact belongs in `constraints.md`, not here.
163
182
  - Follow Gherkin best practices:
164
183
  - Feature title + user story (As a / I want / So that)
165
184
  - Background for shared preconditions
@@ -170,7 +189,7 @@ Signals a genuinely new file: new actor type with no existing file, entirely new
170
189
  **When design data was provided (step 4.0):**
171
190
  - If a Figma snapshot or `grimoire-design` output is available, propose Gherkin scenarios per (component × state) grounded in those artifacts. Walk the component list and the enumerated states; emit one Scenario per pair.
172
191
  - Present the proposed scenarios for user review before writing to `.feature` files — accept all / accept some / edit / reject any. Rejected scenarios are not written.
173
- - If `grimoire-design` already produced user-accepted scenarios under `.grimoire/changes/<change-id>/features/`, do NOT re-propose them; treat them as the baseline and only fill gaps (e.g., new components not yet covered).
192
+ - If `grimoire-design` already produced user-accepted scenarios under `.grimoire/changes/<change-id>/designs/scenarios.feature`, do NOT re-propose them; write the accepted ones live into `features/` (applying the admission test) and only fill gaps (e.g., new components not yet covered).
174
193
 
175
194
  **Brand-tokens grounding:**
176
195
  - When Figma variables map to tokens that also appear in `.grimoire/brand/tokens.json`, scenarios referencing visual properties must use token names, not hex values. Example: write `Then the submit button uses color.primary` not `Then the submit button is #0066ff`.
@@ -183,10 +202,20 @@ Signals a genuinely new file: new actor type with no existing file, entirely new
183
202
  **Security tags on scenarios:**
184
203
  Apply Gherkin tags per `../references/security-compliance.md` (section "Security Tags"). Tags drive stricter checks in plan, review, and verify stages. Apply compliance-specific tags only when `project.compliance` is configured. If no compliance frameworks and no security surface, don't add tags.
185
204
 
205
+ **For constraints (security / NFR / observability / compliance):**
206
+
207
+ Anything that failed the feature admission test because it's an invariant rather than an actor-observable behavior goes here — **not** into a `.feature`.
208
+
209
+ - Append to the live `.grimoire/docs/constraints.md` (create it from `templates/constraints.md` if absent).
210
+ - One row per constraint: **assertion · rationale · how-verified · links**. The assertion is a flat statement of what must always hold ("Log output never contains PII or secrets"), not a Given/When/Then.
211
+ - `how-verified` names the test that proves it (a `unit-invariant` test the plan stage will create) — never a Gherkin scenario.
212
+ - If the constraint stems from a decision, link the MADR; don't restate the decision (DRY).
213
+
186
214
  **For architecture decisions:**
187
- - Write MADR record in `.grimoire/changes/<change-id>/decisions/`
215
+ - Write the MADR record directly into the live `.grimoire/decisions/` with the next sequential number (`NNNN-title.md`)
188
216
  - Use the template from `.grimoire/decisions/template.md` or the AGENTS.md format
189
217
  - Include considered options, decision drivers, and consequences
218
+ - Draft status `proposed`; `grimoire-apply` flips it to `accepted` at finalize
190
219
 
191
220
  **For changes that touch data:**
192
221
  - Check `.grimoire/docs/data/schema.yml` for the current data schema (if it exists)
@@ -271,10 +300,14 @@ This is the contract. Downstream skills (plan, review, verify) use it to generat
271
300
  - Every Feature has a user story
272
301
  - Every Scenario has at least Given + When + Then
273
302
  - No implementation details leaked into features
303
+ - **Re-run the admission test on every scenario you wrote** (step 1): external actor, observable, domain language, survives reimplementation. Any scenario that now fails is slop — move it to `constraints.md` or a MADR before proceeding.
304
+ - **Principles gate** (`../references/principles.md`): no fact written to two homes (DRY), no second way to do an existing thing (one right way), no reinvented wheel (don't reinvent), no artifact created past the stated scope (KISS).
274
305
 
275
306
  ## Important
276
307
  - ONE change at a time. Don't combine unrelated changes.
277
- - Features describe behavior, not implementation. If you catch yourself writing step-level implementation details, you've gone too far.
308
+ - **Features describe actor-observable behavior, not implementation, and not invariants.** If a scenario has no external actor, isn't observable, or names a library/log-level/table, it is not a feature — it's a constraint (→ `constraints.md`) or a decision (→ MADR). This is the #1 source of feature-file slop.
309
+ - **One fact, one home** (`../references/principles.md`). A capability lives in one `.feature`; a control lives in one constraint row; a decision lives in one MADR. Never the same fact in two places.
310
+ - Artifacts are edited **live on the branch** — never copied into `.grimoire/changes/`. git diff is the staging area.
278
311
  - The manifest is lightweight glue — don't over-document. Just enough to capture why.
279
312
  - Always check if a capability/feature already exists before creating a new one.
280
313
  - **Figma access token is read from `FIGMA_ACCESS_TOKEN` env var by the MCP server.** Never log the token, never write it to config, never include it in `manifest.md`, `consult.md`, `figma-snapshot.json`, or any other artifact. The MCP server handles authentication transparently — grimoire-draft never needs to see the token value.