with one click
test-write
// Use when backfilling tests on existing code. Detects test framework, writes behavior-focused regression tests via public interfaces. Modes: targeted (files) or diff-based (changed).
// Use when backfilling tests on existing code. Detects test framework, writes behavior-focused regression tests via public interfaces. Modes: targeted (files) or diff-based (changed).
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | test-write |
| description | Use when backfilling tests on existing code. Detects test framework, writes behavior-focused regression tests via public interfaces. Modes: targeted (files) or diff-based (changed). |
Generate regression tests for existing code. Detect the test framework, analyze behavior through public interfaces, write tests, and run them.
When the user specifies files or modules:
/test-write src/actions/createOrder.ts
/test-write src/utils/
Analyze the specified code and generate tests for its public interface.
When no target is specified:
/test-write
Read git diff (staged + unstaged) to find changed files. Generate tests for the modified behaviors.
If the working tree is clean, check the last commit with git diff HEAD~1.
These commands run automatically when the skill loads — output replaces each line below:
ls vitest.config.* jest.config.* pytest.ini pyproject.toml 2>/dev/null || truels -d __tests__ tests test src/__tests__ 2>/dev/null || truecat package.json 2>/dev/null | grep -E '"test"' || truegit diff --statgit diff --cached --statLook for existing setup in this order:
vitest.config.*, jest.config.*, pytest.ini, etc.) — see pre-run outputpackage.json test scripts — see pre-run outputAlso detect:
The git diff pre-run feeds Diff-Based Mode — if the user gave no target, use the changed files from the diff output.
Read the target files and identify:
Do NOT test:
For each identified behavior, write a test that:
Follow the project's existing conventions for:
If no conventions exist, use sensible defaults for the detected framework.
Execute the tests immediately after writing them.
Tests written: 5
src/actions/createOrder.test.ts — 3 tests (validation, calculation, error handling)
src/utils/formatCurrency.test.ts — 2 tests (formatting, locale handling)
Passed: 5
Failed: 0
Not covered: createOrder webhook side effects (requires external service mock)
If no test framework is detected:
Ask the user before installing dependencies.