mandrel 2.40.0 → 2.41.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 (59) hide show
  1. package/.agents/README.md +2 -2
  2. package/.agents/instructions.md +5 -6
  3. package/.agents/rules/api-conventions.md +43 -7
  4. package/.agents/rules/ci-remediation.md +3 -14
  5. package/.agents/rules/gherkin-standards.md +21 -6
  6. package/.agents/rules/git-conventions.md +6 -5
  7. package/.agents/rules/security-baseline.md +6 -7
  8. package/.agents/rules/testing-standards.md +75 -198
  9. package/.agents/scripts/install-matrix-assert.js +2 -2
  10. package/.agents/scripts/lib/audit-to-stories/epic-grouping-directive.js +6 -0
  11. package/.agents/scripts/lib/orchestration/dependency-candidates.js +139 -0
  12. package/.agents/scripts/lib/orchestration/epic-candidates.js +159 -0
  13. package/.agents/scripts/lib/orchestration/epic-checklist.js +103 -0
  14. package/.agents/scripts/lib/orchestration/epic-container.js +18 -2
  15. package/.agents/scripts/lib/orchestration/plan-context.js +97 -36
  16. package/.agents/scripts/lib/orchestration/plan-persist/cross-plan-links.js +80 -0
  17. package/.agents/scripts/lib/orchestration/plan-persist/epic-adoption.js +192 -0
  18. package/.agents/scripts/lib/orchestration/plan-persist/epic-ops.js +5 -1
  19. package/.agents/scripts/lib/orchestration/plan-persist/external-deps.js +164 -0
  20. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +14 -2
  21. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +26 -5
  22. package/.agents/scripts/lib/orchestration/ticket-validator.js +11 -1
  23. package/.agents/scripts/plan-persist.js +60 -1
  24. package/.agents/skills/core/browser-testing-with-devtools/SKILL.md +5 -10
  25. package/.agents/skills/core/browser-testing-with-devtools/reference.md +7 -46
  26. package/.agents/skills/core/code-review-and-quality/SKILL.md +0 -5
  27. package/.agents/skills/core/documentation-and-adrs/SKILL.md +0 -3
  28. package/.agents/skills/core/gates-and-baselines/SKILL.md +10 -137
  29. package/.agents/skills/core/gates-and-baselines/reference.md +103 -0
  30. package/.agents/skills/core/idea-refinement/SKILL.md +2 -18
  31. package/.agents/skills/core/security-and-hardening/SKILL.md +2 -4
  32. package/.agents/skills/core/security-and-hardening/reference.md +0 -70
  33. package/.agents/skills/skills.index.json +10 -70
  34. package/.agents/skills/stack/qa/gherkin-authoring/SKILL.md +4 -10
  35. package/.agents/skills/stack/qa/gherkin-authoring/reference.md +9 -113
  36. package/.agents/skills/stack/qa/playwright-bdd/SKILL.md +29 -154
  37. package/.agents/skills/stack/qa/qa-harness/SKILL.md +157 -98
  38. package/.agents/workflows/git-cleanup.md +3 -2
  39. package/.agents/workflows/git-deliver.md +3 -2
  40. package/.agents/workflows/helpers/plan-reference.md +82 -2
  41. package/.agents/workflows/mandrel-plan.md +45 -45
  42. package/.agents/workflows/qa-assist.md +20 -17
  43. package/.agents/workflows/qa-explore.md +30 -29
  44. package/.agents/workflows/qa-run.md +2 -1
  45. package/docs/CHANGELOG.md +14 -0
  46. package/package.json +1 -1
  47. package/.agents/rules/changelog-style.md +0 -180
  48. package/.agents/rules/shell-conventions.md +0 -61
  49. package/.agents/scripts/lib/qa/coverage-verdict.js +0 -214
  50. package/.agents/skills/core/api-and-interface-design/SKILL.md +0 -55
  51. package/.agents/skills/core/api-and-interface-design/reference.md +0 -76
  52. package/.agents/skills/core/debugging-and-error-recovery/SKILL.md +0 -45
  53. package/.agents/skills/core/debugging-and-error-recovery/reference.md +0 -56
  54. package/.agents/skills/core/git-workflow-and-versioning/SKILL.md +0 -54
  55. package/.agents/skills/core/idea-refinement/refinement-criteria.md +0 -155
  56. package/.agents/skills/core/idea-refinement/scripts/idea-refine.sh +0 -15
  57. package/.agents/skills/core/qa-coverage-mapping/SKILL.md +0 -105
  58. package/.agents/skills/stack/qa/qa-explore-driving/SKILL.md +0 -152
  59. package/.agents/skills/stack/qa/vitest/SKILL.md +0 -22
@@ -1,24 +1,14 @@
1
1
  {
2
- "generatedAt": "2026-08-06T10:26:18.702Z",
2
+ "generatedAt": "2026-09-06T12:59:23.069Z",
3
3
  "generator": "generate-skills-index.js@1",
4
4
  "skills": [
5
- {
6
- "name": "api-and-interface-design",
7
- "tier": "core",
8
- "category": "core",
9
- "path": ".agents/skills/core/api-and-interface-design/SKILL.md",
10
- "description": "Designs stable, well-documented APIs and module interfaces. Use when creating REST/GraphQL endpoints, defining contracts between modules, or changing public interfaces. The wire-format SSOT — response envelope, HTTP status codes, validation taxonomy, payload naming — lives in `.agents/rules/api-conventions.md`; this skill shows authors how to apply it.",
11
- "policyCapsuleBullets": 9,
12
- "allowedTools": null,
13
- "vendor": null
14
- },
15
5
  {
16
6
  "name": "browser-testing-with-devtools",
17
7
  "tier": "core",
18
8
  "category": "core",
19
9
  "path": ".agents/skills/core/browser-testing-with-devtools/SKILL.md",
20
10
  "description": "Tests in real browsers. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data via Chrome DevTools MCP.",
21
- "policyCapsuleBullets": 9,
11
+ "policyCapsuleBullets": 8,
22
12
  "allowedTools": null,
23
13
  "vendor": null
24
14
  },
@@ -28,17 +18,7 @@
28
18
  "category": "core",
29
19
  "path": ".agents/skills/core/code-review-and-quality/SKILL.md",
30
20
  "description": "Conducts multi-axis code review and runs the disciplined post-green refactor pass. Use before merging any change, when reviewing code written by yourself, another agent, or a human, or when the opt-in `delivery.refactorStage` checkpoint asks for a behaviour-preserving CRAP/duplication pass after the suite is green.",
31
- "policyCapsuleBullets": 12,
32
- "allowedTools": null,
33
- "vendor": null
34
- },
35
- {
36
- "name": "debugging-and-error-recovery",
37
- "tier": "core",
38
- "category": "core",
39
- "path": ".agents/skills/core/debugging-and-error-recovery/SKILL.md",
40
- "description": "Guides systematic root-cause debugging. Use when tests fail, builds break, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need a systematic approach to finding and fixing the root cause rather than guessing.",
41
- "policyCapsuleBullets": 9,
21
+ "policyCapsuleBullets": 7,
42
22
  "allowedTools": null,
43
23
  "vendor": null
44
24
  },
@@ -48,7 +28,7 @@
48
28
  "category": "core",
49
29
  "path": ".agents/skills/core/documentation-and-adrs/SKILL.md",
50
30
  "description": "Records decisions and documentation. Use when making architectural decisions, changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.",
51
- "policyCapsuleBullets": 9,
31
+ "policyCapsuleBullets": 6,
52
32
  "allowedTools": null,
53
33
  "vendor": null
54
34
  },
@@ -57,21 +37,11 @@
57
37
  "tier": "core",
58
38
  "category": "core",
59
39
  "path": ".agents/skills/core/gates-and-baselines/SKILL.md",
60
- "description": "Governs quality gates and the unified-baseline snapshots. Use when authoring a baseline refresh commit (CRAP, maintainability, dead-exports, lighthouse), when setting up or modifying CI quality gates, or when introducing a new gate that asserts on pre-existing state without turning the integration branch red.",
61
- "policyCapsuleBullets": 9,
40
+ "description": "Governs quality gates and the unified-baseline snapshots. Use when authoring a baseline refresh commit (coverage, CRAP, maintainability, duplication, dead-exports), when setting up or modifying CI quality gates, or when introducing a new gate that asserts on pre-existing state without turning the base branch red.",
41
+ "policyCapsuleBullets": 10,
62
42
  "allowedTools": ["Read", "Write", "Bash"],
63
43
  "vendor": null
64
44
  },
65
- {
66
- "name": "git-workflow-and-versioning",
67
- "tier": "core",
68
- "category": "core",
69
- "path": ".agents/skills/core/git-workflow-and-versioning/SKILL.md",
70
- "description": "Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.",
71
- "policyCapsuleBullets": 6,
72
- "allowedTools": null,
73
- "vendor": null
74
- },
75
45
  {
76
46
  "name": "idea-refinement",
77
47
  "tier": "core",
@@ -82,16 +52,6 @@
82
52
  "allowedTools": null,
83
53
  "vendor": null
84
54
  },
85
- {
86
- "name": "qa-coverage-mapping",
87
- "tier": "core",
88
- "category": "core",
89
- "path": ".agents/skills/core/qa-coverage-mapping/SKILL.md",
90
- "description": "Map a quality finding to a per-tier coverage verdict (unit / contract / acceptance) aligned to `.agents/rules/testing-standards.md`. Use when a finding points at a symbol or surface and you need to know which test tiers already cover it and which are missing, so remediation lands the right tier. Delegates the verdict to the deterministic `lib/qa/coverage-verdict.js#coverageVerdict` helper.",
91
- "policyCapsuleBullets": 7,
92
- "allowedTools": ["Read", "Bash"],
93
- "vendor": null
94
- },
95
55
  {
96
56
  "name": "scope-triage",
97
57
  "tier": "core",
@@ -107,7 +67,7 @@
107
67
  "tier": "core",
108
68
  "category": "core",
109
69
  "path": ".agents/skills/core/security-and-hardening/SKILL.md",
110
- "description": "Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. The non-negotiable security MUSTs live in `.agents/rules/security-baseline.md`; this skill shows how to apply them with process guidance, an audit-triage tree, and a review checklist.",
70
+ "description": "Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. The non-negotiable security MUSTs live in `.agents/rules/security-baseline.md`; this skill shows how to apply them, with the project's surfacing and validation-response process.",
111
71
  "policyCapsuleBullets": 6,
112
72
  "allowedTools": null,
113
73
  "vendor": null
@@ -128,7 +88,7 @@
128
88
  "category": "qa",
129
89
  "path": ".agents/skills/stack/qa/playwright-bdd/SKILL.md",
130
90
  "description": "Wires Gherkin `.feature` files to Playwright via the `playwright-bdd` library. Use when running BDD scenarios on a Playwright runtime — pairs with the `gherkin-authoring` skill (scenario prose) and the `playwright` skill (browser conventions). Drives execution by tag expression with trace-first debugging and Playwright-native sharding.",
131
- "policyCapsuleBullets": 8,
91
+ "policyCapsuleBullets": 9,
132
92
  "allowedTools": null,
133
93
  "vendor": "playwright"
134
94
  },
@@ -142,35 +102,15 @@
142
102
  "allowedTools": null,
143
103
  "vendor": "playwright"
144
104
  },
145
- {
146
- "name": "qa-explore-driving",
147
- "tier": "stack",
148
- "category": "qa",
149
- "path": ".agents/skills/stack/qa/qa-explore-driving/SKILL.md",
150
- "description": "Conventions for agent-driven exploratory QA driving — how the agent itself drives a surface during `/qa-explore` (agent-led), as opposed to the human-led `/qa-assist`. Use when the agent explores a running app via the browser MCP (navigation-first, the default) — including authenticated deployed surfaces reached through the resolved environment's sign-in seam — or walks a static surface (the documented interim where no seam resolves), under a strictly read-only capture invariant. The exploration procedure lives in `.agents/workflows/qa-explore.md`; this skill is the driving-conventions reference it leans on.",
151
- "policyCapsuleBullets": 9,
152
- "allowedTools": null,
153
- "vendor": null
154
- },
155
105
  {
156
106
  "name": "qa-harness",
157
107
  "tier": "stack",
158
108
  "category": "qa",
159
109
  "path": ".agents/skills/stack/qa/qa-harness/SKILL.md",
160
- "description": "Conventions for the agent-driven QA harness that drives Gherkin scenarios through a real browser. Use when executing `/qa-run` or instrumenting a live surface — covers navigation-first execution, per-surface console and network capture, design-token visual checks, and the framework-generic heuristic cards for turning signal into findings. The harness procedure lives in `.agents/workflows/qa-run.md`; this skill is the conventions reference it leans on.",
161
- "policyCapsuleBullets": 7,
110
+ "description": "Conventions for agent-driven QA driving the one driving-conventions reference behind both `/qa-run` (the known-scenario sweep through a real browser) and `/qa-explore` (agent-led exploratory driving). Use when instrumenting a live surface — covers navigation-first execution, per-surface console and network capture, design-token visual checks, the `F#` finding shape, per-environment resolution, and static driving as the documented interim. The run procedures live in `.agents/workflows/qa-run.md` and `.agents/workflows/qa-explore.md`; this skill is the conventions reference they lean on.",
111
+ "policyCapsuleBullets": 11,
162
112
  "allowedTools": null,
163
113
  "vendor": null
164
- },
165
- {
166
- "name": "vitest",
167
- "tier": "stack",
168
- "category": "qa",
169
- "path": ".agents/skills/stack/qa/vitest/SKILL.md",
170
- "description": "Writes fast, isolated unit and integration tests with Vitest. Use when each test must run on file-save without shared state — `vi.mock()` for external deps, `vi.spyOn()` for call monitoring, AAA structure, and edge-case coverage for null/undefined/boundary inputs.",
171
- "policyCapsuleBullets": 8,
172
- "allowedTools": null,
173
- "vendor": "vitest"
174
114
  }
175
115
  ]
176
116
  }
@@ -17,7 +17,7 @@ description:
17
17
  - Never assert on HTTP status codes, SQL state, DOM selectors, URLs, or JSON payloads inside `.feature` prose — push those to contract tests.
18
18
  - Tag every Scenario or Outline with exactly one canonical `@domain-*` tag and the appropriate risk/platform tags from the gherkin-standards taxonomy.
19
19
  - Use `Background` only when every scenario in the file genuinely shares the precondition with no per-scenario variation.
20
- - Reuse existing step definitions: grep the steps tree for the verb stem before authoring a new step.
20
+ - Complete the step-reuse sequence in [`gherkin-standards.md` § Step Reuse](../../../../rules/gherkin-standards.md#step-reuse--grep-before-you-write) before authoring any scenario text; that rule is the only home for it.
21
21
  - Author one scenario per PRD acceptance criterion; for bounded matrices, use a Scenario Outline with ≤12 Examples rows.
22
22
  - Use third-person present-tense, role-qualified actors (`the billing-admin`), never first person.
23
23
 
@@ -29,16 +29,10 @@ the rule for the **what**.
29
29
 
30
30
  ## Long-form reference — read on demand
31
31
 
32
- The worked authoring material canonical Given/When/Then phrasing, the
33
- one-AC-to-one-scenario translation walkthrough, Background-vs-Given and
34
- Outline-vs-multi-scenario decisions, the step-definition library layout and
35
- reuse/deprecation workflow, and the pre-PR authoring checklist — lives in the
36
- on-demand sibling [`reference.md`](reference.md). Open a section only when the
37
- task engages it.
32
+ The step-definition library layout and the pre-PR authoring checklist live in
33
+ the on-demand sibling [`reference.md`](reference.md). Open a section only when
34
+ the task engages it.
38
35
 
39
- - [Canonical Given / When / Then Phrasing](reference.md#canonical-given--when--then-phrasing)
40
- - [Translating PRD Acceptance Criteria to Scenarios](reference.md#translating-prd-acceptance-criteria-to-scenarios)
41
- - [Background vs. Given, Outline vs. Multi-Scenario](reference.md#background-vs-given-outline-vs-multi-scenario)
42
36
  - [Step-Definition Library Structure](reference.md#step-definition-library-structure)
43
37
  - [Authoring Checklist](reference.md#authoring-checklist)
44
38
 
@@ -3,102 +3,9 @@
3
3
  **Read this when** a task engages one of the sections below and the Policy
4
4
  Capsule in [`SKILL.md`](SKILL.md) does not settle it on its own. The capsule is
5
5
  the contract; this file is the reference material behind it. The enforcement
6
- rules (tag taxonomy, forbidden patterns, Outline conventions) are owned by the
7
- SSOT rule, [`gherkin-standards.md`](../../../../rules/gherkin-standards.md).
8
-
9
- ## Canonical Given / When / Then Phrasing
10
-
11
- `.feature` prose is written for a product-minded reader, not a test harness.
12
- Each clause has exactly one job:
13
-
14
- - **Given** — a precondition that is *already true* when the scenario starts.
15
- Stative, past or present tense. No actions.
16
- - Good: `Given a signed-in account-owner with an unpaid invoice`.
17
- - Bad: `Given the user clicks the login button` (that's a When).
18
- - **When** — the single business action under test. One verb, one actor, one
19
- event. Splitting a When into multiple clauses is almost always wrong — move
20
- the extra clauses into Given.
21
- - Good: `When they issue the invoice`.
22
- - Bad: `When they log in and issue the invoice and download the PDF`.
23
- - **Then** — an observable, user-visible outcome. Assert what the *user* sees or
24
- what the *business* records, not what the system emits internally.
25
- - Good: `Then the invoice appears in the issued invoices list`.
26
- - Bad: `Then a 201 is returned` (forbidden; see
27
- [gherkin-standards § Forbidden Patterns](../../../../rules/gherkin-standards.md#forbidden-patterns)).
28
- - **And / But** — continuation clauses. They inherit the mood of the most recent
29
- Given/When/Then. Never start a scenario with And/But.
30
-
31
- Voice and tense: third-person, present tense, role-qualified noun actors
32
- (`the user`, `a billing-admin`, not "I" or "we"). One clause, one fact —
33
- comma-chained facts hide compound assertions. Numbers and identifiers go in
34
- `Examples` tables or fixtures, not inline prose.
35
-
36
- ## Translating PRD Acceptance Criteria to Scenarios
37
-
38
- PRD ACs are the raw material. The authoring move is **one AC → one scenario**
39
- unless the AC encodes a matrix (then it becomes a Scenario Outline — see below).
40
-
41
- Walkthrough — a PRD AC from a billing feature:
42
-
43
- > **AC-3:** When a billing-admin issues an invoice for a customer with a
44
- > negative balance, the system rejects the issue and shows an error naming the
45
- > outstanding amount.
46
-
47
- Translation steps:
48
-
49
- 1. **Identify the domain.** Billing → tag the scenario `@domain-billing`.
50
- 2. **Identify the actor and precondition.** "billing-admin", "customer with a
51
- negative balance" → two Givens.
52
- 3. **Identify the single action.** "issues an invoice" → one When.
53
- 4. **Identify the observable outcome.** "rejects the issue and shows an error
54
- naming the outstanding amount" → two Thens (business outcome, then
55
- user-visible detail).
56
- 5. **Pick the risk tag.** If the originating ticket was `risk::high`, add
57
- `@risk-high`.
58
-
59
- Resulting scenario:
60
-
61
- ```gherkin
62
- @domain-billing @risk-high
63
- Scenario: Issuing an invoice is rejected when the customer has a negative balance
64
- Given a signed-in billing-admin
65
- And a customer with a negative account balance
66
- When the billing-admin issues an invoice for that customer
67
- Then the issue is rejected
68
- And the rejection message names the outstanding amount
69
- ```
70
-
71
- Heuristics:
72
-
73
- - If a single AC needs more than **one When**, it is really two ACs. Split
74
- before you write.
75
- - If a Then starts with "and the database has…" or "and the API returned…", you
76
- have crossed into step-definition or contract-test territory. Rewrite it as
77
- user-visible language or move the assertion to a contract test.
78
- - If an AC says "the system logs X", that's an engineering non-functional
79
- requirement — cover it with a focused unit or integration test, not a
80
- `.feature` file.
81
-
82
- ## Background vs. Given, Outline vs. Multi-Scenario
83
-
84
- Two authoring decisions authors routinely get wrong.
85
-
86
- **Background vs. Given.** `Background` runs before **every** scenario in the
87
- file. Use it only when every scenario genuinely shares the precondition **and**
88
- it has no per-scenario variation (no `<placeholders>`, no per-scenario data).
89
- Prefer a per-scenario Given when only some scenarios need the precondition, when
90
- it varies by role/plan/fixture, or when a reader cannot understand the scenario
91
- without scrolling up. Rule of thumb: if you find yourself writing *"except in
92
- the admin scenario, where the Background step is actually…"*, delete the
93
- Background.
94
-
95
- **Scenario Outline vs. multiple Scenarios.** Use `Scenario Outline` when the
96
- **same behavior** is exercised across a **bounded matrix** (roles, plan tiers,
97
- locales) — the Givens/When/Thens are identical and only the data varies. Use
98
- multiple `Scenario` blocks when the Givens differ structurally, the When verb
99
- differs, or the Then outcomes differ in kind, not just value. Keep `Examples`
100
- tables under ~12 rows, and split them by tag when rows need different tags
101
- (e.g. `@risk-high` on admin rows only).
6
+ rules (tag taxonomy, forbidden patterns, Outline conventions, step reuse) are
7
+ owned by the SSOT rule,
8
+ [`gherkin-standards.md`](../../../../rules/gherkin-standards.md).
102
9
 
103
10
  ## Step-Definition Library Structure
104
11
 
@@ -122,22 +29,11 @@ tests/
122
29
  - Step text follows the scenario text verbatim — divergence between scenario
123
30
  prose and step text is a bug. Parameterize only over values that actually
124
31
  vary; keep implementations ≤20 lines (a longer one signals a missing helper).
125
-
126
- **Reuse before authoring** — the non-negotiable workflow is in
127
- [gherkin-standards § Step Reuse](../../../../rules/gherkin-standards.md#step-reuse--grep-before-you-write):
128
-
129
- 1. Search for the verb: `rg -n "issues? an invoice" tests/steps`.
130
- 2. If the phrase exists, **change your scenario** to use it — do not fork a
131
- near-duplicate step.
132
- 3. If a near-match exists, extend the existing step and update every call site
133
- in the same PR.
134
- 4. Only when no reasonable match exists, add a new step in the correct domain
135
- directory.
136
-
137
- **Deprecation.** When a step is superseded, move the old definition into
138
- `steps/_deprecated/` with a comment naming the replacement, migrate every call
139
- site in the same PR, and delete the `_deprecated/` entry when the migration
140
- lands. Never leave two live step definitions that mean the same thing.
32
+ - **Reuse before authoring, and deprecate cleanly.** Both are the SSOT rule's:
33
+ [gherkin-standards § Step Reuse](../../../../rules/gherkin-standards.md#step-reuse--grep-before-you-write).
34
+ A superseded definition moves into `steps/_deprecated/` with a comment naming
35
+ its replacement, every call site migrates in the same PR, and the
36
+ `_deprecated/` entry is deleted when the migration lands.
141
37
 
142
38
  ## Authoring Checklist
143
39
 
@@ -151,7 +47,7 @@ Before opening a PR that adds or edits a `.feature` file:
151
47
  - [ ] `Background` is justified (applies to every scenario in the file).
152
48
  - [ ] If a Scenario Outline is used, the matrix is bounded (≤12 rows) and the
153
49
  shape is truly identical across rows.
154
- - [ ] Every step phrase grep-matches an existing step definition **or** is
50
+ - [ ] Every step phrase matches an existing step definition **or** is
155
51
  accompanied by a new step definition in the right domain directory.
156
52
  - [ ] Reads standalone — a product reader who has never seen the codebase can
157
53
  understand the intent without opening a step file.
@@ -13,14 +13,15 @@ vendor: playwright
13
13
 
14
14
  ## Policy Capsule
15
15
 
16
- - Complete the pre-authoring grep-for-existing-steps checklist before writing any new scenario text; record the matches in your output.
16
+ - Complete the step-reuse sequence in [`gherkin-standards.md` § Step Reuse](../../../../rules/gherkin-standards.md#step-reuse--grep-before-you-write) before any scenario text is written, and report its results; that rule is the only home for it.
17
17
  - Keep `.feature` files free of Playwright API calls — scenarios describe intent, step definitions translate to browser actions.
18
- - Generate step bindings into a dedicated directory (e.g. `.features-gen/`) and add it to `.gitignore`; never commit generated specs.
19
- - Drive runs by tag expression (`--grep "@smoke and not @flaky"`), not filename globs; use the canonical `@smoke`/`@risk-high`/`@platform-*`/`@domain-*` taxonomy.
18
+ - Generate step bindings into a dedicated directory (e.g. `.features-gen/`) and add it to `.gitignore`; never commit generated specs, and point `testDir` at that directory.
19
+ - Drive runs by tag expression (`npx bddgen && npx playwright test --grep "@smoke and not @flaky"`), not filename globs; fail the run when generation matches zero scenarios.
20
20
  - Inject fixtures via `createBdd` rather than pulling singletons from module scope; reset persistent state through fixture teardown, not stray `After` hooks.
21
21
  - Reuse `storageState` for authenticated scenarios — create a logged-in user fixture instead of repeating login steps in `Background`.
22
- - Keep `trace: 'on-first-retry'` (or `'retain-on-failure'`) enabled; reproduce failures by `@scenario-id` tag, not by title.
22
+ - Keep `trace: 'on-first-retry'` (or `'retain-on-failure'`) enabled; reproduce failures by `@scenario-id` tag, not by title, and use `PWDEBUG=1` rather than `page.pause()` in step files.
23
23
  - Shard with Playwright's native `--shard=i/N`; never partition by tag expression across CI jobs.
24
+ - Use Playwright projects (not Cucumber profiles) for browser matrix fan-out, so sharding, retries, and trace config stay in one place.
24
25
 
25
26
  Guidance for running Gherkin `.feature` files against Playwright via
26
27
  `playwright-bdd`. Pairs with the `gherkin-authoring` skill (scenario prose) and
@@ -30,157 +31,31 @@ between them.
30
31
  > **Version:** consumers pick their own `playwright-bdd` version. This skill
31
32
  > documents behavioral constraints, not a pinned release.
32
33
 
33
- ## Pre-authoring checklist (mandatory)
34
-
35
- The agent MUST complete every item below AND MUST include the results in its
36
- output report BEFORE any scenario text is written. See
37
- [§ Step Reuse — Grep Before You Write](../../../../rules/gherkin-standards.md#step-reuse--grep-before-you-write)
38
- for rationale.
39
-
40
- 1. Run `rg` against the project's steps directory and list every step signature
41
- you will reuse. Format: one `Given/When/Then "…"` per line.
42
- 2. For each scenario line you plan to author, identify the matching existing
43
- step. For any line with no match, either rephrase to reuse an existing step
44
- or record it as a gap. Do NOT author new step definitions during scenario
45
- authoring.
46
- 3. State the canonical domain tag and platform tag you will apply (or note
47
- "Cross-Platform no platform tag" per `gherkin-standards.md`).
48
- 4. Confirm the AC's `data-testid`, URL, and payload hints will be stripped from
49
- scenario prose.
50
-
51
- If you cannot complete every item, stop and report — do not proceed to scenario
52
- authoring.
53
-
54
- ## 1. Core Principles
55
-
56
- - **One source of truth per scenario:** `.feature` files describe intent; step
57
- definitions translate intent into Playwright calls. Never author browser
58
- actions in `.feature` prose.
59
- - **Deterministic tag filtering:** every scenario carries enough tags that any
60
- CI shard can be selected by a tag expression without inspecting file paths.
61
- - **Fixture-per-scenario isolation:** scenarios must not share mutable state.
62
- Treat each scenario as a fresh browser context.
63
- - **Trace-first debugging:** keep the Playwright Trace Viewer workflow intact —
64
- `playwright-bdd` wraps Playwright, it does not replace its diagnostics.
65
-
66
- ## 2. Config Patterns
67
-
68
- - Generate step-definition bindings into a dedicated output directory (commonly
69
- `.features-gen/`) and add it to `.gitignore`. Do not commit generated specs.
70
- - Point `playwright.config.ts` at the generated directory via `testDir`; keep a
71
- single `defineBddConfig` block that lists `features` and `steps` paths.
72
- - Register the Cucumber HTML/JSON reporter alongside the Playwright HTML
73
- reporter so a headless CI invocation emits machine-readable evidence
74
- alongside the agent-driven `/qa-run` sweep.
75
- - Use Playwright projects (not Cucumber profiles) for browser matrix fan-out —
76
- keeps sharding, retries, and trace config in one place.
77
-
78
- ## 3. Fixture Composition
79
-
80
- - Extend Playwright's `test` via `playwright-bdd`'s `createBdd` so fixtures
81
- (auth state, API clients, seeded data) are injected into `Given`/`When`/
82
- `Then` callbacks by name, not pulled from module-level singletons.
83
- - Layer fixtures: base Playwright fixtures → domain fixtures (authenticated
84
- user, seeded tenant) → scenario-scoped helpers. Each layer depends only on the
85
- layer below.
86
- - Reset persistent state with fixture teardown, not with `After` hooks buried in
87
- step files — teardown order is then deterministic and visible in the fixture
88
- graph.
89
- - Reuse `storageState` for authenticated scenarios; create a "logged-in user"
90
- fixture rather than repeating login steps in `Background`.
91
-
92
- ## 4. Tag-Filtered Execution
93
-
94
- - Drive runs via tag expressions, not filename globs:
95
- `npx bddgen && npx playwright test --grep "@smoke and not @flaky"`.
96
- - Use the canonical tag taxonomy defined in
97
- [`.agents/rules/gherkin-standards.md`](../../../../rules/gherkin-standards.md#tag-taxonomy)
98
- (`@smoke`, `@risk-high`, `@platform-*`, `@domain-*`). Do not invent parallel
99
- tag vocabularies in the runner config; extend via `@domain-*` only.
100
- - Wire tag-filtered headless runs to a single npm script so operators never
101
- reconstruct the generate-then-run sequence by hand; the agent-driven
102
- `/qa-run` selector mirrors the same tag expressions for browser sweeps.
103
- - Fail the run if generation produces zero matching scenarios — a silent empty
104
- suite is worse than a red build.
105
-
106
- ## 5. Debug & Trace Workflow
107
-
108
- - Keep `trace: 'on-first-retry'` (or `'retain-on-failure'`) in the Playwright
109
- config. `playwright-bdd` preserves the trace attachment because each scenario
110
- maps to a Playwright test.
111
- - Reproduce a single failing scenario with `--grep "@scenario-id"` rather than
112
- the scenario title — titles change, tags are stable.
113
- - Open traces with `npx playwright show-trace` against the artifact produced
114
- under `test-results/`; the trace timeline annotates each `Given`/`When`/
115
- `Then` step, which is the primary debug affordance.
116
- - For step-definition bugs, run with `PWDEBUG=1` to drop into the inspector at
117
- the failing step — do not add `page.pause()` calls inside step files.
118
-
119
- ## 6. Sharding & CI Notes
120
-
121
- - Shard with Playwright's native `--shard=i/N`; do not partition by tag
122
- expression across jobs — tag-sharding makes flake triage non-deterministic.
123
- - Run `bddgen` once per job before `playwright test`; cache the generated
124
- directory only if the cache key includes every `.feature` and step file.
125
- - Publish the Cucumber HTML/JSON report as the evidence artifact, alongside
126
- the Playwright HTML report and any trace zips.
127
- - Quarantine `@flaky` scenarios with a dedicated job that does not gate the
128
- merge queue; do not silently retry flakes in the main suite.
129
-
130
- ## Recommended invocation template
131
-
132
- Use this template when invoking a subagent to author a `.feature` file from an
133
- Acceptance Criterion.
134
-
135
- ```text
136
- You are an AI coding agent. Your sole task is to invoke the
137
- **stack/qa/playwright-bdd** skill (defined in this repo) to author one new
138
- acceptance scenario from a single Acceptance Criterion. You receive nothing
139
- about this codebase except the AC text and the skill itself — you must
140
- discover everything else (existing step library, naming conventions, etc.)
141
- through the skill's prescribed workflow.
142
-
143
- Follow the skill's guidance precisely. Your output will be evaluated
144
- against `.agents/rules/gherkin-standards.md`.
145
-
146
- **Skill to invoke.** Read `.agents/skills/stack/qa/playwright-bdd/SKILL.md`
147
- and follow it. Also read `.agents/rules/gherkin-standards.md` (which the
148
- skill references).
149
-
150
- **The Acceptance Criterion (your sole input).** {{AC_TEXT}}
151
-
152
- **Your task.**
153
- 1. Read the skill and the gherkin rule.
154
- 2. Per the skill's "Step Reuse — Grep Before You Write" section, grep
155
- {{STEPS_DIR}} to discover the existing step vocabulary BEFORE
156
- authoring. List the matches you found.
157
- 3. Author a NEW `.feature` file at {{OUTPUT_PATH}} that covers this AC.
158
- 4. You are FORBIDDEN from editing any file under {{STEPS_DIR}}. This
159
- task tests scenario authorship and step REUSE. If a step you need does
160
- not exist, you must either rephrase the scenario to reuse what exists,
161
- or report that as a gap (do not silently invent).
162
- 5. Tag the feature/scenario per the canonical taxonomy in
163
- `gherkin-standards.md`.
164
- 6. Honor every "Forbidden Patterns" rule. `data-testid` hints in the AC
165
- parentheses are for the step-definition layer; they MUST NOT appear in
166
- your scenario text.
167
-
168
- **Report back.** Sections A–E: discovered steps, exact `.feature` content,
169
- step-coverage analysis, forbidden-patterns self-audit, uncertainty/gaps.
170
- ```
171
-
172
- This template encodes the invocation prompt used in the Epic C pilot of
173
- dsj1984/athlete-portal, where a general-purpose subagent — given only an AC and
174
- a pointer to this skill — produced a publishable scenario on the first attempt
175
- with **zero Forbidden-Patterns violations**, reused **4 of 5** needed steps from
176
- the existing library, and surfaced the single remaining step as a clean, named
177
- gap rather than inventing one. Future maintainers: resist the urge to "simplify"
178
- this template. Its explicit grep-before-author step, the hard prohibition on
179
- editing the steps directory, and the mandated gap-report section are what forced
180
- those outcomes.
181
-
182
- ## 7. Cross-References
34
+ ## Project-Specific Wiring
35
+
36
+ The capsule above is the contract. Three points bind this runtime to the rest
37
+ of the framework:
38
+
39
+ - **Tags come from one taxonomy.** Selection uses the canonical set defined in
40
+ [`.agents/rules/gherkin-standards.md` § Tag Taxonomy](../../../../rules/gherkin-standards.md#tag-taxonomy)
41
+ (`@smoke`, `@risk-high`, `@platform-*`, `@domain-*`, `@flaky`, `@skip`). Do
42
+ not invent parallel tag vocabularies in the runner config; extend via
43
+ `@domain-*` only. The agent-driven `/qa-run` selector mirrors the same tag
44
+ expressions, so a scenario set is addressable identically from both surfaces.
45
+ - **`@flaky` runs in its own non-gating job.** Quarantine `@flaky` scenarios in
46
+ a dedicated CI job that does not gate the merge queue, and never silently
47
+ retry flakes inside the gating suite. `@flaky` is a debt marker with an owner,
48
+ not a permanent label.
49
+ - **The Cucumber JSON report is the headless evidence artifact.** Register the
50
+ Cucumber HTML/JSON reporter alongside the Playwright HTML reporter and publish
51
+ it (with the trace zips) so a headless CI invocation emits machine-readable
52
+ evidence next to the agent-driven [`/qa-run`](../../../../workflows/qa-run.md)
53
+ sweep. Wire the generate-then-run sequence to a single npm script so operators
54
+ never reconstruct it by hand.
55
+
56
+ ## Cross-References
183
57
 
184
58
  - Scenario authoring rules: `.agents/rules/gherkin-standards.md`.
59
+ - Scenario authoring skill: `.agents/skills/stack/qa/gherkin-authoring/SKILL.md`.
185
60
  - Browser-level conventions: `.agents/skills/stack/qa/playwright/SKILL.md`.
186
61
  - Operator entry point: `.agents/workflows/qa-run.md`.