@kiwidata/grimoire 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/AGENTS.md +21 -25
  3. package/LICENSE +36 -0
  4. package/README.md +12 -4
  5. package/dist/cli/index.js +2 -41
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/program.d.ts +4 -0
  8. package/dist/cli/program.d.ts.map +1 -0
  9. package/dist/cli/program.js +47 -0
  10. package/dist/cli/program.js.map +1 -0
  11. package/dist/commands/comment-lint.d.ts +3 -0
  12. package/dist/commands/comment-lint.d.ts.map +1 -0
  13. package/dist/commands/comment-lint.js +14 -0
  14. package/dist/commands/comment-lint.js.map +1 -0
  15. package/dist/commands/configure.d.ts.map +1 -1
  16. package/dist/commands/configure.js +2 -1
  17. package/dist/commands/configure.js.map +1 -1
  18. package/dist/core/branch-check.d.ts.map +1 -1
  19. package/dist/core/branch-check.js +2 -16
  20. package/dist/core/branch-check.js.map +1 -1
  21. package/dist/core/check.d.ts.map +1 -1
  22. package/dist/core/check.js +4 -11
  23. package/dist/core/check.js.map +1 -1
  24. package/dist/core/ci.d.ts.map +1 -1
  25. package/dist/core/ci.js +2 -2
  26. package/dist/core/ci.js.map +1 -1
  27. package/dist/core/comment-lint.d.ts +18 -0
  28. package/dist/core/comment-lint.d.ts.map +1 -0
  29. package/dist/core/comment-lint.js +215 -0
  30. package/dist/core/comment-lint.js.map +1 -0
  31. package/dist/core/doc-style.d.ts +1 -0
  32. package/dist/core/doc-style.d.ts.map +1 -1
  33. package/dist/core/doc-style.js +1 -1
  34. package/dist/core/doc-style.js.map +1 -1
  35. package/dist/core/docs.d.ts.map +1 -1
  36. package/dist/core/docs.js +4 -11
  37. package/dist/core/docs.js.map +1 -1
  38. package/dist/core/health.d.ts.map +1 -1
  39. package/dist/core/health.js +4 -6
  40. package/dist/core/health.js.map +1 -1
  41. package/dist/core/hooks.d.ts.map +1 -1
  42. package/dist/core/hooks.js +44 -41
  43. package/dist/core/hooks.js.map +1 -1
  44. package/dist/core/init.js +1 -0
  45. package/dist/core/init.js.map +1 -1
  46. package/dist/core/list.d.ts.map +1 -1
  47. package/dist/core/list.js +6 -9
  48. package/dist/core/list.js.map +1 -1
  49. package/dist/core/pr.d.ts.map +1 -1
  50. package/dist/core/pr.js +0 -8
  51. package/dist/core/pr.js.map +1 -1
  52. package/dist/core/status.d.ts.map +1 -1
  53. package/dist/core/status.js +5 -5
  54. package/dist/core/status.js.map +1 -1
  55. package/dist/core/update.d.ts.map +1 -1
  56. package/dist/core/update.js +23 -10
  57. package/dist/core/update.js.map +1 -1
  58. package/dist/core/validate.js +1 -1
  59. package/dist/core/validate.js.map +1 -1
  60. package/dist/utils/config.d.ts +2 -0
  61. package/dist/utils/config.d.ts.map +1 -1
  62. package/dist/utils/config.js +4 -0
  63. package/dist/utils/config.js.map +1 -1
  64. package/dist/utils/frontmatter.d.ts +6 -0
  65. package/dist/utils/frontmatter.d.ts.map +1 -0
  66. package/dist/utils/frontmatter.js +13 -0
  67. package/dist/utils/frontmatter.js.map +1 -0
  68. package/dist/utils/paths.d.ts +1 -1
  69. package/dist/utils/paths.d.ts.map +1 -1
  70. package/dist/utils/paths.js +5 -4
  71. package/dist/utils/paths.js.map +1 -1
  72. package/dist/utils/stdin.d.ts +3 -0
  73. package/dist/utils/stdin.d.ts.map +1 -0
  74. package/dist/utils/stdin.js +13 -0
  75. package/dist/utils/stdin.js.map +1 -0
  76. package/package.json +24 -3
  77. package/skills/grimoire-apply/SKILL.md +8 -1
  78. package/skills/grimoire-audit/SKILL.md +4 -1
  79. package/skills/grimoire-bug/SKILL.md +7 -3
  80. package/skills/grimoire-draft/SKILL.md +145 -211
  81. package/skills/grimoire-plan/SKILL.md +4 -28
  82. package/skills/grimoire-pr-review/SKILL.md +1 -0
  83. package/skills/grimoire-refactor/SKILL.md +1 -1
  84. package/skills/grimoire-review/SKILL.md +1 -1
  85. package/skills/grimoire-verify/SKILL.md +12 -0
  86. package/skills/references/artifact-map.md +45 -0
  87. package/skills/references/review-personas.md +9 -3
  88. package/skills/references/test-baseline.md +55 -0
  89. package/templates/draft.md +108 -0
@@ -1,15 +1,22 @@
1
1
  ---
2
2
  name: grimoire-draft
3
- description: Draft or update Gherkin features and MADR architecture decisions collaboratively with the user. Use when the user describes new functionality, requirements, or architecture choices.
3
+ description: Design a change collaboratively on one living draft.md, then project it into Gherkin features, constraints, and MADR decisions. Use when the user describes new functionality, requirements, or architecture choices.
4
4
  compatibility: Designed for Claude Code (or similar products)
5
5
  metadata:
6
6
  author: kiwi-data
7
- version: "0.1"
7
+ version: "0.2"
8
8
  ---
9
9
 
10
10
  # grimoire-draft
11
11
 
12
- Draft or update Gherkin features and MADR architecture decisions collaboratively with the user.
12
+ Design a change on **one living document** (`draft.md`), iterating with the user, then
13
+ **project** the agreed design into its durable homes (features, constraints, decisions).
14
+
15
+ The core idea: spread-out artifacts hinder the thinking. So you do all the designing in a
16
+ single coherent doc — diagram/sketch, a decision ledger, pseudo-code, an open-question
17
+ ledger — and only fragment it into separate homes **after agreement**. `draft.md` is
18
+ ephemeral: retained as reference through the pipeline, deleted when `grimoire-apply` clears
19
+ the change folder. Git history preserves it.
13
20
 
14
21
  ## Triggers
15
22
  - User describes new functionality, behavior changes, or feature requests
@@ -17,240 +24,184 @@ Draft or update Gherkin features and MADR architecture decisions collaboratively
17
24
  - User describes a technology choice, architecture decision, or trade-off
18
25
  - Loose match: contains "feature", "requirement", "spec", "decision", "grimoire" with "create", "draft", "plan", "start", "new"
19
26
 
20
- ## Routing
27
+ ## Routing (coarse — up front)
28
+
29
+ Decide only whether to design at all, and in which skill. The **fine** routing (which fact
30
+ becomes a feature vs. a constraint vs. a decision) happens later, at projection (step 7).
31
+
21
32
  - Bug report ("something is broken") → `grimoire-bug` or `grimoire-bug-report`
22
33
  - Pure refactoring (no behavior change) → no grimoire artifact needed. Suggest an ADR only if architecturally significant.
23
34
  - Config, deps, formatting → not grimoire territory. Just do it.
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.
35
+ - Otherwise design it here. If genuinely unclear whether this is a grimoire change, ask one clarifying question rather than guessing.
25
36
 
26
37
  ## Workflow
27
38
 
28
- ### 1. Qualify the Request — Jurisdiction
39
+ ### 1. Qualify the Request — Jurisdiction (coarse)
29
40
 
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.
41
+ Confirm this is a change worth designing, and which skill owns it (table above). You do
42
+ **not** need to assign each fact to a home yet — during design everything lives in one
43
+ `draft.md`; per-fact routing is a projection concern (step 7, D13).
31
44
 
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. | — |
45
+ The one up-front question that matters: **is this a behavior/feature/architecture change**
46
+ (→ design it here), or a bug / pure refactor / config tweak (→ route away, per the table)?
47
+ If unclear, ask one question. Do not default to "draft a feature".
42
48
 
43
- #### The feature-file admission test
49
+ ### 2. Triviality Gate
44
50
 
45
- A scenario may be written **only if it passes all four gates.** If it fails any, it is not a featureroute it to the home above.
51
+ Complexity is an **output** of design, not an inputyou cannot score it honestly before
52
+ the design exists. Up front, make only one binary call:
46
53
 
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.
54
+ - **Trivial** — config, typo, copy change, single-file fix, dependency bump. Skip the
55
+ `draft.md` loop: make the change directly, record a minimal `manifest.md` (Why + file
56
+ list), done.
57
+ - **Non-trivial** — anything else. Build a `draft.md` and design the change (steps 3–8).
51
58
 
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.
59
+ The full **complexity level (1–4)** is scored at **projection** (step 7), once the design
60
+ is settled, and written to `manifest.md` — not before (a premature number biases the design
61
+ to fit it). During design, use the table below only as a rough guide for how deep to
62
+ research and elicit; depth grows with the change, it is not pre-allocated.
53
63
 
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.
64
+ | Level | Label | Signals | Drives (recorded at projection) |
65
+ |-------|-------|---------|---------------------------------|
66
+ | 1 | Trivial | Config, typo, copy, single-file fix | handled by the gate above — no `draft.md` |
67
+ | 2 | Simple | Single capability, ≤3 files, no architecture/data changes | Plan: coarser tasks · Review: Senior Engineer only |
68
+ | 3 | Moderate | Multiple capabilities, architecture decisions, data/dep changes | Plan: fine-grained · Review: all relevant personas · manifest carries Assumptions + Pre-Mortem |
69
+ | 4 | Complex | Cross-cutting, multiple services, security-sensitive, new infra | Plan: fine-grained · Review: all personas mandatory (`grimoire-review` not optional) · Assumptions + Pre-Mortem |
55
70
 
56
- ### 2. Score Complexity
71
+ If unsure between two levels at projection, pick the higher. The user can override ("treat this as complex").
57
72
 
58
- Assess the change's complexity to determine how much ceremony is appropriate. Score based on these signals:
73
+ ### 3. Research Existing Solutions
59
74
 
60
- | Level | Label | Signals | Ceremony |
61
- |-------|-------|---------|----------|
62
- | 1 | **Trivial** | Config, typo, copy change, single-file fix | Skip research (step 3). Minimal manifest (Why + Feature/Decision list only). No Pre-Mortem. |
63
- | 2 | **Simple** | Single capability, ≤3 files, no architecture decisions, no data changes | Light research (step 3 — check built-ins and first-party only). Standard manifest. |
64
- | 3 | **Moderate** | Multiple capabilities, architecture decisions, data model changes, new dependencies | Full research (step 3). Full manifest with Assumptions and Pre-Mortem. |
65
- | 4 | **Complex** | Cross-cutting concerns, multiple services/systems, security-sensitive, new infrastructure | Full research (step 3). Full manifest. Mandatory `grimoire-review` after plan (not optional). |
75
+ Before designing, research what already exists. Do not ask the user to research — do it yourself.
66
76
 
67
- Record the level in `manifest.md` frontmatter as `complexity: <1-4>`. Downstream skills use this:
68
- - **Plan** adjusts task granularity (level 1-2: coarser tasks; level 3-4: fine-grained with context blocks)
69
- - **Review** adjusts persona depth (level 1: skip review; level 2: Senior Engineer only; level 3: all relevant personas; level 4: all personas mandatory)
77
+ - Trivial changes never reach this step (handled by the gate).
78
+ - Otherwise research **proportional to scope**: a single first-party capability needs only a
79
+ built-ins / first-party check; architecture decisions, new dependencies, or cross-cutting
80
+ concerns need full research across all categories.
70
81
 
71
- If unsure between two levels, pick the higher one. The user can override: "this is simpler than you think" or "treat this as complex."
82
+ Follow the methodology in `../references/build-vs-buy.md`. The findings feed the `draft.md`
83
+ **Why** (and, for an adopt/build/hybrid call, the manifest **Prior Art** at projection).
84
+ Present findings to the user and get agreement on direction before designing deeply.
72
85
 
73
- ### 3. Research Existing Solutions
74
- Before designing, research what already exists. Do not ask the user to research — do it yourself.
86
+ ### 4. Design Input Check
75
87
 
76
- - **Level 1**: Skip this step.
77
- - **Level 2**: Light research check built-ins and first-party ecosystem only.
78
- - **Level 3-4**: Full research across all categories.
88
+ Check whether design artifacts already exist for this change, so the design is grounded in
89
+ real components and states rather than imagined ones. Consumed output anchors the `draft.md`
90
+ **At a glance** section.
79
91
 
80
- Follow the methodology in `../references/build-vs-buy.md`. Present findings to the user and wait for agreement before proceeding.
92
+ - **Existing design output**: If `.grimoire/changes/<change-id>/designs/` is already populated (a prior `grimoire-design` run produced `problem.md`, `variants.md`, `variant-{n}.html`, or `figma-snapshot.json`), read those now. Treat them as authoritative for component shape, states, and visual tokens — do not re-query Figma. The visual + component/state material becomes the **At a glance** anchor and seeds the behavioral **Sketches**.
93
+ - **Figma MCP available, no design folder**: If `project.design_tool.mcp` is configured and `designs/` is absent, ask: "Figma file URL or node ID? (or skip)". On a URL or node reference, query the Figma MCP for frame data and cache the response at `.grimoire/changes/<change-id>/designs/figma-snapshot.json` per `../references/design-input-formats.md` §1 Cache. On "skip" or empty input, continue.
94
+ - **No MCP and no design folder**: skip this step silently.
81
95
 
82
- ### 4.0 Design Input Check
96
+ ### 5. Scaffold & Map Existing State
83
97
 
84
- Before interviewing, check whether design artifacts already exist for this change. If so, the interview is grounded in real components and states rather than imagined ones.
98
+ - Choose a `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`).
99
+ - Ensure you're on a feature branch for this change (`grimoire-branch-guard` usually created it). The branch is where `draft.md` and, later, the projected artifacts are edited live.
100
+ - Create `.grimoire/changes/<change-id>/draft.md` from `templates/draft.md`, setting `kind: greenfield | refactor`.
85
101
 
86
- - **Existing design output**: If `.grimoire/changes/<change-id>/designs/` is already populated (a prior `grimoire-design` run produced `problem.md`, `variants.md`, `variant-{n}.html`, or `figma-snapshot.json`), read those artifacts now. Treat them as authoritative for component shape, states, and visual tokens — do not re-query Figma.
87
- - **Figma MCP available, no design folder**: If `project.design_tool.mcp` is configured and `designs/` is absent, ask: "Figma file URL or node ID? (or skip)". On a URL or node reference, query the Figma MCP for frame data and cache the response at `.grimoire/changes/<change-id>/designs/figma-snapshot.json` per `../references/design-input-formats.md` §1 Cache. On "skip" or empty input, continue to standard elicitation.
88
- - **No MCP and no design folder**: skip this step silently. Fall back to the standard interview elicitation in step 4 below.
102
+ Then map what already exists so the design isn't blind:
89
103
 
90
- When design input is consumed (either path), carry the extracted component list, states, and any token references into the elicitation in step 4 these become concrete anchors for the questions you ask the user, replacing generic prompts.
104
+ - Read `features/` for the current behavioral baseline, `.grimoire/decisions/` for existing decisions, `.grimoire/docs/context.yml` for the deployment environment and sibling services. Check `.grimoire/changes/` for in-progress changes that overlap flag conflicts. See `../references/artifact-map.md` for reading discipline.
105
+ - **For `kind: refactor` — build the Current state section (required).** Map how the touched system works **today**, with `file:line` breadcrumbs, into `draft.md` → *Current state*, followed by a severity-ranked Gaps/drift list. **Mandate the codebase graph**: if the repo isn't indexed, run `index_repository` first, then use `search_graph` / `trace_path` / `get_code_snippet` for qualified names, callers, and call chains. This map is the load-bearing grounding for a refactor — you cannot redesign what you haven't located.
106
+ - If `.grimoire/changes/<change-id>/consult.md` exists (from `grimoire-design-consult`), parse `## Inferred assumptions` and `## Inferred givens` and carry them into the `draft.md` design: assumptions → *Decided/Open* (each becomes an Open row, or a Decided row if the consult resolved it); givens → context for the *Decisions* ledger. The H2 headers `## Inferred assumptions` and `## Inferred givens` are load-bearing — they are the exact section names `grimoire-design-consult` writes; do not paraphrase, retitle, or fuzzy-match. **Open questions from `consult.md` are NOT copied** — they remain in `consult.md` as designer follow-up items.
91
107
 
92
- ### 4. Elicit Requirements
108
+ ### 6. Design the Change — the loop (the interview happens HERE)
93
109
 
94
- **Interview, don't assume.** The most common drafting failure is filling in gaps with plausible-sounding guesses. Every unstated detail is either (a) something the user has an opinion on and you must ask, or (b) something project conventions answer unambiguously. Never a third option where you invent.
110
+ This single loop replaces what used to be separate "elicit requirements", "draft", and
111
+ "collaborate" steps. **Interviewing IS iterating on `draft.md`.** There is no gather-then-
112
+ transcribe split — requirements surface, get questioned, and resolve inside the doc.
95
113
 
96
- Now that you know whether you're building, adopting, or going hybrid, surface the requirements the user hasn't specified.
114
+ Iterate with the user, directly on `draft.md`:
97
115
 
98
- - **Level 1**: Skip this step.
99
- - **Level 2+**: Follow `../references/elicitation-personas.md` at the depth matching your complexity level.
116
+ ```
117
+ loop:
118
+ propose → decisions into the Decisions ledger; shapes into Sketches; a diagram/sketch into At a glance
119
+ question → unknowns become rows under Open (use ../references/elicitation-personas.md as lenses)
120
+ user reacts → answers / edits the doc
121
+ resolve → strike the Open row IN PLACE: `RESOLVED: <answer> (Dn)` — never delete it
122
+ until Decided is stable AND Open is empty-or-deferred.
123
+ ```
100
124
 
101
- The build-vs-buy outcome shapes which questions matter:
102
- - **Adopting**: Focus on integration — how it fits, what config is needed. Skip deep business-rule elicitation.
103
- - **Building custom**: Full elicitation — business rules, edge cases, data contracts, security, NFRs.
104
- - **Hybrid**: Elicit deeply for custom parts. For adopted parts, focus on integration boundaries.
125
+ Discipline for the loop:
105
126
 
106
- #### Interview protocol
127
+ 1. **Outcome & Non-goals first.** Pin these (into *Why*) before anything else — they set scope. Restate them back to the user.
128
+ 2. **Batch questions, then wait.** Ask 3–5 at a time, grouped by concern, as Open rows. Stop. Wait. Do not propose decisions past an unanswered batch.
129
+ 3. **Ask the question; don't pre-answer it.** "Should locked accounts get an email?" — not "I'll assume locked accounts get an email." The pre-answered form lets the user nod through assumptions they'd otherwise correct.
130
+ 4. **One question per real ambiguity, not a checklist dump.** Ask the few that matter for *this* change.
131
+ 5. **Disambiguate immediately.** If an answer is vague ("handle errors gracefully"), ask the specific follow-up and record the concrete answer. Never leave a vague answer in the ledger.
132
+ 6. **Capture, don't extrapolate.** "Out of scope for now" → record as a non-goal and stop. Don't design a scenario "just in case".
133
+ 7. **When the user delegates** ("just write something reasonable"), record it explicitly as an Open→RESOLVED row: "Defaulting to <choice> per user delegation — flag in review if wrong." The assumption stays visible.
134
+ 8. **Sort facts by kind as they emerge.** An invariant (security control, NFR, performance budget, observability guarantee) is not a behavior — capture it in the *Constraints* section, not as a behavioral sketch. Apply the rough behaviour-vs-invariant test as you design (does an external actor observe it without reading code/logs?) so projection's admission test (step 7) gets clean input instead of slop to reroute. The fine fact-to-home routing still happens at projection; this just keeps the design honest while you think.
107
135
 
108
- 1. **Outcome & Non-goals first.** Always ask these two before any persona questions they set scope. Restate the answers back to the user before continuing.
109
- 2. **Batch questions, then wait.** Ask 3-5 questions at a time, grouped by persona. Stop. Wait for the user's reply. Do not draft scenarios until the batch is answered.
110
- 3. **Ask the question; don't pre-answer it.** "Should locked accounts get an email?" — not "I'll assume locked accounts get an email, let me know if not." The pre-answered form lets the user nod through assumptions they'd otherwise correct.
111
- 4. **One question per ambiguity, not a checklist dump.** If the user said "users can reset password", do not ask 12 generic questions. Ask the 3 that matter for *this* feature.
112
- 5. **Disambiguate immediately.** If the user's answer is vague ("yeah, handle errors gracefully"), ask the specific follow-up ("for invalid tokens, do we redirect to login with a flash message, return a 400, or something else?"). Never leave a vague answer in the spec.
113
- 6. **Capture, don't extrapolate.** If the user explicitly says "out of scope for now", note it as a non-goal and stop. Don't draft a scenario "just in case".
114
- 7. **When the user pushes back on a question** ("just write something reasonable"), record their delegation explicitly: "Defaulting to <choice> per user delegation — flag in review if wrong." This makes the assumption visible later.
136
+ **Never silently fill an open question.** Either ask it (as an *Open* row), defer it to a non-goal, or record the inference explicitly in *Decided*. The *Decided/Open* ledger IS the requirements summary — before declaring the design done, walk it back to the user so they see every call and every guess.
115
137
 
116
- #### Open-question discipline
138
+ **Nothing is written to `features/`, `.grimoire/docs/constraints.md`, or `.grimoire/decisions/` during this loop.** Everything lives in `draft.md`. The design is "done" when *Decided* is stable and *Open* is empty-or-deferred — and the user agrees.
117
139
 
118
- After the interview, list every open question that wasn't answered. These become:
119
- - **Manifest Assumptions** (level 3-4) — each open question becomes an unvalidated assumption with the reading you chose.
120
- - **Open questions in the Requirements Summary** — explicitly listed so the user sees what you guessed.
140
+ Do NOT proceed to projection without explicit user approval of the design.
121
141
 
122
- Never silently fill in an open question. Either ask, defer to a non-goal, or record the inference.
142
+ ### 7. Projection generate the homes from draft.md
123
143
 
124
- Present a Requirements Summary (template in the reference) and wait for user confirmation before proceeding.
144
+ Once the user agrees the design is settled, project `draft.md` into its durable homes. This
145
+ is where the **fine routing** happens (each fact → its one home) and where the admission
146
+ test + principles gate run. Artifacts are written **live in their real locations** on the
147
+ branch — `git diff` is the staging area; there is no copy-into-the-change-folder.
125
148
 
126
- ### 5. Check Existing State
127
- - Read `features/` to understand the current behavioral baseline
128
- - Read `.grimoire/decisions/` to understand existing architecture decisions
129
- - Read `.grimoire/docs/context.yml` (if it exists) to understand the deployment environment, related services, and infrastructure — this tells you what's available (caches, queues, sibling services) and what constraints apply (deployment target, environments)
130
- - Check `.grimoire/changes/` for any in-progress changes that might overlap
131
- - If there's a conflict with an active change, flag it
132
- - If `.grimoire/changes/<change-id>/consult.md` exists (from a prior `grimoire-design-consult` run), parse the `## Inferred assumptions` and `## Inferred givens` sections verbatim. Copy the contents of `## Inferred assumptions` into the manifest's Assumptions section, and copy `## Inferred givens` into a new Givens section at the same heading level (Givens applies to level 3-4 only — skip for level 1-2). The H2 headers `## Inferred assumptions` and `## Inferred givens` are load-bearing — they are the exact section names `grimoire-design-consult` writes; do not paraphrase, retitle, or fuzzy-match. Open questions from `consult.md` are NOT copied — they remain in `consult.md` as designer follow-up items.
149
+ First, **score the complexity level (1–4)** now that the design is settled, and write it to
150
+ `manifest.md` frontmatter as `complexity: <1-4>`.
133
151
 
134
- ### 6. Scaffold the Change
135
- - Choose a `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`)
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.
152
+ Then project each kind of fact:
138
153
 
139
- ### 7. Draft Artifacts
140
- **For behavioral changes:**
154
+ **Behaviors `features/*.feature`.** For each behavioral fact in the design:
141
155
 
142
- Before writing any `.feature` file, triage existing files. **The default is always extend. New files are the exception and require explicit justification.**
156
+ *The feature-file admission test* a scenario may be written **only if it passes all four gates**; if it fails any, it is a constraint or a decision, not a feature:
157
+ 1. **External actor** — a user, operator, or external system does the thing. Internal actor → constraint/decision.
158
+ 2. **Observable** — the actor sees the outcome without reading code or logs. "<200ms", "logs scrubbed of PII" → fails → constraint.
159
+ 3. **Domain language** — domain nouns, zero implementation detail. Names a library/log-level/table (`loguru`, `INFO`, `bcrypt`, `users` table) → fails → leaking implementation.
160
+ 4. **Survives reimplementation** — rewrite the internals from scratch; would the scenario still read the same? If it would change, it's pinned to implementation → not a feature.
143
161
 
144
- **Step 1 List existing feature files (required, not skippable)**
162
+ Common slop this catches (all `constraints.md`): "PII is scrubbed from logs", "all endpoints require auth", "responses are gzipped", "errors logged with a trace id".
145
163
 
146
- Read `features/` recursively. Print a table before doing anything else:
164
+ *Extend vs. new default is always extend; new files are the exception and require justification.* List existing feature files first (**required, not skippable** — do not write any scenario until this triage table is complete):
147
165
 
148
166
  ```
149
167
  Existing feature files:
150
168
  features/auth/login.feature — "User Login"
151
- features/auth/registration.feature — "User Registration"
152
169
  features/billing/invoices.feature — "Invoice Management"
153
- ...
154
170
  ```
155
171
 
156
- If `features/` is empty or doesn't exist, skip to step 3.
157
-
158
- **Step 2 — Match each proposed scenario to an existing file**
159
-
160
- For each scenario you intend to draft, explicitly decide: extend or new? Show the decision:
172
+ For each scenario, decide extend-or-new and show it:
161
173
 
162
174
  ```
163
- Scenario triage:
164
- "Admin resets a user's password" extend features/auth/login.feature (same actor domain: auth)
165
- "User exports invoices as CSV" → extend features/billing/invoices.feature (same resource)
166
- "User configures SSO provider" → NEW (no existing file owns SSO configuration)
175
+ "Admin resets a user's password" → extend features/auth/login.feature (same actor domain: auth)
176
+ "User configures SSO provider" NEW (no existing file owns SSO configuration)
167
177
  ```
168
178
 
169
- Do not proceed to writing until this table is complete. If unsure about a match, default to extend.
170
-
171
- **Step 3 — Execute (edit live on the branch)**
172
-
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.
179
+ Signals to extend: same actor, same domain object, same entry point, same HTTP resource or screen. Signals genuinely new: new actor type with no existing file, entirely new domain object, or the existing Feature title would need "and" to cover both. If unsure, extend. A new file requires stating which files were considered and why none fit.
177
180
 
178
- Signals a scenario belongs in an existing file: same actor, same domain object, same entry point, same HTTP resource or screen.
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.
181
+ Then write Gherkin (Feature title + user story; Background for shared preconditions; one scenario per behavior; Given/When/Then describing WHAT, never HOW). Apply security tags per `../references/security-compliance.md` (only when there's a security surface; compliance tags only when `project.compliance` is set). When design input grounded the scenarios (step 4): use brand-token **names** not hex values when `.grimoire/brand/tokens.json` applies; prefer existing component names when `.grimoire/docs/components.md` exists, and flag any net-new component ("new component required — confirm before plan stage").
180
182
 
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, stopthat fact belongs in `constraints.md`, not here.
182
- - Follow Gherkin best practices:
183
- - Feature title + user story (As a / I want / So that)
184
- - Background for shared preconditions
185
- - One scenario per behavior
186
- - Given/When/Then — describe WHAT, never HOW
187
- - No implementation details in feature files
183
+ **Constraints → `.grimoire/docs/constraints.md`.** Every invariant that failed the admission test (it's a security control / NFR / observability / compliance rule, not an actor-observable behavior) becomes one row: **assertion · rationale · how-verified · links**. The assertion is a flat statement ("Log output never contains PII or secrets"), not Given/When/Then. `how-verified` names the test that proves it (a `unit-invariant` the plan stage will create) never a Gherkin scenario. If it stems from a decision, link the MADR; don't restate it. Create the file from `templates/constraints.md` if absent.
188
184
 
189
- **When design data was provided (step 4.0):**
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.
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.
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).
185
+ **Decisions `.grimoire/decisions/NNNN-*.md`.** Project each Decisions-ledger entry, applying the **novelty gate**: a MADR is for a decision with a real, project-specific trade-off between viable alternatives — not for industry-default tooling picks or ecosystem-forced conventions. Ask: *would a competent engineer on this stack make a different choice, and need our reasoning to understand ours?* If no, skip it. Obvious tooling/convention picks fold into the existing `Tooling and convention baseline` ADR (one line: choice → why), not a new sequential record. Genuine trade-offs get the next sequential number, status `proposed` (`grimoire-apply` flips to `accepted` at finalize), using `.grimoire/decisions/template.md`.
193
186
 
194
- **Brand-tokens grounding:**
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`.
196
- - Hardcoded hex values in scenarios drift silently when tokens change. Token names stay correct across re-skins.
197
-
198
- **Component-library awareness:**
199
- - When `.grimoire/docs/components.md` exists, prefer references to existing components by name in scenarios (e.g., `Then a Button with variant="primary" is rendered` over `Then a blue button appears`).
200
- - Flag net-new components explicitly: emit "new component required — confirm before plan stage" alongside any scenario that introduces a component not listed in `components.md`. The plan stage will then decide whether to add it to the inventory or reuse an existing variant.
201
-
202
- **Security tags on scenarios:**
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.
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
-
214
- **For architecture decisions:**
215
- - Write the MADR record directly into the live `.grimoire/decisions/` with the next sequential number (`NNNN-title.md`)
216
- - Use the template from `.grimoire/decisions/template.md` or the AGENTS.md format
217
- - Include considered options, decision drivers, and consequences
218
- - Draft status `proposed`; `grimoire-apply` flips it to `accepted` at finalize
219
-
220
- **For changes that touch data:**
221
- - Check `.grimoire/docs/data/schema.yml` for the current data schema (if it exists)
222
- - If the change adds, modifies, or removes data models, fields, indexes, or external API integrations, write a `data.yml` in `.grimoire/changes/<change-id>/` showing the proposed schema changes
223
- - Use the same YAML format as `schema.yml` but only include what's changing — new models, added/removed fields, new external API integrations
224
- - Mark changes clearly with `action:` on each entry:
187
+ **Data changes → `.grimoire/changes/<change-id>/data.yml`.** If the change adds/modifies/removes data models, fields, indexes, or external API integrations, write `data.yml` (same YAML shape as `schema.yml`, only what's changing, `action:` on each entry):
225
188
 
226
189
  ```yaml
227
190
  # Proposed data changes for: add-user-profiles
228
-
229
191
  users:
230
192
  action: modify
231
193
  source: src/models/user.py
232
194
  fields:
233
- avatar_url: # new field
234
- action: add
235
- type: varchar
236
- nullable: true
237
- legacy_name: # removing a field
238
- action: remove
239
-
195
+ avatar_url: { action: add, type: varchar, nullable: true }
196
+ legacy_name: { action: remove }
240
197
  profiles:
241
- action: add # entirely new model
198
+ action: add
242
199
  type: collection
243
200
  fields:
244
201
  user_id: { type: objectId, ref: users }
245
202
  bio: { type: string, max_length: 500 }
246
- social_links:
247
- type: array
248
- items:
249
- platform: { type: string }
250
- url: { type: string }
251
-
252
203
  github_api:
253
- action: add # new external API dependency
204
+ action: add
254
205
  type: external_api
255
206
  provider: GitHub
256
207
  schema_ref: https://docs.github.com/en/rest
@@ -259,60 +210,43 @@ github_api:
259
210
  get_user:
260
211
  method: GET
261
212
  path: /users/{username}
262
- request: # document what you send
263
- headers:
264
- Authorization: "Bearer {token}"
265
- response: # document what you expect back
213
+ request:
214
+ headers: { Authorization: "Bearer {token}" }
215
+ response:
266
216
  login: { type: string, required: true }
267
217
  avatar_url: { type: string, required: true }
268
218
  name: { type: string, nullable: true }
269
- error_response: # document known error shapes
219
+ error_response:
270
220
  message: { type: string }
271
221
  status: { type: integer }
272
222
  ```
273
223
 
274
- **Contract documentation is mandatory for external APIs.** Every endpoint entry must include:
275
- - **`request`**: headers, query params, or body fields your client sends
276
- - **`response`**: fields your client reads, with types and `required: true` for fields your code depends on
277
- - **`error_response`**: the error shape your client handles
278
-
279
- This is the contract. Downstream skills (plan, review, verify) use it to generate contract tests and detect breaking changes. If you don't know the exact shape, reference the `schema_ref` and document what your client actually uses — that subset is the contract.
280
-
281
- - If the change has no data impact, skip `data.yml` entirely — don't create an empty one
282
-
283
- **For all changes:**
284
- - Write `manifest.md` listing all artifacts, what's added/modified/removed, and why
285
- - Include `complexity: <1-4>` in the manifest frontmatter (from step 2)
286
- - **Level 1-2**: Assumptions and Pre-Mortem sections are optional (include if relevant)
287
- - **Level 3-4**: Include an **Assumptions** section: list what must be true for this change to succeed. For each assumption, note whether there is evidence or it is unvalidated. Unvalidated assumptions on the critical path should be flagged to the user.
288
- - **Level 3-4**: Include a **Pre-Mortem** section: imagine this change has failed or caused a production incident 6 months from now — what went wrong? List 2-5 plausible failure modes with mitigations or "accepted" if the risk is acknowledged.
289
- - The manifest must include a **Prior Art** section summarizing the research from step 3: what was found, what was evaluated, and why the chosen direction (adopt, build, or hybrid) was selected. If the decision was to build, include what's being borrowed from existing implementations. This section is consumed by the plan and review stages — without it, reviewers can't validate the build-vs-buy decision.
290
-
291
- ### 8. Collaborate
292
- - Present the draft to the user
293
- - Iterate based on feedback
294
- - Do NOT proceed to plan stage without user approval
295
-
296
- ### 9. Validate
297
- - Verify `.feature` files have valid Gherkin syntax
298
- - Verify MADR records have valid YAML frontmatter (status, date)
299
- - Verify manifest is complete and accurate
300
- - Every Feature has a user story
301
- - Every Scenario has at least Given + When + Then
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).
224
+ **Contract documentation is mandatory for external APIs.** Every endpoint must document `request` (what you send), `response` (fields you read, `required: true` for those your code depends on), and `error_response` (the error shape you handle). Downstream skills generate contract tests from this. If you don't know the exact shape, reference `schema_ref` and document the subset your client uses — that subset is the contract. No data impact → skip `data.yml` entirely.
225
+
226
+ **Manifest (`manifest.md`).** Generate it from `draft.md` as the durable plan-input glue: `complexity` (just scored), Why + Non-goals, the artifact list (added/modified/removed features, decisions, constraints), and a **Prior Art** section summarizing step 3's research (what was found/evaluated, why adopt/build/hybrid; if building, what's borrowed). **Level 3–4** also carry **Assumptions** (what must be true; mark evidence vs. unvalidated; flag unvalidated ones on the critical path) and a **Pre-Mortem** (2–5 plausible failure modes 6 months out, with mitigations or "accepted"). These come straight from the `draft.md` Decided/Open and Cut sections.
227
+
228
+ **Do NOT delete `draft.md`.** Retain it read-only as the agreed reference through plan → … → apply. `grimoire-apply` removes it with the change folder at finalize.
229
+
230
+ ### 8. Validate (at projection)
231
+
232
+ - `.feature` files have valid Gherkin; every Feature has a user story; every Scenario has at least Given + When + Then.
233
+ - MADR records have valid YAML frontmatter (status, date).
234
+ - Manifest is complete and accurate; `complexity` is set.
235
+ - **Re-run the admission test on every scenario you wrote**: external actor, observable, domain language, survives reimplementation. Any scenario that now fails is slop — move it to `constraints.md` or a MADR.
236
+ - **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, no artifact created past the stated scope (KISS). Note: `draft.md` co-existing with the homes is **not** a DRY violation — it is the (soon-deleted) source the homes were projected from, not a parallel authority.
305
237
 
306
238
  ## Important
307
239
  - ONE change at a time. Don't combine unrelated changes.
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.
311
- - The manifest is lightweight glue don't over-document. Just enough to capture why.
312
- - Always check if a capability/feature already exists before creating a new one.
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.
240
+ - **`draft.md` is the only surface you design on.** Features, constraints, MADRs, and the manifest are **generated from it** at projection never authored by hand in parallel during design.
241
+ - **Features describe actor-observable behavior, not implementation, and not invariants.** No external actor, not observable, or names a library/log-level/table it's a constraint (→ `constraints.md`) or a decision (→ MADR). This is the #1 source of feature-file slop.
242
+ - **One fact, one home** (`../references/principles.md`). A capability lives in one `.feature`; a control in one constraint row; a decision in one MADR. Never the same fact in two homes (at rest).
243
+ - Decisions live in **one inline ledger** in `draft.md` while designing; they project to separate MADRs only at step 7. This is how coupled decisions stay legible during the thinking.
244
+ - Artifacts (post-projection) are edited **live on the branch** — never copied into `.grimoire/changes/`. `git diff` is the staging area.
245
+ - **Figma access token is read from `FIGMA_ACCESS_TOKEN` by the MCP server.** Never log it, never write it to config or any artifact (`manifest.md`, `consult.md`, `figma-snapshot.json`, `draft.md`). The MCP handles auth transparently.
314
246
 
315
247
  ## Done
316
- When the user approves the draft, the workflow is complete. Present the change directory path and suggest next steps:
248
+ When the user approves the design and it has been projected, the workflow is complete.
249
+ `draft.md` remains as reference until `grimoire-apply` clears it. Present the change
250
+ directory path and suggest next steps:
317
251
  - `grimoire-plan` to generate implementation tasks
318
- - Or further iteration if the user wants changes
252
+ - Or further iteration on `draft.md` if the user wants changes
@@ -63,14 +63,11 @@ These are gates, not aspirations — a task that adds a duplicate home or a rein
63
63
 
64
64
  ### 2. Read All Artifacts
65
65
 
66
- **Grimoire docs first, codebase second.** The `.grimoire/docs/` directory is a pre-computed map of the codebase — it tells you where code lives, what utilities exist, what patterns to follow, and what the data layer looks like. Read these *instead of* exploring the raw codebase. Only read specific source files when the docs don't have what you need.
66
+ Read the change's artifacts following `../references/artifact-map.md` — it defines what each file is, the grimoire-docs-first / graph-for-structure discipline, and the staleness gate. Plan-specific reading on top of that:
67
67
 
68
- **Always read:**
69
- - `manifest.md` for the change summary, **including complexity level, Assumptions, Pre-Mortem, and Prior Art sections**
70
- - All `.feature` files for this change (edited live in `features/` on the branch)
71
- - All decision records for this change (edited live in `.grimoire/decisions/`), **including Cost of Ownership sections**
72
- - `.grimoire/docs/constraints.md` — any constraints (security/NFR/observability) this change adds or touches. These produce `unit-invariant` tasks, not scenarios.
73
- - The current baseline (`features/`, `.grimoire/decisions/`) via `git diff main` to see exactly what this change adds vs. what already existed
68
+ - `.grimoire/docs/constraints.md` — any constraints (security/NFR/observability) this change touches. These produce `unit-invariant` tasks, not scenarios.
69
+ - The current baseline (`features/`, `.grimoire/decisions/`) via `git diff main` exactly what this change adds vs. what already existed.
70
+ - Existing duplication in areas you're touching — `search_graph` for similar functions, or `grimoire health` (its `duplicates` metric) so tasks consolidate rather than clone.
74
71
 
75
72
  **Validate the build-vs-buy decision:**
76
73
  - Check that `manifest.md` has a **Prior Art** section documenting what existing solutions were researched. If it's missing or empty, **stop and tell the user** — planning without a build-vs-buy analysis produces plans that ignore cheaper alternatives.
@@ -78,27 +75,6 @@ These are gates, not aspirations — a task that adds a duplicate home or a rein
78
75
  - If the decision was to **build custom**, verify the manifest documents (1) what existing tools were considered, (2) the specific requirements they don't meet, and (3) what design patterns are being borrowed from prior art.
79
76
  - If the decision was **hybrid** (adopt for part, build for part), ensure the boundary between adopted and custom code is clear in the tasks.
80
77
 
81
- **Read from grimoire docs (these replace codebase exploration):**
82
- - **`.grimoire/docs/<area>.md`** for each area the change touches — these contain Purpose, Boundaries, Conventions (naming/structure), and "Where New Code Goes" guidance. For key files, exact symbols, reusable utilities (function names, file paths, line numbers), and call graphs, **query the graph** — `search_graph` / `get_code_snippet` / `get_architecture`. Area docs give you intent and placement; the graph gives you the live structure to write exact file paths and reuse existing code.
83
- - **`.grimoire/docs/data/schema.yml`** — the full data model: every table/collection, field types, relationships, indexes, and external API contracts with `source:` pointers to ORM code. Read this instead of reading individual model files.
84
- - **`.grimoire/docs/context.yml`** — the project's deployment environment, related services, infrastructure dependencies, CI/CD pipelines, and observability setup. Read this to understand deployment constraints (e.g., Lambda means no long-running processes, Kubernetes means you may need health check endpoints), cross-service boundaries (e.g., auth is handled by a sibling service, not this project), and infrastructure available at runtime (e.g., Redis is available for caching, RabbitMQ for async tasks).
85
- - Existing duplication in areas you're touching — query codebase-memory-mcp (`search_graph` for similar functions) or run `grimoire health` (its config-driven `duplicates` metric) so tasks consolidate rather than add more clones.
86
-
87
- **Read proposed data changes:**
88
- - **`data.yml`** if present — proposed schema changes need migration and model tasks
89
-
90
- **Staleness gate:** For each area doc loaded, check its `last_updated` date against `git log -1 --format=%ci <directory>`. If any doc is older than the most recent commit to its directory, it's stale — the file paths, utility names, and patterns it describes may no longer be accurate.
91
-
92
- - **Level 1-2:** Warn ("Area doc for `<area>` is behind recent commits — its boundaries/conventions may be wrong; rely on the graph for structure") and proceed. Note inferred paths with `<!-- inferred: area doc may be stale -->`.
93
- - **Level 3-4:** Treat as a blocker. Do not generate tasks until the user refreshes stale docs via `grimoire-discover` targeted refresh. Planning with stale docs at this complexity produces wrong file paths and misses recent utilities — the cost of re-planning outweighs the cost of refreshing first.
94
-
95
- **Read specific source files only when:**
96
- - Area docs don't exist yet (tell the user to run `/grimoire:discover` first — planning without area docs produces worse tasks)
97
- - Area docs exist but you need to verify a specific implementation detail (e.g., exact function signature, exact import path)
98
- - You need to read existing step definitions to understand the test setup
99
-
100
- **Do NOT read the entire codebase** for "context." The plan skill's job is to produce tasks with specific file paths and specific assertions. Area docs + data schema give you this. Reading dozens of source files wastes context window and doesn't produce better plans.
101
-
102
78
  ### 3. Check Specification Completeness
103
79
 
104
80
  Before generating tasks, evaluate whether the specifications are detailed enough to plan against. Underspecified requirements produce vague tasks, which produce wrong code.
@@ -71,6 +71,7 @@ If present:
71
71
  If no `Change:` trailer exists, that's itself a finding for a grimoire-managed repo: flag as **suggestion** ("commits missing audit trailer — `grimoire trace` won't find this PR") unless the project clearly doesn't use grimoire.
72
72
 
73
73
  ### 4. Gather Project Context
74
+ See `../references/artifact-map.md` for what each artifact is and the grimoire-docs-first / staleness discipline.
74
75
  - `.grimoire/config.yaml` — language, tools, `commit_style`, `comment_style`, `project.compliance`, `dep_audit`
75
76
  - `.grimoire/docs/context.yml` — deployment environment, related services
76
77
  - `.grimoire/docs/data/schema.yml` — current data baseline
@@ -209,7 +209,7 @@ For each item the user approves to fix:
209
209
  4. Hand off to `/grimoire:plan` for task generation, then `/grimoire:apply` for implementation
210
210
 
211
211
  **Refactoring-specific guidance for the plan/apply stages:**
212
- - **All existing tests must keep passing.** A refactoring that breaks tests is not a refactoring.
212
+ - **Capture a baseline first, then keep it.** Apply records which tests were already failing at change start (`baseline.md`, see `../references/test-baseline.md`). For a refactor this is the whole safety net: "passing" means *no new failures vs the baseline*, not "zero failures." A test red before you started is pre-existing and accepted; a test you turn red is the refactor breaking behavior — and that means it's not a refactoring. Diff against the baseline after each incremental move.
213
213
  - **Prefer incremental moves over big-bang rewrites.** Move one function at a time, run tests after each move.
214
214
  - **Add tests before refactoring if test debt is part of the item.** You need a safety net before restructuring.
215
215
  - **Update imports incrementally.** When moving code to a new module, re-export from the old location first, then update consumers, then remove the re-export.
@@ -42,7 +42,7 @@ This step is optional. The user can skip it by saying "skip review" or "go strai
42
42
  - If only one, confirm it
43
43
 
44
44
  ### 2. Gather Context
45
- Read all artifacts for the change:
45
+ Read all artifacts for the change — see `../references/artifact-map.md` for what each is and the grimoire-docs-first / staleness discipline:
46
46
  - `manifest.md` — change summary, scope, **and Prior Art section** (build-vs-buy rationale)
47
47
  - All `.feature` files — behavioral specifications
48
48
  - All decision records — architectural choices