create-hook

Create Cursor hooks that run scripts or prompts around agent events.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill create-hook-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-hook
Source: https://github.com/kkkaoru/dotfiles/tree/main/.cursor/skills-cursor/create-hook
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill create-hook-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Automating behavior around Cursor agent events requires knowing the hooks.json schema, event names, matchers, and JSON stdin/stdout protocol, which is easy to get wrong. This Skill guides the creation of working project or user hooks that observe, block, modify, or follow up on agent behavior. ## Core Features & Use Cases - Event Selection: Maps user goals to the narrowest correct hook event such as beforeShellExecution, preToolUse, afterFileEdit, or subagentStop. - Hook Implementation: Produces hooks.json entries plus executable command scripts or prompt-based hooks with matchers, timeouts, and failClosed settings. - Validation Workflow: Covers executable permissions, helper binary checks, matcher regex pitfalls, and testing via the Hooks settings tab. - Use Case: A user wants to block risky network commands. The Skill creates a beforeShellExecution hook with a curl|wget matcher that returns a permission decision as JSON. ## Quick Start Create a Cursor project hook that asks for approval before any shell command containing curl or wget runs.

Frequently Asked Questions about create-hook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Cursor hook to block shell commands?

Add a beforeShellExecution entry in .cursor/hooks.json pointing to a script that reads JSON from stdin and returns a permission field of allow, ask, or deny. Use a matcher like curl|wget to limit which commands trigger it.

What is the difference between project hooks and user hooks in Cursor?

Project hooks live in .cursor/hooks.json and run from the project root, making them shareable via version control. User hooks live in ~/.cursor/hooks.json, run from ~/.cursor/, and apply across all projects.

When should I use a prompt hook instead of a command hook?

Use a prompt hook when the policy is easier to describe in natural language than to script, such as lightweight safety judgments. Prefer command hooks when behavior must be deterministic, exact, and auditable.

Why is my Cursor hook not loading or firing?

The most common cause is a matcher parsing issue, since matchers use JavaScript-style regex rather than POSIX syntax. Remove the matcher to confirm the base hook fires, verify relative paths, and check the Hooks settings tab or output channel.

How do I make a Cursor hook fail closed on errors?

Set failClosed to true in the hook definition so the action is blocked when the script crashes, times out, or returns invalid JSON. Without it, non-zero exit codes other than 2 fail open by default.