agentleFS
bolivian-perubolivian-peru/os-moda/skills/self-healing/SKILL.md

self-healing

Skill118 starsChanged 6 months agoApache-2.0View on GitHub

Detect service failures and system anomalies. Diagnose root causes. Auto-remediate using NixOS rollback, service restart, or config repair. Every action logged to the hash-chained audit ledger.

8 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use build-premium-website, instantly-campaign and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • vikneshwaran16032005-altSkill

    build-premium-website

    Build a premium, animated marketing website (React + Vite + Tailwind + GSAP) for any industry. Use when the user asks to "build a website", "make a landing page for [business]", "build a marketing site", or wants a high-end animated company website. Adapts color, copy, services, and signature animation to the industry.

    Also in 3 projects that use this

  • vikneshwaran16032005-altSkill

    instantly-campaign

    Create a new Instantly cold-email campaign in the proven 5-email structure of the user's top-performing campaign (~16% reply rate). Use when the user wants to launch a new outbound campaign, write a cold email sequence, create an Instantly campaign, draft outreach for a new service or niche, or set up a sales sequence.

    Also in 3 projects that use this

  • composio-communitySkill

    composio

    Use 1000+ external apps via Composio - either directly through the CLI or by building AI agents and apps with the SDK

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 12 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When you detect a service failure or anomaly during a heartbeat check:

    line 29
  2. Distinctive:

    If the service is down, check again after 10 seconds.

    line 42
  3. Distinctive:

    If restart doesn't fix it, or if config is corrupted:

    line 73
  4. Distinctive:

    If you can identify the exact config issue:

    line 80
  5. Distinctive:

    If disk/memory is the problem:

    line 90
  6. Distinctive:

    ALWAYS do these three things:

    line 98
  7. Distinctive:

    After fixing an issue, compose a clear message for the user:

    line 119
  8. Distinctive:

    Keep it factual, concise, and include the audit reference.

    line 134
  9. Distinctive:

    NEVER make changes without logging them

    line 138
  10. Distinctive:

    NEVER skip verification after a fix

    line 139
  11. Distinctive:

    If unsure, restart is safer than rollback

    line 140
  12. Distinctive:

    If rollback fails, STOP and alert the user — don't cascade

    line 141

“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

Self-Healing Skill

You can detect, diagnose, and fix system problems automatically.

Detection

When you detect a service failure or anomaly during a heartbeat check:

  1. Check teachd for historical patterns first — teachd observes the system 24/7 between conversations
    teach_context({ context: "nginx failure service down" })
    teach_patterns({ min_confidence: 0.5 })
    This surfaces slow-burn issues (memory leaks, recurring failures, correlated events) that you wouldn't catch in a single conversation.
  2. Confirm the failure — don't act on a single check
    service_status({ service: "nginx" })
    If the service is down, check again after 10 seconds. If still down, proceed.
  3. Check journal logs for why it failed
    journal_logs({ unit: "nginx", lines: 30, priority: "err" })
  4. Recall past incidents — have we seen this before?
    memory_recall({ query: "nginx failure", timeframe: "30d" })

Diagnosis

Determine the root cause before acting:

  • Service crashed → check logs for segfault, OOM, config error
  • Config file missing/corrupted → check if NixOS generation has it
  • Dependency failure → another service it depends on is down
  • Resource exhaustion → disk full, OOM killer, too many connections
  • Bad deploy → most recent nixos-rebuild introduced the issue

Remediation (ordered by safety)

Level 1: Restart the service

shell_exec({ command: "systemctl restart nginx" })

Safe, fast, fixes 80% of issues.

Level 2: NixOS rollback

If restart doesn't fix it, or if config is corrupted:

shell_exec({ command: "nixos-rebuild switch --rollback" })

This atomically reverts to the last known-good NixOS generation.

Level 3: Targeted config fix

If you can identify the exact config issue:

file_read({ path: "/etc/nixos/configuration.nix" })

Fix the config, then rebuild:

shell_exec({ command: "nixos-rebuild switch" })

Level 4: Resource relief

If disk/memory is the problem:

shell_exec({ command: "nix-collect-garbage -d" })
shell_exec({ command: "journalctl --vacuum-size=500M" })

After remediation

ALWAYS do these three things:

  1. Verify the fix worked
    service_status({ service: "nginx" })
  2. Store in memory
    memory_store({
      summary: "nginx failure: config missing, rolled back to gen 47",
      detail: "Full diagnosis and fix details...",
      category: "diagnosis",
      tags: "self-healing,nginx,rollback"
    })
  3. Log to audit ledger — this happens automatically through agentd

Notification

After fixing an issue, compose a clear message for the user:

I detected nginx was down at 03:17 UTC.

Cause: The configuration file /etc/nginx/nginx.conf referenced
a missing upstream. This was introduced in NixOS generation 48
(rebuilt 2 hours ago).

Action: Rolled back to generation 47. nginx is running again.
All health checks pass.

Audit entry: #52 (hash: a7f3b2...)

Keep it factual, concise, and include the audit reference.

Critical rules

  • NEVER make changes without logging them
  • NEVER skip verification after a fix
  • If unsure, restart is safer than rollback
  • If rollback fails, STOP and alert the user — don't cascade
  • Store EVERY incident in memory — patterns build over time

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.