Install guard
install_guardInstall a destructive-command guard for Claude Code that blocks irreversible Bash commands (rm, git reset --hard) and allows safe variants, for global or per-project scope, without clobbering existing hooks.
Instructions
Install the destructive-command guard (a PreToolUse/Bash hook) globally into ~/.claude (target=user, default) or into a project's .claude (target=project). Copies destructive-guard.sh into .claude/hooks/ and merges the hook into settings.json WITHOUT clobbering existing keys or hooks (idempotent — safe to re-run). The guard blocks irreversible commands (rm, find -delete, truncate/shred, git reset --hard / clean -f / push --force) while allowing safe variants (git rm, --force-with-lease). Requires jq. Restart the Claude Code session to activate. Note: bootstrap_project already checks for the global (target=user) guard and installs it if missing — you normally only need this tool directly for target='project' or to re-check after a manual jq install.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | Where to install: 'user' → ~/.claude (global, default), 'project' → <project_path>/.claude. | |
| project_path | No | Absolute project path. Required when target='project'. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| protects | Yes | What the guard blocks. | |
| warnings | Yes | Non-fatal issues (e.g. jq missing). | |
| hook_status | Yes | Result of merging the hook into settings.json. | |
| script_path | Yes | Where the guard script was installed. | |
| script_status | Yes | Whether the script was newly written or already present. | |
| settings_path | Yes |