@runecraft/grimoire 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/catalog.json +9 -0
  4. package/dist/grimoire.js +1758 -0
  5. package/package.json +54 -0
  6. package/references/definition-of-done.md +67 -0
  7. package/references/testing-patterns.md +260 -0
  8. package/skills/code-review-and-quality/README.md +13 -0
  9. package/skills/code-review-and-quality/SKILL.md +389 -0
  10. package/skills/code-simplification/README.md +13 -0
  11. package/skills/code-simplification/SKILL.md +338 -0
  12. package/skills/debugging-and-error-recovery/README.md +13 -0
  13. package/skills/debugging-and-error-recovery/SKILL.md +343 -0
  14. package/skills/debugging-and-error-recovery/scripts/__pycache__/triage_state.cpython-314.pyc +0 -0
  15. package/skills/debugging-and-error-recovery/scripts/triage_state.py +206 -0
  16. package/skills/deprecation-and-migration/README.md +13 -0
  17. package/skills/deprecation-and-migration/SKILL.md +248 -0
  18. package/skills/deprecation-and-migration/scripts/__pycache__/migration_tracker.cpython-314.pyc +0 -0
  19. package/skills/deprecation-and-migration/scripts/migration_tracker.py +237 -0
  20. package/skills/doubt-driven-development/README.md +13 -0
  21. package/skills/doubt-driven-development/SKILL.md +251 -0
  22. package/skills/git-commit-learning/.skill-meta.json +14 -0
  23. package/skills/git-commit-learning/README.md +205 -0
  24. package/skills/git-commit-learning/SKILL.md +435 -0
  25. package/skills/git-commit-learning/references/commit-patterns.md +595 -0
  26. package/skills/git-worktree/README.md +13 -0
  27. package/skills/git-worktree/SKILL.md +220 -0
  28. package/skills/idea-refine/README.md +13 -0
  29. package/skills/idea-refine/SKILL.md +186 -0
  30. package/skills/interview-me/README.md +13 -0
  31. package/skills/interview-me/SKILL.md +233 -0
  32. package/skills/linkedin-audit/SKILL.md +98 -0
  33. package/skills/linkedin-audit/references/dashboard-spec.md +43 -0
  34. package/skills/memory-management/README.md +13 -0
  35. package/skills/memory-management/SKILL.md +198 -0
  36. package/skills/security-and-hardening/README.md +13 -0
  37. package/skills/security-and-hardening/SKILL.md +472 -0
  38. package/skills/shipping-and-launch/README.md +13 -0
  39. package/skills/shipping-and-launch/SKILL.md +317 -0
  40. package/skills/skill-forge/README.md +153 -0
  41. package/skills/skill-forge/SKILL.md +291 -0
  42. package/skills/skill-forge/assets/SKILL.template.md +73 -0
  43. package/skills/skill-forge/references/authoring-patterns.md +249 -0
  44. package/skills/skill-forge/references/description-optimization.md +171 -0
  45. package/skills/skill-forge/references/output-evaluation.md +276 -0
  46. package/skills/skill-forge/references/scripts-guide.md +232 -0
  47. package/skills/skill-forge/references/spec.md +175 -0
  48. package/skills/skill-forge/scripts/validate.py +536 -0
  49. package/skills/spec-driven/.skill-meta.json +14 -0
  50. package/skills/spec-driven/README.md +335 -0
  51. package/skills/spec-driven/SKILL.md +174 -0
  52. package/skills/spec-driven/references/code-analysis.md +98 -0
  53. package/skills/spec-driven/references/coding-principles.md +56 -0
  54. package/skills/spec-driven/references/context-limits.md +31 -0
  55. package/skills/spec-driven/references/design.md +199 -0
  56. package/skills/spec-driven/references/discuss.md +136 -0
  57. package/skills/spec-driven/references/implement.md +425 -0
  58. package/skills/spec-driven/references/lessons.md +113 -0
  59. package/skills/spec-driven/references/memory.md +126 -0
  60. package/skills/spec-driven/references/specify.md +210 -0
  61. package/skills/spec-driven/references/sub-agents.md +96 -0
  62. package/skills/spec-driven/references/tasks.md +484 -0
  63. package/skills/spec-driven/references/validate.md +350 -0
  64. package/skills/spec-driven/scripts/__pycache__/lessons.cpython-314.pyc +0 -0
  65. package/skills/spec-driven/scripts/lessons.py +370 -0
  66. package/skills/spec-loop/README.md +36 -0
  67. package/skills/spec-loop/SKILL.md +61 -0
  68. package/skills/test-driven-development/README.md +13 -0
  69. package/skills/test-driven-development/SKILL.md +388 -0
  70. package/skills/typescript-patterns/README.md +13 -0
  71. package/skills/typescript-patterns/SKILL.md +346 -0
  72. package/skills/using-agent-skills/README.md +13 -0
  73. package/skills/using-agent-skills/SKILL.md +187 -0
@@ -0,0 +1,335 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/badge/Skill-spec--driven-blue?style=for-the-badge" alt="skill badge" />
3
+ <img src="https://img.shields.io/badge/Stack-Agnostic-green?style=for-the-badge" alt="stack agnostic" />
4
+ <img src="https://img.shields.io/badge/Version-5.0.0-purple?style=for-the-badge" alt="version" />
5
+ </p>
6
+
7
+ <h1 align="center">🎯 spec-driven</h1>
8
+
9
+ <p align="center">
10
+ <strong>Spec-driven planning with 4 adaptive phases and an independent Verifier.<br/>Tests derive from spec. One atomic commit per task. Lessons improve over time.</strong>
11
+ </p>
12
+
13
+ ---
14
+
15
+ ## ✨ What Is This Skill?
16
+
17
+ **spec-driven** is a feature planning skill that turns a description into traceable requirements, an atomic task breakdown, a verifiable implementation, and a self-improving lessons log. It auto-sizes depth by complexity — using inline execution for small changes and a full phase workflow for large or ambiguous features.
18
+
19
+ ```
20
+ SPECIFY → (DESIGN) → (TASKS) → EXECUTE → VERIFY → LEARN
21
+ ```
22
+
23
+ | Scope | Effort | What happens |
24
+ |-------|--------|--------------|
25
+ | **Small** | ≤3 files, one sentence | One-liner spec inline, implement + verify inline |
26
+ | **Medium** | Clear feature, <10 tasks | Brief spec, design and tasks implicit in Execute |
27
+ | **Large** | Multi-component | Full spec with requirement IDs, architecture, task breakdown |
28
+ | **Complex** | Ambiguity, new domain | Full spec, gray-area discussion, research-backed design, interactive UAT |
29
+
30
+ > **The complexity is in the system, not in your workflow.** Trigger naturally — the skill decides how deep to go.
31
+
32
+ ---
33
+
34
+ ## 🚀 Quick Start
35
+
36
+ ### Installation
37
+
38
+ Install with the catalog installer (`npx @runecraft/grimoire install`) or copy the skill folder manually — see the [catalog README](../../README.md) for targets and options.
39
+
40
+ ### First Commands
41
+
42
+ | What You Want | Say This |
43
+ |---------------|----------|
44
+ | Specify a feature | `/spec` or `specify feature` or `vamos especificar` |
45
+ | Discuss gray areas | `discuss feature` or `discutir este caso` |
46
+ | Design the approach | `design` or `design da feature` |
47
+ | Break into tasks | `plan this` or `quebrar em tarefas` |
48
+ | Implement | `/build` or `implement` or `implementar` |
49
+ | Validate / verify | `validate`, `verify work`, `UAT`, `validar implementação` |
50
+ | Pause session | `/spec pause` or `pausar trabalho` |
51
+ | Resume session | `/spec resume` or `retomar trabalho` |
52
+
53
+ **🇵🇹 🇬🇧 PT/EN — both languages are first-class triggers; the skill body is English.**
54
+
55
+ ---
56
+
57
+ ## 📁 Project Structure
58
+
59
+ The skill creates and maintains a `.specs/` directory:
60
+
61
+ ```
62
+ .specs/
63
+ ├── STATE.md # Project memory: Decisions log (AD-NNN) + Handoff snapshot
64
+ ├── LESSONS.md # Self-improving lessons playbook (rendered, do not hand-edit)
65
+ ├── lessons.json # Canonical lessons state (machine-owned)
66
+ └── features/
67
+ └── <name>/ # One per feature
68
+ ├── spec.md # Requirements with traceable IDs
69
+ ├── context.md # User decisions for gray areas (Complex scope)
70
+ ├── design.md # Architecture & components (Large/Complex)
71
+ ├── tasks.md # Atomic tasks with verification
72
+ └── validation.md # Verifier report: PASS/FAIL, evidence, sensor result
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🔄 The Four Phases
78
+
79
+ #### SPECIFY — Requirements & Traceability
80
+ **Goal:** Capture what to build with testable, traceable requirements.
81
+ **Triggers:** `/spec`, `specify feature`, `vamos especificar`
82
+ **Skipped when:** Never — always required.
83
+ **Output:** `spec.md` with `[FEAT-NN]` requirement IDs.
84
+
85
+ #### DESIGN — Architecture & Components
86
+ **Goal:** Define the technical approach, code reuse analysis, and component boundaries.
87
+ **Triggers:** `design`, `design da feature`
88
+ **Skipped when:** Small/Medium scope (no architectural decisions).
89
+ **Output:** `design.md` with architecture overview, components, data models, decisions.
90
+
91
+ #### TASKS — Atomic Breakdown
92
+ **Goal:** Decompose the spec into atomic, independently verifiable, sequentially ordered tasks.
93
+ **Triggers:** `break into tasks`, `quebrar em tarefas`
94
+ **Skipped when:** ≤3 obvious steps (implicit in Execute).
95
+ **Output:** `tasks.md` with What, Where, Requirement IDs, and Done-when criteria.
96
+
97
+ #### EXECUTE — Implement + Verify
98
+ **Goal:** Implement each task sequentially with one atomic commit per task.
99
+ **Triggers:** `/build`, `implement`, `implementar`
100
+ **Skipped when:** Never — always required.
101
+ **Output:** Code changes, task checkmarks, atomic commits, `validation.md` from the Verifier.
102
+
103
+ ---
104
+
105
+ ## 🛡️ The Verifier
106
+
107
+ After the last task is committed, a **fresh Verifier sub-agent** runs automatically — never optional, never prompted. The author is not the verifier: the Verifier re-derives coverage independently.
108
+
109
+ The Verifier:
110
+
111
+ 1. **Spec-anchored outcome check** — confirms each test's asserted value matches the spec-defined expected outcome. Flags spec-precision gaps.
112
+ 2. **Discrimination sensor** — injects behavior-level faults in scratch state, confirms tests kill them. Surviving mutants become fix tasks.
113
+ 3. **Writes `validation.md`** — PASS/FAIL, per-AC evidence, sensor result, diff range.
114
+ 4. **Returns a compact verdict** + ranked gap list to the orchestrator.
115
+ 5. **Distills lessons** — turns each grounded failure into a reusable project-local lesson via `scripts/lessons.py`. A clean PASS records nothing.
116
+
117
+ The fix→re-verify loop is bounded to 3 iterations before escalating.
118
+
119
+ ---
120
+
121
+ ## 📚 Lessons
122
+
123
+ The lessons layer turns verification failures into project-local guidance:
124
+
125
+ ```bash
126
+ # Load confirmed lessons at Specify / Design
127
+ python3 scripts/lessons.py list --status confirmed
128
+
129
+ # Record a new lesson
130
+ python3 scripts/lessons.py add --rule "..." --rationale "..." --source feature-x
131
+ ```
132
+
133
+ `LESSONS.md` is rendered from `lessons.json` — do not hand-edit. Confirmed lessons only are loaded into planning context; candidates are kept isolated to avoid noise.
134
+
135
+ ---
136
+
137
+ ## 🎯 Complete Trigger Reference
138
+
139
+ ### English Triggers
140
+
141
+ | Phase | Triggers |
142
+ |-------|----------|
143
+ | **SPECIFY** | `/spec`, `specify feature`, `write spec`, `what should we build` |
144
+ | **DISCUSS** | `discuss feature`, `capture context`, `how should this work` |
145
+ | **DESIGN** | `design`, `design the feature` |
146
+ | **TASKS** | `break into tasks`, `create tasks` |
147
+ | **EXECUTE** | `/build`, `implement`, `execute tasks` |
148
+ | **VALIDATE** | `validate`, `verify work`, `UAT`, `walk me through it` |
149
+ | **MEMORY** | `record decision`, `pause work`, `resume work` |
150
+ | **LESSONS** | `load lessons`, `record lesson`, `distill lessons` |
151
+
152
+ ### Portuguese Triggers
153
+
154
+ | Fase | Triggers |
155
+ |------|----------|
156
+ | **SPECIFY** | `vamos especificar`, `preciso de um spec`, `especificar feature` |
157
+ | **DISCUSS** | `discutir feature`, `discutir este caso` |
158
+ | **DESIGN** | `design da feature`, `arquitetura` |
159
+ | **TASKS** | `quebrar em tarefas`, `criar tarefas` |
160
+ | **EXECUTE** | `implementar`, `build`, `construir` |
161
+ | **VALIDATE** | `validar implementação`, `verificar`, `testar comigo` |
162
+ | **MEMORY** | `pausar trabalho`, `retomar trabalho`, `salvar decisão` |
163
+ | **LESSONS** | `carregar lições`, `registrar lição` |
164
+
165
+ ### Special Triggers
166
+
167
+ | Trigger | Action |
168
+ |---------|--------|
169
+ | `/spec pause` or `pausar trabalho` | Save handoff snapshot, update STATE.md |
170
+ | `/spec resume` or `retomar trabalho` | Load handoff, re-confirm Decisions, propose next step |
171
+
172
+ ---
173
+
174
+ ## 🔁 Workflow Examples
175
+
176
+ ### Greenfield Feature
177
+
178
+ ```
179
+ /spec payment-flow → /build → Verifier (auto) → done
180
+ ```
181
+
182
+ Full pipeline: write spec with traceable IDs, design the architecture, break into atomic tasks, implement, independent Verifier.
183
+
184
+ ### Brownfield Fix
185
+
186
+ ```
187
+ specify: fix dark mode persistence → inline execute → Verifier (auto) → done
188
+ ```
189
+
190
+ Small scope: one-liner spec, inline implementation, automatic verification.
191
+
192
+ ### Session Continuity
193
+
194
+ ```
195
+ Session 1: /spec → /build (partial) → /spec pause
196
+ Session 2: /spec resume → continue /build → Verifier (auto) → done
197
+ ```
198
+
199
+ Pause at any point, resume exactly where you left off via STATE.md Handoff.
200
+
201
+ ---
202
+
203
+ ## 🧠 Context Management
204
+
205
+ The skill manages a **40k context token budget** for planning, with 160k+ reserved for work, reasoning, and outputs:
206
+
207
+ | Tier | Documents | When loaded |
208
+ |------|-----------|-------------|
209
+ | **Always-on-demand** | `.specs/STATE.md` (Decisions at Design, Handoff on resume) | Per phase |
210
+ | **Confirmed lessons** | `python3 scripts/lessons.py list --status confirmed` | Specify, Design |
211
+ | **Feature context** | `spec.md`, `context.md`, `design.md`, `tasks.md` | Per feature |
212
+ | **Never simultaneous** | Multiple feature specs, multiple architecture docs | — |
213
+
214
+ If context exceeds 40k, display status and apply the [context-limits](references/context-limits.md) strategy.
215
+
216
+ ---
217
+
218
+ ## 🔗 Skill Integrations
219
+
220
+ | Skill | When activated | Behavior |
221
+ |-------|---------------|----------|
222
+ | **mermaid-studio** | During DESIGN, for architecture diagrams | Delegates diagram generation |
223
+ | **codenavi** | During SPECIFY/DESIGN | Deep codebase navigation for context |
224
+
225
+ Detected automatically. Gracefully falls back if not installed.
226
+
227
+ ---
228
+
229
+ ## 📚 Reference Files
230
+
231
+ 12 supporting files, loaded on-demand within the 40k budget:
232
+
233
+ ### Phase files
234
+ | File | Purpose |
235
+ |------|---------|
236
+ | `specify.md` | Spec writing discipline, requirement IDs, traceability |
237
+ | `discuss.md` | Gray-area discussion, user-decision capture |
238
+ | `design.md` | Architecture, code reuse analysis, components |
239
+ | `tasks.md` | Atomic task breakdown, dependencies, verification |
240
+ | `implement.md` | Build cycle, atomic commit policy, gate enforcement |
241
+ | `validate.md` | Verifier behavior, spec-anchored check, discrimination sensor |
242
+
243
+ ### Memory & patterns
244
+ | File | Purpose |
245
+ |------|---------|
246
+ | `memory.md` | STATE.md (Decisions log + Handoff), pause/resume |
247
+ | `lessons.md` | Lessons layer, machine-owned state, distillation rules |
248
+ | `sub-agents.md` | Sub-agent delegation contracts, Verifier payload |
249
+ | `code-analysis.md` | Code search & structural analysis tools |
250
+ | `coding-principles.md` | Coding standards enforced during BUILD |
251
+ | `context-limits.md` | Token budget strategy, what to drop under pressure |
252
+
253
+ ### Script
254
+ | File | Purpose |
255
+ |------|---------|
256
+ | `scripts/lessons.py` | Lessons CLI — list, add, confirm, render LESSONS.md |
257
+
258
+ ---
259
+
260
+ ## ⚡ Tips for Best Results
261
+
262
+ ### Do's ✅
263
+ - Trigger naturally in PT or EN — the skill understands both
264
+ - Trust the auto-sizing — the skill decides phase depth from scope
265
+ - Read reference files completely (to EOF) before acting on them
266
+ - Say `/spec pause` before ending a session
267
+ - Let the Verifier run — never skip it, never self-validate
268
+
269
+ ### Don'ts ❌
270
+ - Don't weaken, skip, or delete tests to make them pass
271
+ - Don't batch multiple tasks into a single commit
272
+ - Don't load multiple feature specs simultaneously
273
+ - Don't fabricate APIs or patterns — follow the Knowledge Verification Chain
274
+ - Don't accept "tests pass" without checking the test asserts spec outcomes, not implementation details
275
+
276
+ ---
277
+
278
+ ## 🤖 Compatibility
279
+
280
+ Tested and verified on:
281
+
282
+ | Agent | Status | Notes |
283
+ |-------|--------|-------|
284
+ | **Claude Code** | ✅ Fully supported | Primary reference agent |
285
+ | **Cursor** | ✅ Fully supported | Excellent for inline editing |
286
+ | **Opencode** | ✅ Fully supported | Multi-agent routing works natively |
287
+ | **GitHub Copilot** | ✅ Fully supported | Via custom instructions |
288
+
289
+ Works with any agent supporting custom instructions and tool use.
290
+
291
+ ---
292
+
293
+ ## ❓ FAQ
294
+
295
+ **Q: Why is the Verifier separate from the executor?**
296
+ A: Author ≠ verifier prevents the executor's mental model from biasing the validation. The Verifier re-derives coverage independently using evidence-or-zero: each AC either has test evidence or counts as a gap.
297
+
298
+ **Q: What if a test passes but doesn't actually test the spec outcome?**
299
+ A: The spec-anchored outcome check flags this as a spec-precision gap. The test asserts implementation details instead of the spec-defined behavior; the test must be rewritten.
300
+
301
+ **Q: What is the discrimination sensor?**
302
+ A: A mutation-testing pass. The Verifier injects behavior-level faults in scratch state and confirms the test suite kills them. Surviving mutants mean tests are too weak; those mutants become fix tasks.
303
+
304
+ **Q: How do lessons work?**
305
+ A: Each grounded failure (surviving mutant, spec-precision gap, failed AC) becomes a lesson via `scripts/lessons.py`. Confirmed lessons load into Specify and Design context. A clean PASS records nothing — the skill stays quiet when nothing went wrong.
306
+
307
+ **Q: Why did the auto-sizing skip TASKS for my Medium feature?**
308
+ A: When there are ≤3 obvious steps, tasks become implicit in Execute. The safety valve: Execute ALWAYS lists atomic steps inline first. If the list reveals >5 steps or complex dependencies, STOP and create a formal `tasks.md`.
309
+
310
+ **Q: Can I use this for small bug fixes?**
311
+ A: Yes — that's the Small scope (≤3 files, one sentence). One-liner spec inline, implement, verify. No ceremony.
312
+
313
+ **Q: What if I close my session mid-task?**
314
+ A: Say `/spec pause` before ending. The Handoff snapshot in STATE.md captures the in-flight state; `/spec resume` next session continues from there.
315
+
316
+ **Q: PT or EN?**
317
+ A: Both. All triggers work in Portuguese and English as first-class citizens. The skill body is English.
318
+
319
+ **Q: Does this work with any tech stack?**
320
+ A: Yes. Stack-agnostic. Works with any language, framework, or architecture.
321
+
322
+ **Q: Will the agent fabricate APIs or patterns?**
323
+ A: No. The Knowledge Verification Chain enforces: codebase → project docs → Context7 MCP → web search → flag as uncertain. It never guesses silently.
324
+
325
+ ---
326
+
327
+ ## 📄 License
328
+
329
+ MIT
330
+
331
+ ---
332
+
333
+ <p align="center">
334
+ <sub>Part of the <a href="https://github.com/runecraftai/skills">Grimoire</a> catalog</sub>
335
+ </p>
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: spec-driven
3
+ description: >
4
+ Planning and implementation with 4 adaptive phases — Specify, Design, Tasks, Execute. Auto-sizes
5
+ depth by complexity. Atomic tasks with verification criteria, atomic git commits, requirement
6
+ traceability. Independent Verifier (author != verifier, evidence-or-zero), decision log
7
+ (STATE.md), test-coverage-matrix-driven tests, self-improving lessons layer. Stack-agnostic. Use
8
+ when planning features (requirements, design, task breakdown), implementing with verification
9
+ and atomic commits, or validating against a spec. Triggers (PT/EN): "specify feature", "vamos
10
+ especificar", "discutir feature", "discutir este caso", "design", "design da feature",
11
+ "tarefas", "quebrar em tarefas", "implementar", "build", "validar", "verify work", "UAT",
12
+ "validar implementação", "record decision", "pause work", "pausar trabalho", "resume work",
13
+ "retomar trabalho". Do NOT use for architecture decomposition analysis (use architecture skills)
14
+ or technical design docs (Complex scope: gray areas + architecture-focused design).
15
+ license: CC-BY-4.0
16
+ metadata:
17
+ version: 5.0.0
18
+ ---
19
+
20
+ # spec-driven
21
+
22
+ Plan and implement features with precision. Granular tasks. Clear dependencies. Right tools. Zero ceremony.
23
+
24
+ ```
25
+ ┌──────────┐ ┌──────────┐ ┌─────────┐ ┌─────────┐
26
+ │ SPECIFY │ → │ DESIGN │ → │ TASKS │ → │ EXECUTE │
27
+ └──────────┘ └──────────┘ └─────────┘ └─────────┘
28
+ required optional* optional* required
29
+
30
+ * Agent auto-skips when scope doesn't need it
31
+ ```
32
+
33
+ ## Critical Rules (read before acting)
34
+
35
+ **Loading this skill's files.** Reference files live under `references/` in this skill's own directory (where this `SKILL.md` resides). Resolve them relative to the skill directory — never the workspace root — and load them through the active skill by name; never assume a fixed install path. When a step tells you to read a reference, **read it completely (to EOF)** before acting — never act on a partial/truncated read.
36
+
37
+ **Execution contract — every task, non-negotiable (holds even if you do not open the reference files):**
38
+
39
+ 1. Tests derive from the spec's acceptance criteria and assert spec-defined outcomes — they never mirror the implementation.
40
+ 2. The gate must pass (tests pass) before a task is done — the test runner decides, not self-assessment.
41
+ 3. One atomic commit per task. Never batch tasks; never weaken, skip, or delete tests to make them pass.
42
+ 4. After the LAST task, a fresh **Verifier always runs automatically** (author ≠ verifier) — spec-anchored outcome check + discrimination sensor. It is never optional and never prompted. See Sub-Agent Delegation.
43
+
44
+ **Before Execute:** read [implement.md](references/implement.md) completely; if a formal `tasks.md` has more than 3 phases, present the sub-agent offer first (see Sub-Agent Delegation).
45
+
46
+ ## Auto-Sizing: The Core Principle
47
+
48
+ **The complexity determines the depth, not a fixed pipeline.** Before starting any feature, assess its scope and apply only what's needed:
49
+
50
+ | Scope | What | Specify | Design | Tasks | Execute |
51
+ | ----------- | ------------------------ | ------------------------------------------------------- | ----------------------------------------------- | ----------------------------- | ----------------------------------------------------- |
52
+ | **Small** | ≤3 files, one sentence | One-liner spec (inline) | Skip | Skip | Implement + verify inline |
53
+ | **Medium** | Clear feature, <10 tasks | Spec (brief) | Skip — design inline | Skip — tasks implicit | Implement + verify |
54
+ | **Large** | Multi-component feature | Full spec + requirement IDs | Architecture + components | Full breakdown + dependencies | Implement + verify per task |
55
+ | **Complex** | Ambiguity, new domain | Full spec + [discuss gray areas](references/discuss.md) | [Research](references/design.md) + architecture | Breakdown + parallel plan | Implement + [interactive UAT](references/validate.md) |
56
+
57
+ **Rules:**
58
+
59
+ - **Specify and Execute are always required** — you always need to know WHAT and DO it
60
+ - **Design is skipped** when the change is straightforward (no architectural decisions, no new patterns)
61
+ - **Tasks is skipped** when there are ≤3 obvious steps (they become implicit in Execute)
62
+ - **Discuss is triggered within Specify** when the agent detects ambiguous gray areas that need user input, or when the feature has any implicit-requirement dimension present (persistence/state, external calls, auth, payments, concurrency, state transitions)
63
+ - **Interactive UAT is triggered within Execute** only for user-facing features with complex behavior
64
+
65
+ **Safety valve:** Even when Tasks is skipped, Execute ALWAYS starts by listing atomic steps inline (see [implement.md](references/implement.md)). If that listing reveals >5 steps or complex dependencies, STOP and create a formal `tasks.md` — the Tasks phase was wrongly skipped.
66
+
67
+ ## .specs Structure
68
+
69
+ ```
70
+ .specs/
71
+ ├── STATE.md # Project memory: Decisions log (AD-NNN) + Handoff snapshot
72
+ ├── LESSONS.md # Self-improving lessons playbook (rendered by scripts/lessons.py — do not hand-edit)
73
+ ├── lessons.json # Canonical lessons state (machine-owned)
74
+ └── features/ # Feature specifications
75
+ └── [feature]/
76
+ ├── spec.md # Requirements with traceable IDs
77
+ ├── context.md # User decisions for gray areas (only when discuss is triggered)
78
+ ├── design.md # Architecture & components (only for Large/Complex)
79
+ ├── tasks.md # Atomic tasks with verification (only for Large/Complex)
80
+ └── validation.md # Verifier report: PASS/FAIL, per-AC evidence, sensor result, diff range
81
+ ```
82
+
83
+ ## Workflow
84
+
85
+ **New feature:**
86
+
87
+ 1. Specify → (Design) → (Tasks) → Execute (depth auto-sized)
88
+
89
+ **Resume work:**
90
+
91
+ Read `.specs/STATE.md` — Handoff section for in-flight state, Decisions section to re-confirm active constraints — then propose the next step.
92
+
93
+ ## Context Loading Strategy
94
+
95
+ **On-demand load (only what the current task needs):**
96
+
97
+ - `.specs/STATE.md` — Decisions section (read at Design, re-read on resume); Handoff section (read on resume only)
98
+ - confirmed lessons — load at Specify and Design via `python3 scripts/lessons.py list --status confirmed` ([lessons.md](references/lessons.md)); confirmed only, never candidates
99
+ - spec.md (when working on a specific feature)
100
+ - context.md (when designing or implementing from user decisions)
101
+ - design.md (when implementing from design)
102
+ - tasks.md (when executing tasks)
103
+
104
+ **Never load simultaneously:**
105
+
106
+ - Multiple feature specs
107
+ - Multiple architecture docs
108
+
109
+ **Target:** <40k tokens total context
110
+ **Reserve:** 160k+ tokens for work, reasoning, outputs
111
+ **Monitoring:** Display status when >40k (see [context-limits.md](references/context-limits.md))
112
+
113
+ ## Sub-Agent Delegation
114
+
115
+ **Trigger:** >3 phases → offer one worker per phase (sequential); ≤3 phases → execute inline.
116
+
117
+ **Offer-then-confirm** — never auto-spawn. The user must accept before any sub-agent is dispatched.
118
+
119
+ **One worker per phase:** Each phase worker executes all its tasks in order (implement → gate → atomic commit), then reports a compact summary (tasks done, commit hashes, test counts, deviations). Workers never spawn further sub-agents.
120
+
121
+ **Verifier (always-on, never prompted):** After the final task is committed, the orchestrator dispatches a fresh Verifier sub-agent automatically — regardless of phase count. Validation never requires a user prompt; it is the closing step of Execute. **Author ≠ verifier**: the Verifier re-derives coverage independently using evidence-or-zero; it does not inherit the author's mental model. The Verifier: (1) performs a **spec-anchored outcome check** — confirms each test's asserted value matches the spec-defined expected outcome, flags spec-precision gaps; (2) runs a **discrimination sensor** — injects behavior-level faults in scratch state, confirms tests kill them, discards mutations, surviving mutants become fix tasks; (3) writes `.specs/features/[feature]/validation.md` (PASS/FAIL, per-AC evidence, sensor result, diff range); (4) returns a compact verdict + ranked gap list to the orchestrator in chat. Gaps become fix tasks; the fix→re-verify loop is bounded to 3 iterations before escalating. (5) **distills lessons** — turns each grounded failure (surviving mutant, spec-precision gap, failed AC, SPEC_DEVIATION) into a reusable project-local lesson via `scripts/lessons.py`; a clean PASS records nothing (see [lessons.md](references/lessons.md)).
122
+
123
+ **Standalone fallback:** Without sub-agents, run `validate.md` as an independent fresh-eyes pass after the final commit — including the spec-anchored check and discrimination sensor.
124
+
125
+ Full mechanics (worker payload, compact summary format, failure handling, context sizing, Verifier report format): [sub-agents.md](references/sub-agents.md).
126
+
127
+ ## Commands
128
+
129
+ **Feature-level (auto-sized):**
130
+ | Trigger Pattern | Reference |
131
+ |----------------|-----------|
132
+ | Specify feature, define requirements | [specify.md](references/specify.md) |
133
+ | Discuss feature, capture context, how should this work | [discuss.md](references/discuss.md) |
134
+ | Design feature, architecture | [design.md](references/design.md) |
135
+ | Break into tasks, create tasks | [tasks.md](references/tasks.md) |
136
+ | Implement task, build, execute | [implement.md](references/implement.md) |
137
+ | Validate, verify, test, UAT, walk me through it | [validate.md](references/validate.md) |
138
+
139
+ **Memory:**
140
+ | Trigger Pattern | Reference |
141
+ |----------------|-----------|
142
+ | Record decision, this is a project-level decision | [memory.md](references/memory.md) |
143
+ | Pause work, end session, I need to stop | [memory.md](references/memory.md) |
144
+ | Resume work, continue, pick up where we left off | [memory.md](references/memory.md) |
145
+ | Load lessons, what have we learned, apply past lessons | [lessons.md](references/lessons.md) |
146
+ | Record lesson, distill lessons (auto-runs after validation) | [lessons.md](references/lessons.md) |
147
+
148
+ ## Knowledge Verification Chain
149
+
150
+ When researching, designing, or making any technical decision, follow this chain in strict order. Never skip steps.
151
+
152
+ ```
153
+ Step 1: Codebase → check existing code, conventions, and patterns already in use
154
+ Step 2: Project docs → README, docs/, inline comments, `.specs/STATE.md` (Decisions)
155
+ Step 3: Context7 MCP → resolve library ID, then query for current API/patterns
156
+ Step 4: Web search → official docs, reputable sources, community patterns
157
+ Step 5: Flag as uncertain → "I'm not certain about X — here's my reasoning, but verify"
158
+ ```
159
+
160
+ **Rules:**
161
+
162
+ - Never skip to Step 5 if Steps 1-4 are available
163
+ - Step 5 is ALWAYS flagged as uncertain — never presented as fact
164
+ - **NEVER assume or fabricate.** If you cannot find an answer, say "I don't know" or "I couldn't find documentation for this". Inventing APIs, patterns, or behaviors causes cascading failures across design → tasks → implementation. Uncertainty is always preferable to fabrication.
165
+
166
+ ## Output Behavior
167
+
168
+ **Model guidance:** After completing lightweight tasks (validation, feature-level checks), naturally mention once per session that such tasks work well with faster/cheaper models. For heavy tasks (complex design, large features), briefly note the reasoning requirements before starting.
169
+
170
+ Be conversational, not robotic. Don't interrupt workflow—add as a natural closing note. Skip if user seems experienced or has already acknowledged the tip.
171
+
172
+ ## Code Analysis
173
+
174
+ Use available tools with graceful degradation. See [code-analysis.md](references/code-analysis.md).
@@ -0,0 +1,98 @@
1
+ # Code Analysis Tools
2
+
3
+ Use graceful degradation for code search and structural analysis.
4
+
5
+ ## Tool Priority
6
+
7
+ 1. **ast-grep** (`sg`) - Structural pattern-based search
8
+ 2. **ripgrep** (`rg`) - Fast context-aware text search
9
+ 3. **grep** - Standard text search (always available)
10
+
11
+ ## Detection
12
+
13
+ Check tool availability before use:
14
+
15
+ ```bash
16
+ # Check for ast-grep
17
+ if command -v sg >/dev/null 2>&1; then
18
+ # Use ast-grep for structural search
19
+ elif command -v rg >/dev/null 2>&1; then
20
+ # Fall back to ripgrep
21
+ else
22
+ # Use standard grep as final fallback
23
+ fi
24
+ ```
25
+
26
+ ## Usage Examples
27
+
28
+ **Finding function definitions:**
29
+
30
+ ```bash
31
+ # ast-grep (best - structural)
32
+ sg -p 'function $NAME($$$) { $$$ }'
33
+
34
+ # ripgrep (fallback - fast text)
35
+ rg '^function\s+\w+\(' --type-add 'source:*.[extension]' -t source
36
+
37
+ # grep (last resort - basic)
38
+ grep -r '^function ' --include="*.[extension]"
39
+ ```
40
+
41
+ **Finding imports/requires:**
42
+
43
+ ```bash
44
+ # ast-grep
45
+ sg -p 'import { $$$ } from "$MODULE"'
46
+
47
+ # ripgrep
48
+ rg '^import .* from' --type-add 'source:*.[extension]' -t source
49
+
50
+ # grep
51
+ grep -r '^import ' --include="*.[extension]"
52
+ ```
53
+
54
+ **Finding class/component definitions:**
55
+
56
+ ```bash
57
+ # ast-grep
58
+ sg -p 'class $NAME { $$$ }'
59
+
60
+ # ripgrep
61
+ rg '^(class|export class)\s+\w+' --type-add 'source:*.[extension]' -t source
62
+
63
+ # grep
64
+ grep -r '^class ' --include="*.[extension]"
65
+ ```
66
+
67
+ ## Search Scope
68
+
69
+ **Best practices:**
70
+
71
+ - Limit to source file extensions relevant to project
72
+ - Exclude directories: `node_modules`, `vendor`, `dist`, `build`, `.git`
73
+ - Focus on source directories: `src`, `lib`, `app`
74
+ - Use file type filters when available
75
+
76
+ **Performance tips:**
77
+
78
+ - Use specific patterns over broad searches
79
+ - Limit directory depth with `--max-depth` (ripgrep/grep)
80
+ - Cache results for repeated queries
81
+
82
+ ## Fallback Notice
83
+
84
+ If ast-grep unavailable, display once per session:
85
+
86
+ ```
87
+ ⚠️ ast-grep not detected. Install for more precise structural code analysis.
88
+ https://ast-grep.github.io/guide/quick-start.html
89
+ ```
90
+
91
+ ## When to Use
92
+
93
+ - Finding usage patterns across codebase
94
+ - Identifying code structure and organization
95
+ - Locating function/class/component definitions
96
+ - Analyzing import/dependency patterns
97
+ - Refactoring impact analysis
98
+ - Code navigation in unfamiliar codebases
@@ -0,0 +1,56 @@
1
+ # Coding Principles
2
+
3
+ Behavioral bias, not checklist. Read before every implementation.
4
+
5
+ ---
6
+
7
+ ## Before Coding
8
+
9
+ - State assumptions explicitly. If uncertain, ask.
10
+ - Multiple interpretations exist? Present all—don't pick silently.
11
+ - Simpler approach exists? Say so. Push back when warranted.
12
+ - Something unclear? Stop. Name what's confusing. Ask.
13
+ - User's approach seems wrong? Disagree honestly. Don't be sycophantic.
14
+
15
+ ---
16
+
17
+ ## During Implementation
18
+
19
+ ### Simplicity
20
+
21
+ - No features beyond what was asked
22
+ - No abstractions for single-use code
23
+ - No "flexibility" or "configurability" not requested
24
+ - No error handling for impossible scenarios
25
+ - 200 lines that could be 50? Rewrite it.
26
+
27
+ ### Surgical Changes
28
+
29
+ - Don't "improve" adjacent code, comments, or formatting
30
+ - Don't refactor things that aren't broken
31
+ - Match existing style, even if you'd do differently
32
+ - Unrelated dead code noticed? Mention it—don't delete it
33
+ - Remove ONLY imports/variables/functions YOUR changes orphaned
34
+ - Don't remove pre-existing dead code unless asked
35
+
36
+ ### Test Integrity
37
+
38
+ - NEVER weaken an existing test assertion to make it pass
39
+ - NEVER delete a test to reduce failure count
40
+ - NEVER use the test framework's skip/disable/pending mechanism to bypass a failing test
41
+ - NEVER modify a task's tests afterward to make the implementation pass
42
+ - If a test is genuinely wrong, STOP and confirm with the user before changing it
43
+ - Tests are the spec — implementation conforms to tests, not the other way around
44
+
45
+ ### Goal-Driven
46
+
47
+ - Transform vague tasks into verifiable goals
48
+ - Multi-step work? State brief plan with verify checkpoints
49
+ - Every changed line must trace directly to user's request
50
+
51
+ ---
52
+
53
+ ## After Each Change
54
+
55
+ Ask: "Would senior engineer call this overcomplicated?"
56
+ If yes → simplify before proceeding.