agent-safety-hooks

Installation
SKILL.md

Agent Safety Hooks Governance

This skill manages provider-agnostic lifecycle hooks for Android projects following the Single Responsibility Principle (SRP). It installs two focused hooks into the canonical hook locations of the active AI provider:

  1. block-rm-rf.js (Destructive Command Guard): Prevents AI agents from executing destructive shell commands such as rm -rf, git reset --hard, git clean -f, autonomous gh pr merge (ensuring PR merges are strictly human), or force pushes.
  2. check-agents-size.js (AGENTS.md Context Size Guard): Deterministically blocks git commit if AGENTS.md exceeds 10 KB (10,240 bytes) to prevent the "lost in the middle" degradation in AI agent context windows.

Supported Providers & Canonical Hook Locations

Following each provider's official specification (such as Claude Code Hook Locations), hooks are never executed from inside .agents/skills/. Instead, this skill materializes them into the provider's official project-level hook directories so they can be committed and shared with the team:

AI Provider Hook Configuration File Hook Script Locations Event / Matcher
Claude Code .claude/settings.json .claude/hooks/block-rm-rf.js.claude/hooks/check-agents-size.js PreToolUse (Bash|PowerShell)
Gemini / Antigravity (Default) .agents/hooks.json .agents/hooks/block-rm-rf.js.agents/hooks/check-agents-size.js PreToolUse (run_shell_command / run_command)
Cursor .cursor/hooks.json .cursor/hooks/block-rm-rf.js.cursor/hooks/check-agents-size.js beforeShellExecution

[!IMPORTANT] Why .claude/settings.json + .claude/hooks/ instead of Skill Frontmatter? Per the Claude Code documentation, hooks defined in a skill's YAML frontmatter only activate after that specific skill is invoked during a session. Project-wide safety guards like blocking rm -rf and checking AGENTS.md size must be active on every turn from session startup, which requires placing them in .claude/settings.json and .claude/hooks/.

Installs
2
First Seen
Oct 21, 2026