Agent skill

Hook Creator

by softspark in softspark/ai-toolkit

Create new Claude Code lifecycle hook (PreToolUse/PostToolUse/Stop/SessionStart) with bash + hooks.json.

Apache-2.0Auto-check: notesAgent Workflows

Install Hook Creator

skills CLI
$ npx skills add softspark/ai-toolkit --skill hook-creator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install softspark/ai-toolkit hook-creator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/app/skills/hook-creator .claude/skills/hook-creator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hook-creator
GitHub stars
179
Token cost
~3.1k tokens
SKILL.md length
1,400 words
Files
1
Skills in repo
112
Repo updated
First seen
Licence
Apache-2.0

At a glance

Create new Claude Code lifecycle hook (PreToolUse/PostToolUse/Stop/SessionStart) with bash + hooks.json.

  • Works in 6 steps: Capture intent -- ask: what should the… → Select event -- pick from the Supported… → Define matcher -- tool name for… → …
  • Agent Workflows work in your project
  • SKILL.md covers Supported Hook Events, Hook Handler Types, Workflow and Hook Script Conventions, plus 6 more sections
  • Calls bash and git

What it does

Hook Creator is an agent skill from softspark/ai-toolkit. Create new Claude Code lifecycle hook (PreToolUse/PostToolUse/Stop/SessionStart) with bash + hooks.json. Triggers: create hook, lifecycle hook, PreToolUse, PostToolUse, hook event.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows. It works with Bash. The repository describes itself as: Professional-grade AI coding toolkit: 94 skills, 44 agents, multi-platform (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Antigravity, Codex CLI… The licence is Apache-2.0.

When your agent uses it

  • Agent Workflows work in your project

Example prompts

  • “/hook-creator”

Requirements

  • Python 3
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, Grep, Glob

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Capture intent -- ask: what should the hook do? Which lifecycle event?
  2. Select event -- pick from the Supported Hook Events table above
  3. Define matcher -- tool name for PreToolUse/PostToolUse, empty for global
  4. Write script -- create app/hooks/{event-name-kebab}.sh
  5. Register in hooks.json -- add entry to app/hooks.json
  6. Validate -- run scripts/validate.py

What it can do on your machine

Read from SKILL.md and the folder at commit d64db2b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • Grep
    • Glob

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bash
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • code.claude.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Hook Creator loads about 3.1k tokens when it runs. Until then it costs about 48 tokens; SKILL.md has 1,400 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~48
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, Grep, Glob

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from softspark/ai-toolkit at commit d64db2b, republished under its Apache-2.0 licence (© softspark). 1,400 words, ~3,108 tokens.

Download SKILL.mdSave it as .claude/skills/hook-creator/SKILL.md (or your agent's skills folder).
name
hook-creator
description
Create new Claude Code lifecycle hook (PreToolUse/PostToolUse/Stop/SessionStart) with bash + hooks.json. Triggers: create hook, lifecycle hook, PreToolUse, PostToolUse, hook event.
allowed-tools
Read, Write, Edit, Bash, Grep, Glob
effort
high
disable-model-invocation
true
argument-hint
[hook event or description]

Hook Creator

$ARGUMENTS

Create a new Claude Code hook following ai-toolkit conventions.

Supported Hook Events

Core lifecycle
EventFires WhenMatcherTypical Use
SessionStartSession begins, resumes, or clearsstartup|resume|clearContext injection, rules reminder
SessionEndSession is closinganyFlush logs, save transcripts
UserPromptSubmitUser submits a promptanyPrompt governance, usage tracking
NotificationClaude sends a notificationanyOS alerts, Slack pings
MessageDisplayAssistant message text streams in completed-line batchesnoneReturn displayContent to replace the rendered batch without changing the transcript
Tool lifecycle
EventFires WhenMatcherTypical Use
PreToolUseBefore a tool executestool name (e.g. Bash) or if: ruleSafety guards, validation, "defer" for headless
PostToolUseAfter a tool executestool nameFeedback loops, logging, format-on-save
PostToolUseFailureAfter a tool failstool nameFailure telemetry, recovery hints
PostToolBatchAfter a batch of tool calls completesanyBatch summaries, aggregate validation
Turn lifecycle
EventFires WhenMatcherTypical Use
StopClaude finishes respondinganyQuality checks, session save
StopFailureTurn ends due to an API error (rate limit, auth)anyAlerting, fallback behavior
UserPromptExpansionClaude expands or rewrites a submitted promptanyPrompt policy and context shaping
Subagent lifecycle
EventFires WhenMatcherTypical Use
SubagentStartSubagent launchesanyObservability
SubagentStopSubagent completesanyResult validation
Compaction
EventFires WhenMatcherTypical Use
PreCompactBefore context compaction; can block with exit 2 or {"decision":"block"}anyContext preservation
PostCompactAfter compaction completesanyRe-inject state that was summarized away
Model changes
EventFires WhenMatcherTypical Use
PreModelSwitchBefore a user/client model switch; exit 2 or decision: "block" cancels itcanonical target modelModel policy; requires Claude Code 2.1.251+
PostModelSwitchAfter the session model changes; cannot blockcanonical target modelModel-specific context; requires Claude Code 2.1.251+
Permissions & elicitation
EventFires WhenMatcherTypical Use
PermissionRequestTool awaiting permission; can return updatedInputanyHeadless approval flows
PermissionDeniedAuto-mode classifier denied a tool call; return {retry: true} to allow retryanyCoach the model, log denials
ElicitationMCP elicitation/create request arrivesanyIntercept / override MCP UI prompts
ElicitationResultElicitation response ready to be sent backanyValidate / transform elicitation replies
Agent Teams
EventFires WhenMatcherTypical Use
TaskCreatedNew task registered via TaskCreateanyAudit, assignment routing
TaskCompletedAgent Teams task finishedanyLint, type check, notify
TeammateIdleAgent Teams member idleanyCompleteness reminder
Worktrees & environment
EventFires WhenMatcherTypical Use
WorktreeCreateWorktree is being created; type: "http" can return hookSpecificOutput.worktreePathanyProvision worktree dirs
WorktreeRemoveWorktree is being removedanyCleanup
CwdChangedWorking directory changes during a sessionanyReactive env management (e.g., direnv)
DirectoryAddedA working directory was added with /add-dir or SDK register_repo_root; runs asynchronously after the add and cannot block itslash_command|register_repo_rootPrepare a newly added repository
FileChangedTracked file is modified on diskanyRe-lint, reload config
ConfigChangeSettings / config file changedanyRe-validate, warn on drift
Setup / bootstrap
EventFires WhenMatcherTypical Use
SetupFirst-run / initializationanyProject bootstrap
InstructionsLoadedCLAUDE.md or .claude/rules/*.md loaded into contextload reasonVerify presence of mandatory rules

Hook Handler Types

Claude Code supports five handler type values in hooks.json:

TypePurposeRequired fields
commandRun a shell script / binarycommand (path + args)
httpCall a local or remote HTTP endpointurl
promptInject a prompt to the fast inline model and use its verdictprompt
agentSpawn an experimental tool-using subagent to evaluate the eventprompt
mcp_toolInvoke an already-connected MCP toolserver, tool; optional input object

command remains the default and ai-toolkit's hook entries all use it. The other types are documented here so you can author them by hand when needed.

PermissionRequest accepts prompt hooks but skips agent hooks. Both model-switch events accept command, http, and mcp_tool only. MCP tool hooks use input for arguments; arguments is not a supported handler field. MCP hooks on SessionStart cannot run at launch before servers connect, and Setup always skips them. Use command hooks for required initialization.

Source: https://code.claude.com/docs/en/hooks (reviewed 2026-09-23).

Workflow

  1. Capture intent -- ask: what should the hook do? Which lifecycle event?
  2. Select event -- pick from the Supported Hook Events table above
  3. Define matcher -- tool name for PreToolUse/PostToolUse, empty for global
  4. Write script -- create app/hooks/{event-name-kebab}.sh
  5. Register in hooks.json -- add entry to app/hooks.json
  6. Validate -- run scripts/validate.py

Hook Script Conventions

  • Location: app/hooks/{event-name-kebab}.sh
  • Shebang: #!/bin/bash
  • Header comment: script name, purpose, event, matcher
  • Respect TOOLKIT_HOOK_PROFILE env var (minimal = skip non-essential hooks)
  • Exit 0 on success; use exit 2 for a blocking verdict on supported events. Other non-zero codes generally report an error without blocking.
  • Output goes to Claude's context as plain text
  • No external dependencies -- bash builtins and coreutils only
  • Keep output concise -- hooks fire frequently
Show full SKILL.md (626 more words)Show less

hooks.json Entry Format

json
{
    "_source": "ai-toolkit",
    "matcher": "",
    "hooks": [
        {
            "type": "command",
            "command": "\"$HOME/.softspark/ai-toolkit/hooks/{script-name}.sh\""
        }
    ]
}

Required fields:

  • _source: always "ai-toolkit" (used by merge/strip logic)
  • matcher: tool name or regex for Pre/PostToolUse, empty string for global events
  • hooks[].type: "command", "http", "prompt", "agent", or "mcp_tool" (ai-toolkit uses "command")
  • hooks[].command: path to script using $HOME/.softspark/ai-toolkit/hooks/ prefix (for type: command)

Optional fields (read from Claude Code docs, not emitted by ai-toolkit by default):

Common to every handler type:

  • hooks[].if: one permission-rule filter (e.g. "Bash(git push*)"); evaluated only for tool events
  • hooks[].timeout: seconds to wait before canceling the handler (type and event defaults apply if omitted)
  • hooks[].statusMessage: short message surfaced in the UI while the hook runs
  • hooks[].once: run once per session; only honored in skill frontmatter and ignored in settings files or agent frontmatter

Command-handler fields:

  • hooks[].args: argument vector for exec form. Prefer exec form when a command uses ${CLAUDE_PROJECT_DIR}, ${CLAUDE_PLUGIN_ROOT}, or ${CLAUDE_PLUGIN_DATA} path placeholders
  • hooks[].async: run in the background without blocking; background hooks cannot return decisions
  • hooks[].asyncRewake: run in the background and wake Claude on exit code 2; implies async
  • hooks[].shell: choose bash or powershell for shell form; ignored when args selects exec form

Prompt and agent handlers both require hooks[].prompt; type: agent does not accept an agent name field. Agent handlers are experimental, so prefer command for production enforcement.

MessageDisplay has no matcher, runs once per rendered batch in interactive sessions, and defaults to a 10-second timeout. Its displayContent output changes only the screen text; Claude and the transcript retain the original response. DirectoryAdded is always asynchronous and non-blocking regardless of the handler configuration.

Script Template

bash
#!/bin/bash
# {script-name}.sh — {One-line purpose}.
#
# Fires on: {EventName}
# Matcher: {matcher or "all"}
# Skipped when TOOLKIT_HOOK_PROFILE=minimal.

PROFILE="${TOOLKIT_HOOK_PROFILE:-standard}"
[ "$PROFILE" = "minimal" ] && exit 0

# --- Hook logic here ---

exit 0

Rules

  • MUST use one script per hook entry — no inline multi-line commands inside hooks.json
  • MUST keep Pre* hooks fast and deterministic — they gate every matching tool call, slow hooks throttle the whole agent
  • NEVER write secrets, tokens, or credentials to stdout — hook output is injected into LLM context and can be extracted
  • NEVER exit non-zero from a Post* or Stop hook unless you intend to block further processing; exit 0 is the safe default
  • CRITICAL: respect the TOOLKIT_HOOK_PROFILE env var. Profile minimal must be a no-op for non-essential hooks.
  • MANDATORY: test the script standalone (bash app/hooks/{name}.sh) before adding it to hooks.json

Gotchas

  • PreToolUse hooks that exit non-zero block the tool call. A slow or flaky hook (network call, lock contention) becomes a DoS against Claude's own workflow. Keep Pre hooks to pure-bash checks of local state.
  • Hook output (stdout) is injected verbatim into the model's context. A hook that runs git log --all prints hundreds of lines the model then has to wade through — be surgical, print only what matters.
  • The path in hooks.json is resolved relative to the user's machine, not the ai-toolkit repo. Use $HOME/.softspark/ai-toolkit/hooks/<name>.sh as the canonical location (installer symlinks there).
  • SessionStart with matcher startup|compact fires on both fresh starts AND after context compaction. Hooks that assume "new session" will mis-fire after compaction — check for explicit context markers if the distinction matters.
  • Bash hooks on Windows (without WSL) will not run. If the hook must work cross-platform, wrap it in a Node or Python script and call from the bash stub — or flag the hook as posix-only in the description.

Validation Checklist

After creating the hook:

  • Script exists in app/hooks/ and is executable (chmod +x)
  • Entry added to app/hooks.json with _source: "ai-toolkit"
  • Event name matches a supported lifecycle event
  • scripts/validate.py passes
  • Script runs without errors: bash app/hooks/{name}.sh
  • Hook count in README.md and docs updated if needed

When NOT to Use

  • For a skill (slash command) — use /skill-creator
  • For an agent definition — use /agent-creator
  • For a git pre-commit hook (not a Claude Code hook) — use /git-mastery or scripts/install_git_hooks.py
  • For one-off automation that is not tied to a Claude Code event — use a plain shell script outside the toolkit
  • To modify an existing toolkit hook — edit the file directly; this skill is create-only

© softspark, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in app/skills/hook-creator of softspark/ai-toolkit.

Open the folder on GitHubat commit d64db2b

Compare with similar skills

Hook Creator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Hook Creator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Hook Creator this skillsoftspark/ai-toolkit179—~3.1kAutomated safety check: NotesApache-2.0
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k11 repos~4.1kAutomated safety check: NotesApache-2.0
Plugin Settings Patternanthropics/claude-plugins-official38k7 repos~3kAutomated safety check: PassApache-2.0
Neat-Freak Knowledge CloseoutKKKKhazix/khazix-skills21k—~1.9kAutomated safety check: PassMIT
Crush Configurationcharmbracelet/crush29k—~3.7kAutomated safety check: PassCustom licence
Kimi Code DelegationCherryHQ/cherry-studio52k1 repos~504Automated safety check: PassAGPL-3.0

Similar skills

  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 11 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Plugin Settings Pattern

    anthropics/claude-plugins-official

    Official

    Shows how Claude Code plugins keep per-project settings and state in .claude/plugin-name.local.md files with YAML frontmatter and a markdown body.

    38k GitHub starsUsed in 7 repos~3k tokens
    Agent WorkflowsAuto-check passed
  • Neat-Freak Knowledge Closeout

    KKKKhazix/khazix-skills

    Brings project docs, agent rule files, authorized memory and leftover workspace files back in line with what the code and runtime actually do at the end of a work session.

    21k GitHub stars~1.9k tokensUpdated 6 days ago
    Agent WorkflowsAuto-check passed
  • Crush Configuration

    charmbracelet/crush

    Explains how to configure the Crush coding agent with crushrc or crush.json, covering providers, models, LSPs, MCP servers, hooks, permissions and config precedence.

    29k GitHub stars~3.7k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Kimi Code Delegation

    CherryHQ/cherry-studio

    Delegates one bounded repository task to Kimi Code in non-interactive prompt mode and reads back the final result from its JSON event stream.

    52k GitHub starsUsed in 1 repo~504 tokens
    Agent WorkflowsAuto-check passed
  • Official

    Designs and verifies a deterministic grader that measures whether a GitHub Agentic Workflow run reached its real-world or repository outcome.

    5.4k GitHub stars~6.8k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from softspark/ai-toolkit

All 112 skills in this repo
  • Prepare Test Env

    softspark/ai-toolkit

    Prepare or verify a project QA environment with source identity, readiness, browser access, evidence paths and owned cleanup.

    179 GitHub stars~1.8k tokensUpdated yesterday
    Auto-check: notes
  • A11y Validate

    softspark/ai-toolkit

    Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.8k tokensUpdated yesterday
    Auto-check: notes
  • Analyze

    softspark/ai-toolkit

    Analyzes code quality, complexity, patterns across codebase.

    179 GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Autonomous Dev

    softspark/ai-toolkit

    Drives a brief, specification, issue or existing PR through implementation, review, tests and QA to a ready PR.

    179 GitHub stars~2.6k tokensUpdated yesterday
    Auto-check: notes
  • Brand Voice

    softspark/ai-toolkit

    Direct technical voice for docs, README, user-facing text. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • CI

    softspark/ai-toolkit

    Detect/generate/debug CI pipeline config (GitHub Actions, GitLab CI).

    179 GitHub stars~1.1k tokensUpdated yesterday
    Auto-check: notes

Works with

Categories

Questions about Hook Creator

What does Hook Creator do?

Create new Claude Code lifecycle hook (PreToolUse/PostToolUse/Stop/SessionStart) with bash + hooks.json. Hook Creator is an agent skill from softspark/ai-toolkit.json.

When should I use Hook Creator?

Hook Creator fits situations like: agent Workflows work in your project.

How do I install Hook Creator in Claude Code?

Run `npx skills add softspark/ai-toolkit --skill hook-creator -a claude-code`. Or copy the skill folder (app/skills/hook-creator in softspark/ai-toolkit) into .claude/skills/hook-creator in your project. Claude Code loads it when a task matches its description.

How do I install Hook Creator in Codex?

Run `npx skills add softspark/ai-toolkit --skill hook-creator -a codex`. Or copy the skill folder (app/skills/hook-creator in softspark/ai-toolkit) into .agents/skills/hook-creator in your project. Codex loads it when a task matches its description.

Can I use Hook Creator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add softspark/ai-toolkit --skill hook-creator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hook-creator, .gemini/skills/hook-creator, .github/skills/hook-creator and .opencode/skills/hook-creator in your project.

What does Hook Creator need to run?

Going by SKILL.md and its folder, Hook Creator needs the command-line tools its instructions call (bash and git). Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, Grep, Glob.

Does Hook Creator access the network?

SKILL.md names 1 domain. As links in the text: code.claude.com. This is read from the text; nothing was executed.

Is Hook Creator safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Hook Creator use?

Hook Creator is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Hook Creator use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Hook Creator?

Skills that share tags, products or a category with Hook Creator: Hook Development for Claude Code Plugins (anthropics/claude-plugins-official, 38k stars), Plugin Settings Pattern (anthropics/claude-plugins-official, 38k stars), Neat-Freak Knowledge Closeout (KKKKhazix/khazix-skills, 21k stars) and Crush Configuration (charmbracelet/crush, 29k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Hook Creator?

softspark (a GitHub user) maintains it in softspark/ai-toolkit, which has 179 GitHub stars. The repository holds 112 skills in this directory. The repository was last updated on October 7, 2026.

Source: softspark/ai-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.