---
description: Write or expand unit / integration tests for the given code
argument-hint: "[file path, function, or feature to test]"
subagent: true
fork: true
---
Write tests for: $@

Structure your answer as:
1. **Existing conventions** — name patterns, framework, assertion style, fixtures; match what's already there
2. **Test cases to add** — grouped as:
   - **Happy path** — the primary expected behavior
   - **Edge cases** — empty, zero, max, boundary, off-by-one
   - **Error cases** — invalid input, missing deps, timeouts, permission failures
3. **Test code** — minimal, runnable, following the project's framework (jest, pytest, go test, etc.)
4. **How to run** — the exact command, plus how to run just the new tests
5. **Coverage gaps** — anything still untestable without a refactor; flag it but do not refactor in this pass

Keep tests independent, deterministic, and fast. Prefer many small tests over one large one. If the codebase has no test setup yet, propose the smallest viable setup and call it out clearly so the user can approve before you scaffold it.
