testfix
AI-powered CLI that automatically fixes failing tests — non-interactive, pipeable, CI-ready.
# Tests failing? Just run testfix.
$ testfix pytest
──────────────────────── Attempt 1/5 ────────────────────────
🔴 2 failing, 8 passing (attempt 1)
└─ test_login tests/test_auth.py:10
└─ test_register tests/test_auth.py:25
🤖 Asking claude to fix 2 failure(s)…
Generated 1 file fix(es)
─── src/auth.py ──────────────────────────────────────────────
--- a/src/auth.py
+++ b/src/auth.py
@@ -3,7 +3,7 @@
def login(user, password):
- return db.find(user) is not None # BUG: doesn't check password
+ return db.find(user, password) is not None
✔ Applied fix to auth.py (backup: .testfix.bak)
──────────────────────── Attempt 2/5 ────────────────────────
✅ All tests pass! (attempt 2)
Why testfix?
Every developer faces the same loop: run tests → fix code → run tests → ...
Tools like aider are powerful but require an interactive session. testfix is different:
| Feature | testfix | aider |
|---|---|---|
| Non-interactive | ✅ | ❌ (interactive REPL) |
| CI/CD ready | ✅ | ❌ |
| Pre-push hook | ✅ | ❌ |
| Pipe-friendly | ✅ | ❌ |
| Local LLM (ollama) | ✅ | ✅ |
| Auto-retry loop | ✅ | manual |
Install
pip install testfix
Requires Python 3.9+ and one of: Anthropic API key, OpenAI API key, or ollama running locally.
Usage
# Basic: run pytest, fix failures, retry up to 5 times
testfix pytest
# Specific test file
testfix pytest tests/test_auth.py
# Max iterations
testfix --max-tries 3 pytest
# Fix once and re-run (equivalent to --max-tries 2)
testfix --once pytest
# Preview fixes as diffs WITHOUT applying
testfix --dry-run pytest
# Use OpenAI instead of Claude
testfix --provider openai pytest
# Use local ollama (free, no API key needed)
testfix --provider ollama pytest
# Use a stronger model for hard bugs
testfix --provider openai --model gpt-4o pytest
# Focus fixes on a specific source file
testfix --file src/auth.py pytest
# Works with any test runner
testfix npm test
testfix go test ./...
testfix cargo test
testfix vitest
Supported Test Frameworks
| Framework | Failure parsing | Exit code |
|---|---|---|
| pytest | ✅ Full traceback | ✅ |
| jest / vitest | ✅ Test name + location | ✅ |
| go test | ✅ Test name + file:line | ✅ |
| cargo test | ✅ Test name | ✅ |
| rspec | ✅ Test name + location | ✅ |
Pre-push hook
Automatically fix failing tests before every push:
# .git/hooks/pre-push
#!/bin/sh
testfix --once --provider ollama pytest
LLM Providers
# Claude (default) — best quality
export ANTHROPIC_API_KEY=sk-ant-...
testfix pytest
# OpenAI
export OPENAI_API_KEY=sk-...
testfix --provider openai pytest
# Local ollama (free, private, no API key)
# Install: https://ollama.ai then: ollama pull qwen2.5:7b
testfix --provider ollama pytest
How it works
- Run your test command and capture output
- Parse failures: test names, file paths, tracebacks
- Find the source files that need fixing (not the test files)
- Ask AI to fix the source code based on the failure context
- Apply patches (with
.testfix.bakbackups) - Repeat until all tests pass or max tries reached
CI usage
# GitHub Actions
- name: Fix and test
run: |
pip install testfix
testfix --provider openai --max-tries 3 pytest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Full developer workflow
Combine with the rest of the ecosystem for end-to-end AI-assisted development:
# 1. Morning standup
standup-ai --yesterday
# 2. Review your code before committing
critiq --staged
# 3. Fix failing tests automatically
testfix pytest
# 4. Generate commit message
gpr --commit
# 5. Generate PR description
gpr
# 6. Pack context for AI code review
gitbrief --changed-only
# 7. Generate changelog on release
changelog-ai --since v1.0.0
Install the full suite:
pip install standup-ai critiq testfix gpr gitbrief changelog-ai
Related tools
- critiq — AI code reviewer (catches issues before they become failing tests)
- difftests — AI test generator (generates tests for your diffs)
- gpr — AI PR description generator
- gitbrief — AI context packer for LLMs
- standup-ai — AI daily standup generator
- changelog-ai — AI changelog generator
- prcat — AI PR reviewer for teammate PRs
License
Business Source License 1.1 — free for individuals and non-commercial use. Commercial use requires a license after the Change Date (2028-01-01), at which point this project converts to Apache 2.0.
Metadata
Release files for testfix-ai 0.2.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_ai-0.2.0.tar.gz | 18.7 kB | Without provenance | Details for testfix_ai-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| testfix_ai-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for testfix_ai-0.2.0-py3-none-any.whl |
Total release size: 33.8 kB
Release files / testfix_ai-0.2.0.tar.gz
| Download URL | testfix_ai-0.2.0.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c54559bd8e1caabea4fa7056c4bdd84427fe7a090c971f02b623337672157dc
|
|
BLAKE2b-256 checksum How to use checksums |
f5d3d00a45f456c733032eed558cdc2b93b57f5e287f760659175fc324e98cae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / testfix_ai-0.2.0-py3-none-any.whl
| Download URL | testfix_ai-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac416ace80c36344ac8622469718dce1b299cb6c7c521bc12f1e08dd841af727
|
|
BLAKE2b-256 checksum How to use checksums |
26a71ba0dd9fe8de6f2482749623063112e483bedf7e61cc6ded581d4cb3ef01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for testfix-ai 0.2.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.