auto-test #
Run the corresponding test file after Claude Code writes or edits a file.
Maps source files to test files by convention and runs the matching test runner.
Results are prefixed with [auto-test] <runner>: and surfaced to Claude.
If the edited file IS a test file, it runs directly. If no corresponding test file exists, the hook does nothing.
All test runners are optional. If a runner is not in PATH, or the project marker file is missing, the file is skipped.
Required tools #
jq (parses hook input JSON).
Supported languages #
| Extension | Runner | Nixpkgs | Source-to-test mapping | Project marker |
|---|---|---|---|---|
.go |
go test |
go |
same package directory | (none) |
.js, .jsx |
npx jest |
nodejs |
Foo.js -> Foo.test.js or __tests__/Foo.test.js |
package.json |
.py |
python -m pytest |
python3Packages.pytest |
models.py -> tests/test_models.py |
pyproject.toml or setup.py |
.rb |
bundle exec rspec |
via Gemfile | app/models/user.rb -> spec/models/user_spec.rb |
Gemfile |
.ts, .tsx |
npx jest |
nodejs |
Foo.ts -> Foo.test.ts or __tests__/Foo.test.ts |
package.json |
Project-specific configuration #
Create .auto-tools.json at the root of your project to override the built-in test runner for a file extension, or to disable testing for a language:
{
"test": {
".go": "go test -count=1 -race ./...",
".py": null
}
}
{}in the command is replaced with the absolute path to the edited file.nulldisables test running for that extension.- An absent key falls through to the built-in default.
auto-tools discovers .auto-tools.json by walking up from the edited file's directory to the filesystem root. The innermost config file wins.
Trust model:
.auto-tools.jsonis executed as code. Review it before using this plugin in untrusted repositories.
Installation #
/plugin install auto-test@jcmuller-plugins