steeef/claude-hooks
steeef/claude-hooks · 0 stars · 9 plugins
Marketplace Safety and automation hooks for Claude Code
Install
/plugin marketplace add steeef/claude-hooksRun inside Claude Code, then install plugins from it. Check the repo's README before you run it.
Plugins 9
After adding the marketplace, install one with /plugin install <name>@claude-hooks.
- 1command-safetyBlocks dangerous commands (rm, kubectl delete, terraform destroy)
/plugin install command-safety@claude-hooks - 2git-hooksEnforces safe git workflows (no commits to main, branch naming)
/plugin install git-hooks@claude-hooks - 3file-protectionWarns on large files and large reads
/plugin install file-protection@claude-hooks - 4notificationsDesktop notifications on macOS
/plugin install notifications@claude-hooks - 5env-protectionBlocks access to .env files, preventing accidental secret exposure
/plugin install env-protection@claude-hooks - 6git-worktree-hooksBare-container worktrees under ~/wt (clone-on-demand, env-file copy)
/plugin install git-worktree-hooks@claude-hooks - 7gh-formattingRejoins hard-wrapped PR body prose before gh submits it
/plugin install gh-formatting@claude-hooks - 8gh-workflowRequires --draft on gh pr create, asks for confirmation on gh pr ready
/plugin install gh-workflow@claude-hooks - 9comment-styleBlocks multi-line or >7-word comments in new/edited code
/plugin install comment-style@claude-hooks
Files
claude-hooks
Safety and automation hooks for Claude Code.
Plugins
| Plugin | Type | Purpose |
|---|---|---|
| command-safety | PreToolUse | Blocks dangerous commands (rm, kubectl delete, terraform destroy) |
| git-hooks | PreToolUse/PostToolUse | Enforces git safety (no commits to main, blocks dangerous checkout/add patterns) |
| file-protection | PreToolUse | Worktree edit guard, blocks edits to CLAUDE.md, warns on very large files |
| env-protection | PreToolUse | Blocks access to .env files, prevents accidental secret exposure |
| notifications | Stop/Notification | Desktop notifications on macOS |
| git-worktree-hooks | Various | Bare-container worktrees under ~/wt (clone-on-demand, env-file copy) |
| gh-formatting | PreToolUse | Rejoins hard-wrapped PR body prose before gh submits it |
| gh-workflow | PreToolUse | Requires --draft on gh pr create, asks for confirmation on gh pr ready |
| comment-style | PreToolUse | Blocks multi-line or >7-word comments in new/edited code |
Installation
Via Claude Code Plugin System (Recommended)
- Add this repository as a marketplace source:
/plugin marketplace add steeef/claude-hooks
- Install the plugins you want:
/plugin install command-safety@steeef/claude-hooks
/plugin install git-hooks@steeef/claude-hooks
/plugin install file-protection@steeef/claude-hooks
/plugin install notifications@steeef/claude-hooks
Manual Installation
Click to expand manual installation instructions
- Clone the repository:
git clone https://github.com/steeef/claude-hooks.git cd claude-hooks
- Set the
CLAUDE_HOOKS_DIRenvironment variable (add to your shell rc file):
export CLAUDE_HOOKS_DIR="$HOME/code/claude-hooks"
- Configure hooks in
~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/command-safety/hooks/command_hook.py"
},
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/git-hooks/hooks/git_pre_hook.py"
}
]
},
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/file-protection/hooks/file_hook.py"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/git-hooks/hooks/cleanup_hook.py"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/notifications/hooks/notification_hook.sh"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "$CLAUDE_HOOKS_DIR/plugins/notifications/hooks/notification_hook.sh"
}
]
}
]
}
}
Plugin Details
command-safety
Blocks potentially destructive commands:
rmon git-tracked files (allows removal of ignored files like build artifacts)kubectl delete,kubectl scale --replicas=0,kubectl cordon,kubectl drainterraform destroy
Customizing the rm guidance
When rm is blocked, the "what to do instead" guidance comes from a pluggable
handler script, not hardcoded text. By default that's the bundled
plugins/command-safety/hooks/rm_handlers/trash_handler.sh, which reproduces
this plugin's original behavior (move to TRASH/, log to TRASH-FILES.md).
To use a different tool instead, set CLAUDE_HOOKS_RM_HANDLER to the path of
your own executable:
export CLAUDE_HOOKS_RM_HANDLER="$HOME/.claude/hooks/my_rm_handler.sh"
Handler contract:
- Invoked as
<handler> <target1> <target2> ...— the blocked target paths as argv (may be empty). - Must print guidance text to stdout and exit
0. - That output becomes the "how to fix it" portion of the block message shown to Claude — describe your own tool's usage, recovery, and listing commands however you like.
If the configured handler is missing, non-executable, errors, times out (5s), or prints nothing, the hook falls back to the bundled default handler, then to a generic notice if even that fails — so a broken handler config never silently shows guidance for a tool you're not using.
git-hooks
Enforces safe git workflows:
- Blocks commits to main/master - forces feature branch workflow (configurable allowlist)
- Blocks dangerous checkout - prevents
git checkout main -- fileoverwrites - Blocks dangerous add patterns - prevents
git add -A,--forceflags - Suggests worktrees - recommends git worktrees for feature branches
- Cleanup hook - clears branch tracking state after commands
file-protection
Protects important files and encourages worktree workflow:
- Worktree edit guard - deny-then-ask speed bump for edits outside a git worktree (tied to session_id, not a timer)
- Blocks CLAUDE.md edits - project instructions should be edited manually
- Large file warning - warns before editing files over 10,000 lines (speed bump pattern with flag file)
env-protection
Prevents accidental exposure of secrets in .env files:
- Blocks
.envreads - both Bash commands (cat .env,grep .env) and Read tool - Allows safe operations -
ls,mv,cp,touchon.envfiles - Allows templates -
.env.example,.env.template,.env.sample - Safe CLI -
env-safescript for inspecting variable names without values
notifications
Desktop notifications on macOS using osascript:
- Triggers on
Stopevents (task completion) - Triggers on
Notificationevents
gh-formatting
Rejoins hard-wrapped PR body prose before gh submits it:
- Fires on
gh pr {create,edit}andgh api .../pulls/...calls that carry--body-file <path>or-F body=@<path> - Rewrites the referenced file in place, joining hard-wrapped paragraphs into one line each
- Leaves fenced code, lists, blockquotes, headers, tables, and thematic breaks untouched
- Never blocks; inline
--body "..."invocations (no file to rewrite) are left alone
gh-workflow
Enforces a draft-first PR workflow:
gh pr createis denied unless the exact token--draftor-dis present;-h/--helpand--dry-runare always allowedgh pr readyalways asks for confirmation, since it transitions a PR out of draft;--undoand-h/--helpare allowed without asking
comment-style
Denies Write/Edit/MultiEdit when the new/changed text adds a comment
that spans more than one line, or exceeds 7 words -- line-comment languages
only (#, //, --, ;). Shebangs, tool-directive pragmas (noqa,
type:, eslint-disable, etc), and license/copyright headers are exempt.
Development
Requirements: Python 3.11+
# Install dependencies uv sync # Run tests uv run pytest -v # Run pre-commit hooks uvx --with pre-commit-uv pre-commit run --all-files
Acknowledgments
Based on pchalasani/claude-code-tools.
License
MIT License - see LICENSE for details.
{
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
"name": "claude-hooks",
"description": "Safety and automation hooks for Claude Code",
"owner": {
"name": "Stephen Price",
"email": "steeef@gmail.com"
},
"plugins": [
{
"name": "command-safety",
"description": "Blocks dangerous commands (rm, kubectl delete, terraform destroy)",
"version": "1.1.0",
"source": "./plugins/command-safety",
"category": "security"
},
{
"name": "git-hooks",
"description": "Enforces safe git workflows (no commits to main, branch naming)",
"version": "1.2.2",
"source": "./plugins/git-hooks",
"category": "development"
},
{
"name": "file-protection",
"description": "Warns on large files and large reads",
"version": "1.7.3",
"source": "./plugins/file-protection",
"category": "security"
},
{
"name": "notifications",
"description": "Desktop notifications on macOS",
"version": "1.0.2",
"source": "./plugins/notifications",
"category": "productivity"
},
{
"name": "env-protection",
"description": "Blocks access to .env files, preventing accidental secret exposure",
"version": "1.0.1",
"source": "./plugins/env-protection",
"category": "security"
},
{
"name": "git-worktree-hooks",
"description": "Bare-container worktrees under ~/wt (clone-on-demand, env-file copy)",
"version": "1.7.2",
"source": "./plugins/git-worktree-hooks",
"category": "development"
},
{
"name": "gh-formatting",
"description": "Rejoins hard-wrapped PR body prose before gh submits it",
"version": "1.1.0",
"source": "./plugins/gh-formatting",
"category": "productivity"
},
{
"name": "gh-workflow",
"description": "Requires --draft on gh pr create, asks for confirmation on gh pr ready",
"version": "1.0.0",
"source": "./plugins/gh-workflow",
"category": "development"
},
{
"name": "comment-style",
"description": "Blocks multi-line or >7-word comments in new/edited code",
"version": "1.0.0",
"source": "./plugins/comment-style",
"category": "quality"
}
]
}Facts
- Kind
- Marketplace
- Repo
- steeef/claude-hooks
- Group
- Uncategorized
- Stars
- 0
- Marketplace name
- claude-hooks
- Owner
- Stephen Price
- License
- MIT
- Language
- Python
- Created
- 2026-01-08
- Last push
- 2026-10-02
- Plugins
- 9
Next on this shelf
- 2520StevieClear/claude-mem-privacy-forkStevieClear/claude-mem-privacy-fork0
- 2521stickystyle/regentstickystyle/regent0
- 2522StyleList94/claude-pluginsStyleList94/agent-plugins0
- 2523sultano/claude-code-marketplacesultano/claude-code-marketplace0
- 2524Sunalamye/WebViewBridgeSunalamye/WebViewBridge0
- 2525surfertas/claude-react-rtksurfertas/claude-react-rtk0