create-hook
- Repo stars 39
- Author updated Live
- Author repo awesome-omni-skill
- Domain
- AI
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @diegosouzapw · no license declared
- Token usage
- Lean
- Setup complexity
- Guided setup
- External API key
- Not required
- Operating systems
- macOS · Linux · Windows
- Runtime requirements
- Node.js
- Permissions
-
- Read-only
- Write / modify
- Shell exec
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: create-hook
description: Creates or adds Cursor agent lifecycle hooks. Use when the user asks to create a hook, add a hoo…
category: ai
runtime: Node.js
---
# create-hook output preview
## PART A: Task fit
- Use case: 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..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “1. Choose the lifecycle event / 2. Add the script / 3. Register in hooks.json” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “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.”.
- **02** When the source has headings, the agent prioritizes “1. Choose the lifecycle event / 2. Add the script / 3. Register in hooks.json” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source does not require a stable slash command. After installation, invoke the skill by name and describe the task.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files, run shell commands.
Start with a small task and check whether the result follows “1. Choose the lifecycle event / 2. Add the script / 3. Register in hooks.json”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: create-hook
description: Creates or adds Cursor agent lifecycle hooks. Use when the user asks to create a hook, add a hoo…
category: ai
source: diegosouzapw/awesome-omni-skill
---
# create-hook
## When to use
- Creates or adds Cursor agent lifecycle hooks. Use when the user asks to create a hook, add a hook, set up a lifecycle…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “1. Choose the lifecycle event / 2. Add the script / 3. Register in hooks.json” and keep inference separate from source facts.
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "create-hook" {
input -> user goal + target files + boundaries + acceptance criteria
context -> 1. Choose the lifecycle event / 2. Add the script / 3. Register in hooks.json
rules -> SKILL.md triggers / order / output contract
runtime -> Node.js | read files, write/modify files, run shell commands | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} Create Hook
Type: Utility skill (procedural, no agentic lead or sub-agents).
Adds a Cursor lifecycle hook: a script that runs when a specific agent event fires. Hooks are project-level only (.cursor/hooks/ and .cursor/hooks.json).
1. Choose the lifecycle event
Register the hook under one of these keys in hooks.json:
| Event | When it runs |
|---|---|
stop |
When the agent stops (end of turn) |
afterFileEdit |
After the agent edits a file |
afterAgentResponse |
After the agent sends a response |
beforeSubmitPrompt |
Before the user's prompt is submitted |
beforeReadFile / afterShellExecution / etc. |
See Cursor docs for full list |
2. Add the script
- Path:
.cursor/hooks/<name>.js(or.shif shell). Use a clear name (e.g.memory-reminder.js,on-stop.js). - Runtime: Node.js is typical; command in
hooks.jsonis run with Cursor's working directory set so thatnode hooks/<name>.jsresolves (run from.cursor). - Input: The hook receives a single JSON object on stdin. Read it like this:
let input = "";
process.stdin.setEncoding("utf8");
process.stdin.on("data", (chunk) => {
input += chunk;
});
process.stdin.on("end", () => {
const payload = JSON.parse(input);
const roots = payload.workspace_roots || [process.cwd()];
const root = path.resolve(roots[0]); // repo root
// ... use root for paths like path.join(root, '.cursor', 'next-step.md')
});
- Payload: Often includes
workspace_roots(array of repo roots). Use the first root as the project root for paths. Event-specific payloads may includefile_path,prompt, etc. - Output: Hook can write files (e.g.
.cursor/next-step.md), log to stderr, or exit; avoid writing to stdout if the protocol expects JSON there. - Shebang: Start Node scripts with
#!/usr/bin/env node.
3. Register in hooks.json
- Path:
.cursor/hooks.json - Format:
{
"version": 1,
"hooks": {
"stop": [
{ "command": "node hooks/on-stop.js" },
{ "command": "node hooks/my-new-hook.js" }
]
}
}
- Append to the array for the chosen event; do not remove existing hooks unless the user asks to replace them.
Checklist
- Script created under
.cursor/hooks/<name>.js(or.sh) - Script reads JSON from stdin and uses
workspace_rootsfor repo root when needed - Entry added to
.cursor/hooks.jsonunder the correct event key - Command is
node hooks/<name>.js(or./hooks/<name>.sh); path is relative to.cursor
Reference
- Existing hooks in this repo:
.cursor/hooks/on-stop.js,.cursor/hooks/after-file-edit.js,.cursor/hooks/memory-reminder.js— use them as patterns for stdin handling andpath.join(root, ...). - Project memory (
.cursor/memory.md) notes that new hooks should be added under.cursor/hooks/and registered in.cursor/hooks.json.
Decide Fit First
Design Intent
How To Use It
Boundaries And Review