Generate tests for $ARGUMENTS, then run them. This is a generate → run →
verify loop, not just file generation.
1. Discover
- Detect the test framework already in use (look for
jest.config*,
vitest.config*, pytest.ini / pyproject.toml [tool.pytest], Go's
_test.go convention, Cargo.toml [dev-dependencies], etc.). Never
add a new framework or runner.
- Skim 1–2 existing test files near the target to mirror style, fixtures,
setup/teardown, assertion style, and naming convention.
2. Generate
Cover:
- Happy path (expected usage)
- Edges (empty / null / boundary / malformed)
- Errors (invalid input, IO / network / DB failures)
Match existing patterns:
- Same framework, same fixture style, same naming convention.
- Reuse existing setup/teardown helpers; do not add new mock libraries
or new test-runner config.
- Do not add test-only public methods or exports to production code to
make a test possible — if the test wants a hook the prod code doesn't
expose, stop and ask.
3. Run
Execute the project's real test command, scoped to just the new tests
(-t <name>, --testPathPattern, pytest path/to/test.py, go test ./pkg, etc.). Report:
- Pass / fail counts.
- Any failure with the assertion message and
file:line.
4. Verify the tests BITE
A test that passes is not the same as a test that exercises the code.
For each new test, confirm:
- It would fail if the function under test returned the wrong value.
Mentally swap a broken impl — does the assertion actually catch it?
- It isn't
expect(true).toBe(true), expect(fn).toBeDefined(), or a
mock asserting itself.
- It isn't passing only because the setup masked the real call.
Mark each new test biting or superficial (with reason).
Superficial tests count as a failure to ship — either fix or delete.
5. Report
- Files added / modified.
- Pass / fail.
- Biting vs superficial breakdown.
- What was deliberately not tested, and why (third-party shims,
trivial getters/setters, generated code). Documented gaps beat fake
coverage.
Stop and ask when:
- A meaningful test would require a non-obvious design change to
production code (don't pollute prod to make tests pass — present the
options instead).
- The existing test setup has multiple reasonable patterns and it's
unclear which to mirror.
- An existing dependency would need to be mocked in a way the project
doesn't currently do (introducing a new mock style is a design choice).
1---2name: test-generate3description: Generate and run tests [file]4---5Generate tests for $ARGUMENTS, then run them. This is a generate → run →6verify loop, not just file generation.78## 1. Discover9- Detect the test framework already in use (look for `jest.config*`,10 `vitest.config*`, `pytest.ini` / `pyproject.toml [tool.pytest]`, Go's11 `_test.go` convention, `Cargo.toml [dev-dependencies]`, etc.). **Never12 add a new framework or runner.**13- Skim 1–2 existing test files near the target to mirror style, fixtures,14 setup/teardown, assertion style, and naming convention.1516## 2. Generate17Cover:18- **Happy path** (expected usage)19- **Edges** (empty / null / boundary / malformed)20- **Errors** (invalid input, IO / network / DB failures)2122Match existing patterns:23- Same framework, same fixture style, same naming convention.24- Reuse existing setup/teardown helpers; do **not** add new mock libraries25 or new test-runner config.26- Do **not** add test-only public methods or exports to production code to27 make a test possible — if the test wants a hook the prod code doesn't28 expose, stop and ask.2930## 3. Run31Execute the project's real test command, scoped to just the new tests32(`-t <name>`, `--testPathPattern`, `pytest path/to/test.py`, `go test33./pkg`, etc.). Report:34- Pass / fail counts.35- Any failure with the assertion message and `file:line`.3637## 4. Verify the tests BITE38A test that passes is not the same as a test that **exercises** the code.39For each new test, confirm:40- It would fail if the function under test returned the wrong value.41 Mentally swap a broken impl — does the assertion actually catch it?42- It isn't `expect(true).toBe(true)`, `expect(fn).toBeDefined()`, or a43 mock asserting itself.44- It isn't passing only because the setup masked the real call.4546Mark each new test **biting** or **superficial** (with reason).47Superficial tests count as a failure to ship — either fix or delete.4849## 5. Report50- Files added / modified.51- Pass / fail.52- Biting vs superficial breakdown.53- What was deliberately **not** tested, and why (third-party shims,54 trivial getters/setters, generated code). Documented gaps beat fake55 coverage.5657**Stop and ask** when:58- A meaningful test would require a non-obvious design change to59 production code (don't pollute prod to make tests pass — present the60 options instead).61- The existing test setup has multiple reasonable patterns and it's62 unclear which to mirror.63- An existing dependency would need to be mocked in a way the project64 doesn't currently do (introducing a new mock style is a design choice).