Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/kensaurus-create-hook
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/create-hook
What's inside
- Skill name
create-hook- Description
- Create Cursor hooks. Use to create a hook, write hooks.json, add hook scripts, or automate behavior around agent events.
- License
- MIT
- Instructions
- 234 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Creating Cursor Hooks
Create hooks when you want Cursor to run custom logic before or after agent events. Hooks are scripts or prompt-based checks that exchange JSON over stdin/stdout and can observe, block, modify, or follow up on behavior.
When the user asks for a hook, don't stop at describing the format. Gather the missing requirements, then create or update the hook files directly.
## Gather Requirements
Before you write anything, determine:
1. **Scope**: Should this be a project hook or a user hook?
2. **Trigger**: Which event should run the hook?
3. **Behavior**: Should it audit, deny/allow, rewrite input, inject context, or continue a workflow?
4. **Implementation**: Should it be a command hook (script) or a prompt hook?
5. **Filtering**: Does it need a matcher so it only runs for certain tools, commands, or subagent types?
6. **Safety**: Should failures fail open or fail closed?
Infer these from the conversation when possible. Only ask for the missing pieces.
## Choose the Right Location
- **Project hooks**: `.cursor/hooks.json` and `.cursor/hooks/*`
- **User hooks**: `~/.cursor/hooks.json` and `~/.cursor/hooks/*`
Path behavior matters:
- **Project hooks** run from the project root, so use paths like `.cursor/hooks/my-hook.sh`
- **User hooks** run from `~/.cursor/`, so use paths like `./hooks/my-hook.sh` or `hooks/my-hook.sh`
Prefer **project hooks** when the behavior should be shared with the repository and checked into version control.
## Choose the Hook Event
Use the narrowest event that matches the user's goal.
### Common Agent events
- `sessionStart`, `sessionEnd`: set up or audit a session
- `preToolUse`, `postToolUse`, `postToolUseFailure`: work across all tools
- `subagentStart`, `subagentStop`: control or continue Task/subagent workflows
- `beforeShellExecution`, `afterShellExecution`: gate or audit terminal commands
- `beforeMCPExecution`, `afterMCPExecution`: gate or audit MCP tool calls
- `beforeReadFile`, `afterFileEdit`: control file reads or post-process edits
- `beforeSubmitPrompt`: validate prompts before they are sent
- `preCompact`: observe context compaction
- `stop`: handle agent completion
- `afterAgentResponse`, `afterAgentThought`: track agent output or reasoning
### Tab events
- `beforeTabFileRead`: control file access for inline completions
- `afterTabFileEdit`: post-process edits made by Tab
### Quick event chooser
- **Block or approve shell commands** -> `beforeShellExecution`
- **Audit shell output** -> `afterShellExecution`
- **Format files after edits** -> `afterFileEdit`
- **Block or rewrite a specific tool call** -> `preToolUse`
- **Add follow-up context after a tool succeeds** -> `postToolUse`
- **Control whether subagents can run** -> `subagentStart`
- **Chain subagent loops** -> `subagentStop`
- **Check prompts for secrets or policy violations** -> `beforeSubmitPrompt`
- **Protect MCP calls** -> `beforeMCPExecution`
## Hooks File Format
Create a `hooks.json` file with schema version 1:
```json
{
"version": 1,
"hooks": {
"afterFileEdit": [
{
"command": ".cursor/hooks/format.sh"
}
]
}
}
```
Each hook definition can include:
- `command`: shell command or script path
- `type`: `"command"` or `"prompt"` (defaults to `"command"`)
- `timeout`: timeout in seconds
- `matcher`: filter for when the hook runs
- `failClosed`: block the action when the hook crashes, times out, or returns invalid JSON
- `loop_limit`: mainly for `stop` and `subagentStop` follow-up loops
## Matchers
Use matchers to avoid running the hook on every event.
- `preToolUse` / `postToolUse` / `postToolUseFailure`: match on tool type such as `Shell`, `Read`, `Write`, `Task`, or MCP tools in `MCP: ...` form
- `subagentStart` / `subagentStop`: match on subagent type such as `generalPurpose`, `explore`, or `shell`
- `beforeShellExecution` / `afterShellExecution`: match on the full shell command string
- `beforeReadFile`: match on tool type such as `Read` or `TabRead`
- `afterFileEdit`: match on tool type such as `Write` or `TabWrite`
- `beforeSubmitPrompt`: matches the value `UserPromptSubmit`
Important matcher warning:
- Matchers use JavaScript-style regular expressions, not POSIX/grep syntax
- Do not use POSIX classes like `[[:space:]]`; use JavaScript equivalents like `\s`
- If the matcher is at all tricky, start by getting the hook working without one or with a very simple matcher, then tighten it after the hook is confirmed to load and fire
If the user wants a hook for only one risky command family, prefer script-side filtering for the first working version and add a matcher afterward only if it is simple and clearly correct.
## Command Hooks
Command hooks are the default. They receive JSON on stdin and can return JSON on stdout.
Before using a command hook, verify that every executable it depends on will actually run in the hook environment:
- the script itself has a valid shebang and is executable
- any helper binary it calls is already installed and on `$PATH`
- if the script depends on tools like `jq`, `python3`, `node`, or repo-local CLIs, verify that explicitly before finishingFrom kensaurus/skills, MIT.
More from kensaurus/skills
- 0.633score
create-skill
kensaurus
Guide users through creating effective Agent Skills for Cursor.
SkillAFreshness: A★ 9Claude Code +9 - 0.633score
audit-agent-speed
kensaurus
Measure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans.
SkillAFreshness: A★ 9Claude Code +9 - 0.629score
audit-backend-architecture
kensaurus
Read-only backend-architecture audit and pattern advisor, gated by stack.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-analytics
kensaurus
Read-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
create-rule
kensaurus
Create Cursor rules for persistent AI guidance.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
split-to-prs
kensaurus
Split current work into small reviewable PRs.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-accessibility
kensaurus
WCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-auth-flows
kensaurus
Read-only audit of app-layer auth: route×gate matrix, session lifecycle, OAuth, provider traps (getSession vs getUser, middleware-only gates, CVE-2025-29927).
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-bundle-size
kensaurus
Analyse and shrink a web app's JavaScript bundle.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-cicd
kensaurus
Audit GitHub Actions CI/CD for cost, speed, and safety.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-code-quality
kensaurus
Detect and fix repo-wide anti-patterns and consistency drift (naming, organisation, repeated smells).
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
update-cursor-settings
kensaurus
Modify Cursor/VSCode user settings in settings.json.
SkillAFreshness: A★ 9Claude Code +9
Signals
- Stars
- 9
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Sep 23, 2026 (1 month ago)
- Last release
- Oct 19, 2026 (10 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/kensaurus/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from kensaurus
- 0.633score
audit-agent-speed
kensaurus
Measure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans.
SkillAFreshness: A★ 9Claude Code +9 - 0.633score
create-skill
kensaurus
Guide users through creating effective Agent Skills for Cursor.
SkillAFreshness: A★ 9Claude Code +9 - 0.629score
audit-backend-architecture
kensaurus
Read-only backend-architecture audit and pattern advisor, gated by stack.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
split-to-prs
kensaurus
Split current work into small reviewable PRs.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
create-rule
kensaurus
Create Cursor rules for persistent AI guidance.
SkillAFreshness: A★ 9Claude Code +9 - 0.628score
audit-analytics
kensaurus
Read-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events.
SkillAFreshness: A★ 9Claude Code +9
Cite this page
create-hook skill. Agent Mart. https://agentmart.dev/skills/kensaurus-create-hook (last updated 2026-10-24)