Overview
Cursor has more hook events than Claude Code (20 vs 8), providing richer automation capabilities. ECC leverages this with a DRY adapter pattern that reuses existing hook logic.What’s Included
| Component | Count | Details |
|---|---|---|
| Hook Events | 15 | sessionStart, beforeShellExecution, afterFileEdit, beforeMCPExecution, beforeSubmitPrompt, and 10 more |
| Hook Scripts | 16 | Thin Node.js scripts delegating to scripts/hooks/ via shared adapter |
| Rules | 29 | 9 common (alwaysApply) + 20 language-specific (TypeScript, Python, Go, Swift) |
| Agents | Shared | Via AGENTS.md at root (read by Cursor natively) |
| Skills | Shared + Bundled | Via AGENTS.md at root and .cursor/skills/ for translated additions |
| Commands | Shared | .cursor/commands/ if installed |
| MCP Config | Shared | .cursor/mcp.json if installed |
Installation
Quick Install
- Copies rules to
.cursor/rules/with YAML frontmatter - Creates hook scripts in
.cursor/hooks/ - Sets up the DRY adapter pattern
- Configures language-specific settings
Manual Installation
Hook Architecture (DRY Adapter Pattern)
Cursor’s extensive hook system (20 events) is more powerful than Claude Code’s (8 events). The.cursor/hooks/adapter.js module transforms Cursor’s stdin JSON to Claude Code’s format, allowing existing scripts/hooks/*.js to be reused without duplication.
Architecture Benefits
DRY Principle
Hook logic written once, works on both platforms
Zero Duplication
No need to maintain separate hook implementations
Cursor Advantages
More events = richer automation than Claude Code
Easy Maintenance
Bug fixes apply to both platforms automatically
Example Hook
15 Hook Events
Cursor provides these hook events:Session Lifecycle
Session Lifecycle
- sessionStart — Load context on session start
- sessionEnd — Save state on session end
- sessionIdle — Suggest compaction when idle
File Operations
File Operations
- beforeFileRead — Validate file access permissions
- afterFileEdit — Auto-format, run type checks
- beforeFileWrite — Block writes to protected files
- beforeTabFileRead — Block Tab from reading .env, .key, .pem files
Shell Execution
Shell Execution
- beforeShellExecution — Block dev servers outside tmux, git push review
- afterShellExecution — Log command results, detect failures
AI Interactions
AI Interactions
- beforeSubmitPrompt — Detect secrets (sk-, ghp_, AKIA) in prompts
- afterPromptResponse — Extract learnings from responses
MCP Operations
MCP Operations
- beforeMCPExecution — Audit MCP tool calls
- afterMCPExecution — Log MCP results
Other Events
Other Events
- beforeToolUse — Generic pre-tool validation
- afterToolUse — Generic post-tool actions
Key Hooks in Action
Rules Format
Cursor rules use YAML frontmatter withdescription, globs, and alwaysApply:
Type Safety
Use strict TypeScript settings. Avoidany.
Python
Go
Swift
Configuration Example
.cursor/settings.json:
Feature Comparison
| Feature | Claude Code | Cursor IDE |
|---|---|---|
| Agents | 13 agents | Shared (AGENTS.md) |
| Commands | 33 commands | Shared |
| Skills | 50+ skills | Shared + Bundled |
| Hook Events | 8 types | 15 types ✨ |
| Hook Scripts | 9 scripts | 16 scripts |
| Rules | 29 rules | 29 rules (YAML) |
| Custom Tools | Via hooks | Via hooks |
| MCP Servers | 14 servers | Shared |
| Secret Detection | Hook-based | beforeSubmitPrompt hook ✨ |
| Auto-Format | PostToolUse hook | afterFileEdit hook ✨ |
Cursor Advantages: More hook events, richer automation, native IDE integration
Usage Examples
Starting a Feature
Auto-Formatting on Save
Cursor’safterFileEdit hook automatically:
- Runs Prettier on TypeScript/JavaScript files
- Runs TypeScript compiler check
- Warns if
console.logdetected - Updates documentation if needed
Secret Detection
Best Practices
Use AGENTS.md
Keep project-specific context in AGENTS.md at repo root
Leverage Hooks
Cursor’s 15 hook events enable rich automation
Language Rules
Install only rules for languages you use
Test Hooks
Verify hooks work by triggering events manually
Troubleshooting
Hooks not firing
Hooks not firing
- Check
.cursor/hooks/exists and scripts are executable - Verify
cursor.ai.enableHooksis true in settings - Check hook script exit codes (0 = allow, 2 = block)
- View Cursor logs for hook execution errors
Rules not applying
Rules not applying
- Verify rules are in
.cursor/rules/ - Check YAML frontmatter is valid
- Ensure
globsmatch your file extensions - Common rules need
alwaysApply: true
AGENTS.md not detected
AGENTS.md not detected
- Place AGENTS.md at repository root
- Restart Cursor
- Open a file in the project
- Check Cursor AI panel for context loading
Next Steps
Hook Examples
See all 16 hook scripts in detail
Rules Guide
Learn about the 29 rules and how to customize
Agents
Explore shared agent system
Skills
Browse 50+ skills available in Cursor