Connectors

Cursor

Cursor connector wires hooks.json with native ask on beforeShellExecution and beforeMCPExecution. Block on preToolUse, beforeReadFile, beforeTabFileRead, beforeSubmitPrompt, stop.

The Cursor connector wires DefenseClaw into Cursor's user-scoped hooks.json so every shell command and MCP tool call is inspected before it runs.

Setup

defenseclaw setup cursor

Cursor setup is supported on macOS and Linux. The DefenseClaw connector is not certified on native Windows x64, so setup rejects it there.

This runs the observe-mode template. Cursor talks directly to its native upstream; DefenseClaw inspects via hooks. There is no proxy-enforcement path for Cursor — blocking happens hook-side via preToolUse, beforeShellExecution, beforeMCPExecution, beforeReadFile, beforeTabFileRead, beforeSubmitPrompt, and stop. Native ask is supported only on the two before*Execution events.

What setup cursor actually does

The table highlights convenience options rather than the complete alias surface. The alias also accepts --mode, --rule-pack, --fail-mode, approval, block-message, add/replace, workspace, and rule-pack-directory options. See the quick-alias reference; use full guardrail setup for scanner, detection-strategy, and judge-provider configuration.

FlagDefaultWhat it does
--yes / -yoffSkip the confirmation prompt.
--restart / --no-restart--restartBounce defenseclaw-gateway after applying changes so the new hooks wire in.
--with-local-stack / --no-local-stack--no-local-stackAlso run setup local-observability up; follow the command's printed gateway-restart step after it writes the export destination.

setup cursor is the dedicated Cursor alias. It uses the shared guardrail setup backend, defaults to observe mode, and can join an existing hook-connector roster when you choose Add.

Common variations — pick the recipe that fits your phase

defenseclaw setup cursor

Confirms once, wires the hooks against ~/.cursor/hooks.json, and restarts the gateway. Findings flow to mandatory SQLite event history and the TUI; configured v8 destinations receive only the buckets/signals their routes select. No traffic is intercepted and no requests are blocked. Pass --yes to skip the confirmation in CI.

defenseclaw setup cursor --yes --with-local-stack

Same as standard but also runs setup local-observability up so Prom/Loki/Tempo/Grafana come up locally for ad-hoc dashboards. That command writes the export destination after the alias has already restarted the gateway, so run its printed defenseclaw-gateway restart step before expecting exports. See Local observability.

export DEFENSECLAW_LLM_KEY='replace-with-your-key'

defenseclaw setup cursor                                  # base alias first
defenseclaw setup guardrail \
  --connector cursor \
  --rule-pack strict \
  --scanner-mode local \
  --detection-strategy regex_judge \
  --judge-model anthropic/claude-sonnet-4-20250514 \
  --judge-api-key-env DEFENSECLAW_LLM_KEY \
  --judge-hook-connectors cursor \
  --restart

The alias selects Cursor; the follow-up setup guardrail --connector cursor swaps in the strict rule pack, keeps scanning local, and turns the LLM judge on as a second-pass adjudicator on regex-flagged events. Configure the remote scanner separately through full guardrail setup, which validates its endpoint and API-key environment variable.

Cursor has no proxy enforcement, but its hooks can enforce directly:

defenseclaw setup cursor --mode action --human-approval --fail-mode closed

With mode=action, beforeShellExecution and beforeMCPExecution surface a native ask when policy returns an eligible confirmation verdict. The other block events use an alert/context fallback with raw_action preserved; the TUI can review but not resume them.

Decision aids — should I turn this on?

Not sure what to pick? Run defenseclaw setup guardrail (no flags) — the interactive wizard walks you through every choice with safe defaults pre-selected and inline help. The Prompt → flag mapping table gives you the CI-shaped command for the same configuration.

Files DefenseClaw will modify

hooks.json (DefenseClaw entries appended)

Cursor's MCP / skills / rules surfaces are discovered from user-global Cursor locations by default. Workspace-local overlays are included only when you explicitly pin a workspace.

Hook capabilities

Block events

  • preToolUse
  • beforeShellExecution
  • beforeMCPExecution
  • beforeReadFile
  • beforeTabFileRead
  • beforeSubmitPrompt
  • stop

Native ask events

  • beforeShellExecution
  • beforeMCPExecution

Cursor supports native ask only on beforeShellExecution and beforeMCPExecution. The other block events (preToolUse, beforeReadFile, beforeTabFileRead, beforeSubmitPrompt, stop) return an alert/context fallback and retain the original confirm intent in audit.

Disable

defenseclaw guardrail disable --connector cursor --yes