create-hook

A hook creator makes an automation that runs when a Claude Code event occurs. Events include session start, user input, before or after a tool runs, context compaction, and session end.

In plain words
What is it for?
Use it to create a Python or Bash hook with a trigger and tool matcher, then register it in the plugin's hooks configuration.
Why use it?
It removes the manual work of writing the script and registration needed for an event-based automation.

Command

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/primeline-ai/evolving-lite/create-hook
Clone the repo
git clone --depth 1 https://github.com/primeline-ai/evolving-lite
Per session 6 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 433 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00006 $0.00433
Opus 5 $0.00003 $0.00217
Sonnet 5 $0.00001 $0.00087
Haiku 4.5 $0.00001 $0.00043

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

Security

Grade A, and why

create-hook scanned grade A with 0 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 2d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/create-hook.md · 57 lines

What it actually says

Create a new hook that runs automatically on Claude Code events.

Input: $ARGUMENTS

If empty: "What should the hook do? Which event should trigger it?"

Available Events

Event When it fires Common use
SessionStart Session begins Init, health checks
UserPromptSubmit User sends a message Input analysis, routing
PreToolUse Before any tool runs Validation, security
PostToolUse After any tool runs Logging, tracking
PreCompact Before context compaction Save important data
Stop Session ends Cleanup, summaries

Process

  1. Name: kebab-case (e.g., my-validator)
  2. Event: Which event triggers it
  3. Matcher: Which tools/patterns (e.g., "Bash" for PreToolUse, ".*" for all)
  4. Language: Python or Bash
  5. Write script to ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/{name}.py or .sh
  6. Register in ${CLAUDE_PLUGIN_ROOT}/hooks/hooks.json

Template (Python)

#!/usr/bin/env python3
import json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "lib"))
from common import PLUGIN_ROOT, write_sentinel, read_hook_input

def main():
    hook_input = read_hook_input()
    # Your logic here
    write_sentinel("{name}", "ok")
    sys.exit(0)

if __name__ == "__main__":
    main()

Important

  • Every hook MUST call write_sentinel() for health monitoring
  • Keep hooks under 200ms to avoid perceptible lag
  • Use sys.exit(0) for success, sys.exit(2) to block a tool call
  • Read input from stdin (JSON from Claude Code)
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. 2d ago First seen · 57 lines · 6 tokens per session scan A b4c45b7a6a43

Subscribe to this mod's changes

create-hook is a command published in the GitHub repository primeline-ai/evolving-lite (48 stars, last pushed 15d ago), licensed MIT. It adds 6 tokens to every session and 433 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.