# Repo Immune System

> Stop your AI coding agent from breaking the same fragile files twice. Zero-dependency IDE write-hook & CLI guard (gotcha_guard.py) that surfaces file-specific traps, dead ends, and a 3-strike Circuit Breaker the second an agent touches risky code.

Repo Immune System is a paid AI agent skill on Agensi by Scrimal, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $9.99 (one-time purchase)
- Creator: [Scrimal](https://www.agensi.io/creators/scrimal)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Version: 1.1.1
- Last updated: 2026-12-02
- Security: scan passed (2026-12-02); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/repo-immune-system
- Tags: code-review, ai-agents, testing, gotcha, guard, write-hook, agent-memory, adr

## About this skill

Your AI agent fixes a tricky auth bug on Tuesday. On Thursday, it edits the same file and silently reintroduces the exact same bug, because nothing stopped it at the moment of the edit.

**Repo Immune System** acts like antibodies for your codebase. It hooks into your IDE or pre-commit workflow and injects file-specific traps (`[gotcha]`) and forbidden paths (`[dead_end]`) the second an agent touches fragile code.

### Why It Beats Generic `CLAUDE.md` Rules
* **Just-in-Time File Guard:** Instead of dumping 400 lines of global rules into every prompt, `gotcha_guard.py` matches edited paths against `code_refs` and surfaces only the warnings bound to that exact file.
* **Gotcha vs. Dead-End Enforcement:** Distinguishes between edge-case cautions (`[gotcha]`) and falsified architectural paths (`[dead_end]`) that the agent must not retry.
* **3-Strike Circuit Breaker:** Tracks consecutive triggers per trap (with automatic reset and 1h TTL) and fires a hard `[circuit_breaker]` stop on the 3rd repeat so your agent stops burning tokens in an infinite loop.
* **1-Command Trap Scaffolding (`--learn`):** Generates draft gotcha nodes directly from your latest `git commit` fix so every solved bug permanently immunizes your repository.

### What's Inside
1. `scripts/gotcha_guard.py` — Standalone zero-dependency trap matcher (`--hook`, `--repo`, `--learn`, `--clear`) with Circuit Breaker protection.
2. `hooks/` — Drop-in hook configurations for Claude Code (`claude_code.md`), Cursor (`cursor.md`), and pi (`pi.md`).
3. `references/templates.md` & `gotchas/GOTCHA_001.md` — Production templates and live examples for `GOTCHA`, `ADR`, and `DEAD_END` nodes.

## Requires

- Python 3.10+
- Optional: Git

Zero external dependencies or network requests. Works standalone on explicit file paths or IDE hook payloads; Git is only used for --repo staged checks and --learn commit scaffolding.

## Known limitations

File path matching relies on exact or normalized relative paths declared in code_refs rather than AST symbol resolution. Requires wiring the included hook snippets into your IDE config (hooks/) or pre-commit script for automatic execution.

## 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 Repo Immune System 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 is this different from just adding repository rules to my system prompt?

Unlike large system prompts that agents might ignore, this skill uses a 'just-in-time' mechanism to inject specific warnings only when an agent attempts to modify a high-risk file, saving tokens and preventing hallucinated fixes.

### Which AI agents and IDEs are compatible with the Repo Immune System?

Works with any CLI or IDE coding agent. The package includes drop-in hook configurations for Claude Code (PostToolUse), Cursor (afterFileEdit), and pi (tool_result), and runs as a standard CLI command in Windsurf, Cline, or CI pipelines.

### What exactly is included in the purchase of this skill?

You receive SKILL.md (the guard protocol), scripts/gotcha_guard.py (a zero-dependency trap matcher with Circuit Breaker and --learn git scaffolding), ready-to-use IDE hook configs in hooks/ (claude_code.md, cursor.md, pi.md), production templates in references/templates.md, and a working example node (gotchas/GOTCHA_001.md).

### Can I use this skill to automate quality gates in my CI/CD pipeline?

Yes. You can run gotcha_guard.py --repo in pre-commit hooks or CI checks to surface active gotcha and dead_end warnings for any modified files before changes are merged.

### How complex is the initial setup and configuration process?

Setup takes under two minutes: copy the hook snippet for your IDE from hooks/ into your project config, and scaffold your first trap node directly from a past fix using gotcha_guard.py --learn (or copy a template from references/templates.md).

---

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.
