create-hook
Skill0 starsChanged 18 days agoMITView on GitHub
Create, wire up and test agent hooks: Claude Code settings.json or plugin hooks, Cursor hooks.json, or a shared hooks/ tree. Use when asked to run something automatically on an agent event, block or rewrite a tool call, format after edits, inject session context, or debug a hook that never fires.
- Deletes or force-pushes
- Commits and pushes
17 other projects use a version of this.
Adopted by
Most recently taken up by
- MacHatter1/bb-plugin-hookstheir own version, first seen Oct 25, 2026
- tony-hoang-ai-automation/mkt-skillstheir own version, first seen Oct 25, 2026
- ArangoGutierrez/claude-toolkittheir own version, first seen Oct 15, 2026
- 0mlkrizzz655335v/claude-skills-zhtheir own version, first seen Oct 15, 2026
- microsoft/vscodetheir own version, first seen Oct 13, 2026
- leishifu666/skillstheir own version, first seen Oct 9, 2026
Used with
Projects with it also use review-bugbot, update-cli-config and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
0mlkrizzz655335vSkillreview-bugbot
缺陷导向代码审查。用 Bugbot 子代理找 bug。
Also in 5 projects that use this
PandelisZSkillupdate-cli-config
View and modify Cursor CLI configuration settings in ~/.cursor/cli-config.json. Use when the user wants to change CLI settings, configure permissions, switch approval mode, enable vim mode, toggle display options, configure sandbox, or manage any CLI preferences.
Also in 7 projects that use this
32103210Skillmigrate-to-skills
Convert 'Applied intelligently' Cursor rules (.cursor/rules/*.mdc) and slash commands (.cursor/commands/*.md) to Agent Skills format (.cursor/skills/). Use when you want to migrate rules or commands to skills, convert .mdc rules to SKILL.md format, or consolidate commands into the skills directory.
Also in 7 projects that use this
32103210Skillupdate-cursor-settings
Modify Cursor/VSCode user settings in settings.json. Use when you want to change editor settings, preferences, configuration, themes, font size, tab size, format on save, auto save, keybindings, or any settings.json values.
Also in 7 projects that use this
0mlkrizzz655335vSkillorigin
origin CLI 管理。安装、登录、更新、修复 origin.cursor.com 的 CLI。"disabled-environments:
Also in 3 projects that use this
Tsumugii24Skillsplit-to-prs
Split current work into small reviewable PRs. Use when the user asks to split a chat, set of changes, branch, or PR.
Also in 7 projects that use this
- +1 more from 32103210
- +2 more from 0mlkrizzz655335v
Other versions17 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 17
- microsoft/vscode★ 195ksame name
- am-will/codex-skills★ 1ksame name
- zhuangwenhui/CodingSkills★ 82same name
- KhaledSaeed18/dotclaude★ 5same name
- ArangoGutierrez/claude-toolkit★ 4same name
- MacHatter1/bb-plugin-hooks★ 4same name
- tony-hoang-ai-automation/mkt-skills★ 4same name
- 0mlkrizzz655335v/claude-skills-zh★ 2same name
- Iteam-company/claude-code-boilerplates★ 2same name
- Goodnessmbakara/codex-skills★ 1same name
7 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository57 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/comments.mdcCursor rule
- .cursor/rules/commit-messages.mdcCursor rule
- .cursor/rules/git-workflow.mdcCursor rule
- .cursor/rules/manage-stack.mdcCursor rule
- .cursor/rules/no-worktrees.mdcCursor rule
- manage-stackSkill
- convert-as-skillSkill
- create-agentSkill
- create-agents-mdSkill
- create-commandSkill
- create-ruleSkill
- create-skillSkill
- retrospectiveSkill
- super-architectureSkill
- super-cachingSkill
- super-elixirSkill
- super-nodejsSkill
- super-protobufSkill
- super-tech-blueprintSkill
- atomic-semantic-commitSkill
- code-reviewSkill
- create-bruno-collectionSkill
- create-documentationSkill
- create-ticketsSkill
- ready-specSkill
- write-adrSkill
- write-changelogSkill
- write-mr-descriptionSkill
- write-planSkill
- write-postmortemSkill
- write-runbookSkill
- noslopSkill
- output-saversSkill
- safe-refactorSkill
- tddSkill
- verifySkill
- get-movingSkill
- later-listSkill
- standupSkill
- challenge-meSkill
- codebase-learnerSkill
- researchSkill
- second-opinionSkill
- traceSkill
- color-kitSkill
- design-system-kitSkill
- diagramSkill
- infographicSkill
- product-polish-workflowSkill
- prototype-wireframeSkill
- ui-ux-kitSkill
- evidenceSkill
- find-skillsSkill
- handoffSkill
- rumblingSkill
- use-levistackSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 34
Portable: Prefer Node over shell, and verify every binary the script calls exists on the hook's PATH.
- Distinctive: line 53
If a repo already has hooks, extend its setup and keep unrelated entries.
- Distinctive: line 57
Try it by hand: before the harness does:
- Very specific: line 80
Add a Stop hook that blocks without checking stop_hook_active.
- Distinctive: line 81
Put secrets or personal paths in a shared hook, or call the network in a hot-path hook.
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a hook
A hook is a script or check the harness runs on an agent event. The harness runs it, not the model, so it happens every time. Use a hook to observe, block, rewrite or add context. If the guidance only needs to be remembered, write a rule instead.
Principles
- Hooks are for what must happen every time. "Always format after an edit", "never run
rm -rf /". Preferences belong in rules. - Narrowest event, narrowest matcher.
PreToolUseonBashis better than a hook on every event. Filter in the script when a matcher gets tricky. - Fail open unless it is a deliberate blocker. A crash, a timeout or unexpected input should let the action proceed. Reserve blocking (
deny, exit 2,failClosed) for a rule you would defend. - Fast and quiet. A hook on the hot path runs on every call. Set a short
timeout, do no network work, and keep stdout to the JSON the harness expects. - Deterministic over clever. A script beats a
prompthook when the result must be auditable. Use aprompthook only for policy that is easier to describe than to code. - Portable. Prefer Node over shell, and verify every binary the script calls exists on the hook's
PATH. - Opt-in for personal tooling. A hook shared through a plugin or repo affects everyone who installs it. Keep it conservative, or gate it behind a flag file.
Steps
- Gather requirements. Infer from the conversation; ask only for what is missing:
- Trigger: which event, and which tool, command or file it should react to.
- Behavior: audit, block, ask, rewrite input, inject context, or continue a workflow.
- Scope: this user, this project, or a shared plugin or catalog.
- Failure: fail open or closed.
Pick the target.
Target Config Reference Claude Code, project or user .claude/settings.json,~/.claude/settings.jsonclaude-code.md Claude Code plugin hooks/hooks.jsonclaude-code.md Cursor .cursor/hooks.json,~/.cursor/hooks.jsoncursor.md A shared hooks tree ( hooks/<name>.mjswith a launcher)the tree's own convention its hooks/README.mdIf a repo already has hooks, extend its setup and keep unrelated entries.
- Choose the event from the table in the reference for your target. Check what that event can return; not every event can block.
- Write the script (Node by default). Read the JSON from stdin, decide, print only the output JSON, and exit 0. Block with the event's documented decision or with exit 2, never with prose on stdout. Ambiguous input returns allow.
- Wire it up with the smallest matcher that works. Start with no matcher or a simple one and tighten after it fires. Quote path placeholders (
"$CLAUDE_PROJECT_DIR"), because paths contain spaces. Try it by hand before the harness does:
node scripts/try-hook.mjs --event PreToolUse --tool Bash --command "git push --force" --expect ask -- node .claude/hooks/guard.mjsIt builds a Claude Code payload, runs the command, and reports the exit code, the decision and any invalid JSON.
--json '<payload>'sends a raw payload for other events or for Cursor. Run it for one input that should trigger and one that should pass. A hook behind an opt-in flag file reports allow until the flag exists.- Trigger it for real in a session and read the harness's hook log (
claude --debug-file <path>, or Cursor's Hooks tab). Confirm the matcher matched. - Check the repo's gates. In a catalog with its own hook tests or sync step, add a test and run them.
Output at a glance
| Goal | Claude Code | Cursor |
| Allow | exit 0, no output | {"permission":"allow"} |
| Ask the user | PreToolUse permissionDecision: "ask" | {"permission":"ask"} |
| Block | permissionDecision: "deny" or exit 2 with a stderr reason | {"permission":"deny"} or exit 2 |
| Add context | hookSpecificOutput.additionalContext | additional_context (post events) |
Do not
- Print anything but JSON on stdout (a shell profile banner also breaks it).
- Block on an ambiguous or unparseable input.
- Add a
Stophook that blocks without checkingstop_hook_active; it can loop. - Put secrets or personal paths in a shared hook, or call the network in a hot-path hook.
- Overwrite a user's existing
settings.jsonhooks; merge.
Related skills
create-rule: a request is enough and nothing must be enforced.create-command: the action should run on /name, not on an event.create-skill: the automation needs a procedure the model follows.create-agent: the event should start a delegated job.
Done when
- The event, matcher and handler are the narrowest that work.
try-hook.mjsshows the expected decision for one triggering input and one passing input.- It fired in a real session, and the log shows the expected result.
- It fails open on bad input, unless blocking is its stated purpose.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

