evgeniy-mikhailove/rlm-claude-code-os/hook-automation-patterns
Claude Code and agent skill by evgeniy-mikhailove/rlm-claude-code-os
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Claude Code hook patterns for automatic formatting, security scanning, usage measurement, and permission routing. Use when setting up automated behaviors triggered before/after tool use without manual invocation. Covers PreToolUse, PostToolUse, and session lifecycle hooks with ready-to-use JSON configs.
Install
npx vskill@latest install evgeniy-mikhailove/rlm-claude-code-os/hook-automation-patternsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as evgeniy-mikhailove/rlm-claude-code-os/hook-automation-patterns.
Hook Automation Patterns
Hooks run shell commands automatically on Claude Code events. Zero manual intervention.
Hook Lifecycle
| Event | When it fires | Best used for | |
|---|---|---|---|
PreToolUse | Before any tool call | Validation, permission checks, logging | |
PostToolUse | After any tool call | Formatting, security scan, metrics | |
SessionStart | Session begins | Load context, restore state | |
SessionEnd | Session ends | Compress memory, save state | |
Stop | Agent task completes | Final checks, notifications |
Pattern 1: Auto-Format on Save
Prevent CI failures from formatting issues. Fires after every Edit/Write.
Pattern 2: Security Scanner
Catch secrets and vulnerabilities after every file change.
Pattern 3: On-Demand Safety Hooks (Slash Commands)
Pattern 4: Permission Routing
Route expensive/risky Bash operations through an approval gate.
Pattern 5: Skill Usage Measurement
Track which skills fire too rarely (undertriggering) or too often.
Pattern 6: Smart Commit on Edit
Auto-commit file changes in git repos with a generated message.
Hook Environment Variables
| Variable | Content | |
|---|---|---|
$CLAUDE_TOOL_NAME | Tool that fired (Edit, Bash, etc.) | |
$CLAUDE_TOOL_FILE | File path for file-based tools | |
$CLAUDE_TOOL_INPUT | Raw input to the tool | |
$CLAUDE_SESSION_ID | Current session ID | |
$CLAUDE_PROJECT_DIR | Project root directory |
Config Location
| Scope | File | |
|---|---|---|
| Global (all projects) | ~/.claude/settings.local.json | |
| Project-specific | .claude/settings.json in project root |
Project settings override global. Both use the same JSON schema.
Anti-Patterns
- Hooks that fail loudly and block the main agent flow — always add
|| true - Heavy operations in PreToolUse — adds latency to every tool call
- Hooks that modify the file they're scanning — creates loop risk
- Missing
2>/dev/null— stderr from hooks can confuse Claude's output parsing
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/hook-automation-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/evgeniy-mikhailove/rlm-claude-code-os/hook-automation-patterns)