DiffGuard
lint-staged for AI agents — block dangerous diffs before they land
npx -y github:Isco0819/diffguardEver run into this?
AI agents auto-commit code constantly, but lint-staged (13k+ GitHub stars, proven demand for pre-commit diff hooks) has no opinionated mode for LLM footguns: mass file deletions, silently removed auth checks, newly hardcoded secrets, or deleted test files with no source change. Engineers burn hours in post-mortems catching what a 5-second gate should have stopped.
The fix
npx CLI that installs as a git pre-commit hook and scans staged diffs against a ruleset of known AI-agent footguns, blocking commits with a clear line-level report. Ships with an MCP server mode so agents can self-check before calling git commit.
What it does
- Mass-deletion guard: flags when >40% of any file is removed in a single staged commit
- Auth-pattern radar: detects removal of auth middleware, input validation, or rate-limit guards from diff hunks
- Secret sniffer: scans newly added lines for hardcoded token/key/password patterns via regex
- Test-file watchdog: alerts when a test file is deleted without a matching source file deletion