agent-safety-hooks
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:
block-rm-rf.js(Destructive Command Guard): Prevents AI agents from executing destructive shell commands such asrm -rf,git reset --hard,git clean -f, autonomousgh pr merge(ensuring PR merges are strictly human), or force pushes.check-agents-size.js(AGENTS.mdContext Size Guard): Deterministically blocksgit commitifAGENTS.mdexceeds 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 blockingrm -rfand checkingAGENTS.mdsize must be active on every turn from session startup, which requires placing them in.claude/settings.jsonand.claude/hooks/.