levi-gear 0.6.0 → 0.7.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: levi-create-feature
3
- description: Build a new feature end to end, spec first and test first. Finds or writes the spec (confirmed with the user), the brainstorming plan and, for UI work, the designs; then the developer writes unit and feature tests and QA writes test cases (Markdown and Excel), both from the spec and reviewed against it; the tests are locked, only QA may change its test cases, and the developer writes the code until every test passes, the teamlead approves the code review, and then QA passes every scenario end to end in a headless browser. Tests and test cases are never changed to make them pass. On Claude Code the implementation runs as a Workflow of independent subagents. Fits requests such as "build feature X", "implement X", "add X to the app", "triển khai tính năng X", "thêm tính năng X".
3
+ description: Build a new feature end to end, spec first and test first. Finds or writes the spec (confirmed with the user), the brainstorming plan and, for UI work, the designs; then the developer writes unit and feature tests and QA writes test cases (Markdown and Excel), both from the spec and reviewed against it; the tests are locked, only QA may change its test cases, and the developer writes the code until every test passes, the teamlead approves the code review, and, when the user opts in, QA then passes every scenario end to end in a headless browser (browser tests are slow, so the user is asked once at the start, the recommended answer is to skip them, and the test cases are written to be run later). Tests and test cases are never changed to make them pass. On Claude Code the implementation runs as a Workflow of independent subagents. Fits requests such as "build feature X", "implement X", "add X to the app", "triển khai tính năng X", "thêm tính năng X".
4
4
  argument-hint: "<the feature to build, and the spec if you have one>"
5
5
  requires: spec-writing, brainstorming, design, code-review, generate-test-scenarios
6
6
  ---
@@ -12,7 +12,7 @@ Build a feature the spec-driven way: **the spec decides, the tests and scenarios
12
12
  The work has two halves:
13
13
 
14
14
  - **Prepare** (steps 1 to 5), here in the conversation, because it needs the user: the spec, the brainstorming plan and the designs. It reuses the `spec-writing`, `brainstorming` and `design` usecases.
15
- - **Implement** (step 6), without the user: tests, scenarios, code, end-to-end runs and code review. Every agent call is a fresh, independent subagent that sees only the files it is given, never the conversation or another agent's reasoning. Claude Code runs `workflow.js`.
15
+ - **Implement** (step 6), without the user: tests, scenarios, code, code review and, only when the user chose them, end-to-end runs in a browser. Every agent call is a fresh, independent subagent that sees only the files it is given, never the conversation or another agent's reasoning. Claude Code runs `workflow.js`.
16
16
 
17
17
  ## The rules that never bend
18
18
 
@@ -29,7 +29,7 @@ The work has two halves:
29
29
  | `docs/brainstorming/<plan>.md` | PM | The brainstorming plan |
30
30
  | `docs/designs/<design>/` | Designer | The designs, for UI work |
31
31
  | Unit and feature tests, in the framework's folders | Developer | **Deliverable.** Locked once reviewed |
32
- | `docs/tests/<base>.md`, `docs/tests/<base>.xlsx` | QA | **Deliverable.** The test cases with their PASS or FAIL result, in the format of `generate-test-scenarios`. Only QA changes them |
32
+ | `docs/tests/<base>.md`, `docs/tests/<base>.xlsx` | QA | **Deliverable.** The test cases with the PASS or FAIL result of each case that was run, in the format of `generate-test-scenarios`. Only QA changes them |
33
33
  | Application code, migrations | Developer, Teamlead | **Deliverable.** The feature |
34
34
  | `docs/levi/<slug>/tasks.md` | Teamlead | Scratch: execution plan and the interfaces tests and code share. Deleted at the end |
35
35
  | `docs/levi/<slug>/review.md` | Teamlead | Scratch: code review findings. Deleted at the end |
@@ -42,7 +42,7 @@ The work has two halves:
42
42
 
43
43
  1. **Intake.** The request is the feature. If it is empty, ask what to build and stop. Derive the slug. Note any spec the user attached or pointed to (a path, a link, "the spec in ...").
44
44
 
45
- **Opening round.** Before any flow starts, list the candidates for the spec (`docs/specs/`), the plan (`docs/brainstorming/`) and, when the feature has a user interface, the designs (`docs/designs/`), and ask every confirmation below in one round together with anything else unclear in the request, as the run rules say. Steps 2 to 4 then use these answers instead of asking one at a time. The flows they run ask only what they cannot know before they start (the PM's open questions about the spec); after this and those rounds the run goes on alone.
45
+ **Opening round.** Before any flow starts, list the candidates for the spec (`docs/specs/`), the plan (`docs/brainstorming/`) and, when the feature has a user interface, the designs (`docs/designs/`), and ask every confirmation below in one round together with anything else unclear in the request, as the run rules say. **Always add the browser-tests question** ("Browser tests are optional, asked once" in the run rules below): it goes in this round even when nothing else needs asking. Steps 2 to 4 then use these answers instead of asking one at a time. The flows they run ask only what they cannot know before they start (the PM's open questions about the spec); after this and those rounds the run goes on alone.
46
46
  2. **Spec.**
47
47
  - *The user gave one:* use it.
48
48
  - *Otherwise:* list `docs/specs/` and match files against the feature by name, title and goal. When one or more look like the spec for this feature, ask the user to confirm (in the opening round), in one question: each candidate (path and title) as an option, the most likely first, plus "None of these: write a new spec". Never use a candidate the user did not confirm.
@@ -50,7 +50,7 @@ The work has two halves:
50
50
  - **The spec must be Ready.** If its Status is Draft, its open questions would have to be guessed, so do not implement yet. Ask the user to settle them, and run the `spec-writing` flow in update mode with the answers. If the user prefers to leave a point out, that is an answer too: the PM moves it to Out of scope. Continue only when the Status is Ready.
51
51
  3. **Brainstorming plan.** List `docs/brainstorming/` and match plans against the feature and the spec. One clear match: use it, and say which in one line. Two or more equally plausible: ask the user which one (or "none") in the opening round. None: run the `brainstorming` flow, with the feature and the spec, and use the plan it writes.
52
52
  4. **Designs.** Decide from the spec whether the feature has a user interface (screens, pages, forms, components, visible states). If it has none, skip this step. If it has, list `docs/designs/` and match folders against the feature: one clear match is used; two or more plausible ones, ask the user in the opening round; none: run the `design` flow with the feature as subject and the spec as context, and use the folder it writes.
53
- 5. **Get ready.** Delete `docs/levi/<slug>/locked/` and `qa-snapshot/` if an earlier run left them. Work out the feature ID and the output base `<base>` of the test cases from the spec, as the "Features, IDs and file names" table of `levi-generate-test-scenarios/SKILL.md` says. Say in a few lines what will be used (spec, plan, designs) and that implementation starts now.
53
+ 5. **Get ready.** Delete `docs/levi/<slug>/locked/` and `qa-snapshot/` if an earlier run left them. Work out the feature ID and the output base `<base>` of the test cases from the spec, as the "Features, IDs and file names" table of `levi-generate-test-scenarios/SKILL.md` says. Write the browser-tests answer to `docs/levi/<slug>/choices/user-browser-tests.md`, as the run rules say. Say in a few lines what will be used (spec, plan, designs), whether browser tests will run, and that implementation starts now.
54
54
  6. **Implement.**
55
55
  - *With a Workflow tool (Claude Code):* call it with `scriptPath` set to `workflow.js` in this skill's folder, and `args`:
56
56
 
@@ -63,34 +63,39 @@ The work has two halves:
63
63
  "designs": "docs/designs/<design>/ (omit when there is no UI)",
64
64
  "featureId": "<the feature ID>",
65
65
  "testBase": "docs/tests/<base>",
66
+ "browserTests": <true or false>,
67
+ "browserScope": "<the user's words, only when they limited which cases to run>",
66
68
  "skillDir": "<this skill's folder, relative to the project root>"
67
69
  }
68
70
  ```
69
71
 
72
+ `browserTests` is the user's answer to the opening question: `false` when they chose not to run browser tests (also the value when the answer is missing). Omit `browserScope` unless the user limited the run.
73
+
70
74
  The script runs the steps under [Implementation](#implementation) below and returns a result with a `status`. Follow its progress with the user only when they ask.
71
75
  - *Without a Workflow tool:* run the steps under [Implementation](#implementation) yourself, in order, each agent call as a new subagent call that gets only the paths and instructions written there.
72
76
  7. **Act on the result.**
73
- - `done`: go to step 8.
77
+ - `done`: go to step 8. When `browserTests` was off, the result lists the test cases that were not run (`notRun`).
74
78
  - `spec_questions`: the spec is silent or unclear on a point the tests depend on. Ask the user the questions in one round, run the `spec-writing` flow in update mode with the answers, then run step 6 again from the start.
75
79
  - `blocked`: something outside the code stops the work (the app cannot start, a service or a credential is missing, an agent could not finish). Tell the user the stage and the detail, and what they need to provide. Keep `docs/levi/<slug>/`. Run step 6 again when they say to.
76
80
  - `stalled`: the build rounds ran out (10 by default) and something still fails. Tell the user what failed last. Continue in the same session with `resumeFromRunId` and a higher `maxRounds`. Tests and test cases still do not change.
77
81
  8. **Clean up.** Delete `docs/levi/<slug>/` (`tasks.md`, `review.md`, `locked/`), then `docs/levi` if it is empty. Keep everything else: spec, plan, designs, tests, test cases with their results, code.
78
- 9. **Report.** Tell the user: the spec, plan and designs used (and which were created in this run); the test files and the command that runs them; the test case files with their result (for example `12/12 PASS`); how many build rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed.
82
+ 9. **Report.** Tell the user: the spec, plan and designs used (and which were created in this run); the test files and the command that runs them; the test case files with their result (for example `12/12 PASS`); how many build rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed. When browser tests did not run (all or part), add the line "Browser tests: not run (the user chose this)", or the partly-run variant, and list every test case that was not run with its ID and title (read the titles from the test case file).
79
83
 
80
84
  ## Implementation
81
85
 
82
- The steps the Workflow runs, and the ones you run when there is no Workflow tool. Every call names its agent; give it the paths of the spec, the plan, the designs and `docs/levi/<slug>/`. When a call returns questions that only the user can answer about the spec, stop with `spec_questions`. When a call is BLOCKED, stop with `blocked`.
86
+ The steps the Workflow runs, and the ones you run when there is no Workflow tool. Every call names its agent, with the model and effort where this section says so; give it the paths of the spec, the plan, the designs and `docs/levi/<slug>/`. When a call returns questions that only the user can answer about the spec, stop with `spec_questions`. When a call is BLOCKED, stop with `blocked`.
83
87
 
84
88
  1. **Baseline.** Record `git rev-parse HEAD` and the files `git status --porcelain` lists, so the review later sees only this run's changes.
85
- 2. **Plan** — `levi-teamlead`. Reads the spec, the plan, the designs and the project. Writes `docs/levi/<slug>/tasks.md`: the interfaces tests and code share (exact names of modules, functions, endpoints, routes, components, data shapes), the test framework and where tests go, and the development tasks from the brainstorming plan with their owners. Returns: every acceptance criterion ID; test groups (each with its criteria and folder) covering every criterion; implementation batches in dependency order, where tasks of one batch do not touch the same files; any test setup the project needs; the command for the new tests and the one for the whole suite; how to start the app for E2E. A criterion left out of every test group goes back to the teamlead.
89
+ 2. **Plan** — `levi-teamlead`. Reads the spec, the plan, the designs and the project. Writes `docs/levi/<slug>/tasks.md`: the interfaces tests and code share (exact names of modules, functions, endpoints, routes, components, data shapes), the test framework and where tests go, and the development tasks from the brainstorming plan with their owners. Returns: every acceptance criterion ID; test groups (each with its criteria and folder) covering every criterion; implementation batches in dependency order, where tasks of one batch do not touch the same files; any test setup the project needs; the command for the new tests and the one for the whole suite (both leave out the tests that open a browser, unless browser tests are on); how to start the app for E2E (only when browser tests are on). A criterion left out of every test group goes back to the teamlead.
86
90
  3. **Test setup** — `levi-developer`, only when the plan says the project cannot run tests yet.
87
91
  4. **Tests and scenarios**, two tracks at the same time:
88
- - *Developer track.* One `levi-developer` call per test group, in parallel, writes unit and feature tests for its criteria, from the spec alone, against the interfaces in `tasks.md`, each test naming the criterion it covers. Then, until approved (at most 5 reviews): run the new tests (they are expected to fail, the feature does not exist yet), and a fresh `levi-teamlead` call reviews the tests against the spec: every criterion covered, every assertion from the spec and nothing beyond it, each test able to fail, one command that runs them. It does not edit them; a `levi-developer` call fixes what it found.
89
- - *QA track.* `levi-qa` writes the test cases from the spec and the designs, without reading code or tests, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the feature ID, the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/<base>`. Every acceptance criterion is in the refs of at least one case, and every ambiguity it finds comes back as a question. Then, until approved (at most 5 reviews): a fresh `levi-pm` call reviews the test cases against the spec (coverage, exact expected results, nothing invented, runnable from the file alone); `levi-qa` fixes what it found.
92
+ - *Developer track.* One `levi-developer` call per test group, in parallel, writes unit and feature tests for its criteria (none that opens a browser, unless browser tests are on), from the spec alone, against the interfaces in `tasks.md`, each test naming the criterion it covers. Then, until approved (at most 5 reviews): run the new tests (they are expected to fail, the feature does not exist yet), and a fresh `levi-teamlead` call reviews the tests against the spec: every criterion covered, every assertion from the spec and nothing beyond it, each test able to fail, one command that runs them. It does not edit them; a `levi-developer` call fixes what it found.
93
+ - *QA track.* `levi-qa`, called with model `opus` and effort `high`, writes the test cases from the spec and the designs, without reading code or tests, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the feature ID, the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/<base>`. Every acceptance criterion is in the refs of at least one case, and every ambiguity it finds comes back as a question. Then, until approved (at most 5 reviews): a fresh `levi-pm` call reviews the test cases against the spec (coverage, exact expected results, nothing invented, runnable from the file alone); `levi-qa`, again with model `opus` and effort `high`, fixes what it found.
90
94
  5. **Lock.** `node <skill folder>/scripts/lock-tests.mjs lock docs/levi/<slug>/locked <every test file>`, and the same with `docs/levi/<slug>/qa-snapshot docs/tests/<base>.md docs/tests/<base>.xlsx` for the test cases.
91
- 6. **Build**, in rounds (at most 10 unless raised), until the teamlead approves and every scenario passes:
95
+ 6. **Build**, in rounds (at most 10 unless raised), until the teamlead approves and, when browser tests are on, every scenario passes:
92
96
  1. *Code.* First round: each batch in order, the tasks of a batch in parallel, each by its owner (`levi-developer`, or `levi-teamlead` for schema, migrations and CI/CD). Later rounds: the owners fix exactly what the last round found.
93
- 2. *Gate.* Run `lock-tests.mjs verify docs/levi/<slug>/locked` (it restores any locked file that was changed), then the new tests, then the whole suite. Any restored file, failing test or regression sends the round back to the developer with the failures.
97
+ 2. *Gate.* Run `lock-tests.mjs verify docs/levi/<slug>/locked` (it restores any locked file that was changed), then the new tests, then the whole suite (without the tests that open a browser, unless browser tests are on). Any restored file, failing test or regression sends the round back to the developer with the failures.
94
98
  3. *Review* — once the tests pass, a fresh `levi-teamlead` call reviews the change since the baseline against the spec, `tasks.md` and the designs (correctness, security, performance, fit), following `levi-code-review/references/review-guide.md` and its checklists, writes `review.md` and approves only when no critical or warning finding is left. A change of more than 100 reviewable files is not read by one teamlead: it is split into slices of at most 100 files, reviewed by several fresh `levi-teamlead` calls at the same time, and a lead `levi-teamlead` call merges their reports into the one `review.md`, as `levi-code-review/references/large-changes.md` says. Findings go back to their owners, and the round starts again.
95
- 4. *E2E* — only after the review approves. First `lock-tests.mjs verify docs/levi/<slug>/qa-snapshot`, which undoes any change to the test cases made outside QA. Then `levi-qa` starts the app, runs every case in a headless browser (the project's E2E runner such as Playwright, or a browser tool; through the API or CLI when there is no UI), records PASS or FAIL and the evidence as its test case guide says, and stops the app; the snapshot is then taken again. Any case that is not PASS goes back to the developer with the evidence, and the next round runs code, gate, review and E2E again.
96
- 5. The run is done when the review approves and every case passes.
99
+ 4. *E2E* — only when browser tests are on, and only after the review approves. First `lock-tests.mjs verify docs/levi/<slug>/qa-snapshot`, which undoes any change to the test cases made outside QA. Then `levi-qa` starts the app, runs every case in a headless browser (the project's E2E runner such as Playwright, or a browser tool; through the API or CLI when there is no UI), records PASS or FAIL and the evidence as its test case guide says, and stops the app; the snapshot is then taken again. `levi-qa` keeps its default model and effort here. Any case that is not PASS goes back to the developer with the evidence, and the next round runs code, gate, review and E2E again. When the user limited the run, only the cases they chose are run; the others are reported as not run and do not count against the result.
100
+ *Browser tests off:* skip this step. Once the review approves, run `lock-tests.mjs verify docs/levi/<slug>/qa-snapshot` once more, so that the test cases stay as QA wrote them, and the run is done.
101
+ 5. The run is done when the review approves and, when browser tests are on, every case passes.
@@ -1,16 +1,16 @@
1
1
  export const meta = {
2
2
  name: 'levi-create-feature',
3
- description: 'Implement a feature test-first: tests and QA scenarios from the spec, reviewed and locked, then code until every test passes, the teamlead approves the review and every E2E scenario passes',
3
+ description: 'Implement a feature test-first: tests and QA scenarios from the spec, reviewed and locked, then code until every test passes and the teamlead approves the review; when browser tests are on, until every E2E scenario passes too',
4
4
  whenToUse: 'Started by the levi-create-feature skill once the spec, the brainstorming plan and the designs are ready',
5
5
  phases: [
6
6
  { title: 'Plan', detail: 'the teamlead turns the brainstorming plan into an execution plan' },
7
7
  { title: 'Tests', detail: 'developer tests and QA scenarios, written apart and reviewed against the spec' },
8
8
  { title: 'Lock', detail: 'snapshot and hash the tests, and snapshot the test cases as QA wrote them' },
9
- { title: 'Build', detail: 'implement, run the tests, review, then E2E; repeat until the review approves and every scenario passes' },
9
+ { title: 'Build', detail: 'implement, run the tests, review, then E2E when browser tests are on; repeat until the review approves and, with browser tests on, every scenario passes' },
10
10
  ],
11
11
  }
12
12
 
13
- // args: { slug, feature, spec, plan, designs?, featureId?, testBase?, skillDir, maxRounds? } — see the skill's SKILL.md.
13
+ // args: { slug, feature, spec, plan, designs?, featureId?, testBase?, browserTests?, browserScope?, skillDir, maxRounds? } — see the skill's SKILL.md.
14
14
  const A = args || {}
15
15
  const absent = ['slug', 'feature', 'spec', 'plan', 'skillDir'].filter((k) => !A[k])
16
16
  if (absent.length) return { status: 'error', message: `missing args: ${absent.join(', ')}` }
@@ -32,6 +32,14 @@ const LOCK = `node ${A.skillDir}/scripts/lock-tests.mjs`
32
32
  const REVIEW_GUIDE = `${A.skillDir}/../levi-code-review/references/review-guide.md`
33
33
  const MAX_TEST_REVIEWS = 5
34
34
  const MAX_BUILD_ROUNDS = A.maxRounds || 10
35
+ // Browser tests (the E2E run) are slow and optional: the user chooses at the start, and a missing value means no.
36
+ const BROWSER = A.browserTests === true
37
+ const BROWSER_SCOPE = BROWSER && A.browserScope ? String(A.browserScope) : ''
38
+ // QA writes and changes test cases with the strongest setting; running them keeps the agent's default.
39
+ const QA_WRITE = { model: 'opus', effort: 'high' }
40
+
41
+ // With browser tests off, nothing in the run may open a browser: not the new tests, and not the suite the gate runs.
42
+ const NO_BROWSER = BROWSER ? '' : '\n\nBrowser tests are off for this run: write or rely on no test that opens a browser (an E2E runner, Playwright, a browser project of Vitest), and make every test command you return (testCommand and suiteCommand) leave out the tests that do.'
35
43
 
36
44
  const CONTEXT = [
37
45
  `Feature: ${A.feature}`,
@@ -103,6 +111,7 @@ const E2E = obj({
103
111
  status: STATUS,
104
112
  summary: { type: 'string' },
105
113
  results: { type: 'array', items: obj({ id: { type: 'string' }, result: { type: 'string', enum: ['PASS', 'FAIL'] }, evidence: { type: 'string' } }) },
114
+ skipped: { ...STRINGS, description: 'IDs of the cases left out on purpose because of the scope the user set. Empty when no scope was set' },
106
115
  })
107
116
  const IMPL = obj({ status: STATUS, summary: { type: 'string' }, files: STRINGS, blockers: STRINGS })
108
117
  const CODE_REVIEW = obj({
@@ -162,8 +171,8 @@ You are starting the implementation of this feature. Read the spec, the brainsto
162
171
  - criteria: every acceptance criterion ID in the spec.
163
172
  - testGroups: split the unit and feature tests into groups that can be written in parallel, each with the criteria it covers and the folder where the project's framework expects those tests. Every criterion belongs to at least one group.
164
173
  - batches: the implementation tasks in dependency order. Tasks in one batch run in parallel in the same working tree, so they must not touch the same files.
165
- - testSetup when the project cannot run unit and feature tests yet (pick the framework that fits the stack), testCommand, suiteCommand, and how to start the app for end-to-end tests (app.start, app.url, app.notes, including seed data or env it needs).
166
- Ask in questions only what the spec cannot answer.`,
174
+ - testSetup when the project cannot run unit and feature tests yet (pick the framework that fits the stack), testCommand, suiteCommand, and how to start the app for end-to-end tests (app.start, app.url, app.notes, including seed data or env it needs).${BROWSER ? '' : ' Browser tests will not run, so leave app.start, app.url and app.notes empty.'}
175
+ Ask in questions only what the spec cannot answer.${NO_BROWSER}`,
167
176
  { label: 'teamlead:plan', agentType: 'levi-teamlead', schema: PLAN },
168
177
  )
169
178
  for (let i = 0; plan && i < 2; i++) {
@@ -172,7 +181,7 @@ for (let i = 0; plan && i < 2; i++) {
172
181
  if (!uncovered.length) break
173
182
  log(`criteria with no test group: ${uncovered.join(', ')}; asking the teamlead to fix the plan`)
174
183
  plan = await agent(
175
- `${CONTEXT}\n\nYour execution plan in ${TASKS} leaves these acceptance criteria out of every test group: ${uncovered.join(', ')}. Put each into a test group, update ${TASKS}, and return the whole corrected plan.`,
184
+ `${CONTEXT}\n\nYour execution plan in ${TASKS} leaves these acceptance criteria out of every test group: ${uncovered.join(', ')}. Put each into a test group, update ${TASKS}, and return the whole corrected plan.${NO_BROWSER}`,
176
185
  { label: 'teamlead:plan-fix', agentType: 'levi-teamlead', schema: PLAN },
177
186
  )
178
187
  }
@@ -203,7 +212,7 @@ Write the unit tests and feature tests of test group ${g.id} (${g.area}). They c
203
212
  - Every criterion of the group has at least one test, and each test names the criterion it covers (for example "AC-3: ...").
204
213
  - The feature is not built yet, so these tests are expected to fail now. Do not write application code, stubs or fakes of the feature.
205
214
  - Work from the spec alone: do not read ${SCENARIOS} or the tests of other groups. If files from an earlier run exist, bring them in line with the spec.
206
- - After this step the tests are locked: the code will have to pass them and nobody may change them. Get them right now.
215
+ - After this step the tests are locked: the code will have to pass them and nobody may change them. Get them right now.${NO_BROWSER}
207
216
 
208
217
  Return every test file you created or changed (helpers and fixtures included).`,
209
218
  { label: `developer:tests-${g.id}`, phase: 'Tests', agentType: 'levi-developer', schema: WRITTEN },
@@ -231,7 +240,7 @@ Check that:
231
240
  - each test can fail on a real bug; a test that already passes without the feature needs a real reason;
232
241
  - they use the project's framework and the interfaces in ${TASKS}, and one command runs exactly these tests (return it as testCommand).
233
242
 
234
- The tests belong to the developer: do not edit them. Approve only when nothing is left to change.`,
243
+ The tests belong to the developer: do not edit them. Approve only when nothing is left to change.${NO_BROWSER}`,
235
244
  { label: `teamlead:review-tests-${i}`, phase: 'Tests', agentType: 'levi-teamlead', schema: SPEC_REVIEW },
236
245
  )
237
246
  if (!review) return { stop: 'blocked', detail: 'the test review did not complete' }
@@ -240,7 +249,7 @@ The tests belong to the developer: do not edit them. Approve only when nothing i
240
249
  if (questions.length) return { stop: 'spec_questions', questions }
241
250
  if (review.approved) return { files, testCommand }
242
251
  const fixed = await agent(
243
- `${CONTEXT}\n\nThe review of your unit and feature tests against the spec found these problems. Fix each one in the tests, and only these:\n${JSON.stringify(review.issues, null, 2)}\nThe spec decides. Do not write application code. Return every test file of the feature (${files.join(', ')}, plus any you add).`,
252
+ `${CONTEXT}\n\nThe review of your unit and feature tests against the spec found these problems. Fix each one in the tests, and only these:\n${JSON.stringify(review.issues, null, 2)}\nThe spec decides. Do not write application code. Return every test file of the feature (${files.join(', ')}, plus any you add).${NO_BROWSER}`,
244
253
  { label: `developer:fix-tests-${i}`, phase: 'Tests', agentType: 'levi-developer', schema: WRITTEN },
245
254
  )
246
255
  if (fixed) fixed.files.forEach((f) => files.includes(f) || files.push(f))
@@ -261,12 +270,12 @@ Output base: ${TEST_BASE}. If its files exist from an earlier run, they are your
261
270
 
262
271
  On top of the guide:
263
272
  - Every acceptance criterion in ${plan.criteria.join(', ')} is in the refs of at least one case.
264
- - Each case can be run end to end ${plan.hasUi ? 'in a browser' : 'through the API or the CLI'} by someone who has only the rendered file and the running app (${plan.app.url}).
273
+ - Each case can be run end to end ${plan.hasUi ? 'in a browser' : 'through the API or the CLI'} by someone who has only the rendered file and the running app${BROWSER ? ` (${plan.app.url})` : ''}.
265
274
  - Do not record results: they are recorded when the cases are run, after the code is built.
266
275
  - The spec is Ready, so it should settle everything a case needs. Put every ambiguity you find into questions as well.
267
276
 
268
277
  Return the number of cases as scenarioCount.`,
269
- { label: 'qa:scenarios', phase: 'Tests', agentType: 'levi-qa', schema: WRITTEN },
278
+ { label: 'qa:scenarios', phase: 'Tests', agentType: 'levi-qa', schema: WRITTEN, ...QA_WRITE },
270
279
  )
271
280
  if (!written || written.status === 'BLOCKED') return { stop: 'blocked', detail: written ? written.summary : 'QA did not write the scenarios' }
272
281
  let questions = questionsOf(written)
@@ -291,7 +300,7 @@ The file belongs to QA: do not edit it. Approve only when nothing is left to cha
291
300
  written =
292
301
  (await agent(
293
302
  `${CONTEXT}\n\nThe review of ${SCENARIOS} against the spec found these problems. Fix each one, and only these, as your test case guide (${TEST_GUIDE}, "Changing test cases") says, with the cases file ${CASES} and the output base ${TEST_BASE}:\n${JSON.stringify(review.issues, null, 2)}\nThe spec decides. Return the number of cases as scenarioCount.`,
294
- { label: `qa:fix-scenarios-${i}`, phase: 'Tests', agentType: 'levi-qa', schema: WRITTEN },
303
+ { label: `qa:fix-scenarios-${i}`, phase: 'Tests', agentType: 'levi-qa', schema: WRITTEN, ...QA_WRITE },
295
304
  )) || written
296
305
  }
297
306
  return { stop: 'blocked', detail: `the scenarios were not approved after ${MAX_TEST_REVIEWS} reviews` }
@@ -314,6 +323,7 @@ if (!locked || locked.exitCode !== 0) return { status: 'blocked', stage: 'lock',
314
323
  const snapped = await snapshotScenarios()
315
324
  if (!snapped || snapped.exitCode !== 0) return { status: 'blocked', stage: 'lock', detail: snapped ? snapped.summary : 'the test cases could not be snapshotted' }
316
325
  log(`locked ${tests.files.length} test file(s); ${scenarios.scenarioCount} test case(s) kept as QA wrote them`)
326
+ const CASE_IDS = Array.from({ length: scenarios.scenarioCount }, (_, i) => `TC-${FEATURE_ID}-${String(i + 1).padStart(3, '0')}`)
317
327
 
318
328
  const REVIEW_PHASE = 'Build'
319
329
  // ---- review of the change: one teamlead, or slices merged by a lead when the change is large ----
@@ -410,7 +420,7 @@ ${output}`,
410
420
  )
411
421
  }
412
422
 
413
- // ---- 4. Build: implement, tests, review, then E2E, until the review approves and every scenario passes ----
423
+ // ---- 4. Build: implement, tests, review, then E2E when browser tests are on, until the review approves and every scenario passes ----
414
424
 
415
425
  const RULES = LOCKED_RULES(tests.files)
416
426
 
@@ -458,7 +468,11 @@ async function e2e(note) {
458
468
  return agent(
459
469
  `${CONTEXT}
460
470
 
461
- The code was approved in review. Run every test case in ${SCENARIOS} (there are ${scenarios.scenarioCount}) against the running app and record the results, following your test case guide, ${TEST_GUIDE} ("Recording results"), with the cases file ${CASES} and the output base ${TEST_BASE}. Run them ${
471
+ The code was approved in review. Run ${
472
+ BROWSER_SCOPE
473
+ ? `only the test cases in ${SCENARIOS} that the user chose with these words: "${BROWSER_SCOPE}". List the IDs of the others in skipped and do not run them`
474
+ : `every test case in ${SCENARIOS} (there are ${scenarios.scenarioCount})`
475
+ } against the running app and record the results, following your test case guide, ${TEST_GUIDE} ("Recording results"), with the cases file ${CASES} and the output base ${TEST_BASE}. Run them ${
462
476
  plan.hasUi
463
477
  ? "in a headless browser: the project's E2E runner (such as Playwright) or a browser tool you have"
464
478
  : 'through its API or CLI'
@@ -468,6 +482,20 @@ Change no application code. Return the result of every case, by its ID.${note ?
468
482
  )
469
483
  }
470
484
 
485
+ // The result of a finished run. `notRun` lists the test cases that were not run in a browser.
486
+ const finish = (rounds, review, notRun) => ({
487
+ status: 'done',
488
+ rounds,
489
+ tests: tests.files,
490
+ testCommand: tests.testCommand,
491
+ scenarios: { files: SCENARIO_FILES, count: scenarios.scenarioCount },
492
+ browserTests: BROWSER,
493
+ browserScope: BROWSER_SCOPE || undefined,
494
+ notRun,
495
+ review: review.summary,
496
+ suggestions: review.findings.filter((f) => f.severity === 'suggestion'),
497
+ })
498
+
471
499
  phase('Build')
472
500
  let pending = null
473
501
  let last = null
@@ -500,27 +528,19 @@ Check the change against the spec, ${TASKS} and the designs: correctness, securi
500
528
  continue
501
529
  }
502
530
 
503
- // The review approved: QA runs the scenarios end to end.
504
- // Changes to the test cases by anyone but QA are undone before QA runs them; QA's own results are kept after.
531
+ // The review approved. Changes to the test cases by anyone but QA are undone, with browser tests on or off.
505
532
  const restored = await restoreScenarios()
506
533
  if (restored && restored.exitCode !== 0) log('the test cases had been changed outside QA and were restored')
534
+ if (!BROWSER) return finish(round, review, CASE_IDS)
535
+
536
+ // Browser tests on: QA runs the scenarios end to end; QA's own results are kept after.
507
537
  const run = await e2e()
508
538
  if (!run) return { status: 'blocked', stage: 'e2e', detail: 'the E2E run did not complete' }
509
539
  await snapshotScenarios()
510
- const caseIds = Array.from({ length: scenarios.scenarioCount }, (_, i) => `TC-${FEATURE_ID}-${String(i + 1).padStart(3, '0')}`)
540
+ const skipped = new Set(BROWSER_SCOPE ? (run.skipped || []).filter((id) => CASE_IDS.includes(id)) : [])
511
541
  const passed = new Set(run.results.filter((r) => r.result === 'PASS').map((r) => r.id))
512
- const failing = caseIds.filter((id) => !passed.has(id))
513
- if (!failing.length) {
514
- return {
515
- status: 'done',
516
- rounds: round,
517
- tests: tests.files,
518
- testCommand: tests.testCommand,
519
- scenarios: { files: SCENARIO_FILES, count: scenarios.scenarioCount },
520
- review: review.summary,
521
- suggestions: review.findings.filter((f) => f.severity === 'suggestion'),
522
- }
523
- }
542
+ const failing = CASE_IDS.filter((id) => !skipped.has(id) && !passed.has(id))
543
+ if (!failing.length) return finish(round, review, [...skipped])
524
544
  const evidence = failing.map((id) => {
525
545
  const r = run.results.find((x) => x.id === id)
526
546
  return `${id}: ${r ? r.evidence : 'not run'}`
@@ -22,6 +22,20 @@ A design is built from what the user gave: the text, the images, the frames of t
22
22
  | Video or GIF | Cannot be read by the designer. You extract key frames to image files first (step 3) |
23
23
  | Spec in `docs/specs/` | Context only: the user stories and rules the design must serve. Read-only |
24
24
 
25
+ ## Model and effort of the designer
26
+
27
+ The default model and effort of `levi-designer` (set in its agent file) are enough when the design only has to follow something the user already approved. Without one, the designer has to invent the layout, and it is called with model `opus` and effort `high`.
28
+
29
+ An **approved basis** is one of:
30
+
31
+ - an image, a cover or key image, a mockup, a sketch or a video frame that the user attached or pointed to in this request, to be recreated (what the user hands over to be recreated is approved by that act);
32
+ - an HTML preview that the user attached or pointed to (a path or a link);
33
+ - an existing design in `docs/designs/` that the request names or clearly means, or that the user picked in the opening round.
34
+
35
+ These are **not** an approved basis: a text description alone; a reference taken only for its style (colors, type, radii); the spec alone; a design in `docs/designs/` that was found only by matching and that nobody confirmed; anything a designer drew earlier in this same run.
36
+
37
+ Steps 4 and 6 use this rule: with an approved basis, call the designer without overriding model or effort; without one, call it with model `opus` and effort `high`. Decide it once, in step 2, and use the same setting in both steps. When you cannot tell whether a reference or an existing design is approved, do not guess: ask in the opening round (step 2), together with the other questions, never in a round of its own.
38
+
25
39
  ## Files
26
40
 
27
41
  | File | Owner | Purpose |
@@ -37,8 +51,9 @@ A design is built from what the user gave: the text, the images, the frames of t
37
51
 
38
52
  1. **Intake.** The request is the text plus the attachments. If there is neither text nor an attachment, ask what to design and stop. Derive the slug. List every image and video with its file path. Note the user's intent for each: recreate it, take its style, or extract its flow.
39
53
  2. **Find the context.**
40
- - *Existing design.* List `docs/designs/` and match folders against the subject. One clear match is an update: the designer revises those files and leaves the rest as they are. Two or more equally plausible: ask the user which one (or "new design"). None: a new folder `docs/designs/<slug>/`.
54
+ - *Existing design.* List `docs/designs/` and match folders against the subject. One clear match is an update: the designer revises those files and leaves the rest as they are. Two or more equally plausible: ask the user which one (or "new design"). None: a new folder `docs/designs/<slug>/`. A match that the request does not name or clearly mean is not yet approved: ask whether it is the approved design to draw from.
41
55
  - *Spec.* List `docs/specs/` and match files by name and title. Use a clear match as context and say which in one line; with no clear match, go on without one. Never create or edit anything under `docs/specs/`.
56
+ - *Model and effort.* Decide whether the designer has an approved basis (see above). Put every question this step leaves open (which design, whether a reference or a match is approved, anything unclear in the request) into one opening round.
42
57
  3. **Prepare the references.** The designer works only from files, never from the conversation.
43
58
  - *Images with a file path:* pass the path.
44
59
  - *Images that exist only in the conversation* (pasted or attached with no path): write `docs/levi/<slug>/references.md` with one section per image, a plain description of what is visible and nothing else: the layout region by region, every text exactly as written, colors as hex values, sizes and spacing you can read, icons, states, and what you cannot make out. No design opinions, no additions. Name the section `Image N` and tell the designer that the description is its only view of that image.
@@ -49,14 +64,14 @@ A design is built from what the user gave: the text, the images, the frames of t
49
64
  ```
50
65
 
51
66
  If that gives fewer than 3 frames, take one frame every few seconds instead (`-vf "fps=1/3,scale=1280:-2"`). Look at the frames, keep one per distinct screen or state and delete near-duplicates, and write `frames/index.md` listing each frame with its timestamp or order. If ffmpeg is not installed, do not guess what the video shows: tell the user and ask for screenshots of the key screens (or for ffmpeg to be installed), then continue with what you have.
52
- 4. **Designer draws.** Call `levi-designer` with: the request as the user wrote it, the intent for each reference, every reference path (images, `frames/`, `references.md`), the spec path if any, the existing design folder if updating, the output folder `docs/designs/<slug>/`, and the path of `references/svg-guide.md` in this skill's folder (the SVG rules). It must:
67
+ 4. **Designer draws.** Call `levi-designer`, with model `opus` and effort `high` unless it has an approved basis, with: the request as the user wrote it, the intent for each reference, every reference path (images, `frames/`, `references.md`), the spec path if any, the existing design folder if updating, the output folder `docs/designs/<slug>/`, and the path of `references/svg-guide.md` in this skill's folder (the SVG rules). It must:
53
68
  - decide the list of files before drawing, and keep tokens and components the same across all of them;
54
69
  - write only SVG files in the output folder, no notes or other files (variants it did not pick go in `alternatives/` inside it);
55
70
  - when the request leaves a choice open (logo options, layout variants, palettes), draw the variants it needs, pick the best one for the design and say so: do not ask. Record the pick in `docs/levi/<slug>/choices/designer-<topic>.md`, as the run rules say;
56
71
  - follow a recreate reference closely (layout, proportions, texts, colors, icons, states) and be honest about what it could not reproduce; follow a style reference for colors, type, radii and density only;
57
72
  - return in its report the file list with one line per file, the assumptions it made, what it could not reproduce, and its questions.
58
73
  5. **Check the files.** Run the checker over the output folder: `python3 <this skill's folder>/scripts/check-svg.py docs/designs/<slug>/` (or `xmllint --noout` on each file if there is no Python). Then, if a renderer exists (`rsvg-convert`, `inkscape`, or headless Chrome/Chromium), render every SVG to `docs/levi/<slug>/render/<name>.png` and look at the renders. Check that nothing is cut off, overlapping or unreadable, that the texts are the right ones, and, for recreate references, that the design matches the reference. If there is no renderer, say so in the report and rely on the checker.
59
- 6. **Fix, once.** When the checker or the render check found problems, call `levi-designer` once more with the exact problems (file, what is wrong, where) and the paths of the renders and references. It fixes only those, and you run step 5 again. Do not start a third pass: report what is still wrong.
74
+ 6. **Fix, once.** When the checker or the render check found problems, call `levi-designer` once more, with the same model and effort as in step 4, with the exact problems (file, what is wrong, where) and the paths of the renders and references. It fixes only those, and you run step 5 again. Do not start a third pass: report what is still wrong.
60
75
  7. **Settle its questions.** The designer cannot ask. Take the questions from its reports. A choice between layouts or variants is already picked (see step 4); so is missing content that a placeholder can hold. A question left over (an unclear reference that changes the whole design, a fact only the user knows) is parked as the run rules say, and goes with the report; the design carries the assumption meanwhile. Ask nothing now. Skip this step when there are no questions.
61
76
  8. **Clean up.** Read `choices/` for the report, then delete it with `frames/`, `references.md` and `render/` from `docs/levi/<slug>/`, then remove the folder if empty, and `docs/levi` if that is empty. Delete only those, only after the designs are final. Keep the SVG files, the user's uploads and the spec.
62
77
  9. **Report.** Tell the user the folder, the files with one line each (what screen or state it shows), whether it is new or an update, the spec used (if any), the assumptions, what could not be reproduced from the references (photos become labeled placeholders, fonts fall back to the stack), what the checks found and fixed, and whether the render check ran. Offer the next step in one line only when it is obvious, such as the missing states or breakpoints.
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: levi-fix-bug
3
- description: Fix a bug in code that is already merged into the base branch. The developer lists what is unclear in the report and the user confirms it; then, as a Workflow of independent subagents, the developer investigates and fixes it test first (writing unit and feature tests only when the existing ones do not cover the bug) while QA writes the bug's test cases; the teamlead reviews every fix once the tests pass, and after its approval QA runs the test cases end to end in a headless browser and sends the failing ones back to the developer. Tests and test cases are never changed to make them pass. A problem in work that is not merged yet is a revision of that work, not a bug. Fits requests such as "fix this bug", "X is broken", "X shows the wrong value", "sửa bug X", "lỗi X".
3
+ description: Fix a bug in code that is already merged into the base branch. The developer lists what is unclear in the report and the user confirms it; then, as a Workflow of independent subagents, the developer investigates and fixes it test first (writing unit and feature tests only when the existing ones do not cover the bug) while QA writes the bug's test cases; the teamlead reviews every fix once the tests pass, and, when the user opts in, QA then runs the test cases end to end in a headless browser after the approval and sends the failing ones back to the developer (browser tests are slow, so the user is asked once at the start, the recommended answer is to skip them, and the test cases are written to be run later). Tests and test cases are never changed to make them pass. A problem in work that is not merged yet is a revision of that work, not a bug. Fits requests such as "fix this bug", "X is broken", "X shows the wrong value", "sửa bug X", "lỗi X".
4
4
  argument-hint: "<what goes wrong, how to reproduce it, and screenshots or logs if you have them>"
5
5
  requires: create-feature, code-review, generate-test-scenarios
6
6
  ---
7
7
 
8
8
  # Fix a bug
9
9
 
10
- Fix a bug with the team: `levi-developer` clarifies, investigates and fixes, `levi-teamlead` reviews, `levi-qa` writes the scenarios and tests the fix end to end. You run them, relay their questions to the user, and never investigate, fix, review or test yourself.
10
+ Fix a bug with the team: `levi-developer` clarifies, investigates and fixes, `levi-teamlead` reviews, `levi-qa` writes the scenarios and, when the user chose browser tests, tests the fix end to end. You run them, relay their questions to the user, and never investigate, fix, review or test yourself.
11
11
 
12
12
  **What counts as a bug.** A bug is a defect in feature code that is already merged into the base branch. When the code at fault is still on a branch that is not merged, or not committed (for example the output of `create-feature` the user is checking), a request to change it is a revision of that work, not a bug. This usecase does not handle revisions: it says so and stops.
13
13
 
@@ -18,7 +18,7 @@ The work has two halves:
18
18
 
19
19
  ## The rules that never bend
20
20
 
21
- - **Test first.** Before the fix, there are unit and feature tests that fail because of the bug: existing ones when they already cover it, otherwise new ones the developer writes. The fix is done when they pass, together with the whole suite.
21
+ - **Test first.** Before the fix, there are unit and feature tests that fail because of the bug: existing ones when they already cover it, otherwise new ones the developer writes. The fix is done when they pass, together with the whole suite. Unless browser tests are on, neither these tests nor that suite open a browser.
22
22
  - **Tests are locked, test cases are QA's.** The tests that cover the bug are locked before the fix: nobody may edit, delete, skip or weaken them afterwards, and when one fails, the code is fixed. The lock is the `lock-tests.mjs` script of `create-feature`: it hashes the files, checks them after every round and restores any that changed. The test cases belong to QA: QA writes, changes and runs them with the test case guide of `generate-test-scenarios`, and a change by anyone else is undone with the same script before QA runs them. QA never changes an expected result to match what the code does.
23
23
  - **No guessing.** The expected behavior comes from the spec, the designs and the points the user confirmed. What none of them settles is asked, not assumed.
24
24
  - **Nothing is committed.** The changes stay in the working tree for the user to review.
@@ -29,7 +29,7 @@ The work has two halves:
29
29
  |---|---|---|
30
30
  | `docs/specs/<spec>.md`, `docs/designs/<design>/` | PM, Designer | The spec and designs of the feature, when there are. Read-only |
31
31
  | Unit and feature tests, in the framework's folders | Developer | **Deliverable.** The tests that cover the bug. Locked before the fix |
32
- | `docs/tests/bugs/<slug>.md`, `docs/tests/bugs/<slug>.xlsx` | QA | **Deliverable.** The test cases of the bug with their PASS or FAIL result, in the format of `generate-test-scenarios`. Only QA changes them |
32
+ | `docs/tests/bugs/<slug>.md`, `docs/tests/bugs/<slug>.xlsx` | QA | **Deliverable.** The test cases of the bug with the PASS or FAIL result of each case that was run, in the format of `generate-test-scenarios`. Only QA changes them |
33
33
  | Application code | Developer | **Deliverable.** The fix |
34
34
  | `docs/levi/<slug>/report.md` | Workflow | Scratch: the bug report as the user gave it. Deleted at the end |
35
35
  | `docs/levi/<slug>/confirmed.md` | Workflow | Scratch: the developer's questions and the user's answers, word for word. Deleted at the end |
@@ -46,12 +46,12 @@ The work has two halves:
46
46
  2. **Merge check.** Find the base branch: the target of `git symbolic-ref --short refs/remotes/origin/HEAD` when it exists, otherwise `main` or `master`; use `origin/<branch>` when that ref exists, else the local branch. All code is merged when `git status --porcelain` lists nothing and `git merge-base --is-ancestor HEAD <base>` exits 0. Otherwise the workflow checks the lines at the root cause once the developer has found it.
47
47
  - If the user clearly points at work that is not merged (a change still on its branch, the output of a usecase they are reviewing), tell them it is a revision of that work, not a bug, and stop.
48
48
  3. **Write down the report.** Write `docs/levi/<slug>/report.md`: the report exactly as the user wrote it, the path of every attachment, and for an image that exists only in the conversation, a plain description of what it shows (texts exactly, values, states), without opinions. For a video, extract key frames into `docs/levi/<slug>/frames/` as step 3 of `levi-design/SKILL.md` describes, and list them.
49
- 4. **Spec and designs.** List `docs/specs/` and `docs/designs/` and match them against the feature where the bug happens, or use what the user pointed to. One clear match is used; two or more plausible ones, ask the user which (or "none"). With none, the expected behavior comes from the report and the confirmed points alone.
49
+ 4. **Spec and designs.** List `docs/specs/` and `docs/designs/` and match them against the feature where the bug happens, or use what the user pointed to. One clear match is used; two or more plausible ones, ask the user which (or "none"). With none, the expected behavior comes from the report and the confirmed points alone. Those questions, if there are any, are the opening round: put the browser-tests question in it ("Browser tests are optional, asked once" in the run rules below).
50
50
  5. **Clarify with the developer.** Call `levi-developer` with `report.md`, the spec, the designs and `confirmed.md` (when it exists). It reads them and the project, changes nothing, and returns:
51
51
  - every point that is unclear and would change the fix or its tests: the expected behavior, the steps, the data, the environment, the scope (which cases are part of the bug). Each comes with two to four options, the most likely first;
52
52
  - whether it looks like a bug: the behavior differs from what the spec, the designs and the report expect, or the code does exactly what the spec says.
53
53
 
54
- Ask the user all the points in one round (use the tool's structured question feature if it has one). Append the questions and answers to `confirmed.md`, word for word. Do not answer for the user, and do not take an option as the answer unless the user picks it. Then call `levi-developer` again, fresh, with the updated `confirmed.md`. Stop when it has no more points; at most three rounds. If it then says the code works as the spec states, tell the user, quoting the spec: changing that behavior is a change to the feature, not a bug fix. Stop there.
54
+ Ask the user all the points in one round (use the tool's structured question feature if it has one). **If step 4 asked no question, this is the opening round, so add the browser-tests question to it, and ask it alone when the developer has no points.** The question is asked once, in the first round of the run, never twice. Append the developer's questions and the answers to `confirmed.md`, word for word, and write the browser-tests answer to `docs/levi/<slug>/choices/user-browser-tests.md`, as the run rules say (not into `confirmed.md`: the agents read that file as input). Do not answer for the user, and do not take an option as the answer unless the user picks it. Then call `levi-developer` again, fresh, with the updated `confirmed.md`. Stop when it has no more points; at most three rounds. If it then says the code works as the spec states, tell the user, quoting the spec: changing that behavior is a change to the feature, not a bug fix. Stop there.
55
55
  6. **Fix.** Delete `docs/levi/<slug>/locked/` if an earlier run left it.
56
56
  - *With a Workflow tool (Claude Code):* call it with `scriptPath` set to `workflow.js` in this skill's folder, and `args`:
57
57
 
@@ -62,21 +62,23 @@ The work has two halves:
62
62
  "designs": "docs/designs/<design>/ (omit when there is none)",
63
63
  "base": "<base branch ref from step 2>",
64
64
  "allMerged": true,
65
+ "browserTests": <true or false>,
66
+ "browserScope": "<the user's words, only when they limited which cases to run>",
65
67
  "skillDir": "<this skill's folder, relative to the project root>"
66
68
  }
67
69
  ```
68
70
 
69
- Set `allMerged` to false when step 2 found unmerged work.
71
+ Set `allMerged` to false when step 2 found unmerged work. `browserTests` is the user's answer to the opening question: `false` when they chose not to run browser tests (also the value when the answer is missing). Omit `browserScope` unless the user limited the run.
70
72
  - *Without a Workflow tool:* run the steps under [Workflow](#workflow) below yourself, in order, each agent call as a new subagent call that gets only the paths and instructions written there.
71
73
  7. **Act on the result.**
72
- - `done`: go to step 8.
74
+ - `done`: go to step 8. When `browserTests` was off, the result lists the test cases that were not run (`notRun`).
73
75
  - `questions`: an agent found a point that is still open. Ask the user, append the answers to `confirmed.md`, and run step 6 again.
74
76
  - `not_a_bug`: the developer found that the code does what the spec and the confirmed points expect. Tell the user why, clean up (step 8) and stop.
75
77
  - `unmerged`: the root cause is in code that is not merged into the base branch. Tell the user it is a revision of unmerged work, not a bug, with the root cause and its locations. Clean up and stop. The code was not changed.
76
78
  - `blocked`: something outside the code stops the work (the app cannot start, a service or credential is missing, no test could be made to fail on the bug). Tell the user the stage, the detail and what they need to provide. Keep `docs/levi/<slug>/` and run step 6 again when they say to.
77
79
  - `stalled`: the rounds ran out (10 by default) and something still fails. Tell the user what failed last. Continue in the same session with `resumeFromRunId` and a higher `maxRounds`. Tests and test cases still do not change.
78
80
  8. **Clean up.** Delete `docs/levi/<slug>/`, then `docs/levi` if it is empty. Keep everything else.
79
- 9. **Report.** Tell the user: the root cause and where it was; the tests that cover the bug (written now, or existing ones) and the command that runs them; the test case files with their result (for example `4/4 PASS`); how many rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed.
81
+ 9. **Report.** Tell the user: the root cause and where it was; the tests that cover the bug (written now, or existing ones) and the command that runs them; the test case files with their result (for example `4/4 PASS`); how many rounds it took; the review outcome and the suggestions left open; the files changed (from `git status`); and that nothing was committed. When browser tests did not run (all or part), add the line "Browser tests: not run (the user chose this)", or the partly-run variant, and list every test case that was not run with its ID and title (read the titles from the test case file).
80
82
 
81
83
  ## Workflow
82
84
 
@@ -84,13 +86,14 @@ The steps `workflow.js` runs, and the ones you run when there is no Workflow too
84
86
 
85
87
  1. **Baseline.** Record `git rev-parse HEAD` and the files `git status --porcelain` lists, so the review sees only this run's changes.
86
88
  2. **Two tracks at the same time**, neither reading the other's work:
87
- - *QA.* `levi-qa` writes the test cases from the report, the confirmed points, the spec and the designs, without reading code, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/bugs/<slug>`: case 1 follows the steps of the report, the next ones cover nearby cases the same bug could break. The files are snapshotted at once (`lock-tests.mjs lock docs/levi/<slug>/locked/scenarios ...`). QA then waits for the review to approve.
89
+ - *QA.* `levi-qa`, called with model `opus` and effort `high`, writes the test cases from the report, the confirmed points, the spec and the designs, without reading code, following `levi-generate-test-scenarios/references/test-case-guide.md`, with the cases file `docs/levi/<slug>/test-cases.json` and the output base `docs/tests/bugs/<slug>`: case 1 follows the steps of the report, the next ones cover nearby cases the same bug could break. The files are snapshotted at once (`lock-tests.mjs lock docs/levi/<slug>/locked/scenarios ...`). QA then waits for the review to approve (browser tests on) or is done (off).
88
90
  - *Developer, test first.* `levi-developer` finds the root cause (file, line range, other places with the same cause) and writes `investigation.md`. If existing unit and feature tests already cover the bug and fail because of it, it uses them; otherwise it writes the missing ones, from the spec and the confirmed points. The tests are run: some must fail on the current code. If none fails, the developer tries again (at most 3 times). If the code turns out to do what is expected, stop with `not_a_bug`.
89
91
  3. **Merge check**, unless all code is merged: for each root-cause location, `git blame --porcelain -L <from>,<to> -- <file>`, then `git merge-base --is-ancestor <commit> <base>` for each commit. An uncommitted line (all-zero commit), an untracked file or a commit that is not an ancestor of the base means the code is not merged: stop with `unmerged`.
90
92
  4. **Lock** the tests that cover the bug (`lock-tests.mjs lock docs/levi/<slug>/locked/tests ...`).
91
93
  5. **Rounds** (at most 10 unless raised), each starting with a fresh `levi-developer` call:
92
94
  1. *Fix.* The developer fixes the code: first as planned in `investigation.md`, later what the last round sent back. It fixes the cause, not the symptom.
93
- 2. *Tests.* `lock-tests.mjs verify` on the tests (any changed test is restored and the developer is told), then the bug's tests, then the whole suite. A failure goes back to the developer.
95
+ 2. *Tests.* `lock-tests.mjs verify` on the tests (any changed test is restored and the developer is told), then the bug's tests, then the whole suite (without the tests that open a browser, unless browser tests are on). A failure goes back to the developer.
94
96
  3. *Review.* Once the tests pass, a fresh `levi-teamlead` call reviews the change since the baseline: the root cause fixed everywhere, what the spec, designs and confirmed points expect, nothing else broken, security, performance, fit, following `levi-code-review/references/review-guide.md` and its checklists. It writes `review.md`. A change of more than 100 reviewable files is reviewed in slices by several fresh `levi-teamlead` calls and merged by a lead call, as `levi-code-review/references/large-changes.md` says. Critical or warning findings go back to the developer.
95
- 4. *E2E.* Once the review approves, `lock-tests.mjs verify` on the test cases undoes any change made outside QA. Then `levi-qa` runs every case in a headless browser (the project's E2E runner such as Playwright, or a browser tool; through the API or CLI when there is no UI) and records PASS or FAIL as its test case guide says; the snapshot is then taken again. Failing cases go back to the developer, and the next round runs tests, review and E2E again.
96
- 5. The run is done when the review approves and every case passes.
97
+ 4. *E2E*, only when browser tests are on. Once the review approves, `lock-tests.mjs verify` on the test cases undoes any change made outside QA. Then `levi-qa`, with its default model and effort, runs every case in a headless browser (the project's E2E runner such as Playwright, or a browser tool; through the API or CLI when there is no UI) and records PASS or FAIL as its test case guide says; the snapshot is then taken again. Failing cases go back to the developer, and the next round runs tests, review and E2E again. When the user limited the run, only the cases they chose are run; the others are reported as not run and do not count against the result.
98
+ *Browser tests off:* skip this step. Once the review approves, run `lock-tests.mjs verify` on the test cases once more, so that they stay as QA wrote them, and the run is done.
99
+ 5. The run is done when the review approves and, when browser tests are on, every case passes.