From ap-optimal-claude
Use when tests are failing and you need autonomous fix-test-fix iteration until all tests pass. Trigger on "fix all tests", "make tests green", "fix the test suite", or when multiple test failures need systematic resolution.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ap-optimal-claude:fix-loopThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Iteratively fix failing tests until the full suite passes, with a hard cap to prevent infinite loops.
Iteratively fix failing tests until the full suite passes, with a hard cap to prevent infinite loops.
pytest --tb=short -q
Capture the output. If all tests pass, stop - nothing to do.
Before fixing anything, group and prioritize:
git blame to see if the test or its source changed more recently.For each failure group from triage:
pytest path/to/test.py::test_name --tb=shortAfter fixing all groups, run the full suite again. New failures may have appeared from interactions between fixes.
Repeat steps 1-4 until either:
After each iteration, append to FIX_LOG.md in the project root (use the Write tool, not heredocs):
## Iteration N - [timestamp]
- Tests passing: X/Y
- Fixed: [list of tests fixed and what was wrong]
- Remaining failures: [list with brief diagnosis]
- Files changed: [list]
At hard cap or early exit, add a Final Summary:
## Final Summary
- Total tests fixed: X
- Total iterations: N
- Remaining failures: [list with full diagnosis, whether present since iteration 1, suspected root cause]
- Recommended next steps: [e.g., "These appear to be bad tests" or "Requires architectural changes"]
| Step | Command | Stop if |
|---|---|---|
| Full suite | pytest --tb=short -q | All pass |
| Single test | pytest path::test -v | Passes |
| Check coverage | pytest --tb=short -q after fixes | New failures appear |
| Hard cap | Count iterations | 10 reached |
| Stall detection | Compare failing tests | No change in 2 iterations |
npx claudepluginhub coach-foundation/claude-code-best-practices --plugin ap-optimal-claudeGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.