---
description: Generate focused unit tests for the selected code or file
agent: agent
argument-hint: file or function to test
---

Write unit tests for ${selection} (if nothing is selected, use ${file}).

1. Detect the test framework, helpers, and file naming used in this repo by reading an existing test near the target. Follow them exactly.
2. List the behaviors to cover before writing code: the happy path, edge cases (empty, null, boundaries, large inputs), and error paths. Show this list.
3. Write one test per behavior with a descriptive name. Use parametrized/table tests for input variations.
4. Mock only external boundaries (network, clock, filesystem, randomness). Don't mock the unit under test or its simple collaborators.
5. Run the new test file and fix failures in the tests. If a failure reveals a real bug in the code, don't change the code; report the bug with the failing test.
6. Finish with: the file created, the behaviors covered, the command to run them, and any behaviors you couldn't test and why.

Don't modify production code or existing tests in this task.
