test-and-fix
Automatically runs tests and applies fixes to resolve failures.
Install
mkdir -p .claude/skills/test-and-fix && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16837" && unzip -o skill.zip -d .claude/skills/test-and-fix && rm skill.zipInstalls to .claude/skills/test-and-fix
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Run unit tests and automatically fix code failures, regression bugs, or test mismatches. Use when tests are failing, after implementing new features, or to repair "broken" tests.Key capabilities
- →Identify failing unit tests using `make test`
- →Analyze `pytest` output to pinpoint failing files, line numbers, and errors
- →Apply minimal fixes to source code for bugs or test code for outdated tests
- →Verify fixes by re-running tests
- →Loop through identification, analysis, fixing, and verification until all tests pass
- →Terminate the loop if all tests pass or an iteration limit is reached
How it works
The skill operates in a loop to identify failing unit tests, analyze their output, apply minimal fixes to either source or test code, and then re-verify until all tests pass or a limit is met.
Inputs & outputs
When to use test-and-fix
- →Fixing failing unit tests
- →Automating regression bug repairs
- →Maintaining test suite health
About this skill
Test and Fix Loop
Purpose
An autonomous loop for the agent to identify, analyze, and fix failing unit tests using pytest.
Loop Logic
- Identify: Run
make testto identify failing tests. - Analyze: Examine the
pytestoutput to determine:- The failing test file and line number.
- The expected vs actual values (assertion errors).
- Tracebacks for runtime errors.
- Fix: Apply the minimum necessary change to either the source code (if it's a bug) or the test code (if the test is outdated).
- Verify: Re-run
make test(oruv run pytest path/to/failing_test.pyfor speed).- If passed: Move to the next failing test or finish if all are resolved.
- If failed: Analyze the new failure and repeat the loop.
Termination Criteria
- All tests pass (as reported by
make test). - Reached max iteration limit (default: 5).
- The error persists after multiple distinct fix attempts, indicating a need for human intervention.
Examples
Scenario: Fixing a logic error
make testfails insrc/your_package/tests/test_dummy.pydue to an assertion or import error.- Agent inspects the failing test and the implementation under
src/your_package/. - Agent applies the minimum fix in source or test so behavior matches the intended contract.
make testpasses.
Resources
- Pytest Documentation: Official documentation for the pytest framework.
- Testing conventions for this repo: AGENTS.md (Testing section).
When not to use it
- →When all tests are already passing
- →When human intervention is explicitly required due to persistent errors
- →When the task is to write new tests for new features
Limitations
- →Terminates after a maximum iteration limit (default: 5)
- →Requires `pytest` for test execution and output analysis
- →May require human intervention if errors persist after multiple attempts
How it compares
This skill automates the iterative process of finding, fixing, and verifying unit test failures, providing an autonomous loop for bug resolution, unlike manual debugging.
Compared to similar skills
test-and-fix side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| test-and-fix (this skill) | 0 | 3mo | No flags | Intermediate |
| python-testing-patterns | 77 | 3mo | Review | Intermediate |
| python-playground | 2 | 4mo | Review | Beginner |
| mflux-manual-testing | 2 | 2mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
python-testing-patterns
wshobson
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.
python-playground
pydantic
Run and test Python code in a dedicated playground directory. Use when you need to execute Python scripts, test code snippets, investigate CPython behavior, or experiment with Python without affecting the main codebase.
mflux-manual-testing
filipstrand
Manually validate mflux CLIs by exercising the changed paths and reviewing output images/artifacts.
examples-auto-run
openai
Run python examples in auto mode with logging, rerun helpers, and background control.
extract-fuzzer-repro
noir-lang
Extract a Noir reproduction project from fuzzer failure logs in GitHub Actions. Use when a CI fuzzer test fails and you need to create a local reproduction.
klingai-known-pitfalls
jeremylongshore
Manage avoid common mistakes when using Kling AI. Use when troubleshooting issues or learning best practices to prevent problems. Trigger with phrases like 'klingai pitfalls', 'kling ai mistakes', 'klingai gotchas', 'klingai best practices'.