@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
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grimoire-discover
|
|
3
|
+
description: Generate area docs and data schema from a codebase snapshot. Use when initializing grimoire on an existing project or when codebase structure has changed significantly.
|
|
4
|
+
compatibility: Designed for Claude Code (or similar products)
|
|
5
|
+
metadata:
|
|
6
|
+
author: kiwi-data
|
|
7
|
+
version: "0.1"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# grimoire-discover
|
|
11
|
+
|
|
12
|
+
Generate a structured project map in `.grimoire/docs/` from a codebase snapshot. This map helps LLMs understand the codebase layout, find reusable code, and follow existing patterns — preventing duplicate code and misplaced files.
|
|
13
|
+
|
|
14
|
+
## Triggers
|
|
15
|
+
- User wants to document or map the codebase structure
|
|
16
|
+
- User asks about coding standards, patterns, or conventions
|
|
17
|
+
- User wants to prevent duplicate code or find existing utilities
|
|
18
|
+
- Loose match: "discover", "map", "standards", "conventions", "DRY", "utilities", "codebase layout"
|
|
19
|
+
|
|
20
|
+
## Routing
|
|
21
|
+
- Want to document existing behavior as Gherkin features → `grimoire-audit`
|
|
22
|
+
- Want to find undocumented features and decisions → `grimoire-audit` (run discover first, then audit)
|
|
23
|
+
- Want to draft new functionality → `grimoire-draft`
|
|
24
|
+
|
|
25
|
+
## Prerequisites
|
|
26
|
+
|
|
27
|
+
**Structural snapshot:** Run `grimoire map` first. This produces `.grimoire/docs/.snapshot.json` — a structural scan of the directory tree, key files, and file extension counts. The snapshot is the input for directory structure; this skill adds the semantic layer.
|
|
28
|
+
|
|
29
|
+
If `.snapshot.json` doesn't exist or is stale, tell the user to run `grimoire map` (or `grimoire map --refresh` to diff against existing docs).
|
|
30
|
+
|
|
31
|
+
**Symbol intelligence (recommended):** If `codebase-memory-mcp` is available as an MCP server, use its graph tools (`search_graph`, `get_architecture`, `query_graph`) to query symbols, call graphs, and architecture instead of reading source files manually. This provides AST-parsed symbols across 66 languages, call-path tracing, and dead code detection — far more accurate than regex extraction.
|
|
32
|
+
|
|
33
|
+
If `codebase-memory-mcp` is not available, fall back to reading source files directly to identify symbols and patterns.
|
|
34
|
+
|
|
35
|
+
## What It Produces
|
|
36
|
+
|
|
37
|
+
`.grimoire/docs/` with:
|
|
38
|
+
- **`index.yml`** — master index of all documented areas with descriptions and directory mappings
|
|
39
|
+
- **Area docs** — one markdown file per area of the codebase, each covering:
|
|
40
|
+
- Purpose and boundaries of the module/area
|
|
41
|
+
- Key files and their responsibilities
|
|
42
|
+
- Reusable utilities, helpers, and shared functions (the "reuse inventory")
|
|
43
|
+
- Naming conventions and patterns in use
|
|
44
|
+
- Where new code of this type should go
|
|
45
|
+
- Example references (point to specific files as exemplars, don't duplicate code)
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
### 1. Load Snapshot and Graph
|
|
50
|
+
Read `.grimoire/docs/.snapshot.json`. This gives you:
|
|
51
|
+
- **directories** — every directory with file counts, extensions, key files, and subdirectories
|
|
52
|
+
- **keyFiles** — significant files (entry points, configs, route files, etc.) with their detected type
|
|
53
|
+
- **undocumented** — directories not yet covered by existing docs (only present on `--refresh`)
|
|
54
|
+
- **removed** — directories that have docs but no longer exist (only present on `--refresh`)
|
|
55
|
+
|
|
56
|
+
Use this as your roadmap. The snapshot tells you WHERE to look; you add WHAT it means.
|
|
57
|
+
|
|
58
|
+
If the snapshot includes a `duplicates` section (from `grimoire map --duplicates`), use it to populate "Known Duplicates" sections in area docs. This tells the plan skill where code is already duplicated so it can consolidate rather than add more.
|
|
59
|
+
|
|
60
|
+
**If `codebase-memory-mcp` is available**, also query the graph for each area:
|
|
61
|
+
- `search_graph` — find all symbols (functions, classes, types) in a directory
|
|
62
|
+
- `trace_call_path` — understand how modules connect (inbound/outbound calls)
|
|
63
|
+
- `get_architecture` — get a high-level module/dependency overview
|
|
64
|
+
- `query_graph` — Cypher-like queries for specific relationships (e.g., `MATCH (f:Function)-[:CALLS]->(g) WHERE f.file STARTS WITH 'src/api/' RETURN f.name, g.name`)
|
|
65
|
+
|
|
66
|
+
This replaces the need to manually read every source file to extract symbols. The graph gives you AST-accurate function signatures, call relationships, and dead code detection across 66 languages.
|
|
67
|
+
|
|
68
|
+
### 2. Determine Scope
|
|
69
|
+
Ask the user what to document:
|
|
70
|
+
- **Full scan** — document all areas from the snapshot (default for first run)
|
|
71
|
+
- **Area scan** — document specific directories (e.g., "just the API layer")
|
|
72
|
+
- **Gap fill** — only document areas flagged as `undocumented` in the snapshot
|
|
73
|
+
|
|
74
|
+
Check `.grimoire/docs/index.yml` if it exists — don't redo work unless refreshing.
|
|
75
|
+
|
|
76
|
+
### 3. Analyze Each Area
|
|
77
|
+
For each directory cluster in the snapshot, read the actual code to understand:
|
|
78
|
+
|
|
79
|
+
**From the snapshot (already known):**
|
|
80
|
+
- Directory path and file counts
|
|
81
|
+
- File extensions (tells you the language/type mix)
|
|
82
|
+
- Key files (tells you what framework patterns are in use)
|
|
83
|
+
|
|
84
|
+
**From `codebase-memory-mcp` graph (if available):**
|
|
85
|
+
- All symbols in the area: functions, classes, types, constants with signatures
|
|
86
|
+
- Call graph: what calls what, both inbound and outbound
|
|
87
|
+
- Dead code: functions with zero callers
|
|
88
|
+
- Cross-service HTTP links: REST routes and their callers
|
|
89
|
+
|
|
90
|
+
**From reading the code (your job — or to supplement the graph):**
|
|
91
|
+
- What the module/area is responsible for
|
|
92
|
+
- Reusable functions, classes, utilities that other code should import
|
|
93
|
+
- Naming conventions and structural patterns
|
|
94
|
+
- Where new code of this type should be created
|
|
95
|
+
- Import relationships with other areas
|
|
96
|
+
- **Data models and schemas** in or owned by this area (see Data Layer below)
|
|
97
|
+
|
|
98
|
+
### 4. Generate Area Docs
|
|
99
|
+
For each significant area, create a doc file in `.grimoire/docs/`.
|
|
100
|
+
|
|
101
|
+
**Area doc format:**
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
# <Area Name>
|
|
105
|
+
|
|
106
|
+
## Purpose
|
|
107
|
+
<1-2 sentences: what this area of the codebase is responsible for>
|
|
108
|
+
|
|
109
|
+
## Boundaries
|
|
110
|
+
<What belongs here and what doesn't. Where related code lives instead.>
|
|
111
|
+
|
|
112
|
+
## Key Files
|
|
113
|
+
| File | Responsibility |
|
|
114
|
+
|------|---------------|
|
|
115
|
+
| `path/to/file.py` | <what it does> |
|
|
116
|
+
| `path/to/other.py` | <what it does> |
|
|
117
|
+
|
|
118
|
+
## Reusable Code
|
|
119
|
+
Utilities and helpers in this area that MUST be reused (not re-implemented):
|
|
120
|
+
|
|
121
|
+
| Function/Class | Location | What It Does |
|
|
122
|
+
|----------------|----------|-------------|
|
|
123
|
+
| `format_currency()` | `utils/formatters.py:42` | Formats decimal as currency string |
|
|
124
|
+
| `BaseAPIView` | `api/base.py:15` | Base view with auth, pagination, error handling |
|
|
125
|
+
|
|
126
|
+
## Patterns
|
|
127
|
+
<How things are done in this area. Reference specific files as exemplars.>
|
|
128
|
+
|
|
129
|
+
### Naming
|
|
130
|
+
- <naming convention with example>
|
|
131
|
+
|
|
132
|
+
### Structure
|
|
133
|
+
- <structural pattern with example file>
|
|
134
|
+
|
|
135
|
+
## Where New Code Goes
|
|
136
|
+
- New <type> → `path/to/directory/`
|
|
137
|
+
- New <type> → `path/to/other/`
|
|
138
|
+
|
|
139
|
+
## Known Duplicates
|
|
140
|
+
<Only if duplicates data exists in snapshot. List clones that touch this area.>
|
|
141
|
+
|
|
142
|
+
| Files | Lines | What's Duplicated |
|
|
143
|
+
|-------|-------|------------------|
|
|
144
|
+
| `views.py:42-68` ↔ `api/views.py:15-41` | 26 | Request validation logic |
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 5. Generate Data Schema
|
|
148
|
+
|
|
149
|
+
Scan the codebase for data models, ORM definitions, migration files, and schema declarations. Produce `.grimoire/docs/data/schema.yml` documenting the current data layer.
|
|
150
|
+
|
|
151
|
+
**Where to look:**
|
|
152
|
+
- ORM models: Django `models.py`, SQLAlchemy models, Prisma `schema.prisma`, TypeORM entities, Mongoose schemas
|
|
153
|
+
- Migrations: `migrations/`, `alembic/versions/`, `prisma/migrations/`
|
|
154
|
+
- Raw SQL: `*.sql` files, schema definitions
|
|
155
|
+
- NoSQL: Mongoose schemas, DynamoDB table definitions, Firestore rules
|
|
156
|
+
- API schemas: GraphQL `.graphql` files, protobuf `.proto` files, JSON Schema
|
|
157
|
+
- External APIs: OpenAPI/Swagger specs, Postman collections, API client wrappers, SDK config files
|
|
158
|
+
- Message formats: Avro `.avsc`, protobuf `.proto`, JSON Schema for events/messages
|
|
159
|
+
|
|
160
|
+
**Schema format:** See `../references/schema-format.md` for the full YAML format with examples covering tables, nested objects, relationships, and external APIs.
|
|
161
|
+
|
|
162
|
+
**Rules:**
|
|
163
|
+
- Document what exists in the code, not what the database actually contains
|
|
164
|
+
- Use `source:` to point back to the ORM model or migration file — the schema.yml is a summary, the code is the truth
|
|
165
|
+
- Use `type: table` for SQL, `type: collection` for Mongo/document stores, `type: document` for nested sub-documents
|
|
166
|
+
- Use `type: external_api` for APIs you consume or produce but don't own the schema for
|
|
167
|
+
- Nested `fields` for embedded objects/arrays (common in document DBs and JSON columns)
|
|
168
|
+
- Include `note:` only when the field name isn't self-explanatory
|
|
169
|
+
- Include `relationships` when the ORM defines them explicitly
|
|
170
|
+
- For external APIs: `schema_ref` is the most important field — point to the OpenAPI spec, Swagger URL, API docs page, or local spec file so the LLM (and humans) know where to get the full contract
|
|
171
|
+
- For external APIs: `client` points to where the codebase calls the API — this is where changes happen when the API changes
|
|
172
|
+
- Don't duplicate entire OpenAPI specs into schema.yml — summarize the endpoints you actually use with key fields, and point to the full spec via `schema_ref`
|
|
173
|
+
- If the project has no data layer, skip this step entirely
|
|
174
|
+
|
|
175
|
+
If `.grimoire/docs/data/` already exists, update it rather than regenerating. Diff against existing schema.yml to flag new models or removed fields.
|
|
176
|
+
|
|
177
|
+
### 6. Generate Project Context
|
|
178
|
+
|
|
179
|
+
Scan the codebase for deployment and infrastructure artifacts, then populate `.grimoire/docs/context.yml`. This file captures the project's ecosystem — how it's deployed, what services it talks to, and what infrastructure it depends on. If `context.yml` doesn't exist, copy it from the template first (`grimoire init` creates it, but this handles projects initialized before this feature).
|
|
180
|
+
|
|
181
|
+
**Where to look:**
|
|
182
|
+
|
|
183
|
+
| Artifact | What it tells you |
|
|
184
|
+
|----------|------------------|
|
|
185
|
+
| `Dockerfile`, `docker-compose.yml` | Containerized deployment; compose reveals linked services, databases, caches |
|
|
186
|
+
| `k8s/`, `kubernetes/`, `Chart.yaml`, `helmfile.yaml` | Kubernetes deployment; manifests reveal services, ingresses, config maps |
|
|
187
|
+
| `*.tf`, `terraform/`, `cdk.json`, `serverless.yml` | Infrastructure-as-code; reveals cloud provider, services, and architecture |
|
|
188
|
+
| `.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`, `.circleci/` | CI/CD platform and deploy triggers |
|
|
189
|
+
| `Procfile`, `app.json`, `vercel.json`, `netlify.toml` | PaaS deployment target |
|
|
190
|
+
| `fly.toml`, `render.yaml`, `railway.json` | PaaS deployment target |
|
|
191
|
+
| `.env.example`, `.env.template` | Environment variables reveal infrastructure dependencies (DB hosts, cache URLs, API keys) |
|
|
192
|
+
| `docker-compose.yml` services | Related services, databases, caches, queues running locally |
|
|
193
|
+
| API client wrappers, SDK config | Internal service dependencies |
|
|
194
|
+
|
|
195
|
+
**Workflow:**
|
|
196
|
+
1. Scan for the artifacts above — note what exists
|
|
197
|
+
2. Read `docker-compose.yml` (if present) — it's the richest source of service and infrastructure dependencies
|
|
198
|
+
3. Read `.env.example` (if present) — environment variables reveal what the project connects to
|
|
199
|
+
4. Read CI/CD config files — identify the platform, key workflows, and deploy triggers
|
|
200
|
+
5. Read IaC files (Terraform, CDK, etc.) — identify cloud provider and provisioned resources
|
|
201
|
+
6. Populate `context.yml` with what you found — fill in real values, remove unused commented sections
|
|
202
|
+
7. Present findings to the user for confirmation — they'll know about services and infrastructure that aren't discoverable from code alone (e.g., a shared auth service, a data warehouse they push to)
|
|
203
|
+
|
|
204
|
+
**Rules:**
|
|
205
|
+
- Only populate sections where you found evidence. Leave sections empty (with comments) rather than guessing.
|
|
206
|
+
- Use environment variable references (`${DATABASE_HOST}`) for hostnames and credentials — never hardcode real values.
|
|
207
|
+
- The `services` section is for **internal/sibling services** your org owns. Third-party APIs (Stripe, Twilio, etc.) belong in `schema.yml` under `external_api`.
|
|
208
|
+
- If `context.yml` already exists and has content, update it rather than overwriting — the user may have manually added entries.
|
|
209
|
+
- Ask the user about anything you can't determine from code: "I see a Redis connection in docker-compose but I'm not sure if it's just cache or also used for sessions — which is it?"
|
|
210
|
+
|
|
211
|
+
### 7. Generate Index
|
|
212
|
+
Create or update `.grimoire/docs/index.yml`:
|
|
213
|
+
|
|
214
|
+
```yaml
|
|
215
|
+
# Grimoire Project Map
|
|
216
|
+
# Auto-generated by /grimoire:discover
|
|
217
|
+
# Last updated: YYYY-MM-DD
|
|
218
|
+
|
|
219
|
+
areas:
|
|
220
|
+
- name: api
|
|
221
|
+
path: .grimoire/docs/api.md
|
|
222
|
+
directory: src/api
|
|
223
|
+
description: REST API layer — views, serializers, URL routing
|
|
224
|
+
- name: models
|
|
225
|
+
path: .grimoire/docs/models.md
|
|
226
|
+
directory: src/models
|
|
227
|
+
description: Data models, managers, querysets
|
|
228
|
+
- name: utils
|
|
229
|
+
path: .grimoire/docs/utils.md
|
|
230
|
+
directory: src/utils
|
|
231
|
+
description: Shared utilities, helpers, formatters
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The `directory` field links each doc back to the source directory — this is what `grimoire map --refresh` uses to detect gaps.
|
|
235
|
+
|
|
236
|
+
### Freshness Tracking
|
|
237
|
+
|
|
238
|
+
Every area doc and the data schema must include a `Last updated` date in a comment or header. This lets other skills (plan, apply) judge whether the docs are trustworthy or stale.
|
|
239
|
+
|
|
240
|
+
**In `index.yml`**, track freshness per area:
|
|
241
|
+
```yaml
|
|
242
|
+
areas:
|
|
243
|
+
- name: api
|
|
244
|
+
path: .grimoire/docs/api.md
|
|
245
|
+
directory: src/api
|
|
246
|
+
description: REST API layer — views, serializers, URL routing
|
|
247
|
+
last_updated: 2026-04-05
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**In each area doc**, include a last-updated line at the top:
|
|
251
|
+
```markdown
|
|
252
|
+
# API Layer
|
|
253
|
+
> Last updated: 2026-04-05
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**In `schema.yml`**, the `Last updated` comment at the top already serves this purpose.
|
|
257
|
+
|
|
258
|
+
**Staleness rule:** If an area doc is older than the most recent commit touching that directory (check via `git log -1 --format=%ci <directory>`), it's potentially stale. When running a full scan or gap fill, flag stale docs and offer to refresh them.
|
|
259
|
+
|
|
260
|
+
**Why this matters:** Area docs are the primary mechanism for reducing context window usage and preventing hallucinations. Stale docs are worse than no docs — they give the agent confident but wrong information about file paths, function names, and patterns. Freshness tracking lets other skills know when to trust the docs vs. when to fall back to reading source files.
|
|
261
|
+
|
|
262
|
+
### 8. Present Summary
|
|
263
|
+
After generating, show the user:
|
|
264
|
+
- How many areas documented
|
|
265
|
+
- How many reusable utilities inventoried
|
|
266
|
+
- Any areas that seem under-organized or have pattern inconsistencies
|
|
267
|
+
- Suggest which area docs are most critical for the plan skill to read
|
|
268
|
+
|
|
269
|
+
## Config Files
|
|
270
|
+
|
|
271
|
+
Users can customize what gets scanned by editing files in `.grimoire/`:
|
|
272
|
+
|
|
273
|
+
- **`.grimoire/mapignore`** — directories/patterns to skip during scanning (like .gitignore). Edit to exclude vendor code, generated files, etc.
|
|
274
|
+
- **`.grimoire/mapkeys`** — key file definitions (format: `filename = type`). Edit to add project-specific indicators like `factories.py = test-factories` or `signals.py = django-signals`.
|
|
275
|
+
|
|
276
|
+
These are read by `grimoire map` and affect the snapshot this skill consumes.
|
|
277
|
+
|
|
278
|
+
## Integration with Other Skills
|
|
279
|
+
|
|
280
|
+
- The **plan** skill should read `.grimoire/docs/` before generating tasks — look for existing utilities in the reuse inventory, follow documented patterns
|
|
281
|
+
- The **verify** skill can check new code against documented patterns
|
|
282
|
+
- The **audit** skill can trigger a discover pass as part of onboarding
|
|
283
|
+
- Run `grimoire map --refresh` periodically to detect new undocumented areas, then `/grimoire:discover` to fill the gaps
|
|
284
|
+
|
|
285
|
+
## Important
|
|
286
|
+
- **Start from the snapshot.** Don't scan the filesystem yourself — `grimoire map` already did that. Read `.snapshot.json` for structure, then use `codebase-memory-mcp` graph queries for symbols and call graphs (if available), and read actual code files for meaning.
|
|
287
|
+
- **Prefer graph queries over file reads.** If `codebase-memory-mcp` is available, use `search_graph` and `query_graph` to find symbols, call paths, and architecture rather than reading every source file. This is faster, more accurate (AST-parsed), and uses fewer tokens.
|
|
288
|
+
- **Document what IS, not what should be.** This is a map of the actual codebase, not aspirational standards. If the code is inconsistent, note it — don't paper over it.
|
|
289
|
+
- **Point, don't copy.** Reference files and line numbers as exemplars. Don't duplicate code into the docs — it goes stale.
|
|
290
|
+
- **Focus on what helps LLMs.** The goal is preventing duplicate code and misplaced files. Prioritize: reusable utilities > file placement > naming conventions > architectural patterns.
|
|
291
|
+
- **Keep docs lean.** Each area doc should be scannable in 30 seconds. If it's too long, split it.
|
|
292
|
+
- **The reuse inventory is the most valuable output.** An LLM that knows `format_currency()` exists in `utils/formatters.py` won't write a new one.
|
|
293
|
+
- **Don't document the obvious.** Skip areas that are self-explanatory from file names alone. Focus on areas where an LLM would make mistakes.
|
|
294
|
+
- **Update, don't accumulate.** When refreshing, replace stale docs rather than appending. The docs should reflect the current codebase, not its history.
|
|
295
|
+
|
|
296
|
+
## Done
|
|
297
|
+
When area docs, schema, context, and index are generated, the workflow is complete. Suggest `grimoire-audit` to document existing features and decisions as Gherkin specs and ADRs.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
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.
|
|
4
|
+
compatibility: Designed for Claude Code (or similar products)
|
|
5
|
+
metadata:
|
|
6
|
+
author: kiwi-data
|
|
7
|
+
version: "0.1"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# grimoire-draft
|
|
11
|
+
|
|
12
|
+
Draft or update Gherkin features and MADR architecture decisions collaboratively with the user.
|
|
13
|
+
|
|
14
|
+
## Triggers
|
|
15
|
+
- User describes new functionality, behavior changes, or feature requests
|
|
16
|
+
- User asks to create/update a feature spec or requirement
|
|
17
|
+
- User describes a technology choice, architecture decision, or trade-off
|
|
18
|
+
- Loose match: contains "feature", "requirement", "spec", "decision", "grimoire" with "create", "draft", "plan", "start", "new"
|
|
19
|
+
|
|
20
|
+
## Routing
|
|
21
|
+
- Bug report ("something is broken") → `grimoire-bug` or `grimoire-bug-report`
|
|
22
|
+
- Pure refactoring (no behavior change) → no grimoire artifact needed. Suggest an ADR only if architecturally significant.
|
|
23
|
+
- Config, deps, formatting → not grimoire territory. Just do it.
|
|
24
|
+
- If unclear after one clarifying question, default to drafting a feature.
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
### 1. Qualify the Request
|
|
29
|
+
Before doing anything, determine what kind of change this is:
|
|
30
|
+
|
|
31
|
+
- **Behavioral** (Given/When/Then expressible) → draft `.feature` files
|
|
32
|
+
- **Architectural** (trade-off, choice, structural) → draft MADR decision record
|
|
33
|
+
- **Both** → draft features AND decision records
|
|
34
|
+
- **Bug fix** → STOP. Tell the user: "The feature file already describes the correct behavior. Let's just fix the code."
|
|
35
|
+
- **Refactoring** → STOP. No behavior change = no grimoire artifact. Suggest an ADR only if it's a significant architectural shift.
|
|
36
|
+
- **Config/deps/formatting** → STOP. Not grimoire territory.
|
|
37
|
+
|
|
38
|
+
If unclear, ask the user one clarifying question to route correctly.
|
|
39
|
+
|
|
40
|
+
### 2. Score Complexity
|
|
41
|
+
|
|
42
|
+
Assess the change's complexity to determine how much ceremony is appropriate. Score based on these signals:
|
|
43
|
+
|
|
44
|
+
| Level | Label | Signals | Ceremony |
|
|
45
|
+
|-------|-------|---------|----------|
|
|
46
|
+
| 1 | **Trivial** | Config, typo, copy change, single-file fix | Skip research (step 3). Minimal manifest (Why + Feature/Decision list only). No Pre-Mortem. |
|
|
47
|
+
| 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. |
|
|
48
|
+
| 3 | **Moderate** | Multiple capabilities, architecture decisions, data model changes, new dependencies | Full research (step 3). Full manifest with Assumptions and Pre-Mortem. |
|
|
49
|
+
| 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). |
|
|
50
|
+
|
|
51
|
+
Record the level in `manifest.md` frontmatter as `complexity: <1-4>`. Downstream skills use this:
|
|
52
|
+
- **Plan** adjusts task granularity (level 1-2: coarser tasks; level 3-4: fine-grained with context blocks)
|
|
53
|
+
- **Review** adjusts persona depth (level 1: skip review; level 2: Senior Engineer only; level 3: all relevant personas; level 4: all personas mandatory)
|
|
54
|
+
|
|
55
|
+
If unsure between two levels, pick the higher one. The user can override: "this is simpler than you think" or "treat this as complex."
|
|
56
|
+
|
|
57
|
+
### 3. Research Existing Solutions
|
|
58
|
+
Before designing, research what already exists. Do not ask the user to research — do it yourself.
|
|
59
|
+
|
|
60
|
+
- **Level 1**: Skip this step.
|
|
61
|
+
- **Level 2**: Light research — check built-ins and first-party ecosystem only.
|
|
62
|
+
- **Level 3-4**: Full research across all categories.
|
|
63
|
+
|
|
64
|
+
Follow the methodology in `../references/build-vs-buy.md`. Present findings to the user and wait for agreement before proceeding.
|
|
65
|
+
|
|
66
|
+
### 4. Elicit Requirements
|
|
67
|
+
Now that you know whether you're building, adopting, or going hybrid, surface the requirements the user hasn't specified.
|
|
68
|
+
|
|
69
|
+
- **Level 1**: Skip this step.
|
|
70
|
+
- **Level 2+**: Follow `../references/elicitation-personas.md` at the depth matching your complexity level.
|
|
71
|
+
|
|
72
|
+
The build-vs-buy outcome shapes which questions matter:
|
|
73
|
+
- **Adopting**: Focus on integration — how it fits, what config is needed. Skip deep business-rule elicitation.
|
|
74
|
+
- **Building custom**: Full elicitation — business rules, edge cases, data contracts, security, NFRs.
|
|
75
|
+
- **Hybrid**: Elicit deeply for custom parts. For adopted parts, focus on integration boundaries.
|
|
76
|
+
|
|
77
|
+
Present a Requirements Summary (template in the reference) and wait for user confirmation before proceeding.
|
|
78
|
+
|
|
79
|
+
### 5. Check Existing State
|
|
80
|
+
- Read `features/` to understand the current behavioral baseline
|
|
81
|
+
- Read `.grimoire/decisions/` to understand existing architecture decisions
|
|
82
|
+
- 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)
|
|
83
|
+
- Check `.grimoire/changes/` for any in-progress changes that might overlap
|
|
84
|
+
- If there's a conflict with an active change, flag it
|
|
85
|
+
|
|
86
|
+
### 6. Scaffold the Change
|
|
87
|
+
- Choose a `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`)
|
|
88
|
+
- Create `.grimoire/changes/<change-id>/`
|
|
89
|
+
|
|
90
|
+
### 7. Draft Artifacts
|
|
91
|
+
**For behavioral changes:**
|
|
92
|
+
- Write proposed `.feature` files in `.grimoire/changes/<change-id>/features/<capability>/`
|
|
93
|
+
- If modifying an existing feature, copy the current baseline first, then modify
|
|
94
|
+
- Follow Gherkin best practices:
|
|
95
|
+
- Feature title + user story (As a / I want / So that)
|
|
96
|
+
- Background for shared preconditions
|
|
97
|
+
- One scenario per behavior
|
|
98
|
+
- Given/When/Then — describe WHAT, never HOW
|
|
99
|
+
- No implementation details in feature files
|
|
100
|
+
|
|
101
|
+
**Security tags on scenarios:**
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
**For architecture decisions:**
|
|
105
|
+
- Write MADR record in `.grimoire/changes/<change-id>/decisions/`
|
|
106
|
+
- Use the template from `.grimoire/decisions/template.md` or the AGENTS.md format
|
|
107
|
+
- Include considered options, decision drivers, and consequences
|
|
108
|
+
|
|
109
|
+
**For changes that touch data:**
|
|
110
|
+
- Check `.grimoire/docs/data/schema.yml` for the current data schema (if it exists)
|
|
111
|
+
- 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
|
|
112
|
+
- Use the same YAML format as `schema.yml` but only include what's changing — new models, added/removed fields, new external API integrations
|
|
113
|
+
- Mark changes clearly with `action:` on each entry:
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
# Proposed data changes for: add-user-profiles
|
|
117
|
+
|
|
118
|
+
users:
|
|
119
|
+
action: modify
|
|
120
|
+
source: src/models/user.py
|
|
121
|
+
fields:
|
|
122
|
+
avatar_url: # new field
|
|
123
|
+
action: add
|
|
124
|
+
type: varchar
|
|
125
|
+
nullable: true
|
|
126
|
+
legacy_name: # removing a field
|
|
127
|
+
action: remove
|
|
128
|
+
|
|
129
|
+
profiles:
|
|
130
|
+
action: add # entirely new model
|
|
131
|
+
type: collection
|
|
132
|
+
fields:
|
|
133
|
+
user_id: { type: objectId, ref: users }
|
|
134
|
+
bio: { type: string, max_length: 500 }
|
|
135
|
+
social_links:
|
|
136
|
+
type: array
|
|
137
|
+
items:
|
|
138
|
+
platform: { type: string }
|
|
139
|
+
url: { type: string }
|
|
140
|
+
|
|
141
|
+
github_api:
|
|
142
|
+
action: add # new external API dependency
|
|
143
|
+
type: external_api
|
|
144
|
+
provider: GitHub
|
|
145
|
+
schema_ref: https://docs.github.com/en/rest
|
|
146
|
+
client: src/integrations/github.py
|
|
147
|
+
endpoints:
|
|
148
|
+
get_user:
|
|
149
|
+
method: GET
|
|
150
|
+
path: /users/{username}
|
|
151
|
+
request: # document what you send
|
|
152
|
+
headers:
|
|
153
|
+
Authorization: "Bearer {token}"
|
|
154
|
+
response: # document what you expect back
|
|
155
|
+
login: { type: string, required: true }
|
|
156
|
+
avatar_url: { type: string, required: true }
|
|
157
|
+
name: { type: string, nullable: true }
|
|
158
|
+
error_response: # document known error shapes
|
|
159
|
+
message: { type: string }
|
|
160
|
+
status: { type: integer }
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Contract documentation is mandatory for external APIs.** Every endpoint entry must include:
|
|
164
|
+
- **`request`**: headers, query params, or body fields your client sends
|
|
165
|
+
- **`response`**: fields your client reads, with types and `required: true` for fields your code depends on
|
|
166
|
+
- **`error_response`**: the error shape your client handles
|
|
167
|
+
|
|
168
|
+
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.
|
|
169
|
+
|
|
170
|
+
- If the change has no data impact, skip `data.yml` entirely — don't create an empty one
|
|
171
|
+
|
|
172
|
+
**For all changes:**
|
|
173
|
+
- Write `manifest.md` listing all artifacts, what's added/modified/removed, and why
|
|
174
|
+
- Include `complexity: <1-4>` in the manifest frontmatter (from step 2)
|
|
175
|
+
- **Level 1-2**: Assumptions and Pre-Mortem sections are optional (include if relevant)
|
|
176
|
+
- **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.
|
|
177
|
+
- **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.
|
|
178
|
+
- 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.
|
|
179
|
+
|
|
180
|
+
### 8. Collaborate
|
|
181
|
+
- Present the draft to the user
|
|
182
|
+
- Iterate based on feedback
|
|
183
|
+
- Do NOT proceed to plan stage without user approval
|
|
184
|
+
|
|
185
|
+
### 9. Validate
|
|
186
|
+
- Verify `.feature` files have valid Gherkin syntax
|
|
187
|
+
- Verify MADR records have valid YAML frontmatter (status, date)
|
|
188
|
+
- Verify manifest is complete and accurate
|
|
189
|
+
- Every Feature has a user story
|
|
190
|
+
- Every Scenario has at least Given + When + Then
|
|
191
|
+
- No implementation details leaked into features
|
|
192
|
+
|
|
193
|
+
## Important
|
|
194
|
+
- ONE change at a time. Don't combine unrelated changes.
|
|
195
|
+
- Features describe behavior, not implementation. If you catch yourself writing step-level implementation details, you've gone too far.
|
|
196
|
+
- The manifest is lightweight glue — don't over-document. Just enough to capture why.
|
|
197
|
+
- Always check if a capability/feature already exists before creating a new one.
|
|
198
|
+
|
|
199
|
+
## Done
|
|
200
|
+
When the user approves the draft, the workflow is complete. Present the change directory path and suggest next steps:
|
|
201
|
+
- `grimoire-plan` to generate implementation tasks
|
|
202
|
+
- Or further iteration if the user wants changes
|