install-hook

install-hook is a command for Claude Code from alirezarezvani/claude-code-skill-factory. It costs 0 tokens per session (1,753 once invoked), scanned D, original, MIT.

A command that adds a generated hook to Claude Code's settings. A hook is an automatic action linked to an event, and the settings can apply to one project or all projects.

In plain words
What is it for?
Use it to install a hook from a hook.json file at user level or project level.
Why use it?
It installs the hook safely while checking its format, preserving existing settings, and creating a backup.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/alirezarezvani/claude-code-skill-factory/install-hook
Clone the repo
git clone --depth 1 https://github.com/alirezarezvani/claude-code-skill-factory

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for install-hook

README.md
[![agentmods](https://agentmods.dev/badge/commands/alirezarezvani/claude-code-skill-factory/install-hook.svg)](https://agentmods.dev/commands/alirezarezvani/claude-code-skill-factory/install-hook)
Your own site
<a href="https://agentmods.dev/commands/alirezarezvani/claude-code-skill-factory/install-hook"><img src="https://agentmods.dev/badge/commands/alirezarezvani/claude-code-skill-factory/install-hook.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,753 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01753
Opus 5 $0.00000 $0.00877
Sonnet 5 $0.00000 $0.00351
Haiku 4.5 $0.00000 $0.00175

Measured 4d ago against content hash 7b5b0ec6e0a1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

install-hook scanned grade D with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- **User-level** (`~/.claude/settings.json`) - Applies to all projects

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- ✅ No destructive operations (rm -rf, git push --force, etc.)
.claude/commands/install-hook.md · 340 lines

How it starts

The opening of the file, as written. The whole thing — 340 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/install-hook - Install Generated Hook to Settings

Install a generated hook to Claude Code settings (user-level or project-level).


Usage

/install-hook generated-hooks/my-hook
/install-hook generated-hooks/my-hook user
/install-hook generated-hooks/my-hook project

What This Command Does

Installs hook.json configuration to:

  • User-level (~/.claude/settings.json) - Applies to all projects
  • Project-level (.claude/settings.json) - Current project only

Installation process:

  1. ✅ Validates hook.json structure
  2. ✅ Checks for safety violations
  3. ✅ Backs up existing settings.json
  4. ✅ Merges with existing hooks (preserves other settings)
  5. ✅ Saves and displays confirmation

Examples

Install User-Level Hook (All Projects)

/install-hook generated-hooks/auto-format-python user

Performs:

  1. Reads generated-hooks/auto-format-python/hook.json
  2. Validates JSON structure and safety
  3. Creates backup: ~/.claude/settings.json.backup
  4. Opens ~/.claude/settings.json
  5. Adds hook to appropriate event type section
  6. Saves changes

Output:

Installing hook: auto-format-python
Location: User-level (~/.claude/settings.json)

✅ Hook validation PASSED
   - JSON structure: Valid
   - Safety checks: All passed
   - Event type: PostToolUse

Creating backup...
✅ Backup created: ~/.claude/settings.json.backup

Installing to PostToolUse hooks...
✅ Hook installed successfully!

Event type: PostToolUse
Matcher: tool_names=["Write", "Edit"], paths=["**/*.py"]
Command: Auto-format Python with Black

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Next steps:
1. Restart Claude Code (required)
2. Test by editing a .py file
3. Verify hook runs automatically

To test:
claude --continue
> Edit any Python file
> Check if Black formatting runs

Install Project-Level Hook (Current Project Only)

/install-hook generated-hooks/test-runner project

Installs to: .claude/settings.json (current project)

Output:

Installing hook: test-runner
Location: Project-level (.claude/settings.json)

✅ Hook validation PASSED
✅ Backup created: .claude/settings.json.backup
✅ Hook installed successfully!

Event type: SubagentStop
Matcher: (empty - runs for all agents)
Command: Run pytest after agent completes

This hook will only run in this project.

Next steps:
1. Restart Claude Code
2. Run any Task agent
3. Hook will automatically run tests when agent completes

Read the full file on GitHub · 340 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 340 lines · 0 tokens per session scan D 7b5b0ec6e0a1

Subscribe to this mod's changes

install-hook is a command published in the GitHub repository alirezarezvani/claude-code-skill-factory (855 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,753 tokens. A static security scan graded it D with 2 findings (reads agent configuration directories, recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.