Skip to content

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.json with 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 prompt
  • git_pre_check - Run checks before git operations
  • git_block_no_verify - Prevent --no-verify flag usage
  • post_edit_check - Run validation after file edits
  • protected_paths - Make specific paths read-only
  • rulebook_security_guardrails - Protect .cupcake/ files
  • enforce_full_file_read - Enforce reading entire files

Global-level builtins:

  • system_protection - Protect system directories
  • sensitive_data_protection - Block access to sensitive files
  • cupcake_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