| name | add-tests |
| description | Generate tests for uncovered code. Follows existing test patterns in the codebase. |
| disable-model-invocation | true |
| allowed-tools | Bash(*) Read Write Edit Grep Glob |
| arguments | ["target"] |
| argument-hint | path/to/module |
Add Tests
Generate comprehensive tests for uncovered code, following existing test patterns in the codebase.
Step 1: Understand Test Patterns
Before writing any tests, analyze the existing test infrastructure:
- Framework: Identify the test framework (e.g.,
testing, pytest, jest, vitest).
- Naming convention: How are test files and functions named?
- Directory structure: Are tests co-located or in a separate
__tests__/test/ directory?
- Mock patterns: What mocking libraries or patterns are used?
- Fixtures: Are there shared test fixtures, helpers, or setup functions?
- Assertions: What assertion style is preferred?
Step 2: Analyze Target
Examine the target module/file:
- Public functions: List all exported/public functions and methods.
- Input types: Document parameter types, including edge-case values.
- Error conditions: Identify all error return paths and failure modes.
- Side effects: Note file I/O, network calls, database access, or global state mutations.
- Dependencies: List external dependencies that need mocking.
Step 3: Generate Tests
For each public function, generate tests covering:
- Happy path: Normal operation with valid inputs.
- Edge cases: Empty inputs, boundary values, nil/null, zero values.
- Error paths: Invalid inputs, dependency failures, timeout scenarios.
- Type safety: Ensure type constraints are exercised.
Follow the existing test style exactly. Match naming conventions, assertion patterns, and file organization.
Step 4: Verify
- Run the new tests and confirm they pass.
- Run the full test suite to ensure no regressions.
- Report results including any failures or issues discovered.