testfix
AI-powered failing test auto-fixer. Run your tests, let the AI fix the failures, repeat until green — all from one command.
pip install testfix
testfix pytest # run, fix, retry up to 5× until tests pass
Supports pytest · jest · vitest · go test · cargo test
Why testfix?
You've been there: you write a feature, run tests, and see 5 failures. Fixing each one manually means reading tracebacks, understanding what broke, writing a fix, re-running — and repeating. testfix automates that loop.
Unlike GitHub Copilot (needs IDE) or aider (interactive session), testfix is a pure CLI tool: non-interactive, pipeable, pre-push hook-ready.
Installation
pip install testfix
Requires Python 3.9+. No configuration needed — just install and run.
API Keys
Set one of these (or use Ollama for free local inference):
export ANTHROPIC_API_KEY=sk-ant-... # Claude (default)
export OPENAI_API_KEY=sk-... # OpenAI
# or use --provider ollama (no key needed, runs locally)
Quick Start
# Run pytest and fix failures (up to 5 tries)
testfix pytest
# Fix a specific test file
testfix pytest tests/test_auth.py
# Run once: test → fix → test again
testfix --once pytest
# Preview fixes without applying them
testfix --dry-run pytest
# Use OpenAI instead of Claude
testfix --provider openai pytest
# Use local Ollama (free, no API key)
testfix --provider ollama pytest
# Use Jest
testfix npm test
# Use Go test
testfix go test ./...
# Focus on a specific source file
testfix --file src/auth.py pytest
How it works
testfix pytest
│
├─ Attempt 1/5
│ ├─ Run: pytest
│ ├─ 3 failing tests found
│ ├─ 🤖 Asking Claude to fix 3 failure(s)…
│ ├─ Generated 1 file fix(es)
│ │ └─ src/auth.py (diff shown)
│ └─ ✔ Applied fix (backup: .testfix.bak)
│
├─ Attempt 2/5
│ ├─ Run: pytest
│ └─ ✅ All tests pass!
│
└─ Exit 0
- Run your tests with the command you provide
- Parse failures: extracts test name, location, error, traceback
- Collect relevant source files (from tracebacks + heuristics)
- Ask the AI to fix the source code — never modifies test files
- Apply the fix (with
.testfix.bakbackup) - Repeat until tests pass or
--max-triesis reached
Options
testfix [OPTIONS] TEST_COMMAND...
Options:
--max-tries N Max fix-and-retry iterations (default: 5)
--once Run once: test → fix → test again (--max-tries 2)
--dry-run Show diffs but don't apply fixes
--provider NAME LLM provider: claude, openai, ollama (default: claude)
--model NAME Model override (e.g. claude-sonnet-4-5, gpt-4o)
--file PATH Focus fixes on this source file
-v, --verbose Show full test runner stderr
--version Show version and exit
Pre-push hook
Add to .git/hooks/pre-push:
#!/bin/bash
testfix --once --provider ollama pytest
This runs tests, lets AI fix any failures, and blocks the push if tests are still failing.
CI / GitHub Actions
- name: Run and auto-fix tests
run: testfix pytest
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Or use --dry-run in CI to just report what would be fixed without changing files:
- name: Check if AI can fix test failures
run: testfix --dry-run pytest || echo "Tests failing (see diff above)"
Supported test frameworks
| Framework | Command example |
|---|---|
| pytest | testfix pytest |
| jest | testfix npx jest |
| vitest | testfix npx vitest |
| go test | testfix go test ./... |
| cargo test | testfix cargo test |
| rspec | testfix bundle exec rspec |
| any | testfix <your test command> |
Ecosystem
testfix is part of a suite of AI-powered developer CLI tools:
| Tool | Purpose |
|---|---|
| critiq | AI code reviewer — catch issues before you push |
| testfix | AI test fixer — automatically fix failing tests |
| difftests | AI test generator — write tests for your diffs |
| gpr | AI PR description + commit message generator |
| gitbrief | Pack your codebase into LLM context |
| standup-ai | AI daily standup generator |
| changelog-ai | AI CHANGELOG generator |
| prcat | AI PR reviewer for incoming PRs |
| chronicle | Turn git history into stories |
License
Business Source License 1.1 — free for non-commercial use. See LICENSE.
Metadata
Release files for testfix 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| testfix-0.1.0.tar.gz | 15.6 kB | Without provenance | Details for testfix-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| testfix-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for testfix-0.1.0-py3-none-any.whl |
Total release size: 28.0 kB
Release files / testfix-0.1.0.tar.gz
| Download URL | testfix-0.1.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e3b9df3311b6095f48b56875ccaf0747fd7cf43ea265f94fc7ee66aa0d6e5bd
|
|
BLAKE2b-256 checksum How to use checksums |
603230d9d9c2cf7bfc7a4c64b0d70d32bc1bceec73f22cbcb5b0581120010b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / testfix-0.1.0-py3-none-any.whl
| Download URL | testfix-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e370da58799043db05a2f64d544158104bf0bd84f4c5afa104e0b4678b4451bf
|
|
BLAKE2b-256 checksum How to use checksums |
4c22bf74f879d4c5b817e3bc613571c4b41494ee00961b427aadbb9f376d5d42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for testfix 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.