cursor-hooks
This repository provides ready-to-use examples and documentation for Cursor's Agent Hooks.
Install / Use
npx skills add hamzafer/cursor-hooksInstalls into whichever agent you are using.
.cursorrules
Cursor IDE rules (legacy)
Quality Score
Category
Content & MediaSupported Platforms
Skill content
View source on GitHubCursor Hooks Examples
This repo gives you copy‑paste ready recipes for Cursor's Agent Hooks. Hooks are lightweight scripts that exchange JSON with Cursor so you can observe, block, or mutate agent behavior.
Quickstart: Format Hook
Create a minimal hook that runs after every file edit. This repo already includes hooks.json and all referenced scripts under hooks/, so setup is just copying the files into ~/.cursor/.
- Copy
hooks.jsonto~/.cursor/hooks.json. - Copy every script from
hooks/to~/.cursor/hooks/. - Run
chmod +x ~/.cursor/hooks/*.shto make them executable. - Restart Cursor and verify the hook runs after edits. Tail
/tmp/agent-audit.logor/tmp/hooks.logto confirm activity.
Why Hooks Matter
With a handful of scripts you can:
- run formatters or linters immediately after Cursor edits a file
- audit or block shell commands before they execute
- redact secrets before the agent reads sensitive content
- apply safety guardrails around MCP tool usage
Each hook definition maps to an executable script. Cursor streams JSON input on stdin and expects JSON back on stdout, letting you tailor the agent loop without patching Cursor itself.
Hook Catalog
Everything you need to mirror the documentation examples lives in this repository:
hooks.jsonwires each documented hook event to the scripts inhooks/.hooks/format.shis the minimal formatter-style hook used in the Quickstart.hooks/audit.shcaptures every payload into/tmp/agent-audit.logfor auditing.hooks/block-git.shdenies raw git usage, requests approval forgh, and logs decisions to/tmp/hooks.log.hooks/redact-secrets.shprevents Cursor from reading files that look like they contain GitHub tokens.
How To Use This Repo
- Copy
hooks.jsonand the scripts inhooks/into~/.cursor/. - Run
chmod +x ~/.cursor/hooks/*.shso Cursor can execute them. - Tail
/tmp/hooks.logor/tmp/agent-audit.logto verify hook activity. - Restart Cursor after modifying any hook.
Contributing
Issues and pull requests are welcome. Please open an issue first if you plan to add new recipes or extend existing ones.
License
Released under the MIT License. See LICENSE.
Related Skills
siyuan
46.4kAn open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
humanizer
50.9kAgent skill that removes signs of AI-generated writing from text
oh-story-claudecode
7.0kClaude Code / Codex / OpenCode agent skills for writing Chinese web novels (网文): 扫榜、拆文、写作、去AI味、封面全流程,长篇短篇都支持 | 13 skills for novel writing and long-form fiction with file-based continuity tracking. MIT.
iPolloWork
6.5kEnterprise-grade, local-first Agent Workbench for people and agent teams. A unified multi-engine workspace for Codex Harness, DeepSeek Harness, and OpenCode, with unified plugins and Skills, multi-agent projects and tasks, and editable code, documents, presentations, design, and video.
