agentleFS
qyndexqyndex/claude-init/.claude/skills/self-heal/SKILL.md

self-heal

Skill2 starsChanged 5 months agoMITView on GitHub

When a test fails, lint errors, or CI breaks — diagnose with debugger agent, propose minimal fix, implementer applies, verifier reruns, loop up to 3 attempts then escalate. Combines Anthropic Auto-Fix + Playwright self-heal + 4-tier escalation pattern.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the error message matches transient patterns (timeout, connection reset, "Test timeout after Nms" on first run), rerun once.

    line 27
  2. Very specific:

    If second run succeeds, log to .claude/memory/incidents/flaky-<date>.md and move on.

    line 28
  3. Distinctive:

    If second run fails, escalate to Tier 2.

    line 29
  4. Distinctive:

    Run the broader test suite to confirm no regression.

    line 40
  5. Very specific:

    Commit with fix(<scope>): <summary> + git trailer Confidence: high if all tests green.

    line 41
  6. Very specific:

    Write OVERNIGHT_REPORT.md or PR comment with:

    line 45
  7. Distinctive:

    One fix per attempt: Don't batch hypotheses. Test each independently.

    line 57
  8. Very specific:

    Document: Every escalation writes to .claude/memory/incidents/.

    line 59

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “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

Self-Heal

A failure is not "done." It's a debugging task with a defined recovery path.

The four tiers (escalate only when the prior tier fails)

Tier 1 — Pre-flight retry         (transient: network, flake, race)
        ↓
Tier 2 — Debugger diagnosis       (root cause via 4-phase loop)
        ↓
Tier 3 — Implementer applies      (minimal fix from diagnosis)
        ↓
Tier 4 — Human escalation         (after 3 failed Tier 1-3 cycles)

Process

Tier 1 — Transient retry (max 1)

  • If the error message matches transient patterns (timeout, connection reset, "Test timeout after Nms" on first run), rerun once.
  • If second run succeeds, log to .claude/memory/incidents/flaky-<date>.md and move on.
  • If second run fails, escalate to Tier 2.

Tier 2 — Debugger diagnosis (1 invocation)

  • Delegate to debugger agent with the failure output.
  • Debugger runs reproduce → isolate → diagnose → fix-proposal (4 phases).
  • Output: file:line + cause + minimal fix proposal.
  • No commits by debugger.

Tier 3 — Implementer applies (1 invocation)

  • Delegate to implementer agent with the debugger's fix proposal.
  • Implementer writes a failing test first (capturing the bug), then the fix, then watches green.
  • Run the broader test suite to confirm no regression.
  • Commit with fix(<scope>): <summary> + git trailer Confidence: high if all tests green; Confidence: medium if only the targeted test passes.

Tier 4 — Human escalation (after 3 cycles fail)

  • Stop the loop.
  • Write OVERNIGHT_REPORT.md or PR comment with:
    • Failure output
    • Debugger's three diagnoses
    • Implementer's three attempts (commits)
    • Why each failed (paste verify output)
    • Suggested human next step
  • Mark the task failed: bash .claude/scripts/task-status.sh T-<id> failed --note "<one-line why>" (lock-safe; also feeds the consecutive-aborts machine).

Hard rules

  • Don't fix without understanding. Tier 2 is mandatory before any code change.
  • Don't suppress symptoms. No try/except: pass, no // @ts-ignore, no broad catch {}. If the fix looks like suppression, escalate.
  • One fix per attempt. Don't batch hypotheses. Test each independently.
  • Escalate at 3 attempts, not 5. A bug that resists 3 root-cause-driven fixes is a human problem.
  • Document. Every escalation writes to .claude/memory/incidents/.

Auto-trigger

The stop-verify.sh hook fires this skill when:

  • Any task's accept: command exits non-zero
  • bash .claude/scripts/verify.sh exits non-zero
  • /loop iteration reports failure

References

  • PolarOrchid/ClaudeWatch (4-tier recovery pattern)
  • obra/superpowers/skills/systematic-debugging (4-phase debugger loop)
  • Anthropic Auto-Fix (CI-side self-healing via claude-code-action)

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.