create-hook

Create Cursor hooks that automate guardrails around agent events.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cursor hooks let you add guardrails, auditing, and automated follow-up behavior around agent and tool events, but designing them correctly requires knowing the right event, the correct hooks.json structure, and where project vs user hooks must live.

Core Features & Use Cases

  • Hook-driven automation around agent events: Create logic that runs before or after events like tool use, shell execution, file reads, and prompt submission.
  • Command and prompt hook support: Build deterministic command hooks that exchange JSON via stdin/stdout or use prompt hooks for simpler policy decisions.
  • Scoped placement with correct path semantics: Use project hooks under .cursor/ for repo-shared behavior and user hooks under ~/.cursor/ for personal behavior, ensuring paths resolve properly.
  • Matcher-based targeting and safety controls: Narrow hook execution with matchers (JavaScript-style regex) and decide whether failures should fail open or fail closed using failClosed.

Quick Start

Ask your agent to create or update a .cursor/hooks.json hook that blocks potentially risky shell commands by adding a matcher for network tools and implementing the corresponding hook script under .cursor/hooks/, returning allow/deny permissions based on the stdin JSON payload.

Frequently Asked Questions about create-hook

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

FAQPage Schema
How do I create Cursor hooks to block risky shell commands?

Create Cursor hooks by generating a versioned hooks.json file and implementing executable command scripts under .cursor/hooks/ that read stdin JSON and return allow or deny permissions to gate risky shell commands.

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

Project hooks live under the .cursor/ directory for repo-shared team behavior, while user hooks live under ~/.cursor/ for personal automation, ensuring path resolution matches the intended scope.

Can I use matchers to target specific agent events in Cursor hooks?

Yes, matchers use JavaScript-style regex to narrow hook execution to specific agent events, allowing precise targeting of tool use, shell execution, file reads, or prompt submission.

Does Cursor support prompt hooks for policy decisions?

Cursor supports prompt hooks for simpler policy decisions alongside deterministic command hooks, exchanging JSON via stdin/stdout to validate prompts and control agent behavior.

When should I use failClosed for Cursor hooks?

Use failClosed when hook failures should block execution rather than allow it, providing stricter safety controls for auditing file edits or gating shell commands where failing open risks damage.