@kiwidata/grimoire 0.1.1

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 (215) hide show
  1. package/.claude-plugin/plugin.json +8 -0
  2. package/AGENTS.md +217 -0
  3. package/README.md +748 -0
  4. package/bin/grimoire.js +2 -0
  5. package/dist/cli/index.d.ts +2 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +42 -0
  8. package/dist/cli/index.js.map +1 -0
  9. package/dist/commands/archive.d.ts +3 -0
  10. package/dist/commands/archive.d.ts.map +1 -0
  11. package/dist/commands/archive.js +22 -0
  12. package/dist/commands/archive.js.map +1 -0
  13. package/dist/commands/branch-check.d.ts +3 -0
  14. package/dist/commands/branch-check.d.ts.map +1 -0
  15. package/dist/commands/branch-check.js +16 -0
  16. package/dist/commands/branch-check.js.map +1 -0
  17. package/dist/commands/check.d.ts +3 -0
  18. package/dist/commands/check.d.ts.map +1 -0
  19. package/dist/commands/check.js +22 -0
  20. package/dist/commands/check.js.map +1 -0
  21. package/dist/commands/ci.d.ts +3 -0
  22. package/dist/commands/ci.d.ts.map +1 -0
  23. package/dist/commands/ci.js +18 -0
  24. package/dist/commands/ci.js.map +1 -0
  25. package/dist/commands/diff.d.ts +3 -0
  26. package/dist/commands/diff.d.ts.map +1 -0
  27. package/dist/commands/diff.js +10 -0
  28. package/dist/commands/diff.js.map +1 -0
  29. package/dist/commands/docs.d.ts +3 -0
  30. package/dist/commands/docs.d.ts.map +1 -0
  31. package/dist/commands/docs.js +11 -0
  32. package/dist/commands/docs.js.map +1 -0
  33. package/dist/commands/health.d.ts +3 -0
  34. package/dist/commands/health.d.ts.map +1 -0
  35. package/dist/commands/health.js +13 -0
  36. package/dist/commands/health.js.map +1 -0
  37. package/dist/commands/init.d.ts +3 -0
  38. package/dist/commands/init.d.ts.map +1 -0
  39. package/dist/commands/init.js +21 -0
  40. package/dist/commands/init.js.map +1 -0
  41. package/dist/commands/list.d.ts +3 -0
  42. package/dist/commands/list.d.ts.map +1 -0
  43. package/dist/commands/list.js +22 -0
  44. package/dist/commands/list.js.map +1 -0
  45. package/dist/commands/log.d.ts +3 -0
  46. package/dist/commands/log.d.ts.map +1 -0
  47. package/dist/commands/log.js +15 -0
  48. package/dist/commands/log.js.map +1 -0
  49. package/dist/commands/map.d.ts +3 -0
  50. package/dist/commands/map.d.ts.map +1 -0
  51. package/dist/commands/map.js +17 -0
  52. package/dist/commands/map.js.map +1 -0
  53. package/dist/commands/pr.d.ts +3 -0
  54. package/dist/commands/pr.d.ts.map +1 -0
  55. package/dist/commands/pr.js +17 -0
  56. package/dist/commands/pr.js.map +1 -0
  57. package/dist/commands/status.d.ts +3 -0
  58. package/dist/commands/status.d.ts.map +1 -0
  59. package/dist/commands/status.js +12 -0
  60. package/dist/commands/status.js.map +1 -0
  61. package/dist/commands/test-quality.d.ts +3 -0
  62. package/dist/commands/test-quality.d.ts.map +1 -0
  63. package/dist/commands/test-quality.js +37 -0
  64. package/dist/commands/test-quality.js.map +1 -0
  65. package/dist/commands/trace.d.ts +3 -0
  66. package/dist/commands/trace.d.ts.map +1 -0
  67. package/dist/commands/trace.js +12 -0
  68. package/dist/commands/trace.js.map +1 -0
  69. package/dist/commands/update.d.ts +3 -0
  70. package/dist/commands/update.d.ts.map +1 -0
  71. package/dist/commands/update.js +22 -0
  72. package/dist/commands/update.js.map +1 -0
  73. package/dist/commands/validate.d.ts +3 -0
  74. package/dist/commands/validate.d.ts.map +1 -0
  75. package/dist/commands/validate.js +17 -0
  76. package/dist/commands/validate.js.map +1 -0
  77. package/dist/core/archive.d.ts +9 -0
  78. package/dist/core/archive.d.ts.map +1 -0
  79. package/dist/core/archive.js +92 -0
  80. package/dist/core/archive.js.map +1 -0
  81. package/dist/core/branch-check.d.ts +27 -0
  82. package/dist/core/branch-check.d.ts.map +1 -0
  83. package/dist/core/branch-check.js +205 -0
  84. package/dist/core/branch-check.js.map +1 -0
  85. package/dist/core/check.d.ts +24 -0
  86. package/dist/core/check.d.ts.map +1 -0
  87. package/dist/core/check.js +372 -0
  88. package/dist/core/check.js.map +1 -0
  89. package/dist/core/ci.d.ts +24 -0
  90. package/dist/core/ci.d.ts.map +1 -0
  91. package/dist/core/ci.js +162 -0
  92. package/dist/core/ci.js.map +1 -0
  93. package/dist/core/detect.d.ts +10 -0
  94. package/dist/core/detect.d.ts.map +1 -0
  95. package/dist/core/detect.js +368 -0
  96. package/dist/core/detect.js.map +1 -0
  97. package/dist/core/diff.d.ts +29 -0
  98. package/dist/core/diff.d.ts.map +1 -0
  99. package/dist/core/diff.js +197 -0
  100. package/dist/core/diff.js.map +1 -0
  101. package/dist/core/doc-style.d.ts +16 -0
  102. package/dist/core/doc-style.d.ts.map +1 -0
  103. package/dist/core/doc-style.js +192 -0
  104. package/dist/core/doc-style.js.map +1 -0
  105. package/dist/core/docs.d.ts +6 -0
  106. package/dist/core/docs.d.ts.map +1 -0
  107. package/dist/core/docs.js +478 -0
  108. package/dist/core/docs.js.map +1 -0
  109. package/dist/core/health.d.ts +7 -0
  110. package/dist/core/health.d.ts.map +1 -0
  111. package/dist/core/health.js +489 -0
  112. package/dist/core/health.js.map +1 -0
  113. package/dist/core/hooks.d.ts +5 -0
  114. package/dist/core/hooks.d.ts.map +1 -0
  115. package/dist/core/hooks.js +168 -0
  116. package/dist/core/hooks.js.map +1 -0
  117. package/dist/core/init.d.ts +9 -0
  118. package/dist/core/init.d.ts.map +1 -0
  119. package/dist/core/init.js +563 -0
  120. package/dist/core/init.js.map +1 -0
  121. package/dist/core/list.d.ts +4 -0
  122. package/dist/core/list.d.ts.map +1 -0
  123. package/dist/core/list.js +170 -0
  124. package/dist/core/list.js.map +1 -0
  125. package/dist/core/log.d.ts +8 -0
  126. package/dist/core/log.d.ts.map +1 -0
  127. package/dist/core/log.js +150 -0
  128. package/dist/core/log.js.map +1 -0
  129. package/dist/core/map.d.ts +9 -0
  130. package/dist/core/map.d.ts.map +1 -0
  131. package/dist/core/map.js +302 -0
  132. package/dist/core/map.js.map +1 -0
  133. package/dist/core/pr.d.ts +9 -0
  134. package/dist/core/pr.d.ts.map +1 -0
  135. package/dist/core/pr.js +273 -0
  136. package/dist/core/pr.js.map +1 -0
  137. package/dist/core/shared-setup.d.ts +52 -0
  138. package/dist/core/shared-setup.d.ts.map +1 -0
  139. package/dist/core/shared-setup.js +221 -0
  140. package/dist/core/shared-setup.js.map +1 -0
  141. package/dist/core/status.d.ts +6 -0
  142. package/dist/core/status.d.ts.map +1 -0
  143. package/dist/core/status.js +114 -0
  144. package/dist/core/status.js.map +1 -0
  145. package/dist/core/test-quality.d.ts +33 -0
  146. package/dist/core/test-quality.d.ts.map +1 -0
  147. package/dist/core/test-quality.js +378 -0
  148. package/dist/core/test-quality.js.map +1 -0
  149. package/dist/core/trace.d.ts +6 -0
  150. package/dist/core/trace.d.ts.map +1 -0
  151. package/dist/core/trace.js +211 -0
  152. package/dist/core/trace.js.map +1 -0
  153. package/dist/core/update.d.ts +10 -0
  154. package/dist/core/update.d.ts.map +1 -0
  155. package/dist/core/update.js +149 -0
  156. package/dist/core/update.js.map +1 -0
  157. package/dist/core/validate.d.ts +20 -0
  158. package/dist/core/validate.d.ts.map +1 -0
  159. package/dist/core/validate.js +275 -0
  160. package/dist/core/validate.js.map +1 -0
  161. package/dist/index.d.ts +19 -0
  162. package/dist/index.d.ts.map +1 -0
  163. package/dist/index.js +20 -0
  164. package/dist/index.js.map +1 -0
  165. package/dist/utils/config.d.ts +61 -0
  166. package/dist/utils/config.d.ts.map +1 -0
  167. package/dist/utils/config.js +172 -0
  168. package/dist/utils/config.js.map +1 -0
  169. package/dist/utils/fs.d.ts +17 -0
  170. package/dist/utils/fs.d.ts.map +1 -0
  171. package/dist/utils/fs.js +38 -0
  172. package/dist/utils/fs.js.map +1 -0
  173. package/dist/utils/paths.d.ts +10 -0
  174. package/dist/utils/paths.d.ts.map +1 -0
  175. package/dist/utils/paths.js +35 -0
  176. package/dist/utils/paths.js.map +1 -0
  177. package/dist/utils/spawn.d.ts +5 -0
  178. package/dist/utils/spawn.d.ts.map +1 -0
  179. package/dist/utils/spawn.js +34 -0
  180. package/dist/utils/spawn.js.map +1 -0
  181. package/package.json +68 -0
  182. package/skills/grimoire-apply/SKILL.md +274 -0
  183. package/skills/grimoire-audit/SKILL.md +129 -0
  184. package/skills/grimoire-branch-guard/SKILL.md +111 -0
  185. package/skills/grimoire-bug/SKILL.md +160 -0
  186. package/skills/grimoire-bug-explore/SKILL.md +242 -0
  187. package/skills/grimoire-bug-report/SKILL.md +237 -0
  188. package/skills/grimoire-bug-session/SKILL.md +222 -0
  189. package/skills/grimoire-bug-triage/SKILL.md +274 -0
  190. package/skills/grimoire-commit/SKILL.md +150 -0
  191. package/skills/grimoire-discover/SKILL.md +297 -0
  192. package/skills/grimoire-draft/SKILL.md +202 -0
  193. package/skills/grimoire-plan/SKILL.md +329 -0
  194. package/skills/grimoire-pr/SKILL.md +134 -0
  195. package/skills/grimoire-pr-review/SKILL.md +240 -0
  196. package/skills/grimoire-refactor/SKILL.md +251 -0
  197. package/skills/grimoire-remove/SKILL.md +112 -0
  198. package/skills/grimoire-review/SKILL.md +247 -0
  199. package/skills/grimoire-verify/SKILL.md +223 -0
  200. package/skills/references/bug-classification.md +154 -0
  201. package/skills/references/build-vs-buy.md +77 -0
  202. package/skills/references/elicitation-personas.md +118 -0
  203. package/skills/references/refactor-register-format.md +88 -0
  204. package/skills/references/refactor-scan-categories.md +102 -0
  205. package/skills/references/schema-format.md +68 -0
  206. package/skills/references/security-compliance.md +110 -0
  207. package/skills/references/testing-contracts.md +93 -0
  208. package/templates/context.yml +110 -0
  209. package/templates/debt-exceptions.yml +61 -0
  210. package/templates/decision.md +50 -0
  211. package/templates/dupignore +93 -0
  212. package/templates/example.feature +24 -0
  213. package/templates/manifest.md +29 -0
  214. package/templates/mapignore +58 -0
  215. package/templates/mapkeys +65 -0
@@ -0,0 +1,274 @@
1
+ ---
2
+ name: grimoire-bug-triage
3
+ description: Triage bug reports — classify the root cause, route to the right team (code, infra, config, data, third-party, docs), and communicate decisions back. Reads from local reports or external tickets via MCP. Use when picking up a bug report.
4
+ compatibility: Designed for Claude Code (or similar products)
5
+ metadata:
6
+ author: kiwi-data
7
+ version: "0.1"
8
+ ---
9
+
10
+ # grimoire-bug-triage
11
+
12
+ Triage bug reports from any source. Investigate, classify the root cause, decide what to do, and route to the right owner. Not every bug is a code defect — triage must distinguish between code, infrastructure, configuration, data, third-party, and documentation issues so the right team acts on it.
13
+
14
+ ## Triggers
15
+ - User wants to triage a bug report
16
+ - User says "triage this bug", "look at this bug report", "is this a real bug?"
17
+ - User provides a ticket URL or ID (e.g., "triage PROJ-123", "look at #456")
18
+ - Loose match: "triage", "investigate bug", "check this report", "validate bug", "reject bug", "route this"
19
+
20
+ ## Routing
21
+ - No bug report exists and user is a tester → `grimoire-bug-report` first
22
+ - Developer found a simple bug themselves → `grimoire-bug` directly (skip triage for obvious code defects)
23
+ - Bug needs architectural fix → after triage, route to `grimoire-draft` (not `grimoire-bug`)
24
+
25
+ ## Prerequisites
26
+ - A bug report exists in one of these forms:
27
+ - `.grimoire/bugs/<bug-id>/report.md` (created by `grimoire-bug-report`)
28
+ - An external ticket (Jira, Linear, GitHub Issue) — referenced by URL, ID, or key
29
+ - Pasted text, screenshot, or description from the user
30
+
31
+ ## Workflow
32
+
33
+ ### 1. Read the Report
34
+
35
+ **From local report:** Read `.grimoire/bugs/<bug-id>/report.md` directly.
36
+
37
+ **From external ticket:** Check `.grimoire/config.yaml` for configured `bug_trackers` with MCP servers:
38
+ - **Jira**: use the Jira MCP to fetch the issue by key (e.g., `PROJ-123`). Pull: summary, description, reporter, priority, environment, attachments, comments.
39
+ - **Linear**: use the Linear MCP to fetch the issue. Pull: title, description, assignee, priority, labels, comments.
40
+ - **GitHub Issues**: use the GitHub MCP to fetch the issue by number. Pull: title, body, labels, comments, linked PRs.
41
+ - If multiple trackers are configured, match based on what the user provided (URL domain, key format like `PROJ-`, or `#` prefix for GitHub).
42
+
43
+ Create a local report in `.grimoire/bugs/<bug-id>/report.md` from the external ticket data. Include the `ticket:` field in frontmatter linking back to the source. Don't require the full template — work with what the ticket provides.
44
+
45
+ **From pasted text:** Create a local report from whatever the user provided. Fill in what you can, mark gaps.
46
+
47
+ Understand:
48
+ - What behavior is reported
49
+ - What behavior is expected
50
+ - How to reproduce it
51
+ - What severity the reporter assigned
52
+ - What environment (dev/qa/staging/production)
53
+ - Which feature specs are referenced (if any)
54
+
55
+ ### 2. Investigate
56
+
57
+ Before making a triage decision, gather evidence:
58
+
59
+ 1. **Check the referenced specs** — read the feature scenarios the report mentions. Does the spec clearly describe the expected behavior?
60
+ 2. **Read the relevant code** — find the implementation. Does the code match the spec? Use `codebase-memory-mcp` `search_graph`/`trace_path` if available, otherwise grep for route/view/handler.
61
+ 3. **Try to reproduce** — run the relevant tests: `config.tools.bdd_test` for BDD scenarios, `config.tools.unit_test` for unit tests. If testing tool MCPs are configured (Playwright, Cypress), run the relevant test flow.
62
+ 4. **Check recent changes** — `git log --oneline --since="2 weeks ago" -- <affected-files>`. Was this area changed recently? Could it be a regression?
63
+ 5. **Check environment context** — read `.grimoire/docs/context.yml` for environment differences (data, config, infra).
64
+ 6. **Check external dependencies** — read `schema.yml` for external API contracts. Check provider status pages if applicable.
65
+
66
+ ### 3. Classify the Root Cause
67
+
68
+ Classify the issue using the 8-way taxonomy in `../references/bug-classification.md`. Read it now.
69
+
70
+ The categories are: **code**, **infrastructure**, **configuration**, **data**, **third-party**, **security**, **documentation**, **not-a-bug**. Each has specific signals — match the investigation evidence to the signals.
71
+
72
+ For security-classified issues, use the security-specific severity scale in the reference.
73
+
74
+ ### 4. Make a Triage Decision
75
+
76
+ Based on the classification, one of four outcomes:
77
+
78
+ Follow the triage decision framework in `../references/bug-classification.md` (section "Triage Decision Outcomes").
79
+
80
+ Key points:
81
+ 1. **VALIDATE + ROUTE**: Update status to `validated`, adjust severity if needed, write triage response. Security issues → section 7 (special handling).
82
+ 2. **REJECT**: Requires evidence — cite the spec, document reproduction attempts, or reference the duplicate.
83
+ 3. **REDIRECT**: Behavior is correct, confusion is valid. Recommend docs/UX fix.
84
+ 4. **NEEDS INFO**: Ask specific follow-up questions, not "provide more details."
85
+
86
+ ### 5. Write the Triage Response
87
+
88
+ Create or update `.grimoire/bugs/<bug-id>/triage.md`:
89
+
90
+ ```markdown
91
+ ---
92
+ decision: <validated|rejected|redirected|needs-info>
93
+ classification: <code|infrastructure|configuration|data|third-party|security|documentation|not-a-bug>
94
+ route-to: <team or role responsible for the fix>
95
+ triaged-by: <name or role>
96
+ date: <YYYY-MM-DD>
97
+ severity: <original or reclassified>
98
+ ticket: <external ticket URL or ID, if applicable>
99
+ ---
100
+
101
+ # Triage: <bug-id>
102
+
103
+ ## Decision: <VALIDATED|REJECTED|REDIRECTED|NEEDS INFO>
104
+
105
+ ## Classification: <type>
106
+ <!-- Why this classification? What evidence points to this root cause category? -->
107
+ <reasoning>
108
+
109
+ ## Routing
110
+ <!-- Who should own the fix? Why them? -->
111
+ - **Owner**: <team or role>
112
+ - **Why**: <brief justification — e.g., "infrastructure: staging DB is under-provisioned">
113
+ - **Action needed**: <specific action — e.g., "increase staging RDS instance size" or "fix null check in parseEmail()">
114
+
115
+ ## Investigation Evidence
116
+ <!-- What you found. Be specific — cite files, specs, commits, environment state. -->
117
+ <evidence>
118
+
119
+ ## Severity Assessment
120
+ - Reporter: <severity>
121
+ - Triage: <severity> — <reason if changed>
122
+
123
+ ## Environment Assessment
124
+ - Reported on: <environment>
125
+ - Reproduced on: <environment(s) where confirmed, or "not reproduced">
126
+ - Environment-specific: <yes/no — does this only affect certain environments?>
127
+
128
+ ## Next Steps
129
+ <!-- Depends on classification and decision -->
130
+ <!-- Code: "Proceeding to grimoire-bug for fix" -->
131
+ <!-- Infrastructure: "Ticket created for infra team: <link>" -->
132
+ <!-- Configuration: "Config change needed: set X=Y on staging" -->
133
+ <!-- Data: "Data fix script needed for affected records" -->
134
+ <!-- Third-party: "Vendor issue — workaround in progress, upstream ticket filed" -->
135
+ <!-- Security: "Security fix in progress — confidential until patched" -->
136
+ <!-- Documentation: "Docs update needed — filing improvement ticket" -->
137
+ <!-- Rejected: explanation for the reporter -->
138
+ <!-- Needs info: specific questions for the reporter -->
139
+ ```
140
+
141
+ ### 6. Communicate Back
142
+
143
+ Check `.grimoire/config.yaml` for configured `bug_trackers` with MCP servers.
144
+
145
+ **If the bug came from an external ticket:**
146
+ - Update the original ticket with the triage decision using the appropriate MCP
147
+ - **Validated (code)**: comment with root cause summary, note that a fix is in progress
148
+ - **Validated (non-code)**: comment with classification and routing. If the tracker supports it, reassign to the responsible team or add the appropriate label/component. If the issue needs a different tracker (e.g., infra uses a separate Jira project), offer to create a ticket there and link it.
149
+ - **Validated (security)**: see section 7 — do NOT post vulnerability details in public tickets
150
+ - **Rejected**: comment with the full reasoning and evidence. Transition status if supported.
151
+ - **Redirected**: comment explaining the behavior is correct plus the docs/UX improvement needed. Offer to reclassify the ticket as an improvement rather than closing it.
152
+ - **Needs info**: comment with specific follow-up questions. Assign back to the reporter if possible.
153
+
154
+ **If the bug is local-only but trackers are configured:**
155
+ - Offer to create an external ticket for validated bugs
156
+ - For non-code issues routed elsewhere, offer to create the ticket in the right project/board
157
+ - Update the local report's `ticket:` field with the new ticket reference
158
+
159
+ **If no MCP tools are configured:**
160
+ - Tell the user where the triage response is and let them communicate it manually
161
+
162
+ ### 7. Security Issue Handling
163
+
164
+ Security-classified issues follow a restricted workflow. The goal is to fix the vulnerability before details become widely known.
165
+
166
+ **Confidentiality:**
167
+ - Do NOT post exploit details, reproduction steps, or root cause analysis in public trackers, Slack channels, or anywhere outside the security fix workflow
168
+ - If the source ticket is in a public tracker (e.g., public GitHub repo), comment only with: "Confirmed. Fix in progress. Details shared privately with the security team."
169
+ - Use private channels: GitHub security advisories, private Jira projects, direct messages, or whatever the team's private security reporting channel is
170
+ - The local `.grimoire/bugs/<bug-id>/` directory is the detailed record — it stays local
171
+
172
+ **Assessment:**
173
+ Include in the triage response:
174
+ - **Attack vector** — how could this be exploited? (network, local, physical, requires auth?)
175
+ - **Impact** — what's the worst case? (data breach, account takeover, service disruption, information disclosure)
176
+ - **Exploitability** — how easy is it to exploit? (trivial, requires specific conditions, theoretical)
177
+ - **Affected environments** — is this exploitable in production right now?
178
+ - **Data at risk** — what data could be exposed or modified? Is it PII, financial, credentials?
179
+
180
+ **Routing:**
181
+ 1. Notify the security lead or security team immediately — don't wait for the normal triage queue
182
+ 2. If severity is critical or high AND the vulnerability is exploitable on production:
183
+ - Flag for emergency fix (hotfix branch, expedited review)
184
+ - Consider whether the vulnerability needs to be mitigated immediately (e.g., disable the affected endpoint, enable a WAF rule, rotate exposed credentials)
185
+ 3. The code fix goes through `grimoire-bug` but with restricted visibility:
186
+ - Fix branch should use a non-descriptive name (e.g., `fix/auth-edge-case` not `fix/idor-user-data-exposed`)
187
+ - PR description should be minimal until the fix is deployed
188
+ - After deployment, the full details can be added to the commit history and the ticket
189
+
190
+ **After the fix:**
191
+ 1. Verify the fix on all affected environments
192
+ 2. If credentials or secrets were exposed, rotate them
193
+ 3. If user data was at risk, assess whether disclosure or notification is required (legal/compliance team decision)
194
+ 4. Update the bug report with the full timeline: reported → triaged → fixed → deployed → disclosed
195
+ 5. Consider whether a post-mortem is needed (usually yes for critical/high)
196
+ 6. Update documentation or add security test scenarios to prevent recurrence
197
+
198
+ ### 8. Hand Off (Non-Security)
199
+
200
+ Depends on classification:
201
+
202
+ **Code defect (small fix)** → `grimoire-bug` takes over:
203
+ 1. The triage response becomes context for the fix
204
+ 2. The developer already has root cause understanding from investigation
205
+ 3. `grimoire-bug` runs: write repro test → fix → verify
206
+ 4. When complete, update bug report status to `fixed` and reference the fix commit
207
+ 5. If an external ticket exists, update it (add fix commit, transition to resolved)
208
+
209
+ **Code defect (needs architectural changes)** → `grimoire-draft` takes over:
210
+
211
+ If the fix requires significant structural changes (new abstractions, schema changes, cross-cutting modifications), it's not a bug fix — it's a change that needs proper design. Generate a draft manifest stub to hand off context:
212
+
213
+ 1. Create `.grimoire/changes/<change-id>/manifest.md` with:
214
+ ```markdown
215
+ ---
216
+ id: <change-id>
217
+ type: bug-driven-change
218
+ source-bug: <bug-id>
219
+ status: proposed
220
+ date: <YYYY-MM-DD>
221
+ ---
222
+
223
+ # <short description of the change needed>
224
+
225
+ ## Origin
226
+ Bug report: `.grimoire/bugs/<bug-id>/report.md`
227
+ Triage: `.grimoire/bugs/<bug-id>/triage.md`
228
+
229
+ ## Problem
230
+ <root cause summary from triage — why a simple fix isn't enough>
231
+
232
+ ## Violated Specs
233
+ <copy from bug report — which feature scenarios describe the expected behavior>
234
+
235
+ ## Scope
236
+ <what needs to change architecturally — from the triage investigation>
237
+
238
+ ## Context for Draft
239
+ <!-- grimoire-draft should pick up from here -->
240
+ - The bug report has the user-facing symptoms
241
+ - The triage has the root cause analysis and investigation evidence
242
+ - The violated specs define what "correct" looks like
243
+ ```
244
+ 2. Update the bug report status to `routed-to-draft`
245
+ 3. Tell the user: "This needs a proper design change. I've created a draft stub at `<path>` with the bug context. Run `grimoire-draft` to continue."
246
+
247
+ **Infrastructure / Configuration / Data** → the fix happens outside grimoire:
248
+ 1. Ensure a ticket exists for the responsible team with all the triage evidence
249
+ 2. Set the local bug report status to `routed`
250
+ 3. Optionally: if a config change or data fix can be done from this repo (e.g., Terraform, Helm values, migration scripts), offer to help — but flag that this isn't a code bug and should be reviewed by the responsible team
251
+
252
+ **Third-party** → two tracks:
253
+ 1. Short-term: can a workaround be implemented in our code? If yes, treat like a code fix via `grimoire-bug`
254
+ 2. Long-term: file upstream (vendor support ticket, GitHub issue on the library). Document the workaround and the upstream reference.
255
+
256
+ **Documentation** → outside grimoire's core workflow:
257
+ 1. Note the docs/UX improvement needed
258
+ 2. Offer to create a ticket for it
259
+ 3. Mark the bug report as `redirected`
260
+
261
+ ## Important
262
+ - **Classify before routing.** The whole point of triage is figuring out who should own this. Dumping every issue on developers wastes their time and delays real fixes.
263
+ - **Non-code issues are still real issues.** "It's not a code bug" is not the same as "it's not a problem." Infrastructure, config, and data issues need owners and fixes too.
264
+ - **Security issues are confidential by default.** Don't share exploit details publicly until the fix is deployed. When in doubt, treat it as security.
265
+ - **Rejection is not dismissal.** A well-reasoned rejection with evidence is respectful. A lazy rejection breeds distrust.
266
+ - **Don't skip investigation.** Reading the report and immediately saying "this is infra" without checking is not triage. Look at the code, the config, the environment.
267
+ - **Severity can change.** The reporter sees symptoms. Triage sees root cause. A "minor" report might reveal a critical data integrity issue. A "critical" report might be a cosmetic rendering glitch.
268
+ - **Environment context drives classification.** "Works in dev, broken in prod" is almost certainly config or infra, not code. "Broken everywhere" is almost certainly code.
269
+ - **Keep the audit trail.** Every triage decision is written down with classification, routing, and reasoning. This prevents the same issue from being triaged three times by three people.
270
+ - **One triage per bug.** If new information arrives after a "needs info" response, update the existing triage — don't create a new one.
271
+ - **Sync both directions.** If you update the local triage, update the external ticket. If the external ticket gets new comments, incorporate them.
272
+
273
+ ## Done
274
+ When the triage response is written and communicated, the workflow is complete. The bug is now classified, routed, and documented. Next steps depend on classification — the triage response specifies the handoff.
@@ -0,0 +1,150 @@
1
+ ---
2
+ name: grimoire-commit
3
+ description: Write a contextual commit message from staged changes and active grimoire change context. Use when the user asks to commit or after completing a task.
4
+ compatibility: Designed for Claude Code (or similar products)
5
+ metadata:
6
+ author: kiwi-data
7
+ version: "0.1"
8
+ ---
9
+
10
+ # grimoire-commit
11
+
12
+ Write a commit message from staged changes and active grimoire context. Never auto-commit — always present for approval.
13
+
14
+ ## Triggers
15
+ - User asks to commit, write a commit message, or prepare a commit
16
+ - User asks to stage and commit changes
17
+ - Loose match: "commit", "commit message", "stage", "save progress"
18
+
19
+ ## Routing
20
+ - No changes to commit → nothing to do
21
+ - Want to create a PR → `grimoire-pr` (commit first, then PR)
22
+ - Want to review changes before committing → show the diff first
23
+
24
+ ## Workflow
25
+
26
+ ### 1. Gather Context
27
+ - Run `git diff --cached` to read staged changes (if nothing staged, check `git diff` for unstaged changes and ask if user wants to stage)
28
+ - Read `.grimoire/config.yaml` to get `commit_style` setting
29
+ - Find active grimoire change: scan `.grimoire/changes/*/manifest.md`
30
+ - Read `tasks.md` from the active change if it exists — note which tasks are being completed
31
+ - Note any modified `.feature` files or decision records
32
+
33
+ ### 2. Analyze Changes
34
+ From the diff, determine:
35
+ - **Type**: feat, fix, refactor, docs, test, chore, build, ci, style, perf
36
+ - **Scope**: infer from the directories/modules changed (e.g., auth, api, models)
37
+ - **Summary**: what changed and why
38
+ - **Grimoire context**: which change ID, which scenarios affected, which decisions
39
+
40
+ ### 3. Generate Commit Message
41
+
42
+ **Conventional commits (default):**
43
+ ```
44
+ <type>(<scope>): <short description>
45
+
46
+ <body — what changed and why, referencing grimoire context>
47
+
48
+ Change: <change-id>
49
+ Scenarios: <affected scenario names>
50
+ Decisions: <affected ADR numbers>
51
+ ```
52
+
53
+ **Angular style:**
54
+ Same structure as conventional commits with stricter type enforcement:
55
+ - feat, fix, docs, style, refactor, perf, test, build, ci, chore
56
+
57
+ **Custom:**
58
+ If `commit_style` in config is anything else, read it as a format hint and adapt.
59
+
60
+ ### 4. Quality Rules
61
+ - First line under 72 characters
62
+ - Body explains WHY, not just WHAT (the diff shows what)
63
+ - Use imperative mood ("add", "fix", "update" — not "added", "fixes", "updated")
64
+ - Don't include file lists in the commit message — `git log --stat` shows that
65
+ - If multiple logical changes are staged, suggest splitting into separate commits
66
+
67
+ ### 5. Git Trailers (mandatory for audit trail)
68
+ 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
+
70
+ ```
71
+ Change: add-2fa-login
72
+ Scenarios: "Login with valid TOTP code", "Login with expired TOTP code"
73
+ Decisions: 0003-totp-library
74
+ ```
75
+
76
+ - `Change:` is **required** when committing during an active grimoire change
77
+ - `Scenarios:` and `Decisions:` are included when relevant
78
+ - These are standard git trailers (parsed by `git log --format="%(trailers)"`)
79
+ - The bug skill should also include `Change:` if a scenario was added to cover a spec gap
80
+ - Commits outside grimoire changes (config, deps, formatting) don't need trailers
81
+
82
+ ### 6. Branch Naming
83
+ If no branch exists for the change yet, suggest creating one before committing:
84
+
85
+ ```
86
+ <type>/<change-id>
87
+ ```
88
+
89
+ Where `<type>` matches the commit type:
90
+ - `feat/add-2fa-login` — new feature
91
+ - `fix/handle-null-pricing` — bug fix
92
+ - `refactor/migrate-to-sqlalchemy` — refactoring
93
+ - `chore/update-dependencies` — maintenance
94
+
95
+ The branch name links the git history to the grimoire change. Create the branch before the first commit for a change:
96
+ ```
97
+ git checkout -b feat/<change-id>
98
+ ```
99
+
100
+ ### 7. Present to User
101
+ Show the proposed commit message and offer:
102
+ - **Accept** — run `git commit` with the message
103
+ - **Edit** — user modifies the message, then commit
104
+ - **Cancel** — abort, nothing happens
105
+
106
+ If the user accepts, execute:
107
+ ```
108
+ git commit -m "<message>"
109
+ ```
110
+
111
+ ## Examples
112
+
113
+ **Feature implementation (with grimoire context):**
114
+ ```
115
+ feat(auth): add TOTP verification for two-factor login
116
+
117
+ Implement TOTP code verification using pyotp. Step definitions
118
+ cover both valid and expired code scenarios.
119
+
120
+ Change: add-2fa-login
121
+ Scenarios: "Login with valid TOTP code", "Login with expired TOTP code"
122
+ ```
123
+
124
+ **Bug fix (no grimoire context):**
125
+ ```
126
+ fix(api): handle null response from external pricing service
127
+
128
+ The pricing API occasionally returns null for discontinued items.
129
+ Added null check before accessing price field.
130
+ ```
131
+
132
+ **Refactoring (with decision reference):**
133
+ ```
134
+ refactor(db): migrate from raw SQL to SQLAlchemy ORM
135
+
136
+ Follows decision in 0005-adopt-sqlalchemy.md. Converts all
137
+ direct SQL queries in the reporting module to ORM equivalents.
138
+
139
+ Decisions: 0005-adopt-sqlalchemy
140
+ ```
141
+
142
+ ## Important
143
+ - **Never auto-commit.** Always present the message for approval first.
144
+ - If no grimoire change is active, still write a good commit message from the diff alone.
145
+ - If the diff is too large to summarize meaningfully, suggest the user split it into smaller commits.
146
+ - The grimoire footer (Change/Scenarios/Decisions) is only included when an active grimoire change exists and is relevant to the staged changes.
147
+ - Respect the project's configured `commit_style` from `.grimoire/config.yaml`.
148
+
149
+ ## Done
150
+ When the commit is created (or the user cancels), the workflow is complete. If this was the last commit for a change, suggest `grimoire-pr` to create a pull request.