@massa-ai/cursor-plugin 1.6.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 (172) hide show
  1. package/.cursor-plugin/plugin.json +5 -0
  2. package/README.md +87 -0
  3. package/agents/massa-ai-architecture-specialist.md +65 -0
  4. package/agents/massa-ai-audit-specialist.md +81 -0
  5. package/agents/massa-ai-builder.md +67 -0
  6. package/agents/massa-ai-context-curator.md +67 -0
  7. package/agents/massa-ai-documentation-agent.md +65 -0
  8. package/agents/massa-ai-furps-analyst.md +71 -0
  9. package/agents/massa-ai-investigator.md +68 -0
  10. package/agents/massa-ai-mobile-specialist.md +82 -0
  11. package/agents/massa-ai-navigator.md +75 -0
  12. package/agents/massa-ai-plan-critic.md +90 -0
  13. package/agents/massa-ai-planner.md +65 -0
  14. package/agents/massa-ai-requirements-analyst.md +64 -0
  15. package/agents/massa-ai-reviewer.md +66 -0
  16. package/agents/massa-ai-test-engineer.md +66 -0
  17. package/agents/massa-ai-verification-agent.md +65 -0
  18. package/hooks/hooks.json +26 -0
  19. package/hooks/massa-ai-hook +298 -0
  20. package/install.sh +413 -0
  21. package/package.json +30 -0
  22. package/skills/agents/architecture-specialist/SKILL.md +69 -0
  23. package/skills/agents/audit-specialist/SKILL.md +85 -0
  24. package/skills/agents/builder/SKILL.md +71 -0
  25. package/skills/agents/context-curator/SKILL.md +71 -0
  26. package/skills/agents/documentation-agent/SKILL.md +69 -0
  27. package/skills/agents/furps-analyst/SKILL.md +74 -0
  28. package/skills/agents/investigator/SKILL.md +72 -0
  29. package/skills/agents/mobile-specialist/SKILL.md +86 -0
  30. package/skills/agents/navigator/SKILL.md +79 -0
  31. package/skills/agents/plan-critic/SKILL.md +93 -0
  32. package/skills/agents/planner/SKILL.md +69 -0
  33. package/skills/agents/requirements-analyst/SKILL.md +68 -0
  34. package/skills/agents/reviewer/SKILL.md +70 -0
  35. package/skills/agents/test-engineer/SKILL.md +70 -0
  36. package/skills/agents/verification-agent/SKILL.md +69 -0
  37. package/skills/def/SKILL.md +17 -0
  38. package/skills/find/SKILL.md +19 -0
  39. package/skills/graph/SKILL.md +16 -0
  40. package/skills/index/SKILL.md +19 -0
  41. package/skills/map/SKILL.md +24 -0
  42. package/skills/massa-ai/SKILL.md +315 -0
  43. package/skills/massa-ai/personas/README.md +35 -0
  44. package/skills/massa-ai/personas/ai-native-nodejs-cli-architect.md +76 -0
  45. package/skills/massa-ai/personas/catalog.json +157 -0
  46. package/skills/massa-ai/personas/context-skill-harness-engineer-architect.md +74 -0
  47. package/skills/massa-ai/personas/product-manager.md +67 -0
  48. package/skills/massa-ai/personas/senior-mobile-engineer.md +74 -0
  49. package/skills/massa-ai/personas/senior-mobile-qa-automation-engineer.md +75 -0
  50. package/skills/massa-ai/references/adr-authoring.md +189 -0
  51. package/skills/massa-ai/references/agent-orchestration.md +221 -0
  52. package/skills/massa-ai/references/architecture-coupling-lens.md +239 -0
  53. package/skills/massa-ai/references/architecture-deepening-lens.md +136 -0
  54. package/skills/massa-ai/references/architecture-domain-lens.md +186 -0
  55. package/skills/massa-ai/references/architecture-lenses.md +108 -0
  56. package/skills/massa-ai/references/audit-report-io.md +459 -0
  57. package/skills/massa-ai/references/audit-scope.md +103 -0
  58. package/skills/massa-ai/references/code-annotation.md +111 -0
  59. package/skills/massa-ai/references/codebase-investigation.md +96 -0
  60. package/skills/massa-ai/references/context-firewall.md +62 -0
  61. package/skills/massa-ai/references/conversation-feedback.md +104 -0
  62. package/skills/massa-ai/references/debug-diagnosis-loop.md +140 -0
  63. package/skills/massa-ai/references/decision-engine.md +73 -0
  64. package/skills/massa-ai/references/evidence-gate.md +53 -0
  65. package/skills/massa-ai/references/furps/analyst-role.md +49 -0
  66. package/skills/massa-ai/references/furps/checklist.md +92 -0
  67. package/skills/massa-ai/references/furps/intake.md +104 -0
  68. package/skills/massa-ai/references/furps/report-contract.md +140 -0
  69. package/skills/massa-ai/references/hook-enforcement.md +137 -0
  70. package/skills/massa-ai/references/implementation-delivery.md +101 -0
  71. package/skills/massa-ai/references/installation.md +110 -0
  72. package/skills/massa-ai/references/lessons.md +119 -0
  73. package/skills/massa-ai/references/maestro/artifacts-reports.md +69 -0
  74. package/skills/massa-ai/references/maestro/cli-device.md +65 -0
  75. package/skills/massa-ai/references/maestro/cloud.md +67 -0
  76. package/skills/massa-ai/references/maestro/config-env-output.md +76 -0
  77. package/skills/massa-ai/references/maestro/fact-ledger.md +71 -0
  78. package/skills/massa-ai/references/maestro/js-scripting.md +70 -0
  79. package/skills/massa-ai/references/maestro/mcp.md +59 -0
  80. package/skills/massa-ai/references/maestro/patterns.md +96 -0
  81. package/skills/massa-ai/references/maestro/selectors.md +91 -0
  82. package/skills/massa-ai/references/maestro/workspace-execution.md +81 -0
  83. package/skills/massa-ai/references/maestro/yaml-commands.md +203 -0
  84. package/skills/massa-ai/references/maestro.md +47 -0
  85. package/skills/massa-ai/references/mcp-tools.md +296 -0
  86. package/skills/massa-ai/references/memory-policy.md +103 -0
  87. package/skills/massa-ai/references/mobile-context.md +113 -0
  88. package/skills/massa-ai/references/mobile-diagnosis.md +106 -0
  89. package/skills/massa-ai/references/mobile-figma-matcher/ATTRIBUTION.md +5 -0
  90. package/skills/massa-ai/references/mobile-figma-matcher/android-compose.md +13 -0
  91. package/skills/massa-ai/references/mobile-figma-matcher/android-views.md +13 -0
  92. package/skills/massa-ai/references/mobile-figma-matcher/core.md +117 -0
  93. package/skills/massa-ai/references/mobile-figma-matcher/ios-swiftui.md +12 -0
  94. package/skills/massa-ai/references/mobile-figma-matcher/ios-uikit.md +12 -0
  95. package/skills/massa-ai/references/mobile-figma-matcher/kmp-compose-multiplatform.md +14 -0
  96. package/skills/massa-ai/references/mobile-figma-matcher/repository-detection.md +77 -0
  97. package/skills/massa-ai/references/naming-standards.md +47 -0
  98. package/skills/massa-ai/references/pr-task-fix.md +80 -0
  99. package/skills/massa-ai/references/project-context.md +76 -0
  100. package/skills/massa-ai/references/rfc/ATTRIBUTION.md +5 -0
  101. package/skills/massa-ai/references/rfc/discovery-and-sizing.md +120 -0
  102. package/skills/massa-ai/references/rfc/document-contract.md +85 -0
  103. package/skills/massa-ai/references/rfc/quality-and-lifecycle.md +101 -0
  104. package/skills/massa-ai/references/root-cause-scripts.md +97 -0
  105. package/skills/massa-ai/references/spec-driven/artifact-store.md +98 -0
  106. package/skills/massa-ai/references/spec-driven/code-analysis.md +119 -0
  107. package/skills/massa-ai/references/spec-driven/coding-principles.md +80 -0
  108. package/skills/massa-ai/references/spec-driven/context-limits.md +64 -0
  109. package/skills/massa-ai/references/spec-driven/design.md +257 -0
  110. package/skills/massa-ai/references/spec-driven/discuss.md +182 -0
  111. package/skills/massa-ai/references/spec-driven/execute.md +471 -0
  112. package/skills/massa-ai/references/spec-driven/lessons.md +5 -0
  113. package/skills/massa-ai/references/spec-driven/memory.md +214 -0
  114. package/skills/massa-ai/references/spec-driven/specify.md +283 -0
  115. package/skills/massa-ai/references/spec-driven/sub-agents.md +151 -0
  116. package/skills/massa-ai/references/spec-driven/tasks.md +494 -0
  117. package/skills/massa-ai/references/spec-driven/validate.md +397 -0
  118. package/skills/massa-ai/references/subagent-design.md +132 -0
  119. package/skills/massa-ai/references/synapse-policy.md +160 -0
  120. package/skills/massa-ai/references/tdd/calibrated-examples.md +54 -0
  121. package/skills/massa-ai/references/tdd/discovery-and-sizing.md +83 -0
  122. package/skills/massa-ai/references/tdd/document-contract.md +136 -0
  123. package/skills/massa-ai/references/tdd/quality-and-lifecycle.md +83 -0
  124. package/skills/massa-ai/references/the-fool/cognitive-bias-inventory.md +103 -0
  125. package/skills/massa-ai/references/the-fool/dialectic-synthesis.md +170 -0
  126. package/skills/massa-ai/references/the-fool/evidence-audit.md +202 -0
  127. package/skills/massa-ai/references/the-fool/mode-selection-guide.md +113 -0
  128. package/skills/massa-ai/references/the-fool/pre-mortem-analysis.md +200 -0
  129. package/skills/massa-ai/references/the-fool/red-team-adversarial.md +206 -0
  130. package/skills/massa-ai/references/the-fool/socratic-questioning.md +153 -0
  131. package/skills/massa-ai/references/ticket/atlassian-fix.md +130 -0
  132. package/skills/massa-ai/references/ticket/intake-and-sources.md +65 -0
  133. package/skills/massa-ai/references/ticket/templates-and-quality.md +129 -0
  134. package/skills/massa-ai/references/verification-ladder.md +62 -0
  135. package/skills/massa-ai/scripts/lessons.py +590 -0
  136. package/skills/massa-ai/workflows/adr.md +33 -0
  137. package/skills/massa-ai/workflows/architecture/architecture-audit.md +125 -0
  138. package/skills/massa-ai/workflows/architecture/architecture-fix.md +110 -0
  139. package/skills/massa-ai/workflows/bugs/bugs-audit.md +113 -0
  140. package/skills/massa-ai/workflows/bugs/bugs-fix.md +97 -0
  141. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +154 -0
  142. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +99 -0
  143. package/skills/massa-ai/workflows/commit.md +61 -0
  144. package/skills/massa-ai/workflows/debug.md +86 -0
  145. package/skills/massa-ai/workflows/design.md +54 -0
  146. package/skills/massa-ai/workflows/exploration.md +119 -0
  147. package/skills/massa-ai/workflows/feature.md +52 -0
  148. package/skills/massa-ai/workflows/general.md +46 -0
  149. package/skills/massa-ai/workflows/implementation/implementation-audit.md +87 -0
  150. package/skills/massa-ai/workflows/implementation/implementation-fix.md +90 -0
  151. package/skills/massa-ai/workflows/long-session.md +44 -0
  152. package/skills/massa-ai/workflows/maestro/maestro-audit.md +56 -0
  153. package/skills/massa-ai/workflows/maestro/maestro-fix.md +74 -0
  154. package/skills/massa-ai/workflows/maestro/maestro.md +68 -0
  155. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +68 -0
  156. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +74 -0
  157. package/skills/massa-ai/workflows/onboarding.md +23 -0
  158. package/skills/massa-ai/workflows/refactor.md +47 -0
  159. package/skills/massa-ai/workflows/refinement/furps-refinement.md +81 -0
  160. package/skills/massa-ai/workflows/requirements/requirements-audit.md +114 -0
  161. package/skills/massa-ai/workflows/requirements/requirements-fix.md +93 -0
  162. package/skills/massa-ai/workflows/rfc.md +55 -0
  163. package/skills/massa-ai/workflows/security/security-audit.md +113 -0
  164. package/skills/massa-ai/workflows/security/security-fix.md +97 -0
  165. package/skills/massa-ai/workflows/spec-driven.md +217 -0
  166. package/skills/massa-ai/workflows/tdd.md +71 -0
  167. package/skills/massa-ai/workflows/tests/tests-audit.md +114 -0
  168. package/skills/massa-ai/workflows/tests/tests-fix.md +96 -0
  169. package/skills/massa-ai/workflows/the-fool.md +82 -0
  170. package/skills/massa-ai/workflows/ticket.md +42 -0
  171. package/skills/persona-router/SKILL.md +158 -0
  172. package/skills/status/SKILL.md +15 -0
@@ -0,0 +1,471 @@
1
+ # Spec-Driven Execute
2
+
3
+ Use this reference for the required Execute phase. Implement ONE task at a time: surgical changes, verify, commit, repeat. Validation is the mandatory final Execute gate, not a separate phase.
4
+
5
+ <!-- validator anchors: evidence-or-zero mapping -->
6
+
7
+ ## Inputs
8
+
9
+ - Approved `.specs/features/<slug>/spec.md`.
10
+ - `.specs/features/<slug>/design.md` when Design was included.
11
+ - `.specs/features/<slug>/tasks.md` when Tasks was included, otherwise the inline atomic step list from `workflows/spec-driven.md`.
12
+ - Current `.specs/project/STATE.md`.
13
+ - `references/spec-driven/coding-principles.md`.
14
+ - `references/spec-driven/sub-agents.md` when a formal task plan packs into more than one task-budgeted batch (> ~8 tasks), or final validation needs the standalone verifier fallback.
15
+
16
+ Artifact-store evidence: active artifact key, version, and checksum after write (see `references/spec-driven/artifact-store.md`).
17
+
18
+ ---
19
+
20
+ ## MANDATORY: Before Starting Any Implementation
21
+
22
+ Read [coding-principles.md](coding-principles.md) and state:
23
+
24
+ 1. **Assumptions** - What am I assuming? Any uncertainty?
25
+ 2. **Files to touch** - List ONLY files this task requires.
26
+ 3. **Success criteria** - How will I verify this works?
27
+
28
+ Do not proceed without stating these explicitly.
29
+
30
+ ---
31
+
32
+ ## Process
33
+
34
+ **Batch worker context:** When this task is executed as part of a phase-batch sub-agent, the worker receives the task definitions for every phase in its batch, coding principles, the generated Test Coverage Matrix and Gate Check Commands from tasks.md, and relevant spec/design context. A batch is one or more consecutive whole phases packed to ~7 tasks. The worker executes ALL tasks in its assigned batch in order — finishing every task in one phase before starting the next phase in the batch — and each task follows every step below (implement → gate → atomic commit) before moving to the next. After all tasks in the batch are complete, the worker reports a compact summary (tasks done, commit hashes, test counts, deviations/blockers) to the orchestrator. See [sub-agents.md](sub-agents.md) for the full model.
35
+
36
+ ### Before implementing: assess sub-agent delegation (MANDATORY — before the first task)
37
+
38
+ Before implementing anything, if a formal `.specs/features/<slug>/tasks.md` with an Execution Plan exists, **count its total tasks** and pack the phases into task-budgeted batches (~7 tasks per worker, whole phases — see [sub-agents.md](sub-agents.md)). If that yields **more than one batch** (> ~8 tasks), you MUST present the sub-agent offer to the user and wait for their choice before starting Execute — do not silently proceed inline. If the feature fits a single batch (≤ ~8 tasks, or the user declines), execute inline. Skip this check only when you are already a batch worker executing a delegated batch (the orchestrator already made the delegation decision).
39
+
40
+ ### 0. List Atomic Steps (MANDATORY when Tasks phase was skipped)
41
+
42
+ If there is no `tasks.md` for this feature, you MUST list atomic steps before writing any code. This is non-negotiable — it prevents the agent from losing focus and doing too many things at once.
43
+
44
+ ```
45
+ ## Execution Plan
46
+
47
+ 1. [Step] → files: [list] → verify: [how] → commit: [message]
48
+ 2. [Step] → files: [list] → verify: [how] → commit: [message]
49
+ 3. [Step] → files: [list] → verify: [how] → commit: [message]
50
+ ```
51
+
52
+ **Each step must be:**
53
+
54
+ - ONE deliverable (one component, one function, one endpoint, one file change)
55
+ - Independently verifiable (can prove it works before moving on)
56
+ - Independently committable (gets its own atomic git commit)
57
+
58
+ If listing steps reveals >5 steps or complex dependencies, STOP and create a formal `.specs/features/<slug>/tasks.md` instead. The Tasks phase was wrongly skipped.
59
+
60
+ ### 1. Pick Task
61
+
62
+ From `.specs/features/<slug>/tasks.md` (if it exists) or from the execution plan above. The user specifies ("implement T3") or suggest the next available task.
63
+
64
+ ### 2. Verify Dependencies
65
+
66
+ If `tasks.md` exists, check dependencies. If using the inline plan, follow the order listed.
67
+
68
+ If blocked: "T3 depends on T2 which isn't done. Should I do T2 first?"
69
+
70
+ ### 3. State Implementation Plan
71
+
72
+ Before writing code:
73
+
74
+ ```
75
+ Files: [list]
76
+ Approach: [brief description]
77
+ Success: [how to verify]
78
+ ```
79
+
80
+ Load `references/naming-standards.md` before writing or changing identifiers; use meaningful domain or precise role names.
81
+
82
+ Ask the MCP and skill question when tool choice can change correctness or verification.
83
+
84
+ ### 4. Write Tests (derived from spec, not from implementation)
85
+
86
+ If the task includes tests (per the Tests field and **Test Coverage Matrix** in `tasks.md`):
87
+
88
+ 1. Write the test file(s) covering the task's acceptance criteria.
89
+ 2. Tests MUST be derived from the task's "Done when" criteria and `spec.md` ACs — **not** from the implementation. Each test encodes what the spec requires; never write tests by reading the code and asserting what it currently does.
90
+ 3. Each acceptance criterion from "Done when" maps to at least one test assertion whose asserted value matches the **spec-defined expected outcome**. Where the spec does not define a precise outcome, note it as a **spec-precision gap** rather than writing a vague assertion and passing silently.
91
+ 4. Edge cases from `spec.md` that apply to this task get test cases too.
92
+
93
+ **HARD CONSTRAINTS (test integrity — never violate):**
94
+
95
+ - Do NOT weaken assertions (making them less specific to pass more easily).
96
+ - Do NOT delete or skip test cases.
97
+ - Do NOT use the test framework's skip/disable/pending mechanism to bypass failing tests.
98
+
99
+ If a test is genuinely wrong (tests the wrong behavior per spec), STOP and ask the user before modifying it. Never silently change a test.
100
+
101
+ Protect validation assets: do not weaken or delete tests, specs, fixtures, snapshots, schemas, or checks to make work pass.
102
+
103
+ If the task does NOT include tests (e.g., entity-only, config-only), skip to Step 4b.
104
+
105
+ ### 4b. Implement
106
+
107
+ Write the minimum implementation needed to satisfy the task's success criteria: pass all relevant tests (when present) and meet the defined verification/gate checks when there are no direct tests.
108
+
109
+ **HARD CONSTRAINTS:**
110
+
111
+ - Do NOT modify tests except to fix a genuinely wrong assertion (ask the user first). The tests are the spec — implementation conforms to them.
112
+ - Do NOT weaken assertions (making them less specific to pass more easily).
113
+ - Do NOT delete or skip test cases.
114
+ - Do NOT use the test framework's skip/disable/pending mechanism to bypass failing tests.
115
+ - Minimum code to pass — save structural improvements for a refactor task.
116
+
117
+ Follow [coding-principles.md](coding-principles.md):
118
+
119
+ - Simplest code that works.
120
+ - Touch ONLY listed files.
121
+ - No scope creep.
122
+
123
+ **Code analysis priority:** Use massa-ai tooling FIRST (list_projects, project_map, search, optimized_context) to locate existing patterns and reuse before falling back to ast-grep/rg/grep. Apply freshness and source-precedence: current repository source overrides a stale index or memory; never let an outdated index reconstruct canonical artifact or code state.
124
+
125
+ **SPEC_DEVIATION markers:** If implementation diverges from spec/design, mark it inline:
126
+
127
+ ```
128
+ // SPEC_DEVIATION: [what diverged]
129
+ // Reason: [why the deviation was necessary]
130
+ ```
131
+
132
+ ### 5. Gate Check (VERIFY)
133
+
134
+ Run the gate check command from the task definition. This is MANDATORY — not "if applicable."
135
+
136
+ 1. Look up the command for the task's Gate level (quick/full/build) in the **Gate Check Commands** section of `tasks.md`, then run it.
137
+ 2. Non-zero exit code = STOP. Fix the failure. Re-run. Do not proceed until it passes.
138
+ 3. Confirm the test count matches expectations (no tests were silently deleted or skipped).
139
+
140
+ **Tiered gates (from the Gate Check Commands section of tasks.md):**
141
+
142
+ | Task includes | Gate level | What runs |
143
+ | -------------------------------- | ---------- | ------------------------ |
144
+ | Unit tests only | Quick | Unit test command |
145
+ | E2E or integration tests | Full | Unit + E2E commands |
146
+ | Last task in a phase, or config/entity-only | Build | Build + lint + all tests |
147
+
148
+ The gate check is deterministic. The test runner decides if the code is correct, not the agent's self-assessment.
149
+
150
+ ### 6. Post-Gate Review
151
+
152
+ After the gate check passes:
153
+
154
+ 1. Verify test count: are there at least as many test cases as before? (prevents silent deletion)
155
+ 2. Verify no unaddressed SPEC_DEVIATION: markers from Step 4b are recorded, not silently left in place.
156
+ 3. Quick complexity check: "Would a senior engineer flag this as overcomplicated?"
157
+ - Yes → Simplify, re-run gate.
158
+ - No → Proceed.
159
+ 4. **Test Adequacy Review (MANDATORY — hard gate).**
160
+
161
+ A task cannot be committed or marked done until all four checks below pass. Tests must be both **necessary** (every test traces to a requirement) and **sufficient** (every requirement is covered). The scope boundary is the feature spec — do not test beyond it.
162
+
163
+ **Check A — Sufficient coverage (per-layer depth).** Build and output this table:
164
+
165
+ | Done-when criterion / spec AC / listed edge case | `file:line` + assertion expression | Spec-defined outcome | Covered? |
166
+ | ------------------------------------------------- | ---------------------------------- | -------------------- | -------- |
167
+ | [criterion from task or spec] | `path/to/test.ts:42` — `expect(result.field).toBe(expected)` | [expected value from spec] | ✅ Yes / ❌ No / ⚠️ Spec-precision gap |
168
+
169
+ **Evidence-or-zero rule:** Each covered cell MUST cite the exact `file:line` where the assertion lives AND reproduce the assertion expression (not just the `describe`/`it` name). A criterion with no located `file:line` evidence counts as **NOT covered**; the task cannot be marked done. Do not declare a criterion absent without first searching the test files — show the search before concluding it is missing (mirror: evidence or zero, never a guess).
170
+
171
+ **Spec-anchored outcome check:** For each covered criterion, derive the expected outcome from `spec.md` (or the task's "Done when" field) and confirm the test's asserted value matches it — not just that an assertion exists. Where the spec defines a precise outcome (e.g., a specific status code, a specific field value, a specific error message), the test assertion MUST target that exact outcome. Where the spec does not define a precise outcome, mark the cell as **⚠️ Spec-precision gap** and add a note; do NOT silently pass a vague assertion as if it were covered.
172
+
173
+ Every "Done when" criterion, every `spec.md` acceptance criterion, and every listed edge case that applies to this task must map to at least one concrete test assertion. Enforce the layer's Coverage Expectation from the Test Coverage Matrix:
174
+
175
+ - Domain / service layer: assertions map 1:1 to spec ACs; every listed edge case has a dedicated test.
176
+ - Route / controller / e2e layer: every route the task adds or modifies must have a happy-path test, a test for each listed edge case, and a test for each documented error/failure path.
177
+
178
+ No criterion left unverified.
179
+
180
+ **Check B — Non-shallow litmus.** Reject each of the following shallow patterns:
181
+ - Assertion-free tests or `expect(true)` / `expect(1).toBe(1)` style tautologies.
182
+ - "No error thrown" as the only assertion — unless not-throwing IS the specified behavior.
183
+ - Asserting only on mock call counts when the actual output/state is what the criterion demands.
184
+ - Happy-path only when the task's "Done when" or `spec.md` lists edge cases.
185
+
186
+ **Payload/conjunction rule.** For each named field in an emitted event, returned object, or persisted record, apply a separate check:
187
+ 1. Open the constructed object at its `file:line` and confirm the field is present in the assertion.
188
+ 2. Confirm the assertion targets the field's **value or state**, not just the call that produced it.
189
+ 3. A present `emit(...)` / `return ...` / `save(...)` call does NOT prove the field — only an assertion on the result does.
190
+ 4. Asserting a method was called (spy/mock) != asserting the resulting state. Both may be needed; neither substitutes for the other.
191
+
192
+ Apply this check to every payload-bearing criterion before marking it covered.
193
+
194
+ **Stack-agnostic litmus:** An assertion is shallow if it would still pass under a plausible *wrong* implementation. If so, strengthen it before committing.
195
+
196
+ **Check C — Necessary (no tests beyond the spec).** Reverse-map every test back to a spec AC, a listed edge case, or a "Done when" criterion. Build this table:
197
+
198
+ | `file:line` + assertion expression | Maps to (AC / edge case / Done-when criterion) | Keep? |
199
+ | ---------------------------------- | ---------------------------------------------- | ----- |
200
+ | `path/to/test.ts:42` — `expect(result.field).toBe(expected)` | [requirement ID or criterion text] | ✅ Keep / ❌ Remove |
201
+
202
+ Any test that maps to nothing → remove it. A test with no requirement is scope creep — it proves nothing about the feature and expands scope beyond the spec. Do not write speculative "what if" tests, do not test framework or library behavior, and do not duplicate an assertion that is already covered at another layer for the same scenario.
203
+
204
+ **Check D — Guideline conformance.** If project quality/testing guidelines were found during the Tasks phase, verify this task's tests conform to them (naming conventions, file locations, coverage thresholds, etc.). Note the guideline file followed.
205
+
206
+ **Bound:** Tests prove the work; they do not expand it. Thoroughness is scoped to the feature + spec. Repo depth is a floor (never less thorough than existing tests for the same layer); the spec is the ceiling. Do not invent requirements or tests that have no spec anchor.
207
+
208
+ **Anti-patterns — known verification cheats (treat any of these as an automatic Check failure):**
209
+
210
+ | Anti-pattern | Why it fails |
211
+ | ------------ | ------------ |
212
+ | Committing before the gate check passes | Skips the deterministic verifier — the gate is not optional |
213
+ | Asserting call count / spy invocation instead of the resulting state | Proves the method ran, not that it did the right thing |
214
+ | Marking a criterion covered without a `file:line` citation | Violates evidence-or-zero; suspicion of coverage is not coverage |
215
+ | Weakening an assertion (making it less specific) to force a pass | Moves the goalposts instead of fixing the code |
216
+ | Deleting or skipping a test to make the suite pass | Destroys coverage permanently; a failing test is a signal, not noise |
217
+ | "Tested elsewhere" deferral without citing where | Coverage gaps hide behind vague claims; cite the file:line or it doesn't count |
218
+ | Speculative "what if" tests with no spec anchor | Expands scope beyond the ceiling; remove them in Check C |
219
+ | Testing framework or library behavior | Tests a dependency, not the feature; remove them in Check C |
220
+
221
+ **On any failure** → rewrite or remove the affected test(s), re-run the gate, then re-run this review.
222
+
223
+ *Honest caveat:* This is an inspection-based review (model judgment), complementary to — not a replacement for — the deterministic gate. The gate confirms the test suite runs; the feature-level discrimination sensor (step 10) confirms the tests can detect regressions. This review confirms the suite is meaningful and bounded.
224
+
225
+ Add the two mapping tables and a one-line adequacy verdict to the Execution Template's Post-Gate section.
226
+
227
+ ### 7. Atomic Git Commit
228
+
229
+ Each task gets its own commit immediately after verification. Never batch multiple tasks into one commit. Use one atomic commit per task when the environment and user permissions allow commits; otherwise record why the commit was skipped.
230
+
231
+ **Format ([Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)):**
232
+
233
+ ```
234
+ <type>(<scope>): <description>
235
+
236
+ [optional body]
237
+
238
+ [optional footer(s)]
239
+ ```
240
+
241
+ **Types:**
242
+
243
+ | Type | When to use |
244
+ | ---------- | ------------------------------------------------------- |
245
+ | `feat` | New feature or capability |
246
+ | `fix` | Bug fix |
247
+ | `refactor` | Code change that neither fixes a bug nor adds a feature |
248
+ | `docs` | Documentation only |
249
+ | `test` | Adding or correcting tests |
250
+ | `style` | Formatting, missing semicolons, etc. (no code change) |
251
+ | `perf` | Performance improvement |
252
+ | `build` | Build system or external dependencies |
253
+ | `ci` | CI configuration files and scripts |
254
+ | `chore` | Maintenance tasks that don't modify src or test files |
255
+
256
+ **Scope:** Feature name or module area, lowercase, e.g., `auth`, `cart`, `api`.
257
+
258
+ **Description rules:**
259
+
260
+ - Imperative mood ("add", not "added" or "adds").
261
+ - Lowercase first letter.
262
+ - No period at the end.
263
+ - Complete the sentence: "If applied, this commit will _[your description]_."
264
+
265
+ **Breaking changes:** Append `!` after type/scope AND add a `BREAKING CHANGE:` footer:
266
+
267
+ ```
268
+ feat(api)!: change authentication endpoint response format
269
+
270
+ BREAKING CHANGE: login endpoint now returns JWT in body instead of cookie
271
+ ```
272
+
273
+ **Examples:**
274
+
275
+ ```
276
+ feat(auth): add email validation to login form
277
+ ```
278
+
279
+ ```
280
+ fix(cart): prevent negative quantity on item decrement
281
+ ```
282
+
283
+ ```
284
+ refactor(api): extract token refresh logic into service
285
+
286
+ Move token refresh from inline handler to dedicated AuthTokenService
287
+ for reuse across multiple endpoints.
288
+ ```
289
+
290
+ **Rules:**
291
+
292
+ - One task = one commit.
293
+ - Description references what was DONE, not what was planned.
294
+ - Include only files listed in the task — never sneak in "while I'm here" changes.
295
+ - If tests are part of the task, include them in the same commit.
296
+
297
+ ### 8. Scope Guardrail / Scope Control
298
+
299
+ During implementation, you will notice things that could be improved, refactored, or added. **Do not act on them.** Instead:
300
+
301
+ - If it's a bug: surface it to the user (or capture it as a separate task).
302
+ - If it's an improvement: add it to the feature's `.specs/features/<slug>/context.md` under "Deferred Ideas" (or surface it to the user if there is no `context.md`).
303
+ - If it's related to the current task: only include it if it is in the "Done when" criteria.
304
+
305
+ **The heuristic:** "Is this in my task definition?" If no, don't touch it. "While I'm here" scope creep during implementation is the #1 quality killer.
306
+
307
+ - Do not add requirements during Execute. New behavior goes back to Specify.
308
+ - Do not make unapproved architecture or contract decisions. New decisions go back to Design.
309
+ - Do not expand task scope to opportunistic refactors.
310
+ - Keep changed files limited to the approved scope and validation.
311
+
312
+ ### 9. Update Task Status
313
+
314
+ Mark the task complete in `.specs/features/<slug>/tasks.md`. Update requirement traceability in `spec.md` if requirement IDs are used. Update logical feature artifact status and `.specs/project/STATE.md` with evidence and the exact next step.
315
+
316
+ **Distill a confirmed lesson** when a task produced a reusable signal (an unexpected failure mode, a confirmed pattern, a corrected assumption):
317
+
318
+ ```
319
+ python3 skills/massa-ai/scripts/lessons.py --root . add \
320
+ --feature <slug> --signal <S> --source <src> --text "<T>" --scope <O>
321
+ ```
322
+
323
+ `--source` is mandatory (grounding gate). Load applicable confirmed lessons before starting a task:
324
+
325
+ ```
326
+ python3 skills/massa-ai/scripts/lessons.py --root . list --status confirmed [--scope <relevant>]
327
+ ```
328
+
329
+ ### 10. Feature-Level Validation (after the LAST task — MANDATORY, always runs)
330
+
331
+ When the task you just completed is the **last task of the feature** (or of a priority group being delivered on its own, e.g. all P1 tasks), you MUST run feature-level validation before reporting the work as done. **This is not optional and is never prompted — it runs automatically.** Do not stop at the final task's commit.
332
+
333
+ **Author ≠ verifier rationale.** The implementer (you, or the batch worker) is the author of the code and tests. An author checking their own work applies the same mental model that may have produced any gaps. The Verifier is a fresh sub-agent that re-derives coverage from the spec independently — it does not inherit the author's assumptions. This separation is the quality gate, not just a style preference.
334
+
335
+ **Layering:**
336
+ - Per-task adequacy self-check (steps 5–6): cheap, always runs, author does it, confirms each task in isolation.
337
+ - Feature-level validation (step 10): one trustworthy independent gate at completion, always-on, Verifier sub-agent does it.
338
+
339
+ **How to delegate to the Verifier:**
340
+ Dispatch a fresh sub-agent following the **Verifier** role described in [sub-agents.md](sub-agents.md). Provide it with:
341
+ - `spec.md` (ACs = source of truth).
342
+ - The git diff surface for this feature (commit range).
343
+ - The test files in scope.
344
+ - `references/spec-driven/validate.md` as its operating checklist.
345
+
346
+ **What the Verifier does (full description in [validate.md](validate.md) and [sub-agents.md](sub-agents.md)):**
347
+ 1. **Spec-anchored coverage check** — re-derives coverage evidence-or-zero; confirms each test's asserted value matches the spec-defined outcome; flags spec-precision gaps.
348
+ 2. **Discrimination sensor** — injects a small behavior-level fault (flip a condition, change a return value, off-by-one) in a scratch/throwaway state (git stash or temp copy), runs the relevant tests, confirms they kill the mutant, then discards the mutation. Reports killed/survived; surviving mutants become fix tasks.
349
+ 3. **Persisted report** — writes `.specs/features/<slug>/validation.md` with PASS/FAIL, per-AC evidence (`file:line` + assertion + spec outcome), gate exit results, sensor result, and the diff/commit range covered.
350
+ 4. **Chat return** — returns a compact verdict + ranked gap list to the orchestrator in chat; the orchestrator surfaces it and routes gaps to fix tasks.
351
+
352
+ The Verifier runs read-only over the real implementation tree (mutations run in a scratch state only). It does NOT fix.
353
+
354
+ If the Verifier returns FAIL, the orchestrator routes the ranked gaps back to an implementer as fix tasks, then re-dispatches the Verifier — bounded to a max of **3 fix→re-verify iterations** before escalating to the user.
355
+
356
+ If you are unsure whether more tasks remain, check `tasks.md`: if every task is marked complete, dispatch the Verifier now.
357
+
358
+ **Verification Before Validate.** Before dispatching the final verifier, collect:
359
+
360
+ - Commands run and results, including build/test count evidence where available.
361
+ - Requirements believed complete.
362
+ - Files changed.
363
+ - Artifact versions and checksums written in `.specs/features/<slug>/` files and `.specs/project/STATE.md`.
364
+ - Per-task test adequacy review outcomes.
365
+ - Known skipped checks with reasons.
366
+ - Any accepted assumptions used during implementation.
367
+ - Whether interactive UAT is required for user-facing behavior.
368
+
369
+ Then run `references/spec-driven/validate.md` as the final Execute gate. The verifier always runs automatically, writes `.specs/features/<slug>/validation.md`, and returns `Pass`, `Needs Fix`, or `Blocked`.
370
+
371
+ ---
372
+
373
+ ## Execution Template
374
+
375
+ ```markdown
376
+ ## Implementing T[X]: [Task Title]
377
+
378
+ **Reading**: task definition from tasks.md
379
+ **Dependencies**: [All done? ✅ | Blocked by: TY]
380
+ **Tests**: [unit/e2e/integration/none]
381
+ **Gate**: [quick/full/build]
382
+
383
+ ### Pre-Implementation (MANDATORY)
384
+
385
+ - **Assumptions**: [state explicitly]
386
+ - **Files to touch**: [list ONLY these]
387
+ - **Success criteria**: [how to verify]
388
+
389
+ ### Tests: Write tests derived from spec ACs
390
+
391
+ - Test file(s): [paths]
392
+ - Test count: [N test cases]
393
+ - Spec-derived: each test's asserted value maps to spec-defined outcome (or gap flagged)
394
+
395
+ ### Implement
396
+
397
+ [Write minimum code to pass tests]
398
+
399
+ - Tests modified: None
400
+ - Tests skipped/deleted: None
401
+
402
+ ### VERIFY: Gate Check
403
+
404
+ - Command: [gate check command]
405
+ - Result: [X passed, 0 failed]
406
+ - Test count: [N — matches planned test count]
407
+
408
+ ### Post-Gate
409
+
410
+ - [x] No SPEC_DEVIATION (or markers added)
411
+ - [x] No unnecessary changes made
412
+ - [x] Matches existing patterns
413
+
414
+ **Test Adequacy Review:**
415
+
416
+ *Check A — Sufficient (coverage mapping):*
417
+
418
+ | Done-when criterion / spec AC / listed edge case | `file:line` + assertion expression | Spec-defined outcome | Covered? |
419
+ | ------------------------------------------------- | ---------------------------------- | -------------------- | -------- |
420
+ | [criterion] | `path/to/test.ts:42` — `expect(result.field).toBe(expected)` | [spec value] | ✅ Yes / ⚠️ Gap |
421
+
422
+ *Check C — Necessary (reverse mapping):*
423
+
424
+ | `file:line` + assertion expression | Maps to (AC / edge case / Done-when criterion) | Keep? |
425
+ | ---------------------------------- | ---------------------------------------------- | ----- |
426
+ | `path/to/test.ts:42` — `expect(result.field).toBe(expected)` | [requirement or criterion text] | ✅ Keep |
427
+
428
+ - [ ] Check A: every criterion covered with `file:line` evidence; spec-defined outcomes matched or gap flagged; per-layer depth met
429
+ - [ ] Check B: no shallow assertions; payload/conjunction rule applied to every payload-bearing criterion
430
+ - [ ] Check C: every test maps to a requirement — no speculative or unclaimed tests
431
+ - [ ] Check D: guideline conformance — [guideline file followed, or "none — strong defaults applied"]
432
+
433
+ **Verdict**: [All criteria covered, spec outcomes matched, no shallow assertions, all tests necessary] / [Rewritten: describe what was fixed]
434
+
435
+ **Status**: ✅ Complete | ❌ Blocked | ⚠️ Partial
436
+ ```
437
+
438
+ **After the LAST task:** dispatch the Verifier sub-agent (see step 10 and [sub-agents.md](sub-agents.md)) for independent feature-level validation, including the spec-anchored check and discrimination sensor. Validation always runs automatically — never prompted. Execute is not done until the Verifier reports PASS and the validation report is written.
439
+
440
+ ---
441
+
442
+ ## Tips
443
+
444
+ - **One task at a time** — Focus prevents errors.
445
+ - **Tools matter** — Wrong MCP = wrong approach; ask the MCP and skill question when tool choice changes correctness or verification.
446
+ - **Reuses save tokens** — Copy patterns, don't reinvent; reach for massa-ai tooling first to locate existing reuse.
447
+ - **Check before commit** — Verify all criteria, then commit.
448
+ - **Stay surgical** — Touch only what's necessary.
449
+ - **Commit per task** — Clean git history enables bisect and rollback.
450
+ - **Never "while I'm here"** — Scope creep during implementation is the #1 quality killer.
451
+ - **Learn from mistakes** — If something goes wrong, distill a confirmed lesson and surface it so it informs the next task.
452
+ - **Don't stop at the last commit** — Feature-level validation (step 10) is the final step of Execute, not optional.
453
+
454
+ ---
455
+
456
+ ## Pause / End of Session
457
+
458
+ When work is interrupted, paused, or a session ends before the feature is complete:
459
+
460
+ 1. Update `.specs/project/STATE.md` — append any new decisions to the `## Decisions` section (append-only; decisions are normally written during Design, but runtime decisions discovered during Execute may be appended).
461
+ 2. Open `.specs/HANDOFF.md`.
462
+ 3. **Replace the body of `HANDOFF.md`** with the current snapshot (feature, phase/task, completed, in-progress `file:line`, next step, blockers, uncommitted files, branch). See `references/spec-driven/memory.md` for the exact format.
463
+ 4. Do NOT touch the `## Decisions` log in `.specs/project/STATE.md` beyond appending — decisions are never clobbered.
464
+
465
+ **Section-scoped write (critical):** Replace the content of `.specs/HANDOFF.md` only. In `.specs/project/STATE.md`, append to `## Decisions`; never overwrite the full file — doing so silently destroys the Decisions log.
466
+
467
+ ---
468
+
469
+ ## Done
470
+
471
+ Execute is done when all approved steps are implemented, deterministic checks have run or are explicitly blocked, per-task test adequacy reviews pass or have clear blockers, final validation passed or produced a bounded fix/blocker verdict, `.specs/project/STATE.md` is restartable, `.specs/HANDOFF.md` reflects the current snapshot, and completion evidence is recorded.
@@ -0,0 +1,5 @@
1
+ # Spec-Driven Lessons
2
+
3
+ Use `references/lessons.md` for lesson loading, capture, and lifecycle. The lesson system is no longer spec-driven only — it applies to all implementation, fix, and debug workflows.
4
+
5
+ See `references/lessons.md` for the full signal table, capture commands, loading commands, promotion lifecycle, and fallback behavior.