Cursor Setup
Cursor only supports global hooks (not project-level). All hooks are configured at ~/.cursor/hooks.json.
Project Setup with Global Hooks
Navigate to your project directory and initialize Cupcake:
cupcake init --harness cursor
This creates:
.cupcake/directory in your project with policies~/.cursor/hooks.jsonwith global hook configuration (uses relative paths)
When you open this project in Cursor, the hooks will automatically find the project's .cupcake/ directory.
Global Setup
For organization-wide policies:
cupcake init --global --harness cursor
This creates configuration at ~/.config/cupcake/ and sets up global hooks with absolute paths.
Enable Built-in Policies
# Project-level builtins
cupcake init --harness cursor --builtins git_pre_check,protected_paths
# Global security builtins
cupcake init --global --harness cursor --builtins system_protection,sensitive_data_protection
Project-level builtins:
always_inject_on_prompt- Add context to every user promptgit_pre_check- Run checks before git operationsgit_block_no_verify- Prevent--no-verifyflag usagepost_edit_check- Run validation after file editsprotected_paths- Make specific paths read-onlyrulebook_security_guardrails- Protect.cupcake/filesenforce_full_file_read- Enforce reading entire files
Global-level builtins:
system_protection- Protect system directoriessensitive_data_protection- Block access to sensitive filescupcake_exec_protection- Prevent cupcake binary execution
See the Built-in Configuration Reference for complete details.
Verify Installation
Test that Cupcake is working:
# Create test event
cat > test-event.json << 'EOF'
{
"hook_event_name": "beforeShellExecution",
"conversation_id": "test",
"generation_id": "test",
"workspace_roots": ["/tmp"],
"command": "echo 'Hello from Cupcake!'",
"cwd": "/tmp"
}
EOF
# Evaluate
cupcake eval --harness cursor < test-event.json
Expected output:
{
"permission": "allow"
}
Next Steps
- Cursor Reference - Events, response formats, hook configuration
- Writing Policies - Create custom Rego policies
- Cursor Tutorial - Hands-on walkthrough