Test Fixing
Systematically identify and fix all failing tests by grouping similar failures and fixing them in dependency order.
When to use
- User explicitly asks to fix tests ("fix these tests", "make tests pass").
- User reports failures ("tests are failing", "test suite is broken", "failing after my refactor").
- After finishing an implementation and wanting the suite green.
- CI/CD pipeline fails on the test stage.
Approach
1. Run the suite
Run the project's test command (e.g. make test, uv run pytest, npm test). Capture:
- Total failure count
- Error types / patterns
- Affected modules and files
2. Group failures
Cluster failures by:
- Error type — ImportError, AttributeError, AssertionError, TypeError, etc.
- Module/file — one file causing many failures
- Root cause — missing deps, API/signature changes, refactor fallout
Prioritize groups by impact (most affected tests first) and dependency order (infrastructure before logic).
3. Fix one group at a time
For each group, highest impact first:
- Find root cause — read the code, check
git diff for recent changes, understand the pattern.
- Fix — minimal, focused edits that follow project conventions (check CLAUDE.md).
- Verify the group — run just those tests before moving on:
uv run pytest tests/path/to/test_file.py -v
uv run pytest -k "pattern" -v
- Only advance once the current group passes.
4. Fix order strategy
- Infrastructure first — import errors, missing dependencies, config issues.
- Then API changes — signature changes, module reorg, renames.
- Finally logic — assertion failures, business-logic bugs, edge cases.
5. Final verification
- Re-run the full suite (
make test).
- Confirm no regressions and coverage stays intact.
Best practices / gotchas
- Fix one group at a time; never jump ahead while a group is still red.
- Use
git diff to understand what recently changed — most post-refactor failures are renames/signature drifts.
- Keep changes minimal and focused; don't refactor unrelated code.
- Run focused tests after each fix to catch new breakage early.
Example
User: "The tests are failing after my refactor."
make test → 15 failures.
- Group: 8 ImportErrors (module renamed), 5 AttributeErrors (signature changed), 2 AssertionErrors (logic).
- Fix ImportErrors → run subset → verify.
- Fix AttributeErrors → run subset → verify.
- Fix AssertionErrors → run subset → verify.
- Run full suite → all pass.
1---2name: test-fixing3description: "Use when tests are failing, the test suite is broken, CI/CD test jobs fail, or the user says 'fix these tests', 'make tests pass', 'tests are failing after my refactor' — run the suite and systematically fix all failures via smart error grouping."4version: 1.0.05license: Apache-2.06tags: [testing, pytest, ci, debugging, refactor, test-failures, fix-tests, regression]7source: https://github.com/mhattingpete/claude-skills-marketplace/tree/main/engineering-workflow-plugin/skills/test-fixing8derived_from: awesomeclaude9metadata:10 source: https://skillmd.com/skills/aashutosh396/test-fixing11---1213# Test Fixing1415Systematically identify and fix all failing tests by grouping similar failures and fixing them in dependency order.1617## When to use1819- User explicitly asks to fix tests ("fix these tests", "make tests pass").20- User reports failures ("tests are failing", "test suite is broken", "failing after my refactor").21- After finishing an implementation and wanting the suite green.22- CI/CD pipeline fails on the test stage.2324## Approach2526### 1. Run the suite27Run the project's test command (e.g. `make test`, `uv run pytest`, `npm test`). Capture:28- Total failure count29- Error types / patterns30- Affected modules and files3132### 2. Group failures33Cluster failures by:34- **Error type** — ImportError, AttributeError, AssertionError, TypeError, etc.35- **Module/file** — one file causing many failures36- **Root cause** — missing deps, API/signature changes, refactor fallout3738Prioritize groups by impact (most affected tests first) and dependency order (infrastructure before logic).3940### 3. Fix one group at a time41For each group, highest impact first:421. **Find root cause** — read the code, check `git diff` for recent changes, understand the pattern.432. **Fix** — minimal, focused edits that follow project conventions (check CLAUDE.md).443. **Verify the group** — run just those tests before moving on:45 ```bash46 uv run pytest tests/path/to/test_file.py -v47 uv run pytest -k "pattern" -v48 ```494. Only advance once the current group passes.5051### 4. Fix order strategy521. **Infrastructure first** — import errors, missing dependencies, config issues.532. **Then API changes** — signature changes, module reorg, renames.543. **Finally logic** — assertion failures, business-logic bugs, edge cases.5556### 5. Final verification57- Re-run the full suite (`make test`).58- Confirm no regressions and coverage stays intact.5960## Best practices / gotchas61- Fix one group at a time; never jump ahead while a group is still red.62- Use `git diff` to understand what recently changed — most post-refactor failures are renames/signature drifts.63- Keep changes minimal and focused; don't refactor unrelated code.64- Run focused tests after each fix to catch new breakage early.6566## Example67User: "The tests are failing after my refactor."681. `make test` → 15 failures.692. Group: 8 ImportErrors (module renamed), 5 AttributeErrors (signature changed), 2 AssertionErrors (logic).703. Fix ImportErrors → run subset → verify.714. Fix AttributeErrors → run subset → verify.725. Fix AssertionErrors → run subset → verify.736. Run full suite → all pass.