agentleFS
nodealchemynodealchemy/powernode-platform/.claude/skills/fix-tests/SKILL.md

fix-tests

Skill4 starsChanged 18 days agoMITView on GitHub

Run tests, diagnose failures, fix and re-run until green

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the test suite for the given scope, diagnose failures, fix them, and re-run.

    line 10
  2. Very specific:

    Import path issues (use @/shared/, @/features/)

    line 39
  3. Distinctive:

    If still failing after 3 attempts on the same test, stop and report — do not keep iterating

    line 42
  4. Distinctive:

    If any TypeScript files were modified:

    line 46
  5. Very specific:

    If --loop flag was provided and Step 5 still has failures:

    line 60
  6. Distinctive:

    If failures persist after 3 full loops, stop and report

    line 63

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fix Tests Workflow

Run the test suite for the given scope, diagnose failures, fix them, and re-run. The fixed parts are the 3-attempt limit per failure, the final re-run of the original scope, and the summary; how you diagnose each failure is your call (the Step 3 checklist lists common causes in this codebase).

Step 1: Determine Scope & Mode

Parse the argument to determine what to run:

  • backend or no argument → cd server && bundle exec rspec --format progress
  • frontend → cd frontend && CI=true npm test
  • e2e → cd frontend && npx playwright test
  • A specific file path → run that file directly

Loop mode (--loop): Run the full fix cycle autonomously without asking for input. Make best-judgment fixes. Suitable for headless/unattended runs via claude -p "/fix-tests backend --loop".

Step 2: Run Tests

Execute the test command and capture output. Note all failures.

Step 3: Fix Loop (max 3 attempts per failure)

For each failing test:

  1. Read the failing spec file and the source file it tests
  2. Diagnose the root cause — check for:
    • Missing factory traits (check spec/factories/ and spec/factories/ai/)
    • Wrong test helpers (use user_with_permissions, auth_headers_for, json_response)
    • Missing shared examples (spec/support/shared_examples/)
    • Missing mocks or stubs for external services
    • Stale selectors in E2E tests (prefer data-testid)
    • Import path issues (use @/shared/, @/features/)
  3. Fix the issue using Edit
  4. Re-run just the failing file to verify the fix
  5. If still failing after 3 attempts on the same test, stop and report — do not keep iterating

Step 4: TypeScript Check (frontend/e2e only)

If any TypeScript files were modified:

cd frontend && npx tsc --noEmit

Fix any type errors found (same 3-attempt limit).

Step 5: Final Run

Re-run the full suite for the original scope to confirm everything passes.

Step 6: Loop Mode Continuation (--loop only)

If --loop flag was provided and Step 5 still has failures:

  1. Return to Step 3 with the NEW set of failures (not the originals)
  2. Repeat the full cycle up to 3 total loop iterations
  3. If failures persist after 3 full loops, stop and report

This enables autonomous fix pipelines: claude -p "/fix-tests backend --loop" --allowedTools "Bash,Read,Edit,Grep,Glob"

Step 7: Summary

Report:

  • Total tests: pass / fail / pending
  • Failures fixed (list each with one-line description of what was wrong)
  • Failures remaining (if any, with diagnosis of why they couldn't be auto-fixed)
  • Loop iterations completed (if --loop mode)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.