mandrel 2.7.0 → 2.9.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 (95) hide show
  1. package/.agents/README.md +104 -330
  2. package/.agents/agents/auditor.md +135 -0
  3. package/.agents/agents/plan-critic.md +80 -0
  4. package/.agents/audit-checklists/dependencies.md +7 -0
  5. package/.agents/audit-checklists/documentation.md +1 -0
  6. package/.agents/docs/SDLC.md +69 -162
  7. package/.agents/docs/configuration.md +159 -499
  8. package/.agents/docs/quality-gates.md +59 -180
  9. package/.agents/instructions.md +170 -295
  10. package/.agents/rules/changelog-style.md +8 -66
  11. package/.agents/rules/ci-remediation.md +65 -124
  12. package/.agents/rules/gherkin-standards.md +10 -31
  13. package/.agents/rules/git-conventions-reference.md +28 -61
  14. package/.agents/rules/git-conventions.md +1 -1
  15. package/.agents/rules/orchestration-error-handling.md +5 -15
  16. package/.agents/rules/security-baseline.md +7 -13
  17. package/.agents/rules/shell-conventions.md +4 -13
  18. package/.agents/rules/test-seams.md +2 -2
  19. package/.agents/rules/testing-standards.md +7 -17
  20. package/.agents/schemas/agentrc.schema.json +21 -0
  21. package/.agents/scripts/audit-to-stories.js +51 -0
  22. package/.agents/scripts/lib/audit-to-stories/dedupe-against-github.js +120 -55
  23. package/.agents/scripts/lib/config-settings-schema.js +32 -0
  24. package/.agents/scripts/lib/findings/semantic-issue-search.js +43 -5
  25. package/.agents/scripts/lib/observability/terse-result.js +114 -0
  26. package/.agents/scripts/lib/orchestration/complexity-gate.js +207 -0
  27. package/.agents/scripts/lib/orchestration/plan-context.js +3 -0
  28. package/.agents/scripts/lib/orchestration/single-story-close/phases/auto-merge.js +221 -8
  29. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +55 -14
  30. package/.agents/scripts/lib/orchestration/story-close/emit-blocked.js +9 -3
  31. package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +4 -1
  32. package/.agents/scripts/lib/orchestration/task-body-validator.js +13 -40
  33. package/.agents/scripts/lib/story-body/body-format-lints.js +215 -0
  34. package/.agents/scripts/lib/story-body/story-body.js +18 -2
  35. package/.agents/scripts/lib/templates/decomposer-prompts.js +16 -0
  36. package/.agents/scripts/providers/github/issues.js +54 -7
  37. package/.agents/scripts/providers/github/search-budget.js +124 -0
  38. package/.agents/scripts/providers/github/search-query.js +71 -0
  39. package/.agents/scripts/single-story-confirm-merge.js +14 -5
  40. package/.agents/scripts/single-story-init.js +19 -3
  41. package/.agents/scripts/sync-branch-from-base.js +9 -3
  42. package/.agents/skills/core/api-and-interface-design/SKILL.md +23 -297
  43. package/.agents/skills/core/api-and-interface-design/reference.md +76 -0
  44. package/.agents/skills/core/browser-testing-with-devtools/SKILL.md +20 -327
  45. package/.agents/skills/core/browser-testing-with-devtools/reference.md +74 -0
  46. package/.agents/skills/core/code-review-and-quality/reference.md +16 -398
  47. package/.agents/skills/core/debugging-and-error-recovery/reference.md +14 -281
  48. package/.agents/skills/core/documentation-and-adrs/reference.md +42 -338
  49. package/.agents/skills/core/git-workflow-and-versioning/SKILL.md +28 -326
  50. package/.agents/skills/core/idea-refinement/SKILL.md +67 -193
  51. package/.agents/skills/core/security-and-hardening/SKILL.md +15 -31
  52. package/.agents/skills/core/security-and-hardening/reference.md +15 -273
  53. package/.agents/skills/skills.index.json +5 -5
  54. package/.agents/skills/stack/qa/gherkin-authoring/SKILL.md +16 -222
  55. package/.agents/skills/stack/qa/gherkin-authoring/reference.md +157 -0
  56. package/.agents/skills/stack/qa/playwright/SKILL.md +0 -29
  57. package/.agents/skills/stack/qa/qa-explore-driving/SKILL.md +19 -23
  58. package/.agents/skills/stack/qa/qa-harness/SKILL.md +35 -53
  59. package/.agents/skills/stack/qa/vitest/SKILL.md +0 -29
  60. package/.agents/workflows/audit-accessibility.md +34 -108
  61. package/.agents/workflows/audit-architecture.md +35 -123
  62. package/.agents/workflows/audit-clean-code.md +19 -78
  63. package/.agents/workflows/audit-data-model.md +32 -100
  64. package/.agents/workflows/audit-dependencies.md +47 -111
  65. package/.agents/workflows/audit-devops.md +16 -83
  66. package/.agents/workflows/audit-documentation.md +46 -93
  67. package/.agents/workflows/audit-navigability.md +26 -80
  68. package/.agents/workflows/audit-performance.md +40 -106
  69. package/.agents/workflows/audit-privacy.md +17 -80
  70. package/.agents/workflows/audit-quality.md +35 -99
  71. package/.agents/workflows/audit-security.md +20 -78
  72. package/.agents/workflows/audit-seo.md +20 -98
  73. package/.agents/workflows/audit-sre.md +20 -88
  74. package/.agents/workflows/audit-to-stories.md +1 -8
  75. package/.agents/workflows/audit-ux-ui.md +17 -80
  76. package/.agents/workflows/deliver.md +54 -9
  77. package/.agents/workflows/git-cleanup.md +50 -275
  78. package/.agents/workflows/helpers/audit-lens-core.md +230 -0
  79. package/.agents/workflows/helpers/code-review.md +11 -23
  80. package/.agents/workflows/helpers/deliver-story-reference.md +114 -17
  81. package/.agents/workflows/helpers/deliver-story.md +36 -186
  82. package/.agents/workflows/helpers/qa-core.md +174 -0
  83. package/.agents/workflows/helpers/qa-run-scenario-reference.md +35 -0
  84. package/.agents/workflows/helpers/qa-run-scenario.md +11 -25
  85. package/.agents/workflows/helpers/worktree-lifecycle.md +6 -67
  86. package/.agents/workflows/mandrel-update.md +7 -13
  87. package/.agents/workflows/plan.md +44 -17
  88. package/.agents/workflows/qa-assist.md +140 -269
  89. package/.agents/workflows/qa-explore.md +125 -316
  90. package/.agents/workflows/qa-run.md +180 -380
  91. package/docs/CHANGELOG.md +30 -0
  92. package/package.json +1 -1
  93. package/.agents/workflows/helpers/audit-dual-path.md +0 -59
  94. package/.agents/workflows/helpers/audit-self-check.md +0 -70
  95. package/.agents/workflows/helpers/audit-severity-scale.md +0 -19
@@ -1,191 +1,18 @@
1
1
  # Code Review and Quality — Reference (on-demand)
2
2
 
3
3
  **Read this when** a task engages one of the sections below and the Policy
4
- Capsule in [`SKILL.md`](SKILL.md) does not settle it on its own. The capsule
5
- is the contract; this file is the reference material behind it. Nothing here
6
- relaxes a capsule MUST, and nothing here is required reading merely because
7
- the skill is active.
4
+ Capsule in [`SKILL.md`](SKILL.md) does not settle it on its own. The capsule is
5
+ the contract; this file is the reference material behind it. The generic
6
+ five-axis review method, change-sizing heuristics, and review-etiquette prose
7
+ are frontier-known and are not reproduced here — this file keeps the two
8
+ project-specific contracts: the finding-severity table and the measured
9
+ post-green refactor pass.
8
10
 
9
- ## Overview
11
+ ## Finding-Severity Table
10
12
 
11
- Multi-dimensional code review with quality gates. Every change gets reviewed
12
- before mergeno exceptions. Review covers five axes: correctness, readability,
13
- architecture, security, and performance.
14
-
15
- **The approval standard:** Approve a change when it definitely improves overall
16
- code health, even if it isn't perfect. Perfect code doesn't exist — the goal is
17
- continuous improvement. Don't block a change because it isn't exactly how you
18
- would have written it. If it improves the codebase and follows the project's
19
- conventions, approve it.
20
-
21
- ## When to Use
22
-
23
- - Before merging any PR or change
24
- - After completing a feature implementation
25
- - When another agent or model produced code you need to evaluate
26
- - When refactoring existing code
27
- - After any bug fix (review both the fix and the regression test)
28
-
29
- ## The Five-Axis Review
30
-
31
- Every review evaluates code across these dimensions:
32
-
33
- ### 1. Correctness
34
-
35
- Does the code do what it claims to do?
36
-
37
- - Does it match the spec or task requirements?
38
- - Are edge cases handled (null, empty, boundary values)?
39
- - Are error paths handled (not just the happy path)?
40
- - Does it pass all tests? Are the tests actually testing the right things?
41
- - Are there off-by-one errors, race conditions, or state inconsistencies?
42
-
43
- ### 2. Readability & Simplicity
44
-
45
- Can another engineer (or agent) understand this code without the author
46
- explaining it?
47
-
48
- - Are names descriptive and consistent with project conventions? (No `temp`,
49
- `data`, `result` without context)
50
- - Is the control flow straightforward (avoid nested ternaries, deep callbacks)?
51
- - Is the code organized logically (related code grouped, clear module
52
- boundaries)?
53
- - Are there any "clever" tricks that should be simplified?
54
- - **Could this be done in fewer lines?** (1000 lines where 100 suffice is a
55
- failure)
56
- - **Are abstractions earning their complexity?** (Don't generalize until the
57
- third use case)
58
- - Would comments help clarify non-obvious intent? (But don't comment obvious
59
- code.)
60
- - Are there dead code artifacts: no-op variables (`_unused`), backwards-compat
61
- shims, or `// removed` comments?
62
-
63
- ### 3. Architecture
64
-
65
- Does the change fit the system's design?
66
-
67
- - Does it follow existing patterns or introduce a new one? If new, is it
68
- justified?
69
- - Does it maintain clean module boundaries?
70
- - Is there code duplication that should be shared?
71
- - Are dependencies flowing in the right direction (no circular dependencies)?
72
- - Is the abstraction level appropriate (not over-engineered, not too coupled)?
73
-
74
- ### 4. Security
75
-
76
- For detailed security guidance, see `security-and-hardening`. Does the change
77
- introduce vulnerabilities?
78
-
79
- - Is user input validated and sanitized?
80
- - Are secrets kept out of code, logs, and version control?
81
- - Is authentication/authorization checked where needed?
82
- - Are SQL queries parameterized (no string concatenation)?
83
- - Are outputs encoded to prevent XSS?
84
- - Are dependencies from trusted sources with no known vulnerabilities?
85
- - Is data from external sources (APIs, logs, user content, config files) treated
86
- as untrusted?
87
- - Are external data flows validated at system boundaries before use in logic or
88
- rendering?
89
-
90
- ### 5. Performance
91
-
92
- Measure before optimizing, and only on the hot path. Does the change introduce
93
- performance problems?
94
-
95
- - Any N+1 query patterns?
96
- - Any unbounded loops or unconstrained data fetching?
97
- - Any synchronous operations that should be async?
98
- - Any unnecessary re-renders in UI components?
99
- - Any missing pagination on list endpoints?
100
- - Any large objects created in hot paths?
101
-
102
- ## Change Sizing
103
-
104
- Small, focused changes are easier to review, faster to merge, and safer to
105
- deploy. Target these sizes:
106
-
107
- ```text
108
- ~100 lines changed → Good. Reviewable in one sitting.
109
- ~300 lines changed → Acceptable if it's a single logical change.
110
- ~1000 lines changed → Too large. Split it.
111
- ```
112
-
113
- **What counts as "one change":** A single self-contained modification that
114
- addresses one thing, includes related tests, and keeps the system functional
115
- after submission. One part of a feature — not the whole feature.
116
-
117
- **Splitting strategies when a change is too large:**
118
-
119
- | Strategy | How | When |
120
- | ----------------- | ------------------------------------------------------- | ----------------------- |
121
- | **Stack** | Submit a small change, start the next one based on it | Sequential dependencies |
122
- | **By file group** | Separate changes for groups needing different reviewers | Cross-cutting concerns |
123
- | **Horizontal** | Create shared code/stubs first, then consumers | Layered architecture |
124
- | **Vertical** | Break into smaller full-stack slices of the feature | Feature work |
125
-
126
- **When large changes are acceptable:** Complete file deletions and automated
127
- refactoring where the reviewer only needs to verify intent, not every line.
128
-
129
- **Separate refactoring from feature work.** A change that refactors existing
130
- code and adds new behavior is two changes — submit them separately. Small
131
- cleanups (variable renaming) can be included at reviewer discretion.
132
-
133
- ## Change Descriptions
134
-
135
- Every change needs a description that stands alone in version control history.
136
-
137
- **First line:** Short, imperative, standalone. "Delete the FizzBuzz RPC" not
138
- "Deleting the FizzBuzz RPC." Must be informative enough that someone searching
139
- history can understand the change without reading the diff.
140
-
141
- **Body:** What is changing and why. Include context, decisions, and reasoning
142
- not visible in the code itself. Link to bug numbers, benchmark results, or
143
- design docs where relevant. Acknowledge approach shortcomings when they exist.
144
-
145
- **Anti-patterns:** "Fix bug," "Fix build," "Add patch," "Moving code from A to
146
- B," "Phase 1," "Add convenience functions."
147
-
148
- ## Review Process
149
-
150
- ### Step 1: Understand the Context
151
-
152
- Before looking at code, understand the intent:
153
-
154
- ```text
155
- - What is this change trying to accomplish?
156
- - What spec or task does it implement?
157
- - What is the expected behavior change?
158
- ```
159
-
160
- ### Step 2: Review the Tests First
161
-
162
- Tests reveal intent and coverage:
163
-
164
- ```text
165
- - Do tests exist for the change?
166
- - Do they test behavior (not implementation details)?
167
- - Are edge cases covered?
168
- - Do tests have descriptive names?
169
- - Would the tests catch a regression if the code changed?
170
- ```
171
-
172
- ### Step 3: Review the Implementation
173
-
174
- Walk through the code with the five axes in mind:
175
-
176
- ```text
177
- For each file changed:
178
- 1. Correctness: Does this code do what the test says it should?
179
- 2. Readability: Can I understand this without help?
180
- 3. Architecture: Does this fit the system?
181
- 4. Security: Any vulnerabilities?
182
- 5. Performance: Any bottlenecks?
183
- ```
184
-
185
- ### Step 4: Categorize Findings
186
-
187
- Label every comment with its severity so the author knows what's required vs
188
- optional:
13
+ Label every review comment with its severity so the author knows what's
14
+ required vs. optional this prevents authors from treating all feedback as
15
+ mandatory:
189
16
 
190
17
  | Prefix | Meaning | Author Action |
191
18
  | ----------------------------- | ------------------ | ------------------------------------------------------- |
@@ -195,204 +22,6 @@ optional:
195
22
  | **Optional:** / **Consider:** | Suggestion | Worth considering but not required |
196
23
  | **FYI** | Informational only | No action needed — context for future reference |
197
24
 
198
- This prevents authors from treating all feedback as mandatory and wasting time
199
- on optional suggestions.
200
-
201
- ### Step 5: Verify the Verification
202
-
203
- Check the author's verification story:
204
-
205
- ```text
206
- - What tests were run?
207
- - Did the build pass?
208
- - Was the change tested manually?
209
- - Are there screenshots for UI changes?
210
- - Is there a before/after comparison?
211
- ```
212
-
213
- ## Multi-Model Review Pattern
214
-
215
- Use different models for different review perspectives:
216
-
217
- ```text
218
- Model A writes the code
219
-
220
-
221
- Model B reviews for correctness and architecture
222
-
223
-
224
- Model A addresses the feedback
225
-
226
-
227
- Human makes the final call
228
- ```
229
-
230
- This catches issues that a single model might miss — different models have
231
- different blind spots.
232
-
233
- **Example prompt for a review agent:**
234
-
235
- ```text
236
- Review this code change for correctness, security, and adherence to
237
- our project conventions. The spec says [X]. The change should [Y].
238
- Flag any issues as Critical, Important, or Suggestion.
239
- ```
240
-
241
- ## Dead Code Hygiene
242
-
243
- After any refactoring or implementation change, check for orphaned code:
244
-
245
- 1. Identify code that is now unreachable or unused
246
- 2. List it explicitly
247
- 3. **Ask before deleting:** "Should I remove these now-unused elements: [list]?"
248
-
249
- Don't leave dead code lying around — it confuses future readers and agents. But
250
- don't silently delete things you're not sure about. When in doubt, ask.
251
-
252
- ```text
253
- DEAD CODE IDENTIFIED:
254
- - formatLegacyDate() in src/utils/date.ts — replaced by formatDate()
255
- - OldTaskCard component in src/components/ — replaced by TaskCard
256
- - LEGACY_API_URL constant in src/config.ts — no remaining references
257
- → Safe to remove these?
258
- ```
259
-
260
- ## Review Speed
261
-
262
- Slow reviews block entire teams. The cost of context-switching to review is less
263
- than the waiting cost imposed on others.
264
-
265
- - **Respond within one business day** — this is the maximum, not the target
266
- - **Ideal cadence:** Respond shortly after a review request arrives, unless deep
267
- in focused coding. A typical change should complete multiple review rounds in
268
- a single day
269
- - **Prioritize fast individual responses** over quick final approval. Quick
270
- feedback reduces frustration even if multiple rounds are needed
271
- - **Large changes:** Ask the author to split them rather than reviewing one
272
- massive changeset
273
-
274
- ## Handling Disagreements
275
-
276
- When resolving review disputes, apply this hierarchy:
277
-
278
- 1. **Technical facts and data** override opinions and preferences
279
- 2. **Style guides** are the absolute authority on style matters
280
- 3. **Software design** must be evaluated on engineering principles, not personal
281
- preference
282
- 4. **Codebase consistency** is acceptable if it doesn't degrade overall health
283
-
284
- **Don't accept "I'll clean it up later."** Experience shows deferred cleanup
285
- rarely happens. Require cleanup before submission unless it's a genuine
286
- emergency. If surrounding issues can't be addressed in this change, require
287
- filing a bug with self-assignment.
288
-
289
- ## Honesty in Review
290
-
291
- When reviewing code — whether written by you, another agent, or a human:
292
-
293
- - **Don't rubber-stamp.** "LGTM" without evidence of review helps no one.
294
- - **Don't soften real issues.** "This might be a minor concern" when it's a bug
295
- that will hit production is dishonest.
296
- - **Quantify problems when possible.** "This N+1 query will add ~50ms per item
297
- in the list" is better than "this could be slow."
298
- - **Push back on approaches with clear problems.** Sycophancy is a failure mode
299
- in reviews. If the implementation has issues, say so directly and propose
300
- alternatives.
301
- - **Accept override gracefully.** If the author has full context and disagrees,
302
- defer to their judgment. Comment on code, not people — reframe personal
303
- critiques to focus on the code itself.
304
-
305
- ## Dependency Discipline
306
-
307
- Part of code review is dependency review:
308
-
309
- **Before adding any dependency:**
310
-
311
- 1. Does the existing stack solve this? (Often it does.)
312
- 2. How large is the dependency? (Check bundle impact.)
313
- 3. Is it actively maintained? (Check last commit, open issues.)
314
- 4. Does it have known vulnerabilities? (`npm audit`)
315
- 5. What's the license? (Must be compatible with the project.)
316
-
317
- **Rule:** Prefer standard library and existing utilities over new dependencies.
318
- Every dependency is a liability.
319
-
320
- ## The Review Checklist
321
-
322
- ```markdown
323
- ## Review: [PR/Change title]
324
-
325
- ### Context
326
-
327
- - [ ] I understand what this change does and why
328
-
329
- ### Correctness
330
-
331
- - [ ] Change matches spec/task requirements
332
- - [ ] Edge cases handled
333
- - [ ] Error paths handled
334
- - [ ] Tests cover the change adequately
335
-
336
- ### Readability
337
-
338
- - [ ] Names are clear and consistent
339
- - [ ] Logic is straightforward
340
- - [ ] No unnecessary complexity
341
-
342
- ### Architecture
343
-
344
- - [ ] Follows existing patterns
345
- - [ ] No unnecessary coupling or dependencies
346
- - [ ] Appropriate abstraction level
347
-
348
- ### Security
349
-
350
- - [ ] No secrets in code
351
- - [ ] Input validated at boundaries
352
- - [ ] No injection vulnerabilities
353
- - [ ] Auth checks in place
354
- - [ ] External data sources treated as untrusted
355
-
356
- ### Performance
357
-
358
- - [ ] No N+1 patterns
359
- - [ ] No unbounded operations
360
- - [ ] Pagination on list endpoints
361
-
362
- ### Verification
363
-
364
- - [ ] Tests pass
365
- - [ ] Build succeeds
366
- - [ ] Manual verification done (if applicable)
367
-
368
- ### Verdict
369
-
370
- - [ ] **Approve** — Ready to merge
371
- - [ ] **Request changes** — Issues must be addressed
372
- ```
373
-
374
- ## Common Rationalizations
375
-
376
- | Rationalization | Reality |
377
- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
378
- | "It works, that's good enough" | Working code that's unreadable, insecure, or architecturally wrong creates debt that compounds. |
379
- | "I wrote it, so I know it's correct" | Authors are blind to their own assumptions. Every change benefits from another set of eyes. |
380
- | "We'll clean it up later" | Later never comes. The review is the quality gate — use it. Require cleanup before merge, not after. |
381
- | "AI-generated code is probably fine" | AI code needs more scrutiny, not less. It's confident and plausible, even when wrong. |
382
- | "The tests pass, so it's good" | Tests are necessary but not sufficient. They don't catch architecture problems, security issues, or readability concerns. |
383
-
384
- ## Red Flags
385
-
386
- - PRs merged without any review
387
- - Review that only checks if tests pass (ignoring other axes)
388
- - "LGTM" without evidence of actual review
389
- - Security-sensitive changes without security-focused review
390
- - Large PRs that are "too big to review properly" (split them)
391
- - No regression tests with bug fix PRs
392
- - Review comments without severity labels — makes it unclear what's required vs
393
- optional
394
- - Accepting "I'll fix it later" — it never happens
395
-
396
25
  ## Post-Green Refactor Pass
397
26
 
398
27
  Review's sibling discipline is the **behaviour-preserving refactor** that drives
@@ -437,22 +66,11 @@ Keep each refactor an isolated, reviewable commit separate from feature or fix
437
66
  work, refactor only the targeted functions/duplications (no drive-by rewrites),
438
67
  and leave no dead code behind (unused imports, orphaned helpers).
439
68
 
440
- ## Verification
441
-
442
- After review is complete:
443
-
444
- - [ ] All Critical issues are resolved
445
- - [ ] All Important issues are resolved or explicitly deferred with
446
- justification
447
- - [ ] Tests pass
448
- - [ ] Build succeeds
449
- - [ ] The verification story is documented (what changed, how it was verified)
450
-
451
- After a post-green refactor pass:
69
+ **After a post-green refactor pass, confirm:**
452
70
 
453
- - [ ] The suite was green before and after, with **no test modifications**
71
+ - [ ] The suite was green before and after, with **no test modifications**.
454
72
  - [ ] CRAP did not rise and maintainability did not fall on any touched file
455
- (baselines re-run and compared)
456
- - [ ] No gate, floor, or coverage threshold was loosened
457
- - [ ] Duplication was removed at the root (one helper), not just locally patched
458
- - [ ] Each refactor is an isolated commit, separate from feature or fix work
73
+ (baselines re-run and compared).
74
+ - [ ] No gate, floor, or coverage threshold was loosened.
75
+ - [ ] Duplication was removed at the root (one helper), not just locally patched.
76
+ - [ ] Each refactor is an isolated commit, separate from feature or fix work.