Install git safety guard hook at project or user scope
Installs git safety guard hook to block destructive commands at project or user scope.
/plugin marketplace add SomtoUgeh/somto-dev-toolkit/plugin install somto-dev-toolkit@somto-dev-toolkitYou are helping the user install the git safety guard hook. This hook blocks destructive git commands like git reset --hard, git checkout --, rm -rf, etc.
The user wants to install at: {{ scope }} scope
.claude/settings.json - applies to this project only, can be shared via git~/.claude/settings.json - applies to ALL Claude Code sessionsFirst, check if the guard script exists in the plugin:
${CLAUDE_PLUGIN_ROOT}/hooks/git_guard.pyBased on scope, do the following:
a. Create .claude directory if it doesn't exist:
mkdir -p .claude
b. Copy the guard script to .claude/hooks/:
mkdir -p .claude/hooks
cp "${CLAUDE_PLUGIN_ROOT}/hooks/git_guard.py" .claude/hooks/git_guard.py
chmod +x .claude/hooks/git_guard.py
c. Read existing .claude/settings.json if it exists, then merge the hook config:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 .claude/hooks/git_guard.py",
"timeout": 5
}
]
}
]
}
}
d. Add .claude/hooks/ to .gitignore OR commit it (ask user preference)
a. Copy the guard script to ~/.claude/hooks/:
mkdir -p ~/.claude/hooks
cp "${CLAUDE_PLUGIN_ROOT}/hooks/git_guard.py" ~/.claude/hooks/git_guard.py
chmod +x ~/.claude/hooks/git_guard.py
b. Read existing ~/.claude/settings.json if it exists, then merge the hook config:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 ~/.claude/hooks/git_guard.py",
"timeout": 5
}
]
}
]
}
}
Tell the user:
git reset --hard, git checkout --, git clean -f, rm -rf, force pushes, stash dropsgit checkout -b, rm -rf node_modules, git restore --staged