/somto-dev-toolkit:setup-git-guard [project|user]from somto-dev-toolkit
Install git safety guard hook at project or user scope
Ships in somto-dev-toolkit. Installing the plugin adds it to Claude Code.
You 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: $ARGUMENTS 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 --stagedWhat the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
15 commands in this plugin
/completenpx claudepluginhub somtougeh/somto-dev-toolkit --plugin somto-dev-toolkitOther plugins' commands for the same job