@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.
- package/.claude-plugin/plugin.json +8 -0
- package/AGENTS.md +217 -0
- package/README.md +748 -0
- package/bin/grimoire.js +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +42 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/archive.d.ts +3 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +22 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/branch-check.d.ts +3 -0
- package/dist/commands/branch-check.d.ts.map +1 -0
- package/dist/commands/branch-check.js +16 -0
- package/dist/commands/branch-check.js.map +1 -0
- package/dist/commands/check.d.ts +3 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +22 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/ci.d.ts +3 -0
- package/dist/commands/ci.d.ts.map +1 -0
- package/dist/commands/ci.js +18 -0
- package/dist/commands/ci.js.map +1 -0
- package/dist/commands/diff.d.ts +3 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +10 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/docs.d.ts +3 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +11 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/health.d.ts +3 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +13 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +21 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +22 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/log.d.ts +3 -0
- package/dist/commands/log.d.ts.map +1 -0
- package/dist/commands/log.js +15 -0
- package/dist/commands/log.js.map +1 -0
- package/dist/commands/map.d.ts +3 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +17 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/pr.d.ts +3 -0
- package/dist/commands/pr.d.ts.map +1 -0
- package/dist/commands/pr.js +17 -0
- package/dist/commands/pr.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +12 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/test-quality.d.ts +3 -0
- package/dist/commands/test-quality.d.ts.map +1 -0
- package/dist/commands/test-quality.js +37 -0
- package/dist/commands/test-quality.js.map +1 -0
- package/dist/commands/trace.d.ts +3 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +12 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +22 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +17 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/archive.d.ts +9 -0
- package/dist/core/archive.d.ts.map +1 -0
- package/dist/core/archive.js +92 -0
- package/dist/core/archive.js.map +1 -0
- package/dist/core/branch-check.d.ts +27 -0
- package/dist/core/branch-check.d.ts.map +1 -0
- package/dist/core/branch-check.js +205 -0
- package/dist/core/branch-check.js.map +1 -0
- package/dist/core/check.d.ts +24 -0
- package/dist/core/check.d.ts.map +1 -0
- package/dist/core/check.js +372 -0
- package/dist/core/check.js.map +1 -0
- package/dist/core/ci.d.ts +24 -0
- package/dist/core/ci.d.ts.map +1 -0
- package/dist/core/ci.js +162 -0
- package/dist/core/ci.js.map +1 -0
- package/dist/core/detect.d.ts +10 -0
- package/dist/core/detect.d.ts.map +1 -0
- package/dist/core/detect.js +368 -0
- package/dist/core/detect.js.map +1 -0
- package/dist/core/diff.d.ts +29 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +197 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/doc-style.d.ts +16 -0
- package/dist/core/doc-style.d.ts.map +1 -0
- package/dist/core/doc-style.js +192 -0
- package/dist/core/doc-style.js.map +1 -0
- package/dist/core/docs.d.ts +6 -0
- package/dist/core/docs.d.ts.map +1 -0
- package/dist/core/docs.js +478 -0
- package/dist/core/docs.js.map +1 -0
- package/dist/core/health.d.ts +7 -0
- package/dist/core/health.d.ts.map +1 -0
- package/dist/core/health.js +489 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +168 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/init.d.ts +9 -0
- package/dist/core/init.d.ts.map +1 -0
- package/dist/core/init.js +563 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/list.d.ts +4 -0
- package/dist/core/list.d.ts.map +1 -0
- package/dist/core/list.js +170 -0
- package/dist/core/list.js.map +1 -0
- package/dist/core/log.d.ts +8 -0
- package/dist/core/log.d.ts.map +1 -0
- package/dist/core/log.js +150 -0
- package/dist/core/log.js.map +1 -0
- package/dist/core/map.d.ts +9 -0
- package/dist/core/map.d.ts.map +1 -0
- package/dist/core/map.js +302 -0
- package/dist/core/map.js.map +1 -0
- package/dist/core/pr.d.ts +9 -0
- package/dist/core/pr.d.ts.map +1 -0
- package/dist/core/pr.js +273 -0
- package/dist/core/pr.js.map +1 -0
- package/dist/core/shared-setup.d.ts +52 -0
- package/dist/core/shared-setup.d.ts.map +1 -0
- package/dist/core/shared-setup.js +221 -0
- package/dist/core/shared-setup.js.map +1 -0
- package/dist/core/status.d.ts +6 -0
- package/dist/core/status.d.ts.map +1 -0
- package/dist/core/status.js +114 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/test-quality.d.ts +33 -0
- package/dist/core/test-quality.d.ts.map +1 -0
- package/dist/core/test-quality.js +378 -0
- package/dist/core/test-quality.js.map +1 -0
- package/dist/core/trace.d.ts +6 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +211 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/update.d.ts +10 -0
- package/dist/core/update.d.ts.map +1 -0
- package/dist/core/update.js +149 -0
- package/dist/core/update.js.map +1 -0
- package/dist/core/validate.d.ts +20 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +275 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/config.d.ts +61 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +172 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/fs.d.ts +17 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +38 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/paths.d.ts +10 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +35 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/spawn.d.ts +5 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +34 -0
- package/dist/utils/spawn.js.map +1 -0
- package/package.json +68 -0
- package/skills/grimoire-apply/SKILL.md +274 -0
- package/skills/grimoire-audit/SKILL.md +129 -0
- package/skills/grimoire-branch-guard/SKILL.md +111 -0
- package/skills/grimoire-bug/SKILL.md +160 -0
- package/skills/grimoire-bug-explore/SKILL.md +242 -0
- package/skills/grimoire-bug-report/SKILL.md +237 -0
- package/skills/grimoire-bug-session/SKILL.md +222 -0
- package/skills/grimoire-bug-triage/SKILL.md +274 -0
- package/skills/grimoire-commit/SKILL.md +150 -0
- package/skills/grimoire-discover/SKILL.md +297 -0
- package/skills/grimoire-draft/SKILL.md +202 -0
- package/skills/grimoire-plan/SKILL.md +329 -0
- package/skills/grimoire-pr/SKILL.md +134 -0
- package/skills/grimoire-pr-review/SKILL.md +240 -0
- package/skills/grimoire-refactor/SKILL.md +251 -0
- package/skills/grimoire-remove/SKILL.md +112 -0
- package/skills/grimoire-review/SKILL.md +247 -0
- package/skills/grimoire-verify/SKILL.md +223 -0
- package/skills/references/bug-classification.md +154 -0
- package/skills/references/build-vs-buy.md +77 -0
- package/skills/references/elicitation-personas.md +118 -0
- package/skills/references/refactor-register-format.md +88 -0
- package/skills/references/refactor-scan-categories.md +102 -0
- package/skills/references/schema-format.md +68 -0
- package/skills/references/security-compliance.md +110 -0
- package/skills/references/testing-contracts.md +93 -0
- package/templates/context.yml +110 -0
- package/templates/debt-exceptions.yml +61 -0
- package/templates/decision.md +50 -0
- package/templates/dupignore +93 -0
- package/templates/example.feature +24 -0
- package/templates/manifest.md +29 -0
- package/templates/mapignore +58 -0
- package/templates/mapkeys +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,748 @@
|
|
|
1
|
+
# Grimoire
|
|
2
|
+
|
|
3
|
+
**Spec-driven AI development framework.** Encodes decades of software engineering discipline — requirements, design review, TDD, change management, traceability — into AI coding workflows so they can't be skipped.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Your request → Gherkin spec → Implementation plan → Red-green BDD → Verified, auditable code
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
<!-- GRIMOIRE:HEALTH:START -->
|
|
10
|
+
<!-- GRIMOIRE:HEALTH:END -->
|
|
11
|
+
|
|
12
|
+
## Why Grimoire
|
|
13
|
+
|
|
14
|
+
The software industry spent decades learning hard lessons about building reliable systems. AI coding agents have abandoned most of these practices, hoping LLMs will magically produce correct code without discipline. They don't — AI-generated code has [1.7x more bugs](RESEARCH.md), [76% of LLM refactoring suggestions are hallucinations](RESEARCH.md), and developers using AI are [19% slower while believing they're faster](RESEARCH.md).
|
|
15
|
+
|
|
16
|
+
Grimoire adds the missing discipline:
|
|
17
|
+
|
|
18
|
+
- **Specs before code** — every behavior is a Gherkin `.feature` file that doubles as an executable acceptance test
|
|
19
|
+
- **Plans before implementation** — concrete task lists with exact file paths, not "implement the feature"
|
|
20
|
+
- **Tests that actually test** — mandatory red-green BDD cycle with assertion quality checks
|
|
21
|
+
- **Codebase knowledge without exploration** — area docs, data schemas, and symbol maps so the AI doesn't waste context reading files
|
|
22
|
+
- **Full audit trail** — every commit traces back to a requirement via git trailers
|
|
23
|
+
- **Architecture decisions on record** — MADR decision records so the AI doesn't re-litigate choices
|
|
24
|
+
|
|
25
|
+
Works with **any AI coding agent** that reads AGENTS.md: Claude Code, Cursor, Codex, Windsurf, Cline, Aider, and more.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g @kiwidata/grimoire
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<details>
|
|
34
|
+
<summary>Install from source</summary>
|
|
35
|
+
|
|
36
|
+
Requires Node.js 20+ and git.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/kiwi-data/grimoire.git
|
|
40
|
+
cd grimoire
|
|
41
|
+
npm install
|
|
42
|
+
npm run build
|
|
43
|
+
npm link # makes `grimoire` available globally
|
|
44
|
+
grimoire --version # should print 0.1.0
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To update after pulling new changes:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd /path/to/grimoire
|
|
51
|
+
git pull
|
|
52
|
+
npm run build
|
|
53
|
+
|
|
54
|
+
cd /path/to/your-project
|
|
55
|
+
grimoire update # refreshes AGENTS.md + skills to latest
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
To unlink: `npm unlink -g @kiwidata/grimoire`
|
|
59
|
+
|
|
60
|
+
</details>
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd my-project
|
|
66
|
+
grimoire init # Auto-detect tools, configure checks, install skills
|
|
67
|
+
grimoire map --symbols # Scan codebase + extract function signatures
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then talk to your AI assistant:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
You: "Users should be able to log in with 2FA"
|
|
74
|
+
|
|
75
|
+
→ /grimoire:draft Creates login.feature with Given/When/Then scenarios
|
|
76
|
+
→ /grimoire:plan Generates tasks: write step defs, then production code
|
|
77
|
+
→ /grimoire:review (optional) Product, security, and engineering review
|
|
78
|
+
→ /grimoire:apply Implements with strict red-green BDD
|
|
79
|
+
→ /grimoire:verify Confirms all scenarios pass, no regressions
|
|
80
|
+
→ grimoire archive Syncs to baseline, archives manifest
|
|
81
|
+
→ grimoire pr Generates PR description from artifacts
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary>What <code>grimoire init</code> creates</summary>
|
|
86
|
+
|
|
87
|
+
Interactive setup that auto-detects your project's tools and asks preferences for commit style, doc generator, AI agents, security tools, and compliance frameworks (OWASP, PCI-DSS, HIPAA, SOC2, GDPR, ISO 27001). Creates:
|
|
88
|
+
|
|
89
|
+
- `AGENTS.md` — workflow instructions read by AI coding assistants
|
|
90
|
+
- `.grimoire/config.yaml` — tool configuration and check pipeline
|
|
91
|
+
- `.grimoire/` — decisions, docs, change tracking, archive directories
|
|
92
|
+
- `features/` — where Gherkin specs live
|
|
93
|
+
- `.claude/skills/` — Claude Code skill definitions (ignored by other agents)
|
|
94
|
+
- `.git/hooks/pre-commit` — runs `grimoire check` before commits
|
|
95
|
+
|
|
96
|
+
Use `grimoire init --no-detect` to skip interactive tool detection. Most unconfigured steps are skipped, but **security, dep_audit, secrets, and best_practices have built-in LLM fallbacks** that run automatically — every project gets baseline security scanning out of the box.
|
|
97
|
+
|
|
98
|
+
</details>
|
|
99
|
+
|
|
100
|
+
## Workflow
|
|
101
|
+
|
|
102
|
+
### 1. Draft — Define what you're building
|
|
103
|
+
|
|
104
|
+
Grimoire routes your request to the right format:
|
|
105
|
+
|
|
106
|
+
- **"Users should be able to log in with 2FA"** → Gherkin feature
|
|
107
|
+
- **"We should use PostgreSQL instead of MySQL"** → MADR decision record
|
|
108
|
+
- **"The login page is broken"** → `/grimoire:bug` (reproduce first, then fix)
|
|
109
|
+
- **"A tester found a problem"** → `/grimoire:bug-report` → `/grimoire:bug-triage` → routed fix
|
|
110
|
+
|
|
111
|
+
Produces `.feature` files (with security tags like `@security`, `@auth`, `@pii`, `@pci-dss` when applicable), decision records, `data.yml` for schema changes, and a manifest tracking the change.
|
|
112
|
+
|
|
113
|
+
### 2. Plan — Generate concrete tasks
|
|
114
|
+
|
|
115
|
+
Every scenario becomes a pair: write the step definition (test), then write the production code. Tasks reference exact file paths, exact assertions, and real patterns from area docs. Data changes (models, migrations) are ordered before feature code.
|
|
116
|
+
|
|
117
|
+
The plan skill reads `.grimoire/docs/` to find reusable utilities, coding patterns, and where new code should go — so the AI plans with real codebase knowledge, not guesses.
|
|
118
|
+
|
|
119
|
+
### 3. Review — Multi-perspective design review (optional)
|
|
120
|
+
|
|
121
|
+
Five personas validate the change before any code is written:
|
|
122
|
+
|
|
123
|
+
- **Product manager** — completeness, missing edge cases, unclear requirements
|
|
124
|
+
- **Senior engineer** — simplicity, code reuse, architecture fit, task quality
|
|
125
|
+
- **Security engineer** — STRIDE threat analysis, OWASP Top 10 / CWE classification, compliance verification (PCI-DSS, HIPAA, GDPR, SOC2 when configured), input validation, auth boundaries, vulnerable dependencies, secrets
|
|
126
|
+
- **QA engineer** — testability, negative scenarios, edge cases, observability, regression risk
|
|
127
|
+
- **Data engineer** — schema design, migration safety, index coverage (when `data.yml` present)
|
|
128
|
+
|
|
129
|
+
Issues flagged as **blocker** or **suggestion**. Security findings tagged with OWASP category and CWE ID. Skip for small/low-risk changes.
|
|
130
|
+
|
|
131
|
+
### 4. Apply — Build with strict red-green BDD
|
|
132
|
+
|
|
133
|
+
For each task:
|
|
134
|
+
1. Write the step definition (test)
|
|
135
|
+
2. Run it — **must fail** (red). A test that passes immediately is broken.
|
|
136
|
+
3. Write production code
|
|
137
|
+
4. Run it — **must pass** (green)
|
|
138
|
+
5. Test quality check — verify strong assertions, not `assert True`
|
|
139
|
+
6. Mark done, move to next task
|
|
140
|
+
|
|
141
|
+
**Session management:** Each task (or group of 2-3) runs in a fresh subagent to avoid context bloat. `tasks.md` is the coordination mechanism — if the session is interrupted, the next agent picks up where you left off.
|
|
142
|
+
|
|
143
|
+
**Stuck detection:** After 3 failed attempts with different approaches on a single task, the agent stops and asks for help instead of looping.
|
|
144
|
+
|
|
145
|
+
### 5. Verify — Confirm everything works
|
|
146
|
+
|
|
147
|
+
- **Completeness** — all tasks done
|
|
148
|
+
- **Correctness** — every scenario has a step definition with real assertions
|
|
149
|
+
- **Coherence** — architecture decisions are followed
|
|
150
|
+
- **Test quality** — flags weak assertions (`assert True`, `toBeDefined()`), empty bodies, tautological tests
|
|
151
|
+
- **Security compliance** — verifies plan-stage security patterns were followed (parameterized queries, bcrypt, no hardcoded secrets), checks review blockers were addressed, runs OWASP Top 10 surface scan on the diff, validates security-tagged scenarios (`@security`, `@auth`, `@pii`, `@pci-dss`, etc.)
|
|
152
|
+
- **Dead features** — specs that exist but code no longer implements
|
|
153
|
+
|
|
154
|
+
### 6. PR & Archive
|
|
155
|
+
|
|
156
|
+
`grimoire pr` generates a PR description from manifests, features, decisions, and task progress. Optional `--review` runs an LLM review of the actual diff. `--create` creates via `gh` or `glab`.
|
|
157
|
+
|
|
158
|
+
`grimoire archive` syncs features to baseline, accepts decisions, updates data schema, and archives the manifest.
|
|
159
|
+
|
|
160
|
+
## Walkthrough
|
|
161
|
+
|
|
162
|
+
Full grimoire cycle end-to-end — adding two-factor authentication to an existing login feature.
|
|
163
|
+
|
|
164
|
+
<details>
|
|
165
|
+
<summary>Expand walkthrough</summary>
|
|
166
|
+
|
|
167
|
+
### Draft
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
You: "Users should verify their identity with a TOTP code after entering their password"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The AI runs `/grimoire:draft` and produces:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
.grimoire/changes/add-2fa-login/
|
|
177
|
+
├── manifest.md # Why, what's changing, scope
|
|
178
|
+
├── features/
|
|
179
|
+
│ └── auth/
|
|
180
|
+
│ └── login.feature # Updated with 2FA scenarios
|
|
181
|
+
└── decisions/
|
|
182
|
+
└── 0003-totp-library.md # Chose pyotp over django-otp
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**login.feature:**
|
|
186
|
+
```gherkin
|
|
187
|
+
Feature: Login with two-factor authentication
|
|
188
|
+
As a user
|
|
189
|
+
I want to verify my identity with a second factor
|
|
190
|
+
So that my account is protected from unauthorized access
|
|
191
|
+
|
|
192
|
+
Background:
|
|
193
|
+
Given I am a registered user with 2FA enabled
|
|
194
|
+
|
|
195
|
+
Scenario: Successful login with valid TOTP code
|
|
196
|
+
Given I have entered valid credentials
|
|
197
|
+
When I enter a valid TOTP code
|
|
198
|
+
Then I should be redirected to the dashboard
|
|
199
|
+
And my session should be marked as fully authenticated
|
|
200
|
+
|
|
201
|
+
Scenario: Login rejected with expired TOTP code
|
|
202
|
+
Given I have entered valid credentials
|
|
203
|
+
When I enter an expired TOTP code
|
|
204
|
+
Then I should see an error message "Code expired"
|
|
205
|
+
And I should remain on the verification page
|
|
206
|
+
|
|
207
|
+
Scenario: Login rejected with invalid TOTP code
|
|
208
|
+
Given I have entered valid credentials
|
|
209
|
+
When I enter an invalid TOTP code
|
|
210
|
+
Then I should see an error message "Invalid code"
|
|
211
|
+
And I should remain on the verification page
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
You review and approve. Manifest status: `draft` → `approved`.
|
|
215
|
+
|
|
216
|
+
### Plan
|
|
217
|
+
|
|
218
|
+
The AI runs `/grimoire:plan`, reads the approved features + area docs + data schema, and generates `tasks.md`:
|
|
219
|
+
|
|
220
|
+
```markdown
|
|
221
|
+
# Tasks: add-2fa-login
|
|
222
|
+
|
|
223
|
+
> **Change**: Add TOTP-based 2FA to login
|
|
224
|
+
> **Features**: auth/login.feature
|
|
225
|
+
> **Decisions**: 0003-totp-library.md
|
|
226
|
+
> **Test command**: `pytest tests/ -k "auth"`
|
|
227
|
+
> **Status**: 0/8 tasks complete
|
|
228
|
+
|
|
229
|
+
## 1. Data Layer
|
|
230
|
+
- [ ] 1.1 Add `totp_secret` field to User model in `src/models/user.py`
|
|
231
|
+
- CharField, nullable, 32 chars
|
|
232
|
+
- Migration: add nullable column (safe for live DB)
|
|
233
|
+
- [ ] 1.2 Run `python manage.py makemigrations && python manage.py migrate`
|
|
234
|
+
|
|
235
|
+
## 2. TOTP Verification
|
|
236
|
+
- [ ] 2.1 Write step defs in `tests/step_defs/test_auth.py` for scenario: "Successful login with valid TOTP code"
|
|
237
|
+
- Given: create user with 2FA enabled, generate valid TOTP secret
|
|
238
|
+
- When: POST to `/verify-totp/` with valid code from `pyotp.TOTP(secret).now()`
|
|
239
|
+
- Then: assert response redirects to `/dashboard/` (status 302)
|
|
240
|
+
- Then: assert session `is_2fa_verified` is True
|
|
241
|
+
- [ ] 2.2 Implement `VerifyTOTPView` in `src/views/auth.py`
|
|
242
|
+
|
|
243
|
+
## 3. Error Cases
|
|
244
|
+
- [ ] 3.1 Write step defs for scenario: "Login rejected with expired TOTP code"
|
|
245
|
+
- [ ] 3.2 Write step defs for scenario: "Login rejected with invalid TOTP code"
|
|
246
|
+
|
|
247
|
+
## 4. Verification
|
|
248
|
+
- [ ] 4.1 Run `pytest tests/ -k "auth"` — all new scenarios green
|
|
249
|
+
- [ ] 4.2 Run `pytest tests/` — no regressions in existing tests
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Apply
|
|
253
|
+
|
|
254
|
+
The AI runs `/grimoire:apply`, creates branch `feat/add-2fa-login`, and works through tasks:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
Task 1.1: Add totp_secret field to User model
|
|
258
|
+
→ Editing src/models/user.py
|
|
259
|
+
✓ Done
|
|
260
|
+
|
|
261
|
+
Task 2.1: Write step defs for "Successful login with valid TOTP code"
|
|
262
|
+
→ Writing tests/step_defs/test_auth.py
|
|
263
|
+
→ Running: pytest tests/ -k "successful_login_with_valid_totp"
|
|
264
|
+
✗ FAILED (red) — good, test correctly fails without production code
|
|
265
|
+
|
|
266
|
+
Task 2.2: Implement VerifyTOTPView
|
|
267
|
+
→ Writing src/views/auth.py
|
|
268
|
+
→ Running: pytest tests/ -k "successful_login_with_valid_totp"
|
|
269
|
+
✓ PASSED (green)
|
|
270
|
+
→ Test quality check: assert response.status_code == 302 ✓ strong assertion
|
|
271
|
+
|
|
272
|
+
...continues through all tasks...
|
|
273
|
+
|
|
274
|
+
Task 4.2: Full regression check
|
|
275
|
+
→ Running: pytest tests/
|
|
276
|
+
✓ 47 passed, 0 failed
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Every commit includes `Change: add-2fa-login` trailer. `tasks.md` is updated in real time.
|
|
280
|
+
|
|
281
|
+
### Verify
|
|
282
|
+
|
|
283
|
+
The AI runs `/grimoire:verify`:
|
|
284
|
+
|
|
285
|
+
```markdown
|
|
286
|
+
# Verification Report: add-2fa-login
|
|
287
|
+
|
|
288
|
+
## Summary
|
|
289
|
+
- Scenarios verified: 3
|
|
290
|
+
- Decisions verified: 1
|
|
291
|
+
- Issues found: 0 critical, 1 suggestion
|
|
292
|
+
|
|
293
|
+
## Verified Scenarios
|
|
294
|
+
- [x] "Successful login with valid TOTP code" — step def in test_auth.py:42
|
|
295
|
+
- [x] "Login rejected with expired TOTP code" — step def in test_auth.py:67
|
|
296
|
+
- [x] "Login rejected with invalid TOTP code" — step def in test_auth.py:85
|
|
297
|
+
|
|
298
|
+
## Suggestions
|
|
299
|
+
- Consider adding a rate-limiting scenario for repeated failed TOTP attempts
|
|
300
|
+
|
|
301
|
+
Recommendation: Ready to archive.
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### PR & Archive
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
grimoire pr --create # Creates PR via gh with full description
|
|
308
|
+
grimoire archive add-2fa-login # Syncs features, accepts decision, archives manifest
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
The feature files move to `features/auth/login.feature` (baseline). The decision moves to `.grimoire/decisions/0003-totp-library.md` with status `accepted`. The manifest is archived to `.grimoire/archive/`.
|
|
312
|
+
|
|
313
|
+
`grimoire trace src/views/auth.py:42` now shows: commit `abc123` → Change: `add-2fa-login` → features: `auth/login.feature` → decision: `0003-totp-library.md`.
|
|
314
|
+
|
|
315
|
+
</details>
|
|
316
|
+
|
|
317
|
+
## Scope & Boundaries
|
|
318
|
+
|
|
319
|
+
Grimoire owns the **inner loop** — the Dev and Sec portions of DevSecOps. Ops is explicitly out of scope.
|
|
320
|
+
|
|
321
|
+
### What Grimoire covers
|
|
322
|
+
|
|
323
|
+
| Area | What it does | How |
|
|
324
|
+
|---|---|---|
|
|
325
|
+
| Requirements engineering | Gherkin specs as executable acceptance tests | Draft skill |
|
|
326
|
+
| Architecture decisions | MADR records with cost-of-ownership | Draft skill |
|
|
327
|
+
| Design review | Multi-persona review before code is written | Review skill |
|
|
328
|
+
| Test-driven development | Strict red-green BDD enforcement | Apply skill |
|
|
329
|
+
| Test quality | Static analysis for weak/empty/tautological tests | `grimoire test-quality`, verify skill |
|
|
330
|
+
| Regression prevention | All existing tests must pass; regressions block completion | Apply + verify skills |
|
|
331
|
+
| Change management | Manifests, task tracking, session resumption, archive | Full lifecycle |
|
|
332
|
+
| Traceability | Every commit → change → feature → decision | `grimoire trace` |
|
|
333
|
+
| Security review | STRIDE threat modeling, OWASP/CWE tagging at design time | Review + plan + verify skills |
|
|
334
|
+
| Security tooling | SAST, SCA, secrets scanning in pre-commit pipeline | `grimoire check` |
|
|
335
|
+
| Bug discipline | Reproduce-first fixes, structured triage, confidential security handling | Bug workflow skills |
|
|
336
|
+
| Exploratory testing | Gap analysis, coverage mapping, charter-based sessions | Bug-explore + bug-session skills |
|
|
337
|
+
| Tech debt tracking | Structured debt register with severity and formal exceptions | Refactor skill |
|
|
338
|
+
| CI integration | Spec validation + checks + test quality with GHA annotations | `grimoire ci` |
|
|
339
|
+
|
|
340
|
+
### What Grimoire does not cover
|
|
341
|
+
|
|
342
|
+
**Ops is out of scope.** The outer loop — deploy, run, monitor, scale — requires infrastructure and environment management that a repo-local framework cannot own:
|
|
343
|
+
|
|
344
|
+
- **Deployment automation** — CD pipelines, environment promotion, rollback, blue-green/canary deploys
|
|
345
|
+
- **Integration and e2e testing** — need running services, realistic data, and production-like infrastructure
|
|
346
|
+
- **Performance and load testing** — requires dedicated infrastructure and load generators
|
|
347
|
+
- **Monitoring and observability** — APM, alerting, SLOs, incident response tooling
|
|
348
|
+
- **Infrastructure as code** — Terraform, Pulumi, Kubernetes manifests
|
|
349
|
+
- **Feature flags and progressive rollout**
|
|
350
|
+
|
|
351
|
+
Grimoire captures environment context (`.grimoire/docs/context.yml`) so the AI understands deployment topology, and the review skill flags when changes need integration or performance testing. But orchestrating those tests is platform work, not framework work.
|
|
352
|
+
|
|
353
|
+
### Security model
|
|
354
|
+
|
|
355
|
+
Grimoire's security capabilities are **AI-mediated at design time**, not static analysis enforcement at build time. The review skill runs STRIDE threat modeling, the plan skill mandates proven security patterns (OAuth2, bcrypt, parameterized queries), and the verify skill checks that guidance was followed. The check pipeline runs SAST/SCA/secrets tools when configured.
|
|
356
|
+
|
|
357
|
+
This means security coverage depends on: (1) configuring the right tools in your check pipeline, and (2) the AI following its own instructions. Projects that run `grimoire init` with detection get solid defaults. Projects that skip detection should configure `tools.security`, `tools.dep_audit`, and `tools.secrets` in `.grimoire/config.yaml`.
|
|
358
|
+
|
|
359
|
+
Grimoire does not provide compliance framework enforcement (OWASP ASVS checklists, CWE mapping), SBOM generation, artifact signing, or DAST. These require dedicated security tooling.
|
|
360
|
+
|
|
361
|
+
## Features
|
|
362
|
+
|
|
363
|
+
### Codebase Intelligence
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
grimoire map --symbols # Extract function signatures, classes, exports
|
|
367
|
+
grimoire map --compress # Also generate compressed .symbols.md
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Extracts the API surface of your codebase — function signatures, class definitions, methods, exports, and constants across Python, TypeScript, JavaScript, Go, and Rust. No native dependencies. Feeds into area docs and the plan skill.
|
|
371
|
+
|
|
372
|
+
For richer intelligence (call graphs, data flow tracing, dependency analysis), see [codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp).
|
|
373
|
+
|
|
374
|
+
### Area Docs & Data Schema
|
|
375
|
+
|
|
376
|
+
`grimoire map` + `/grimoire:discover` generates docs in `.grimoire/docs/`:
|
|
377
|
+
|
|
378
|
+
- Purpose and boundaries of each module
|
|
379
|
+
- Key files with responsibilities
|
|
380
|
+
- **Reusable code inventory** — exact function names, file paths, line numbers
|
|
381
|
+
- Naming conventions, structural patterns, where new code goes
|
|
382
|
+
|
|
383
|
+
`.grimoire/docs/data/schema.yml` captures your data layer — SQL tables, document collections, external API contracts — so the AI reads this instead of model files.
|
|
384
|
+
|
|
385
|
+
`grimoire docs` generates a browsable `.grimoire/docs/OVERVIEW.md` project summary.
|
|
386
|
+
|
|
387
|
+
### Pre-Commit Pipeline
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
grimoire check
|
|
391
|
+
|
|
392
|
+
lint ✓ passed (0.8s)
|
|
393
|
+
format ✓ passed (0.3s)
|
|
394
|
+
duplicates ✓ passed (1.2s)
|
|
395
|
+
complexity ✓ passed (0.5s)
|
|
396
|
+
unit_test ✓ passed (3.4s)
|
|
397
|
+
bdd_test ✓ passed (2.1s)
|
|
398
|
+
security ✓ passed (12.1s)
|
|
399
|
+
dep_audit ✓ passed (1.0s)
|
|
400
|
+
secrets ✓ passed (0.4s)
|
|
401
|
+
best_practices ✓ passed (8.2s)
|
|
402
|
+
|
|
403
|
+
9 passed, 0 failed, 1 skipped
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Auto-detected during `grimoire init`. Any tool can use `name: llm` with a `prompt:` for AI-powered review. Also sets up enforcement hooks for Claude Code (`.claude/hooks.json`) and git (`.git/hooks/pre-commit`).
|
|
407
|
+
|
|
408
|
+
### Test Quality
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
grimoire test-quality # Analyze all test files
|
|
412
|
+
grimoire test-quality tests/** # Specific files
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Static analysis catching weak tests: empty bodies, missing assertions, weak assertions (`assert True`, `toBeDefined()`), tautological tests. Supports Python and JS/TS. Integrated into apply (per-task gate) and verify (test intelligence).
|
|
416
|
+
|
|
417
|
+
### Bug Workflow
|
|
418
|
+
|
|
419
|
+
<details>
|
|
420
|
+
<summary>Full bug lifecycle for teams with testers and developers</summary>
|
|
421
|
+
|
|
422
|
+
```
|
|
423
|
+
Tester finds issue → /grimoire:bug-report → structured report with spec references
|
|
424
|
+
↓
|
|
425
|
+
Developer picks it up → /grimoire:bug-triage → classify root cause
|
|
426
|
+
↓
|
|
427
|
+
┌─────────────┬───────────┼───────────────┐
|
|
428
|
+
↓ ↓ ↓ ↓
|
|
429
|
+
CODE (small) CODE (big) INFRA/CONFIG SECURITY
|
|
430
|
+
/grimoire:bug → draft route to team confidential fix
|
|
431
|
+
(repro → fix manifest (create ticket) (restricted workflow)
|
|
432
|
+
→ tester stub)
|
|
433
|
+
checklist)
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Bug reports** accept output from testing tools (Playwright, Cypress, Postman, k6) via MCP or pasted directly — auto-extracting failed assertions, screenshots, and reproduction steps.
|
|
437
|
+
|
|
438
|
+
**Triage** classifies into 8 categories (code, infrastructure, configuration, data, third-party, security, documentation, not-a-bug) and routes to the right team. Security issues follow a restricted workflow with confidential handling.
|
|
439
|
+
|
|
440
|
+
**Bug fixes** (`/grimoire:bug`) follow reproduce-first discipline and generate a tester verification checklist.
|
|
441
|
+
|
|
442
|
+
**Exploratory testing** (`/grimoire:bug-explore`) operates in tester mode (spec-only gap analysis), developer mode (code-level analysis), and onboard mode (tester's guide).
|
|
443
|
+
|
|
444
|
+
**Testing sessions** (`/grimoire:bug-session`) provide charter-based exploratory testing with progress tracking, inline bug filing, and structured debrief.
|
|
445
|
+
|
|
446
|
+
</details>
|
|
447
|
+
|
|
448
|
+
### Audit Trail
|
|
449
|
+
|
|
450
|
+
Every commit includes a `Change:` git trailer linking code → commit → change → feature → decision.
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
grimoire trace src/auth.py:42 # What requirement introduced this line?
|
|
454
|
+
grimoire log --from v1.0 # Release notes from archived changes
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Project Health
|
|
458
|
+
|
|
459
|
+
```
|
|
460
|
+
grimoire health
|
|
461
|
+
|
|
462
|
+
features 100% ██████████ 12 scenarios in 5 files
|
|
463
|
+
decisions 89% █████████░ 8/9 current
|
|
464
|
+
area docs 75% ████████░░ 6/8 areas documented
|
|
465
|
+
data schema 100% ██████████ 4 models documented
|
|
466
|
+
test coverage 60% ██████░░░░ 3/5 features have step definitions
|
|
467
|
+
unit coverage 82% █████████░ 82% line coverage
|
|
468
|
+
duplicates — 2 clones detected
|
|
469
|
+
complexity — no high-complexity functions
|
|
470
|
+
|
|
471
|
+
Overall 84% █████████░
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Contract Testing
|
|
475
|
+
|
|
476
|
+
The plan, apply, and verify skills enforce a contract-first approach for external APIs:
|
|
477
|
+
|
|
478
|
+
- **Mock at the HTTP boundary only** — never mock internal code or client wrappers
|
|
479
|
+
- **Fixtures must match `schema.yml`** — test data mirrors the documented API contract
|
|
480
|
+
- **Contract drift detection** — verify flags when external API changes don't have matching test updates
|
|
481
|
+
- **Client code reads only documented fields** — prevents coupling to undocumented API behavior
|
|
482
|
+
|
|
483
|
+
### Caveman Mode
|
|
484
|
+
|
|
485
|
+
Token optimization for context-constrained agents. Set `project.caveman` in `.grimoire/config.yaml`:
|
|
486
|
+
|
|
487
|
+
| Level | Effect |
|
|
488
|
+
|-------|--------|
|
|
489
|
+
| `none` | Full AGENTS.md instructions (default) |
|
|
490
|
+
| `lite` | Trimmed explanations, same workflow |
|
|
491
|
+
| `full` | Minimal instructions, experienced users |
|
|
492
|
+
| `ultra` | Bare-minimum workflow skeleton |
|
|
493
|
+
|
|
494
|
+
### Conflict Detection
|
|
495
|
+
|
|
496
|
+
`grimoire list` detects when multiple active changes modify the same feature file and flags the conflict.
|
|
497
|
+
|
|
498
|
+
### Debt Register
|
|
499
|
+
|
|
500
|
+
The refactor skill maintains `.grimoire/debt-register.yml` — a persistent record of tech debt items with severity, Fowler quadrant classification (deliberate/inadvertent × prudent/reckless), fingerprint-based dedup, and aging signals. Formal exceptions live in `.grimoire/debt-exceptions.yml` with optional expiry dates.
|
|
501
|
+
|
|
502
|
+
### Multi-LLM Support
|
|
503
|
+
|
|
504
|
+
Grimoire works with any AI coding assistant that reads [AGENTS.md](https://agents.md/) (open standard, 60K+ repos):
|
|
505
|
+
|
|
506
|
+
- **Claude Code** — skills in `.claude/skills/`, hooks via `.claude/hooks.json`
|
|
507
|
+
- **OpenCode** — skills in `.opencode/skills/` (also reads `.claude/skills/` natively)
|
|
508
|
+
- **Codex (OpenAI)** — skills in `.agents/skills/`
|
|
509
|
+
- **Cursor** — `.cursor/rules/grimoire.mdc` (AGENTS.md derivative)
|
|
510
|
+
- **GitHub Copilot** — `.github/copilot-instructions.md` (AGENTS.md derivative)
|
|
511
|
+
- **Windsurf, Cline, Aider, etc.** — read `AGENTS.md` for workflow instructions
|
|
512
|
+
|
|
513
|
+
`grimoire init` prompts for which agents you use and installs skills to the correct path(s) for each. You can also pass `--agent` to select non-interactively:
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
grimoire init --agent claude --agent opencode # skills to both dirs
|
|
517
|
+
grimoire init --agent cursor # .cursor/rules/grimoire.mdc
|
|
518
|
+
grimoire init --agent copilot # .github/copilot-instructions.md
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## Reference
|
|
522
|
+
|
|
523
|
+
<details>
|
|
524
|
+
<summary>Skills</summary>
|
|
525
|
+
|
|
526
|
+
| Skill | Purpose |
|
|
527
|
+
|-------|---------|
|
|
528
|
+
| `/grimoire:draft` | Draft features and/or decisions collaboratively |
|
|
529
|
+
| `/grimoire:plan` | Generate detailed implementation tasks from specs |
|
|
530
|
+
| `/grimoire:review` | Multi-perspective design review (PM, engineer, security, QA, data) |
|
|
531
|
+
| `/grimoire:apply` | Execute tasks with strict red-green BDD |
|
|
532
|
+
| `/grimoire:verify` | Post-implementation verification + test quality |
|
|
533
|
+
| `/grimoire:audit` | Discover undocumented features and decisions |
|
|
534
|
+
| `/grimoire:remove` | Tracked feature removal with impact assessment |
|
|
535
|
+
| `/grimoire:discover` | Generate area docs and data schema from codebase |
|
|
536
|
+
| `/grimoire:refactor` | Find, prioritize, and track tech debt |
|
|
537
|
+
| `/grimoire:bug` | Disciplined bug fix with reproduction test first |
|
|
538
|
+
| `/grimoire:bug-report` | Structured bug reporting (accepts test tool output) |
|
|
539
|
+
| `/grimoire:bug-triage` | Classify and route bug reports |
|
|
540
|
+
| `/grimoire:bug-explore` | AI-guided exploratory testing and gap analysis |
|
|
541
|
+
| `/grimoire:bug-session` | Charter-based exploratory testing sessions |
|
|
542
|
+
| `/grimoire:commit` | Contextual commit messages with change trailers |
|
|
543
|
+
| `/grimoire:pr` | Generate PR description + optional diff review |
|
|
544
|
+
| `/grimoire:pr-review` | Review a teammate's PR with the multi-persona lens |
|
|
545
|
+
|
|
546
|
+
</details>
|
|
547
|
+
|
|
548
|
+
<details>
|
|
549
|
+
<summary>CLI commands</summary>
|
|
550
|
+
|
|
551
|
+
| Command | Description |
|
|
552
|
+
|---------|-------------|
|
|
553
|
+
| `grimoire init [path]` | Initialize grimoire (auto-detects tools, installs skills, sets up hooks) |
|
|
554
|
+
| `grimoire update [path]` | Update AGENTS.md, skills, and hooks to latest version |
|
|
555
|
+
| `grimoire list` | List active changes (with conflict detection) |
|
|
556
|
+
| `grimoire list --features` | List feature files |
|
|
557
|
+
| `grimoire list --decisions` | List decision records |
|
|
558
|
+
| `grimoire status <id>` | Show change status, branch, and task progress |
|
|
559
|
+
| `grimoire validate [id]` | Validate features, decisions, and manifests |
|
|
560
|
+
| `grimoire archive <id>` | Archive a completed change |
|
|
561
|
+
| `grimoire map` | Structural codebase scan |
|
|
562
|
+
| `grimoire map --symbols` | Extract function signatures, classes, exports |
|
|
563
|
+
| `grimoire map --compress` | Generate compressed symbol map (`.symbols.md`) |
|
|
564
|
+
| `grimoire map --duplicates` | Run jscpd duplicate detection |
|
|
565
|
+
| `grimoire map --refresh` | Diff against existing docs, show gaps |
|
|
566
|
+
| `grimoire check [steps...]` | Run pre-commit pipeline |
|
|
567
|
+
| `grimoire ci [--setup]` | Run CI pipeline / generate GitHub Actions workflow |
|
|
568
|
+
| `grimoire pr [id]` | Generate PR description from change artifacts |
|
|
569
|
+
| `grimoire pr --create` | Create PR via gh/glab |
|
|
570
|
+
| `grimoire pr --review` | Run post-implementation LLM review of diff |
|
|
571
|
+
| `grimoire test-quality [files]` | Analyze test files for quality issues |
|
|
572
|
+
| `grimoire log [--from] [--to]` | Generate change log / release notes |
|
|
573
|
+
| `grimoire trace <file[:line]>` | Trace file to originating grimoire change |
|
|
574
|
+
| `grimoire diff <id>` | Compare proposed change specs against the baseline |
|
|
575
|
+
| `grimoire docs` | Generate human-readable project overview |
|
|
576
|
+
| `grimoire health [--badges]` | Project health score with optional badges |
|
|
577
|
+
|
|
578
|
+
Most commands support `--json` for machine-readable output. `grimoire check` also supports `--changed` (only changed files), `--continue-on-fail`, and `--skip <steps>`.
|
|
579
|
+
|
|
580
|
+
</details>
|
|
581
|
+
|
|
582
|
+
<details>
|
|
583
|
+
<summary>Check pipeline tools</summary>
|
|
584
|
+
|
|
585
|
+
| Check step | What it does | Example tools |
|
|
586
|
+
|---|---|---|
|
|
587
|
+
| `lint` | Static analysis / linter | eslint, biome, ruff, flake8 |
|
|
588
|
+
| `format` | Code formatting | prettier, biome, black, ruff format |
|
|
589
|
+
| `unit_test` | Unit test runner | vitest, jest, pytest, go test |
|
|
590
|
+
| `bdd_test` | BDD / feature test runner | cucumber-js, behave, pytest-bdd |
|
|
591
|
+
| `duplicates` | Copy-paste detection | jscpd |
|
|
592
|
+
| `complexity` | Cyclomatic complexity | radon, eslint-complexity |
|
|
593
|
+
| `dead_code` | Unused code detection | knip, ts-prune, vulture |
|
|
594
|
+
| `doc_style` | Docstring/comment style compliance | Built-in (Google, NumPy, Sphinx, JSDoc, TSDoc) |
|
|
595
|
+
| `security` | Security scanner | bandit, semgrep, npm audit, or `name: llm` |
|
|
596
|
+
| `dep_audit` | Dependency vulnerability audit | npm audit, pip-audit, safety |
|
|
597
|
+
| `secrets` | Hardcoded secret detection | gitleaks, detect-secrets, trufflehog, or `name: llm` |
|
|
598
|
+
| `best_practices` | General code review | `name: llm` (LLM-powered) |
|
|
599
|
+
|
|
600
|
+
</details>
|
|
601
|
+
|
|
602
|
+
<details>
|
|
603
|
+
<summary>Full config schema</summary>
|
|
604
|
+
|
|
605
|
+
```yaml
|
|
606
|
+
# .grimoire/config.yaml
|
|
607
|
+
|
|
608
|
+
project:
|
|
609
|
+
language: typescript # Auto-detected: python, typescript, javascript, go, rust
|
|
610
|
+
package_manager: npm # Auto-detected: npm, yarn, pnpm, uv, poetry, pip, cargo
|
|
611
|
+
commit_style: conventional # conventional, angular, or custom
|
|
612
|
+
doc_tool: typedoc # sphinx, mkdocs, typedoc, jsdoc, rustdoc, godoc
|
|
613
|
+
comment_style: tsdoc # google, numpy, sphinx, jsdoc, tsdoc, pep257
|
|
614
|
+
caveman: none # Token optimization: none, lite, full, ultra
|
|
615
|
+
compliance: # Compliance frameworks (affects review, plan, verify, check)
|
|
616
|
+
- owasp # Options: owasp, pci-dss, hipaa, soc2, gdpr, iso27001
|
|
617
|
+
- gdpr
|
|
618
|
+
|
|
619
|
+
features_dir: features # Gherkin feature files
|
|
620
|
+
decisions_dir: .grimoire/decisions # MADR decision records
|
|
621
|
+
|
|
622
|
+
# Separate thinking (planning, review) and coding (implementation) agents
|
|
623
|
+
llm:
|
|
624
|
+
thinking:
|
|
625
|
+
command: claude
|
|
626
|
+
model: opus
|
|
627
|
+
coding:
|
|
628
|
+
command: claude
|
|
629
|
+
model: sonnet
|
|
630
|
+
|
|
631
|
+
# Tool configuration — each key matches a check step name
|
|
632
|
+
tools:
|
|
633
|
+
lint:
|
|
634
|
+
name: eslint
|
|
635
|
+
command: npx eslint .
|
|
636
|
+
format:
|
|
637
|
+
name: prettier
|
|
638
|
+
check_command: npx prettier --check .
|
|
639
|
+
unit_test:
|
|
640
|
+
name: vitest
|
|
641
|
+
command: npx vitest run
|
|
642
|
+
bdd_test:
|
|
643
|
+
name: cucumber-js
|
|
644
|
+
command: npx cucumber-js
|
|
645
|
+
security:
|
|
646
|
+
name: llm
|
|
647
|
+
prompt: "Review these changed files for security vulnerabilities"
|
|
648
|
+
|
|
649
|
+
# Check pipeline — ordered list of steps (must match keys in tools)
|
|
650
|
+
checks:
|
|
651
|
+
- lint
|
|
652
|
+
- format
|
|
653
|
+
- duplicates
|
|
654
|
+
- complexity
|
|
655
|
+
- unit_test
|
|
656
|
+
- bdd_test
|
|
657
|
+
- security
|
|
658
|
+
- dep_audit
|
|
659
|
+
- secrets
|
|
660
|
+
- best_practices
|
|
661
|
+
|
|
662
|
+
# Bug tracking and testing tools
|
|
663
|
+
bug_trackers:
|
|
664
|
+
- name: jira
|
|
665
|
+
mcp:
|
|
666
|
+
name: atlassian
|
|
667
|
+
url: https://mcp.atlassian.com/v1/sse
|
|
668
|
+
transport: sse
|
|
669
|
+
|
|
670
|
+
testing_tools:
|
|
671
|
+
- name: playwright
|
|
672
|
+
purpose: e2e
|
|
673
|
+
mcp:
|
|
674
|
+
name: playwright
|
|
675
|
+
command: npx
|
|
676
|
+
args: ["-y", "@playwright/mcp@latest"]
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
</details>
|
|
680
|
+
|
|
681
|
+
## Contributing
|
|
682
|
+
|
|
683
|
+
<details>
|
|
684
|
+
<summary>Development setup and project structure</summary>
|
|
685
|
+
|
|
686
|
+
### Development Setup
|
|
687
|
+
|
|
688
|
+
```bash
|
|
689
|
+
git clone https://github.com/kiwi-data/grimoire.git
|
|
690
|
+
cd grimoire
|
|
691
|
+
npm install
|
|
692
|
+
npm run build # Compile TypeScript
|
|
693
|
+
npm run dev # Watch mode
|
|
694
|
+
npm test # vitest
|
|
695
|
+
npm run lint # eslint
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### Project Structure
|
|
699
|
+
|
|
700
|
+
```
|
|
701
|
+
grimoire/
|
|
702
|
+
├── src/
|
|
703
|
+
│ ├── cli/index.ts # CLI entry point
|
|
704
|
+
│ ├── commands/ # Command definitions (thin — delegate to core/)
|
|
705
|
+
│ ├── core/ # Business logic
|
|
706
|
+
│ └── utils/ # Config, path resolution, helpers
|
|
707
|
+
├── skills/ # Claude Code skill definitions (SKILL.md per skill)
|
|
708
|
+
├── templates/ # Files copied during grimoire init
|
|
709
|
+
├── AGENTS.md # Universal LLM instructions (installed into projects)
|
|
710
|
+
└── bin/grimoire.js # CLI entry script
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
### Adding a New Skill
|
|
714
|
+
|
|
715
|
+
1. Create `skills/grimoire-<name>/SKILL.md` with trigger, prerequisites, workflow, and important notes
|
|
716
|
+
2. Add `"grimoire-<name>"` to the `skillNames` array in both `src/core/init.ts` and `src/core/update.ts`
|
|
717
|
+
3. Build and test: `npm run build && node bin/grimoire.js update .`
|
|
718
|
+
|
|
719
|
+
Skills are pure markdown — instructions for the AI, not executable code.
|
|
720
|
+
|
|
721
|
+
### Adding a New CLI Command
|
|
722
|
+
|
|
723
|
+
1. Create `src/commands/<name>.ts` — thin wrapper that parses args and calls core
|
|
724
|
+
2. Create `src/core/<name>.ts` — business logic
|
|
725
|
+
3. Register in `src/cli/index.ts`
|
|
726
|
+
|
|
727
|
+
### Adding a New Tool Detection
|
|
728
|
+
|
|
729
|
+
1. Add a `detect<Tool>` function in `src/core/detect.ts`
|
|
730
|
+
2. Add it to the `checks` array in `detectTools`
|
|
731
|
+
3. Add the category to `CATEGORY_LABELS` and `CATEGORY_ORDER` in `src/core/init.ts`
|
|
732
|
+
|
|
733
|
+
</details>
|
|
734
|
+
|
|
735
|
+
## Philosophy
|
|
736
|
+
|
|
737
|
+
- **Features are tests.** A `.feature` file is both the requirement and the acceptance test.
|
|
738
|
+
- **Red-green is mandatory.** A test must fail before it passes. If it doesn't fail, it's not a real test.
|
|
739
|
+
- **Decisions are documented.** Architecture choices that aren't written down get relitigated.
|
|
740
|
+
- **Reproduce before you fix.** Every bug gets a failing test before any code changes.
|
|
741
|
+
- **Simple over clever.** Less code, fewer abstractions, smallest surface area.
|
|
742
|
+
- **Verify before using.** Confirm imports, functions, and packages exist before writing code that depends on them.
|
|
743
|
+
- **Removal is deliberate.** Removing a feature gets the same rigor as adding one.
|
|
744
|
+
- **The fix is upstream.** You don't fix codebase entropy by reviewing harder — you fix it by requiring specs before code.
|
|
745
|
+
|
|
746
|
+
## License
|
|
747
|
+
|
|
748
|
+
MIT
|