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:

  • Security rules (hookguard.yaml): blocks rm -rf / Remove-Item -Recurse -Force, git push --force, git reset --hard, curl | bash, and .env/key reads & writes (while allowing .env.example).
  • Loop & thrashing detector: stops consecutive or ping-pong command loops when no files changed in between, plus rapid repeated edits to the same file.
  • Session budget cap: local SQLite tracking (~/.hookguard/data.db, native node:sqlite, zero C++ deps) with 80% warning and 100% cap.
  • Local dashboard (hookguard ui): dark-mode UI to inspect sessions, blocked actions, loop alerts, and edit hookguard.yaml with live Zod validation.

GitHub: https://github.com/hediem/HookGuard

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