create-hook

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

Updated May 28, 2023
One-click install
npx skills add https://github.com/steveulrich/ProjectB --skill create-hook-steveulrich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: create-hook
Source: https://github.com/steveulrich/ProjectB/tree/main/.cursor/skills/create-hook
Command: npx skills add https://github.com/steveulrich/ProjectB --skill create-hook-steveulrich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Automating custom behavior around Cursor agent events requires knowing the hooks.json schema, event names, matchers, and JSON stdin/stdout protocol, which is error-prone to set up manually. ## Core Features & Use Cases - Hook Configuration: Creates or updates project-level (.cursor/hooks.json) or user-level (~/.cursor/hooks.json) hook files with schema version 1. - Event and Matcher Selection: Chooses the narrowest correct event such as beforeShellExecution, afterFileEdit, preToolUse, or subagentStop, and adds JavaScript-style regex matchers when appropriate. - Command and Prompt Hooks: Writes executable shell scripts that exchange JSON over stdin/stdout, or prompt-based hooks for lightweight policy decisions. - Use Case: When you want to block or require approval for network commands like curl or wget, this Skill creates a beforeShellExecution hook with a failClosed script that returns permission decisions as JSON. ## Quick Start Create a project hook that asks for approval before running any shell command containing curl or wget.

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 an executable script. The script reads JSON from stdin and returns a permission field of allow, ask, or deny, with optional user_message and agent_message fields.

What is the difference between command hooks and prompt hooks in Cursor?▼

Command hooks run a shell script that exchanges JSON over stdin/stdout for deterministic behavior. Prompt hooks send the hook input to a model with a policy prompt, which suits lightweight decisions that are easier to describe than to script.

Where should Cursor hooks be stored for a project?▼

Project hooks live in .cursor/hooks.json with scripts under .cursor/hooks/, and paths are relative to the project root. User hooks live in ~/.cursor/hooks.json with paths relative to ~/.cursor/.

Why is my Cursor hook not loading or firing?▼

Matcher or config parsing errors are the most common cause. Remove the matcher to confirm the base hook works, verify relative paths, ensure the script is executable, and check the Hooks settings tab or Hooks output channel.

How do Cursor hook matchers work?▼

Matchers use JavaScript-style regular expressions, not POSIX syntax, so use \s instead of [[:space:]]. They filter events by tool type, shell command string, or subagent type depending on the event.

What happens when a Cursor hook script fails?▼

Exit code 0 means success and exit code 2 blocks the action. Other non-zero exits fail open by default unless failClosed is set to true, which blocks the action on crashes, timeouts, or invalid JSON.