@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,329 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grimoire-plan
|
|
3
|
+
description: Derive implementation tasks from approved Gherkin features and MADR decisions. Use when features are approved and ready for task breakdown.
|
|
4
|
+
compatibility: Designed for Claude Code (or similar products)
|
|
5
|
+
metadata:
|
|
6
|
+
author: kiwi-data
|
|
7
|
+
version: "0.1"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# grimoire-plan
|
|
11
|
+
|
|
12
|
+
Derive implementation tasks from approved Gherkin features and MADR decisions. The output must be detailed enough that any LLM can execute the tasks without further planning.
|
|
13
|
+
|
|
14
|
+
## Triggers
|
|
15
|
+
- User has approved a grimoire draft and wants to plan implementation
|
|
16
|
+
- User asks to create tasks or plan work for a grimoire change
|
|
17
|
+
- Loose match: "plan", "tasks" with a change reference
|
|
18
|
+
|
|
19
|
+
## Routing
|
|
20
|
+
- No approved change exists → `grimoire-draft` first
|
|
21
|
+
- Change is Level 1 (trivial) → plan is optional; suggest applying directly with minimal tasks
|
|
22
|
+
- User wants to review the design → `grimoire-review` (after plan, before apply)
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
- A change exists in `.grimoire/changes/<change-id>/` with:
|
|
26
|
+
- `manifest.md` (approved)
|
|
27
|
+
- At least one `.feature` file or decision record
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
### 1. Select Change
|
|
32
|
+
- List active changes in `.grimoire/changes/`
|
|
33
|
+
- If multiple, ask user which one to plan
|
|
34
|
+
- If only one, confirm it
|
|
35
|
+
|
|
36
|
+
### 2. Read All Artifacts
|
|
37
|
+
|
|
38
|
+
**Grimoire docs first, codebase second.** The `.grimoire/docs/` directory is a pre-computed map of the codebase — it tells you where code lives, what utilities exist, what patterns to follow, and what the data layer looks like. Read these *instead of* exploring the raw codebase. Only read specific source files when the docs don't have what you need.
|
|
39
|
+
|
|
40
|
+
**Always read:**
|
|
41
|
+
- `manifest.md` for the change summary, **including complexity level, Assumptions, Pre-Mortem, and Prior Art sections**
|
|
42
|
+
- All proposed `.feature` files
|
|
43
|
+
- All proposed decision records, **including Cost of Ownership sections**
|
|
44
|
+
- The current baseline (`features/`, `.grimoire/decisions/`) for context on what's changing
|
|
45
|
+
|
|
46
|
+
**Validate the build-vs-buy decision:**
|
|
47
|
+
- Check that `manifest.md` has a **Prior Art** section documenting what existing solutions were researched. If it's missing or empty, **stop and tell the user** — planning without a build-vs-buy analysis produces plans that ignore cheaper alternatives.
|
|
48
|
+
- If the decision was to **adopt** a library/service, the plan tasks should focus on integration, configuration, and contract testing — not reimplementation.
|
|
49
|
+
- If the decision was to **build custom**, verify the manifest documents (1) what existing tools were considered, (2) the specific requirements they don't meet, and (3) what design patterns are being borrowed from prior art.
|
|
50
|
+
- If the decision was **hybrid** (adopt for part, build for part), ensure the boundary between adopted and custom code is clear in the tasks.
|
|
51
|
+
|
|
52
|
+
**Read from grimoire docs (these replace codebase exploration):**
|
|
53
|
+
- **`.grimoire/docs/<area>.md`** for each area the change touches — these contain: key files with responsibilities, reusable utilities (exact function names, file paths, line numbers), naming conventions, structural patterns, and "Where New Code Goes" guidance. This is the information that lets you write tasks with exact file paths without reading every source file.
|
|
54
|
+
- **`.grimoire/docs/data/schema.yml`** — the full data model: every table/collection, field types, relationships, indexes, and external API contracts with `source:` pointers to ORM code. Read this instead of reading individual model files.
|
|
55
|
+
- **`.grimoire/docs/context.yml`** — the project's deployment environment, related services, infrastructure dependencies, CI/CD pipelines, and observability setup. Read this to understand deployment constraints (e.g., Lambda means no long-running processes, Kubernetes means you may need health check endpoints), cross-service boundaries (e.g., auth is handled by a sibling service, not this project), and infrastructure available at runtime (e.g., Redis is available for caching, RabbitMQ for async tasks).
|
|
56
|
+
- **`.grimoire/docs/.snapshot.json`** `duplicates` section if present — existing clones in areas you're touching, so tasks consolidate rather than add more.
|
|
57
|
+
|
|
58
|
+
**Read proposed data changes:**
|
|
59
|
+
- **`data.yml`** if present — proposed schema changes need migration and model tasks
|
|
60
|
+
|
|
61
|
+
**Read specific source files only when:**
|
|
62
|
+
- Area docs don't exist yet (tell the user to run `grimoire map` + `/grimoire:discover` first — planning without area docs produces worse tasks)
|
|
63
|
+
- Area docs exist but you need to verify a specific implementation detail (e.g., exact function signature, exact import path)
|
|
64
|
+
- You need to read existing step definitions to understand the test setup
|
|
65
|
+
|
|
66
|
+
**Do NOT read the entire codebase** for "context." The plan skill's job is to produce tasks with specific file paths and specific assertions. Area docs + data schema give you this. Reading dozens of source files wastes context window and doesn't produce better plans.
|
|
67
|
+
|
|
68
|
+
### 3. Check Specification Completeness
|
|
69
|
+
|
|
70
|
+
Before generating tasks, evaluate whether the specifications are detailed enough to plan against. Underspecified requirements produce vague tasks, which produce wrong code.
|
|
71
|
+
|
|
72
|
+
Review the specs through each persona's lens and flag gaps. **Only check personas relevant to the change** — don't manufacture issues.
|
|
73
|
+
|
|
74
|
+
#### Outcome & Scope check
|
|
75
|
+
- Does the manifest have a clear **Why** that describes the outcome, not just the mechanism? ("Users can reset passwords" not "Add password reset endpoint.")
|
|
76
|
+
- Does the manifest have a **Non-goals** section? If missing or empty on a level 3-4 change, flag it — without non-goals, scope creep is invisible during implementation.
|
|
77
|
+
- Do any scenarios appear to implement something listed as a non-goal? Flag as **blocker** — the draft contradicts itself.
|
|
78
|
+
|
|
79
|
+
Evaluate through each relevant persona's lens — see `../references/elicitation-personas.md` for the full question set. In plan, you're checking completeness, not asking questions. Flag gaps as issues.
|
|
80
|
+
|
|
81
|
+
**Key checks per persona:**
|
|
82
|
+
- **Outcome & Scope**: Does the manifest have a clear Why (outcome, not mechanism)? Does it have Non-goals? Do any scenarios contradict non-goals?
|
|
83
|
+
- **PM**: Scenarios for success AND errors? User stories on every feature? Specific Given/When/Then (not vague)?
|
|
84
|
+
- **Engineer**: Unvalidated assumptions on critical path? Prior art patterns documented (if building custom)? Scenarios specific enough for concrete file paths?
|
|
85
|
+
- **Security**: Input/auth/sensitive-data scenarios have corresponding error/abuse scenarios? Quality Attribute targets not blank?
|
|
86
|
+
- **Data**: External APIs or new models without `data.yml`? Data constraints specified (required, unique, nullable)?
|
|
87
|
+
- **QA**: Negative scenario for every happy path? Boundary values specified?
|
|
88
|
+
|
|
89
|
+
**If issues are found:**
|
|
90
|
+
|
|
91
|
+
1. Present findings grouped by persona, with a specific question for each gap
|
|
92
|
+
2. Ask the user to choose:
|
|
93
|
+
- **Clarify now** — answer the questions and update the draft before continuing to task generation
|
|
94
|
+
- **Proceed anyway** — acknowledge the gaps and plan around them (tasks will note where assumptions were made)
|
|
95
|
+
- **Return to draft** — go back to `grimoire-draft` to fill in the gaps
|
|
96
|
+
|
|
97
|
+
This is not a gate — level 1-2 changes (from manifest `complexity`) can proceed with minor gaps. Level 3-4 changes with multiple signals should strongly recommend clarification before planning.
|
|
98
|
+
|
|
99
|
+
**If no issues are found**, proceed directly to task generation.
|
|
100
|
+
|
|
101
|
+
### 4. Generate Tasks
|
|
102
|
+
Create `.grimoire/changes/<change-id>/tasks.md`. **Every scenario must produce both production code AND tests.** Tasks are structured as pairs: step definitions first, then production code.
|
|
103
|
+
|
|
104
|
+
**THE PLAN MUST RESPECT NON-GOALS.** Read the manifest's Non-goals section. If a task would touch, implement, or extend something listed as a non-goal, do not include it. If you think a non-goal should be reconsidered, flag it to the user — don't silently include it.
|
|
105
|
+
|
|
106
|
+
**THE PLAN MUST BE SPECIFIC ENOUGH TO EXECUTE WITHOUT FURTHER PLANNING.**
|
|
107
|
+
|
|
108
|
+
**THE PLAN MUST PREFER SIMPLICITY.** For each task, choose the approach with the least code, fewest new files, and smallest surface area. If a task can be solved by adding a few lines to an existing file, don't create a new module. If a standard library function does the job, don't pull in a dependency. If three lines of inline code are clearer than a helper, keep them inline. Flag any task that introduces a new abstraction, utility, or pattern — it needs a reason.
|
|
109
|
+
|
|
110
|
+
**THE PLAN MUST USE PROVEN PATTERNS, NOT INVENT NEW ONES.** When the task fits a well-known pattern, name it and follow it:
|
|
111
|
+
- **Data pipelines** → ETL (Extract, Transform, Load) or ELT. Name stages explicitly. Don't invent a bespoke "data flow."
|
|
112
|
+
- **Web applications** → MVC, MVP, or MVVM depending on the framework's conventions. Follow the framework, don't fight it.
|
|
113
|
+
- **APIs** → RESTful resource design, or the project's existing API style. Don't mix conventions.
|
|
114
|
+
- **Background jobs** → Producer/consumer, pub/sub, or the framework's job/task pattern (e.g., Celery tasks, Bull queues).
|
|
115
|
+
- **State management** → Use the framework's idiomatic approach (Redux, Vuex, signals, etc.), not a hand-rolled event system.
|
|
116
|
+
- **Authentication & security** → Always recommend proven security processes: OAuth2/OIDC for auth flows, bcrypt/argon2 for password hashing, CSRF protection for forms, parameterized queries for database access. Never roll custom crypto, custom auth tokens, or custom session management when a battle-tested library exists.
|
|
117
|
+
|
|
118
|
+
**THE PLAN MUST RESPECT SECURITY TAGS AND COMPLIANCE.**
|
|
119
|
+
Check `.grimoire/config.yaml` under `project.compliance`. When scenarios have security tags, the plan must include corresponding tasks per `../references/security-compliance.md` (section "What Each Tag Requires — In planning").
|
|
120
|
+
|
|
121
|
+
If no compliance frameworks are configured and no security tags are present, skip this.
|
|
122
|
+
|
|
123
|
+
If no established pattern applies, state that explicitly in the task and explain why.
|
|
124
|
+
|
|
125
|
+
**THE PLAN MUST ENFORCE SINGLE RESPONSIBILITY.** Each file, class, and function should do one thing:
|
|
126
|
+
- A function that fetches data should not also format it for display
|
|
127
|
+
- A class that manages database access should not also handle HTTP responses
|
|
128
|
+
- A module that defines routes should not also contain business logic
|
|
129
|
+
- If a task description combines two distinct responsibilities (e.g., "fetch and render", "validate and persist"), split it into separate tasks or explicitly call out the boundary in the task description
|
|
130
|
+
- When planning new files, each file should have a clear, singular purpose. Name it after what it does, not what feature it supports
|
|
131
|
+
|
|
132
|
+
**THE PLAN MUST USE CLEAR NAMING AND FLAT STRUCTURE.**
|
|
133
|
+
- Variables, functions, classes, and files must have descriptive names that reveal intent — `calculate_invoice_total` not `calc`, `UserAuthenticationService` not `UAS`, `test_login_redirects_to_dashboard` not `test_login_1`
|
|
134
|
+
- Avoid abbreviations unless they are universally understood in the domain (e.g., `URL`, `HTTP`, `ID`)
|
|
135
|
+
- Avoid deep nesting: if a task would produce code with more than 3 levels of indentation, restructure it. Use early returns/guard clauses, extract helper functions, or use pipeline/chain patterns. The plan should call this out explicitly when the task involves conditional or iterative logic
|
|
136
|
+
|
|
137
|
+
Each task must include:
|
|
138
|
+
- **What file(s) to create or edit** — exact paths, not vague references
|
|
139
|
+
- **What to implement** — specific functions, classes, views, routes, not just "implement the feature"
|
|
140
|
+
- **Which scenario it satisfies** — traceability back to the .feature file
|
|
141
|
+
- **What the step definition should assert** — the expected behavior, not just "write a test"
|
|
142
|
+
|
|
143
|
+
Bad task (too vague — will trigger re-planning):
|
|
144
|
+
```
|
|
145
|
+
- [ ] 1.1 Implement login with 2FA
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Good task (specific enough to execute):
|
|
149
|
+
```
|
|
150
|
+
- [ ] 1.1 Write step defs in `tests/step_defs/test_auth.py` for scenario: "Successful login with valid TOTP code" in `auth/login.feature`
|
|
151
|
+
- Given step: call `client.post('/login/', credentials)` to log in
|
|
152
|
+
- When step: call `client.post('/verify-totp/', {'code': valid_code})`
|
|
153
|
+
- Then step: assert response redirects to `/dashboard/` (status 302)
|
|
154
|
+
- [ ] 1.2 Add TOTP verification to `auth/views.py`:
|
|
155
|
+
- Create `VerifyTOTPView` accepting POST with `code` field
|
|
156
|
+
- Validate code against user's TOTP secret using `pyotp`
|
|
157
|
+
- On success: complete login session, redirect to dashboard
|
|
158
|
+
- On failure: return to verification page with error message
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**From feature scenarios:**
|
|
162
|
+
- Each new scenario → step definition task + implementation task
|
|
163
|
+
- Each modified scenario → update step def + update implementation
|
|
164
|
+
- Group by capability/feature file
|
|
165
|
+
- Step definitions come BEFORE production code (red-green BDD cycle)
|
|
166
|
+
- **Use the project's configured BDD tool** — check `.grimoire/config.yaml` under `tools.bdd_test` for the test runner (e.g., `behave`, `pytest-bdd`, `cucumber-js`, `cucumber`). Step definitions must follow that tool's conventions:
|
|
167
|
+
- **behave** (Python): step defs in `features/steps/`, use `@given`, `@when`, `@then` decorators from `behave`
|
|
168
|
+
- **pytest-bdd** (Python): step defs alongside tests, use `@scenario`, `@given`, `@when`, `@then` from `pytest_bdd`
|
|
169
|
+
- **cucumber-js** (JS/TS): step defs in `features/step_definitions/`, use `Given`, `When`, `Then` from `@cucumber/cucumber`
|
|
170
|
+
- If no BDD tool is configured, check the existing test directory structure and imports to infer which framework is in use
|
|
171
|
+
|
|
172
|
+
**From decisions:**
|
|
173
|
+
- Each decision → implementation task(s) with specific files and changes
|
|
174
|
+
- If the ADR has a Confirmation section → add a test/check task for it
|
|
175
|
+
|
|
176
|
+
**Shared step definitions:**
|
|
177
|
+
- Identify steps that will be reused across scenarios (Given steps especially)
|
|
178
|
+
- These go in the project's common step location (check existing test setup)
|
|
179
|
+
- Group by domain concept, NOT by feature file
|
|
180
|
+
|
|
181
|
+
**From data.yml (if present):**
|
|
182
|
+
- Each new model → migration task + ORM/schema task
|
|
183
|
+
- Each modified field → migration task (specify: is it safe to run live? nullable? default?)
|
|
184
|
+
- Each removed field → migration task with data cleanup if needed
|
|
185
|
+
- Each new external API → client wrapper task referencing `schema_ref` for the full contract
|
|
186
|
+
- Each new or modified external API → **contract validation test task** that asserts the client's request/response shapes match the contract documented in `data.yml` / `schema.yml`. The test should:
|
|
187
|
+
- Validate that every `required: true` response field is read and typed correctly in the client
|
|
188
|
+
- Validate that request payloads match the documented shape (required fields present, types correct)
|
|
189
|
+
- Validate error response handling matches the documented `error_response` shape
|
|
190
|
+
- Use a recorded/fixture response (not a live call) so the test runs locally without network access
|
|
191
|
+
- Each modified external API client (existing API, changed usage) → **contract regression test** that catches if the client drifts from the documented contract. If the client starts reading a new field or stops sending a required field, the test must fail.
|
|
192
|
+
- Data tasks come BEFORE feature implementation tasks — the models must exist before code that uses them
|
|
193
|
+
- Order: schema/model changes → migrations → contract tests → seed data (if any) → then feature code
|
|
194
|
+
|
|
195
|
+
**Mocking strategy for external services:**
|
|
196
|
+
Follow the rules in `../references/testing-contracts.md`. Key points: mock at HTTP boundary (not client), fixtures must match `schema.yml`, include error fixtures. Each contract test task must specify: (1) which HTTP mocking library, (2) which fixture file, (3) what the fixture contains (from `schema.yml`).
|
|
197
|
+
|
|
198
|
+
**From manifest Assumptions:**
|
|
199
|
+
- Each unvalidated assumption on the critical path → a verification task (spike, proof-of-concept, or integration test that confirms the assumption holds)
|
|
200
|
+
- If an assumption turns out to be wrong during planning, flag it to the user — it may invalidate the change
|
|
201
|
+
|
|
202
|
+
**From manifest Pre-Mortem:**
|
|
203
|
+
- Each failure mode with a mitigation → the mitigation becomes a task or an edge case to cover in an existing task
|
|
204
|
+
- Each failure mode marked "accepted" → add a comment in the relevant code or test noting the accepted risk, so future developers understand the trade-off
|
|
205
|
+
- Pre-mortem risks often reveal missing scenarios — if a failure mode isn't covered by any Gherkin scenario, consider whether it should be
|
|
206
|
+
|
|
207
|
+
**From decision Cost of Ownership:**
|
|
208
|
+
- Prefer implementation approaches that minimize the maintenance burden identified in the ADR
|
|
209
|
+
- If the ADR identifies sunset criteria, add a task to document them where they'll be seen (e.g., a comment in config, a monitoring alert, or a calendar reminder)
|
|
210
|
+
- If maintenance burden is high, prefer simpler alternatives even if they're less elegant
|
|
211
|
+
|
|
212
|
+
**From manifest Prior Art (when building custom):**
|
|
213
|
+
- If the manifest identifies design patterns borrowed from existing tools, tasks must follow those patterns — don't reinvent what the prior art already refined
|
|
214
|
+
- If the manifest identifies specific data flows or API shapes from existing tools, reference them in the task descriptions so the implementing agent understands the intent
|
|
215
|
+
- If the prior art research surfaced an existing tool that covers part of the need, consider whether the plan should adopt it for that part instead of building everything custom — flag this to the user as a simplification opportunity
|
|
216
|
+
- If a library was rejected for a specific reason (e.g., doesn't support X), add a comment to the relevant task noting this so future developers don't re-evaluate the same option
|
|
217
|
+
|
|
218
|
+
**Existing code to reuse:**
|
|
219
|
+
- If `.grimoire/docs/` has area docs, check the Reusable Code tables for utilities that apply to this change
|
|
220
|
+
- If the snapshot has duplicate data, check whether the area you're touching already has clones — tasks should consolidate rather than add more
|
|
221
|
+
- Add a "Reuse" section at the top of tasks.md listing specific functions/classes to import instead of rewriting
|
|
222
|
+
|
|
223
|
+
**Verification (always last):**
|
|
224
|
+
- Run ALL feature files — new and existing
|
|
225
|
+
- Run full project test suite
|
|
226
|
+
- Validate ADR confirmation criteria (if applicable)
|
|
227
|
+
|
|
228
|
+
### 5. Task Format
|
|
229
|
+
The tasks file starts with a context block so any LLM can orient without re-reading every artifact. Each task section includes a `<!-- context: ... -->` block listing the exact files an agent should load before working on that section. This is critical for reducing context rot — each task or task group can run in a fresh session that loads only what it needs.
|
|
230
|
+
|
|
231
|
+
```markdown
|
|
232
|
+
# Tasks: <change-id>
|
|
233
|
+
|
|
234
|
+
> **Change**: <one-line summary from manifest>
|
|
235
|
+
> **Features**: <list of .feature files in this change>
|
|
236
|
+
> **Decisions**: <list of ADRs in this change, or "none">
|
|
237
|
+
> **Test command**: `<exact command to run feature tests, e.g., pytest tests/ -k "auth">`
|
|
238
|
+
> **Status**: X/Y tasks complete
|
|
239
|
+
|
|
240
|
+
## 1. <Capability/Area>
|
|
241
|
+
<!-- context:
|
|
242
|
+
- .grimoire/changes/<change-id>/features/<capability>/<name>.feature
|
|
243
|
+
- .grimoire/docs/<area>.md
|
|
244
|
+
- src/<area>/<file-to-edit>.ts
|
|
245
|
+
- tests/<area>/<test-file>.ts
|
|
246
|
+
-->
|
|
247
|
+
- [ ] 1.1 Write step defs in `<exact path>` for scenario: "<scenario name>" in `<file>`
|
|
248
|
+
- Given: <what the step does, what it calls>
|
|
249
|
+
- When: <what the step does, what it calls>
|
|
250
|
+
- Then: <what to assert — specific expected values/states>
|
|
251
|
+
- [ ] 1.2 Implement in `<exact path>`:
|
|
252
|
+
- <specific function/class/view to create or modify>
|
|
253
|
+
- <specific behavior to implement>
|
|
254
|
+
- <edge cases to handle>
|
|
255
|
+
- [ ] 1.3 Write step defs in `<exact path>` for scenario: "<next scenario>"
|
|
256
|
+
...
|
|
257
|
+
- [ ] 1.4 Implement in `<exact path>`:
|
|
258
|
+
...
|
|
259
|
+
|
|
260
|
+
## 2. Shared Steps
|
|
261
|
+
<!-- context:
|
|
262
|
+
- tests/step_defs/common.py
|
|
263
|
+
- .grimoire/changes/<change-id>/features/<all relevant .feature files>
|
|
264
|
+
-->
|
|
265
|
+
- [ ] 2.1 Add to `<exact path>`:
|
|
266
|
+
- Given "<step text>": <what it does>
|
|
267
|
+
- Given "<step text>": <what it does>
|
|
268
|
+
|
|
269
|
+
## 3. Architecture
|
|
270
|
+
<!-- context:
|
|
271
|
+
- .grimoire/changes/<change-id>/decisions/<nnnn-title>.md
|
|
272
|
+
- src/<files affected by decision>
|
|
273
|
+
-->
|
|
274
|
+
- [ ] 3.1 In `<exact path>`: <specific change from ADR>
|
|
275
|
+
- [ ] 3.2 Add test in `<exact path>`: <ADR confirmation check — what to assert>
|
|
276
|
+
|
|
277
|
+
## 4. Verification
|
|
278
|
+
- [ ] 4.1 Run `<exact test command>` — all new scenarios green
|
|
279
|
+
- [ ] 4.2 Run `<exact test command>` — no regressions
|
|
280
|
+
- [ ] 4.3 Run `<exact test command>` — full project suite
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Context blocks are mandatory.** Every task section (except Verification) must have a `<!-- context: ... -->` listing the files needed. This serves two purposes:
|
|
284
|
+
1. **Fresh sessions:** An agent starting a new session loads only the context block for its current section, avoiding accumulated noise from prior work
|
|
285
|
+
2. **Subagent delegation:** In Claude Code, the parent agent passes the context list when spawning a subagent for a task group
|
|
286
|
+
|
|
287
|
+
### 6. Quality Check
|
|
288
|
+
Before presenting to the user, verify the plan:
|
|
289
|
+
- [ ] Every task references a specific file path (no "implement the feature")
|
|
290
|
+
- [ ] Every step definition task describes what to assert (no "write a test")
|
|
291
|
+
- [ ] Every implementation task describes what to create/modify (no "add the code")
|
|
292
|
+
- [ ] The verification section has the exact commands to run
|
|
293
|
+
- [ ] Tasks are ordered: shared steps → step defs → production code → verification
|
|
294
|
+
- [ ] No task requires the LLM to make architectural decisions — those should already be in the ADR
|
|
295
|
+
|
|
296
|
+
If any task is too vague, make it more specific before presenting. Read more codebase if needed.
|
|
297
|
+
|
|
298
|
+
### 7. Present to User
|
|
299
|
+
- Present tasks to user
|
|
300
|
+
- Confirm order and scope
|
|
301
|
+
- Adjust based on feedback
|
|
302
|
+
|
|
303
|
+
### 8. Design Review
|
|
304
|
+
- Once the user approves the tasks, suggest running `grimoire-review` for a multi-perspective design review
|
|
305
|
+
- **Complexity 1**: Skip review — suggest proceeding directly to `grimoire-apply`
|
|
306
|
+
- **Complexity 2-3**: Review is **optional** — the user can skip it and go straight to `grimoire-apply`
|
|
307
|
+
- **Complexity 4**: Review is **mandatory** — do not suggest skipping
|
|
308
|
+
- If the user wants the review, hand off to the `grimoire-review` skill
|
|
309
|
+
- Do NOT proceed to apply without user approval
|
|
310
|
+
|
|
311
|
+
### Agent Configuration
|
|
312
|
+
Check `.grimoire/config.yaml` for the configured agents:
|
|
313
|
+
- **Planning** uses the `thinking` agent (`llm.thinking.command` / `llm.thinking.model`) — optimized for reasoning and design
|
|
314
|
+
- **Implementation** uses the `coding` agent (`llm.coding.command` / `llm.coding.model`) — optimized for code generation
|
|
315
|
+
- If the user has configured separate thinking/coding agents, note this in the tasks.md header so the apply stage knows which agent to use
|
|
316
|
+
|
|
317
|
+
## Important
|
|
318
|
+
- **Specificity is the whole point.** A vague plan is worse than no plan — it gives false confidence and the LLM will re-plan anyway. Every task must be executable without thinking.
|
|
319
|
+
- Tasks should be small and specific — one logical unit of work each
|
|
320
|
+
- Every task traces back to a scenario or decision
|
|
321
|
+
- Order matters: dependencies first, verification last
|
|
322
|
+
- Don't generate tasks for things that already work (check the baseline)
|
|
323
|
+
- Read the actual codebase before writing tasks. Reference real file paths, real patterns, real conventions. Don't guess.
|
|
324
|
+
|
|
325
|
+
## Done
|
|
326
|
+
When the user approves the tasks, the workflow is complete. Suggest next steps based on complexity:
|
|
327
|
+
- **Level 1**: Skip review, proceed to `grimoire-apply`
|
|
328
|
+
- **Level 2-3**: Optionally run `grimoire-review`, or proceed to `grimoire-apply`
|
|
329
|
+
- **Level 4**: `grimoire-review` is mandatory before `grimoire-apply`
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grimoire-pr
|
|
3
|
+
description: Generate a pull request description from grimoire change artifacts with optional post-implementation LLM review. Use when the user is ready to create a PR.
|
|
4
|
+
compatibility: Designed for Claude Code (or similar products)
|
|
5
|
+
metadata:
|
|
6
|
+
author: kiwi-data
|
|
7
|
+
version: "0.1"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# grimoire-pr
|
|
11
|
+
|
|
12
|
+
Generate a pull request description from grimoire change artifacts and optionally run a post-implementation review.
|
|
13
|
+
|
|
14
|
+
## Triggers
|
|
15
|
+
- User wants to create a PR for a completed grimoire change
|
|
16
|
+
- User asks to generate a PR description
|
|
17
|
+
- Loose match: "PR", "pull request", "ready to merge", "create PR"
|
|
18
|
+
|
|
19
|
+
## Routing
|
|
20
|
+
- Tasks incomplete → `grimoire-apply` first (or create a draft PR)
|
|
21
|
+
- Haven't committed yet → `grimoire-commit` first
|
|
22
|
+
- Want a pre-merge design review → this skill includes optional post-implementation review
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
- A change exists in `.grimoire/changes/<change-id>/` with:
|
|
26
|
+
- `manifest.md`
|
|
27
|
+
- `tasks.md` with all (or most) tasks checked
|
|
28
|
+
- Feature files and/or decision records
|
|
29
|
+
- The change should be on a feature branch (created during apply)
|
|
30
|
+
|
|
31
|
+
## Workflow
|
|
32
|
+
|
|
33
|
+
### 1. Select Change
|
|
34
|
+
- List active changes in `.grimoire/changes/`
|
|
35
|
+
- If multiple, ask user which one to create a PR for
|
|
36
|
+
- If only one, confirm it
|
|
37
|
+
|
|
38
|
+
### 2. Gather Artifacts
|
|
39
|
+
Read all change artifacts:
|
|
40
|
+
- `manifest.md` — change summary, scope, and why
|
|
41
|
+
- `tasks.md` — implementation checklist (check completion status)
|
|
42
|
+
- All `.feature` files — scenario names for the test plan
|
|
43
|
+
- All decision records — ADR titles for the description
|
|
44
|
+
- Read `.grimoire/config.yaml` for commit style
|
|
45
|
+
|
|
46
|
+
### 3. Generate PR Description
|
|
47
|
+
Compose the PR body from grimoire artifacts:
|
|
48
|
+
|
|
49
|
+
```markdown
|
|
50
|
+
## Summary
|
|
51
|
+
<from manifest's "Why" section — 1-3 sentences>
|
|
52
|
+
|
|
53
|
+
## Changes
|
|
54
|
+
<from manifest's "Feature Changes" section>
|
|
55
|
+
- **ADDED** `capability/name.feature` — description
|
|
56
|
+
- **MODIFIED** `capability/name.feature` — what changed
|
|
57
|
+
|
|
58
|
+
## Scenarios
|
|
59
|
+
<list all scenario names from the feature files>
|
|
60
|
+
- "Scenario name" (`feature/file.feature`)
|
|
61
|
+
- "Scenario name" (`feature/file.feature`)
|
|
62
|
+
|
|
63
|
+
## Decisions
|
|
64
|
+
<list ADR titles, or "None" if no architectural decisions>
|
|
65
|
+
- 0005: Use PostgreSQL for vector storage
|
|
66
|
+
|
|
67
|
+
## Test Plan
|
|
68
|
+
- [ ] All new feature scenarios pass
|
|
69
|
+
- [ ] No regressions in existing tests
|
|
70
|
+
- [ ] ADR confirmation criteria met (if applicable)
|
|
71
|
+
<additional items from tasks.md verification section>
|
|
72
|
+
|
|
73
|
+
## Security
|
|
74
|
+
<only include this section if the change has security-tagged scenarios or touches security-relevant code>
|
|
75
|
+
- Tags: `@security`, `@auth`, `@pii`, etc. (list all security tags from the feature files)
|
|
76
|
+
- Compliance: <list applicable frameworks from config, or "none configured">
|
|
77
|
+
- Security-tagged scenarios verified: X/Y
|
|
78
|
+
<if any security findings from review/verify exist, summarize the resolution>
|
|
79
|
+
|
|
80
|
+
Change: <change-id>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**PR title:** Derive from manifest heading, following the project's commit style:
|
|
84
|
+
- conventional: `feat: add two-factor authentication`
|
|
85
|
+
- angular: `feat(auth): add two-factor authentication`
|
|
86
|
+
|
|
87
|
+
### 4. Post-Implementation Review (Optional)
|
|
88
|
+
If the user wants a review, run a quick automated pass on the actual diff:
|
|
89
|
+
|
|
90
|
+
1. Get the diff: `git diff main...HEAD` (or the base branch)
|
|
91
|
+
2. Read `.grimoire/config.yaml` for `project.compliance` and check feature files for security tags
|
|
92
|
+
3. Feed the diff + PR description to the LLM with this prompt:
|
|
93
|
+
|
|
94
|
+
> Review this pull request for issues that the design review might have missed now that real code exists. Focus on:
|
|
95
|
+
> - Implementation doesn't match the scenarios described
|
|
96
|
+
> - Missing error handling for edge cases in the scenarios
|
|
97
|
+
> - Dependencies added that weren't in the plan
|
|
98
|
+
> - Files changed that aren't covered by the task list (scope creep)
|
|
99
|
+
> - Test quality: are step definitions making real assertions?
|
|
100
|
+
>
|
|
101
|
+
> **Security review** — scan changed files per `../references/security-compliance.md`: OWASP surface scan, security tag verification, compliance verification. Tag findings with OWASP/CWE.
|
|
102
|
+
> Flag issues as **blocker** or **suggestion**. Be concise.
|
|
103
|
+
|
|
104
|
+
4. Present findings alongside the PR description.
|
|
105
|
+
|
|
106
|
+
### 5. Create PR
|
|
107
|
+
Offer to create the PR:
|
|
108
|
+
- **Preview only** (default): Output the PR title + body for the user to copy
|
|
109
|
+
- **Create via gh**: If the user confirms and `gh` is available, run:
|
|
110
|
+
```
|
|
111
|
+
gh pr create --title "<title>" --body "<body>"
|
|
112
|
+
```
|
|
113
|
+
- **Create via glab**: If the project uses GitLab and `glab` is available:
|
|
114
|
+
```
|
|
115
|
+
glab mr create --title "<title>" --description "<body>"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Check that the branch is pushed to the remote before creating. If not, offer to push first.
|
|
119
|
+
|
|
120
|
+
### 6. Link Back
|
|
121
|
+
After PR creation:
|
|
122
|
+
- Update manifest's status to `complete` if not already
|
|
123
|
+
- Add the PR URL to the manifest as a comment or field
|
|
124
|
+
- Suggest running `grimoire archive <change-id>` to complete the lifecycle
|
|
125
|
+
|
|
126
|
+
## Important
|
|
127
|
+
- The PR description must trace back to grimoire artifacts — this is what makes the audit trail work.
|
|
128
|
+
- Include the `Change: <change-id>` line at the bottom so `grimoire trace` can find it.
|
|
129
|
+
- Don't pad the description with boilerplate. Keep it factual: what changed, why, how to verify.
|
|
130
|
+
- The post-implementation review is optional and quick — it's not a replacement for the design review, just a sanity check on the actual code.
|
|
131
|
+
- If tasks are incomplete, warn the user but don't block PR creation — they may want a draft PR.
|
|
132
|
+
|
|
133
|
+
## Done
|
|
134
|
+
When the PR is created (or description is presented for manual creation), the workflow is complete. Suggest `grimoire archive <change-id>` to complete the lifecycle.
|