create-hook

Create and register Cursor agent lifecycle hooks in .cursor/hooks.json.

1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/danalexilewis/taskgraph --skill create-hook-danalexilewis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-hook
Source: https://github.com/danalexilewis/taskgraph/tree/main/.cursor/skills/create-hook
Command: npx skills add https://github.com/danalexilewis/taskgraph --skill create-hook-danalexilewis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creates or adds Cursor agent lifecycle hooks. Use when the user asks to create a hook, add a hook, set up a lifecycle hook, or automate something on agent stop, afterFileEdit, afterAgentResponse, or other Cursor hook events. Hooks live in .cursor/hooks/ and are registered in .cursor/hooks.json.

Core Features & Use Cases

  • Automates the setup of Cursor lifecycle hooks by providing a standard workflow for defining a hook script, its location, and its event registration.
  • Supports events like stop, afterFileEdit, afterAgentResponse, beforeSubmitPrompt, and other Cursor hook events, enabling automation and lifecycle customization for agents.
  • Keeps hooks at project scope (in .cursor/hooks/ and .cursor/hooks.json) for consistent, shareable behavior across agents and runs.
  • Use Case: When a user asks to create a hook that logs or enforces behavior at agent stop, or to run cleanup steps after file edits.

Quick Start

Create a new Node.js or shell script in .cursor/hooks/ for the desired hook behavior, then add an entry to .cursor/hooks.json to register the hook for the appropriate event.

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 automate agent lifecycle events?

Cursor hooks are scripts triggered by agent lifecycle events like stop, afterFileEdit, or afterAgentResponse. They run automatically to enforce behavior, execute cleanup steps, or log activities during agent workflows.

How do I set up a hook that runs a script after a file edit in Cursor?

To set up an afterFileEdit hook, create a script in .cursor/hooks/ and add an entry to .cursor/hooks.json. This registers the script to execute deterministic tasks automatically whenever the agent edits a file.

What Cursor hook events are available for automating agent workflows?

Available Cursor hook events include stop, afterFileEdit, afterAgentResponse, and beforeSubmitPrompt. These events allow you to run scripts that customize agent behavior at specific lifecycle stages.

Do I need a specific project structure to configure Cursor lifecycle hooks?

Yes, configuring Cursor lifecycle hooks requires a project with a .cursor/hooks/ directory for script files and a .cursor/hooks.json file for registration. This keeps hooks at project scope for consistent behavior.

Can I use shell scripts for Cursor agent hooks?

Yes, you can use shell scripts or Node.js scripts for Cursor agent hooks. You place the script file in the .cursor/hooks/ directory and register it in the .cursor/hooks.json configuration file.