# I built HookGuard: A <50ms Local Guardrail & Loop Detector for AI Coding Agents

> Source: <https://dev.to/hediem/i-built-hookguard-a-50ms-local-guardrail-loop-detector-for-ai-coding-agents-57a4>
> Published: 2026-11-30 13:40:23+00:00

**Key takeaway:** HookGuard enforces a local YAML ruleset across Claude Code, Cursor, Codex CLI and Antigravity to block destructive commands and .env access at under 50ms overhead, with loop detection capping repeated actions at 80% warning and 100% hard stop.

Got tired of coding agents getting stuck running the same failing command over and over or trying to read `.env` / run `git reset --hard`, so I open-sourced **HookGuard** (MIT, 100% local, <50ms overhead).

One command (`hookguard init`) configures hooks for **Claude Code, Antigravity, Cursor, and Codex CLI**:

`hookguard.yaml`):` rm -rf` / `Remove-Item -Recurse -Force`, `git push --force`, `git reset --hard`, `curl | bash`, and `.env`/key reads & writes (while allowing `.env.example`).`~/.hookguard/data.db`, native `node:sqlite`, zero C++ deps) with 80% warning and 100% cap.` hookguard ui`):
GitHub: [https://github.com/hediem/HookGuard](https://github.com/hediem/HookGuard)

Would love any feedback on rules, adapters, or features you'd want in v0.2!
