# Self-Healing Verify Loop

> Tests pass, or your agent tells you exactly why: auto-detected test command, compact failure summaries and hard stop rules. No infinite loops, no fake "done".

Self-Healing Verify Loop is a paid AI agent skill on Agensi by Rakgorak Rak, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Rakgorak Rak](https://www.agensi.io/creators/superai-rakkyxd)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Version: 1.0
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/self-healing-verify-loop
- Tags: testing, code-review, devops, node-js, continuous-integration, debugging

## About this skill

AI agents waste time and tokens in two ways after writing code: they say "done" without running anything, or they retry the same broken fix again and again. This skill stops both with a bounded **test → fix → re-test** loop whose exit codes tell the agent to continue or stop.

### What it does
- **Auto-detects the right check:** `typecheck`/`lint` + `test` with the correct package manager (npm, pnpm, yarn, bun), pytest, cargo, go vet + go test, dotnet, Maven, Gradle, make.
- **Compact failure summaries:** thousands of log lines become the error lines, their context and stack frames, with ANSI colours stripped. Your agent reads the error, not the noise.
- **Failure fingerprinting:** if a fix produces the *same* failure (ignoring timings, timestamps, addresses and line shifts), the loop stops with exit `5`: no progress, report it.
- **Hard budget:** 3 attempts by default, capped at 5.
- **Anti-cheating rules:** the agent may not delete tests, loosen assertions, add ignore comments or swallow errors to get a green run. Environmental failures are reported, not "fixed".
- **Evidence:** `history` shows every attempt's result and fingerprint for an honest final report.

### How it works
1. `node scripts/verify.mjs detect` picks the check and the agent tells you which command it will run.
2. `node scripts/verify.mjs run` runs it with a timeout and prints a failure summary.
3. Exit `0` passed, `4` fix and retry, `5` stop (same failure twice), `6` stop (budget used).
4. The agent reports exactly what it observed, with the attempt history.

### Frameworks & tools
A single zero-dependency Node.js 18+ script. Works with Node, Python, Rust, Go, .NET, Maven, Gradle and Makefile projects on Windows, macOS and Linux.

### Why this beats prompting it yourself
"Keep going until the tests pass" has no stop rule, so agents loop, burn tokens, or quietly weaken the tests. Deterministic exit codes and failure fingerprints make the agent stop at the right time and report honestly.

### Security
Runs only your project's own verification command (detected from its manifest, or one you give) through the system shell, with a timeout that ends the whole process tree. Writes only `.self-heal/log.json`. No network calls of its own.

### Known limitations
Needs a project with a runnable test, build or type-check command. It cannot fix environmental problems (missing services, credentials or network); it reports them instead.

## Requires

- Node.js 18+
- Python
- Optional: Your project's own test toolchain

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Self-Healing Verify Loop skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill prevent an agent from repeatedly trying the same broken fix?

This skill eliminates 'success hallucination' where agents claim to be finished without actually running tests. It forces the agent to interact with your real CLI tools, using failure fingerprinting to stop it from getting stuck in an infinite loop of the same mistake.

### Which programming languages and test frameworks are supported?

The skill is language-agnostic and includes auto-detection for Node.js, Python, Rust, Go, .NET, and Java. As long as your environment supports Node.js 18+ to run the controller script, it can trigger almost any standard build or test runner.

### What exactly is included?

One zero-dependency Node.js script (scripts/verify.mjs) with detect, run, history and reset commands, plus a SKILL.md that teaches your agent the loop: how to choose the check, how to fix between attempts, the anti-cheating rules and how to report. Attempt history is written to .self-heal/log.json automatically.

### Do I need to write special tests for the 'self healing verify' skill to work?

No, this skill is designed to work with your existing infrastructure. It automatically detects and uses the commands you already have defined, such as `npm test`, `pytest`, or `cargo test`, so you don't have to write new tests from scratch.

### How does the skill protect my token budget from runaway retries?

Each failure summary gets a fingerprint that ignores timings, timestamps, addresses and line shifts. If a fix produces the same failure again, the script exits with code 5 and tells the agent to stop and report. The attempt budget (3 by default, capped at 5) ends the loop with exit code 6.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
