create-hook

Create Cursor hooks that automate behavior around agent events via hooks.json and scripts.

Updated Aug 6, 2026
One-click install
npx skills add https://github.com/ferrarifankid04/ai-skills-public --skill create-hook-ferrarifankid04
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-hook
Source: https://github.com/ferrarifankid04/ai-skills-public/tree/main/cursor/skills-cursor/create-hook
Command: npx skills add https://github.com/ferrarifankid04/ai-skills-public --skill create-hook-ferrarifankid04

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Automating custom logic around Cursor agent events requires knowing the correct hook event, file location, JSON schema, and script conventions, which is error-prone without guidance. ## Core Features & Use Cases - Hook Scaffolding: Creates or updates project-level (.cursor/hooks.json) or user-level (~/.cursor/hooks.json) hook configurations with schema version 1. - Event and Matcher Selection: Chooses the narrowest correct event (e.g., beforeShellExecution, afterFileEdit, preToolUse) and writes JavaScript-style regex matchers to filter when hooks fire. - Command and Prompt Hooks: Generates executable shell scripts that exchange JSON over stdin/stdout, or prompt-based hooks for lightweight policy checks. - Use Case: Ask for a hook that flags shell commands making network requests, and get a working beforeShellExecution hook with an executable script that returns allow/ask/deny JSON. ## Quick Start Create a Cursor project hook that asks for confirmation before running any curl or wget shell command.

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. Exit code 2 also blocks the action, and setting `failClosed: true` blocks on script failure.

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 for that user.

Should I use a command hook or a prompt hook in Cursor?

Use a command hook when the logic must be deterministic and auditable, such as regex-based command filtering. Use a prompt hook when the policy is easier to describe in natural language than to script, like judging whether a command looks safe.

Why is my Cursor hook not loading or firing?

The most common cause is a broken matcher, since matchers use JavaScript regex syntax rather than POSIX. Remove the matcher to confirm the base hook fires, verify relative paths match the hook location, and restart Cursor if reloading on save fails.

Which Cursor hook event should I use to format files after edits?

Use `afterFileEdit`, which runs after file edits and supports matchers on tool types like Write or TabWrite. It is the narrowest event for post-processing edits, such as running a formatter script on changed files.