Cursor Integration
Install FireGuard hooks for Cursor prompts, shell commands, tool calls, and file access.
Use the Cursor integration when you want FireGuard to check agent activity before Cursor submits prompts or runs actions in your workspace.
Requirements
python3available onPATH.- A FireGuard API key.
- A FireGuard project ID with the policies and security guardrails you want to enforce.
Install
Install the Cursor hooks:
curl -fsSL https://raw.githubusercontent.com/fireravenai/fireraven-agent-hooks/refs/heads/main/install.sh | sh -s -- --agent cursorOr install from a local clone of github.com/fireravenai/fireraven-agent-hooks:
./fg install --agent cursor
./fg doctorConfigure
Edit config.env in ~/.cursor/hooks/:
FIRERAVEN_GUARDRAILS_API_KEY=fg_...
FIRERAVEN_PROJECT_ID=00000000-0000-0000-0000-000000000000Optional overrides (installer defaults are normal / open if omitted):
FIRERAVEN_API_URL=https://api.fireraven.ai
# FIRERAVEN_EXECUTION_MODE=fast
FIRERAVEN_REQUEST_TIMEOUT_SEC=15
# FIRERAVEN_FAIL_MODE=closedRestart Cursor after editing config.env.
Configuration reference
| Variable | Required | Default | Description |
|---|---|---|---|
FIRERAVEN_GUARDRAILS_API_KEY | yes | — | Organization FireGuard API key. See FireGuard API keys. |
FIRERAVEN_PROJECT_ID | yes | — | FireGuard project ID from Project Settings → General. See Project configuration. |
FIRERAVEN_API_URL | no | https://api.fireraven.ai | FireGuard API base URL. |
FIRERAVEN_EXECUTION_MODE | no | normal | Execution mode sent on each guardrail API call. See below. |
FIRERAVEN_REQUEST_TIMEOUT_SEC | no | 15 | HTTP timeout in seconds for FireGuard requests. |
FIRERAVEN_FAIL_MODE | no | open | Hook behavior when FireGuard cannot be reached. See below. |
FIRERAVEN_EXECUTION_MODE
Controls how FireGuard runs policy and security checks for each hook invocation. The value is passed as execution_mode on input and output guardrail API requests.
| Value | Default | Use when |
|---|---|---|
normal | yes | You want complete response-path results. FireGuard runs guardrails sequentially and returns full policy and security details. |
fast | You want lower latency in the IDE. FireGuard runs eligible checks in parallel and returns as soon as a blocking result is known. |
This setting can override the project default for agent hook calls without changing the project configuration in the Fireraven app. See FireGuard concepts — Execution modes.
FIRERAVEN_FAIL_MODE
Controls hook behavior when FireGuard cannot be reached because of a network error, request timeout, or HTTP failure.
| Value | Default | Use when |
|---|---|---|
open | yes | Developer velocity should take priority over enforcement during transient API failures. The hook allows the action through. |
closed | You want enforcement even during outages. The hook blocks the Cursor action (deny / continue: false). Use for strict production enforcement. |
closed and open apply only to FireGuard connectivity failures. Policy violations, guardrail blocks, and missing FIRERAVEN_GUARDRAILS_API_KEY or FIRERAVEN_PROJECT_ID always block regardless of FIRERAVEN_FAIL_MODE.
What Cursor Checks
| Event | Mode | What FireGuard checks |
|---|---|---|
beforeSubmitPrompt | Blocking | User prompts before submission. |
beforeShellExecution | Blocking | Shell commands before execution. |
beforeMCPExecution | Blocking | MCP tool name and arguments (failClosed). |
beforeReadFile | Blocking | File path and body (failClosed). Local sensitive paths (for example .env, keys) hard-deny before FireGuard. |
preToolUse | Blocking | All tools (matcher: ".*"). Shell, Read, and MCP are deferred to the dedicated hooks above to avoid double FireGuard checks. |
subagentStart | Blocking | Subagent launch. |
afterFileEdit | Audit | Written hunks after the edit; cannot undo. |
Blocking responses
beforeSubmitPrompt blocks with:
{
"continue": false,
"user_message": "Blocked by Fireraven FireGuard."
}Other blocking events return:
{
"permission": "deny",
"user_message": "Blocked by Fireraven FireGuard.",
"agent_message": "Blocked by Fireraven FireGuard."
}afterFileEdit is audit-only and returns an empty success object.
Human override
On FireGuard policy or security violations for beforeShellExecution, beforeMCPExecution, beforeReadFile, preToolUse, and subagentStart, the hook shows a blocking OS confirmation dialog (zenity or kdialog on Linux, osascript on macOS, MessageBox on Windows):
- Allow continues that action once.
- Deny, timeout, or no display keeps the deny.
Local sensitive-path blocks and missing FIRERAVEN_GUARDRAILS_API_KEY or FIRERAVEN_PROJECT_ID are not overridable. Prompt blocks on beforeSubmitPrompt stay hard deny — edit the prompt instead.
Cursor’s native permission: "ask" is not used; it is not reliably enforced today.
If Cursor also loads Claude Code third-party hooks, Fireraven’s Claude adapter no-ops under Cursor so enforcement stays on these native Cursor hooks.
JSONC and existing hooks
~/.cursor/hooks.json may contain JSONC comments (// or /* */). That is useful for temporarily disabling hooks or documenting entries.
The Fireraven installer reads JSONC and applies surgical edits so:
- Existing comments and formatting stay in place.
- Third-party hooks (for example another tool’s
preToolUsematcher) are kept alongside Fireraven’s livepreToolUseentry. - Commented-out Fireraven blocks stay commented; the installer registers separate live Fireraven entries.
If install fails with a JSONC parse error, fix syntax problems in the file (not comments). Re-run the installer after correcting the file.
Verify
From a clone of the hooks repository, use:
./fg doctorWindows
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/fireravenai/fireraven-agent-hooks/refs/heads/main/install.ps1))) -Agent cursorThe PowerShell installer writes:
| File | Purpose |
|---|---|
%USERPROFILE%\.cursor\hooks.json | Cursor hook registration |
%USERPROFILE%\.cursor\hooks\ | Fireraven hook scripts and config |
%USERPROFILE%\.cursor\hooks\config.env | Fireraven credentials |
The installer registers Cursor hooks as py -3 hooks/cursor_guardrail.py, which Cursor runs from %USERPROFILE%\.cursor. After editing config.env, restart Cursor or reload the window, then check View > Output > Hooks if a hook does not appear to run.
If the Python launcher is not available in Cursor's hook environment, edit hooks.json to use the fallback:
{
"command": "powershell -NoProfile -ExecutionPolicy Bypass -File hooks/run_cursor_guardrail.ps1"
}