SecGuardRail Docs

SecGuardRail checks what AI agents do before it runs. These docs cover what is live today: Claude Code and Cursor hooks, Codex CLI hooks (beta, Windows), the Policy Check API for any other agent, policies, approvals and the audit log.

Choosing controls? Compare hooks, sandboxes and gateways.

Works with Claude Code · Cursor · Codex

Contents

1. Get started

  1. Request access at secguardrail.com/signup and we email you within one working day. Your workspace comes with default policies, such as Block git push to main/master and Block .env file access.
  2. Connect an agent: Claude Code or Cursor with one command from Connect your agent (on the Overview and Integrations pages), or any agent through the Policy Check API.
  3. Watch decisions arrive in Activity and the Audit Log.

Codex CLI (beta, Windows) is installed machine-wide by an administrator: see Connect Codex CLI.

2. Connect Claude Code

One command (recommended). In Connect your agent, pick Claude Code and your OS, click Get my command and paste it in PowerShell (irm https://secguardrail.com/connect/sgc_… | iex) or a macOS / Linux terminal (curl -fsSL https://secguardrail.com/connect/sgc_… | sh). The command works once, for 15 minutes, and contains no key. It saves this computer's key in your user environment, adds SecGuardRail to ~/.claude/settings.json so every folder is covered (your own settings stay, and the old file is backed up), saves an offline uninstall script in ~/.secguardrail, and sends a test event: the dashboard shows Connected. Then open a new terminal and start Claude Code. On macOS and Linux it needs python3.

Manual setup, for one repo:

  1. Go to Integrations → Claude Code and click Add Agent. Copy the key (grcc_…). It is shown once, and only its hash is stored.
  2. Put the generated settings in .claude/settings.local.json in your repo.
  3. Set the key in your shell before starting Claude Code: export GUARDRAIL_HOOK_KEY=grcc_…. It stays out of the settings file and out of git.

Each tool call goes to SecGuardRail before it runs. For example, one entry of the generated settings:

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "^(Bash|PowerShell)$",
      "hooks": [{
        "type": "http",
        "url": "https://secguardrail.com/api/hooks/claude-code",
        "headers": { "Authorization": "Bearer ${GUARDRAIL_HOOK_KEY}" },
        "allowedEnvVars": ["GUARDRAIL_HOOK_KEY"],
        "timeout": 10,
        "onFailure": "block"
      }]
    }]
  }
}

Why this matters: permission rules match command text and miss other spellings of the same action. See Claude Code security for teams.

A blocked call shows the agent the reason, for example Blocked by policy "Block git push to main/master". Prompts that contain a credential, such as a GitHub token, are stopped before they are sent. Credentials in commands, files and prompts are redacted before anything is stored or sent to Slack, and the Block credentials sent off this machine policy in the Secrets pack stops a credential from being sent to another host or MCP server.

To stop agents during an incident, an Owner, Admin or Security Analyst can turn on the kill switch for the whole workspace (Agents → Stop all agents, confirmed by typing the workspace name), for one agent, or for one session. From the next tool call each tool call is denied with the reason given, and Claude Code stops its session, until the switch is turned off.

3. Connect Cursor

One command (recommended). In Connect your agent, pick Cursor and your OS and run the command the same way as for Claude Code. It adds SecGuardRail to your user hooks (~/.cursor/hooks.json, with the hook script in ~/.secguardrail), keeps your own hooks, and sends a test event through the script. Restart Cursor.

Manual setup, for one project:

  1. Go to Integrations → Cursor, choose macOS / Linux or Windows, and click Add Agent. Copy the key.
  2. Save the hook script as .cursor/hooks/secguardrail.sh (or .ps1 on Windows), and the generated JSON as .cursor/hooks.json.
  3. Set SECGUARDRAIL_HOOK_KEY to the key and restart Cursor.

Cursor's shell commands, MCP tools, file reads, file writes and deletes, and prompts are then checked. The same policies apply as for Claude Code: a policy for Bash also decides Cursor's shell commands, and one for Read decides its file reads.

Why this matters: Cursor hooks fail open by default, and hooks in user or project files can be edited by the agent. See Cursor hooks security for teams.

A key only works for its own connector. A Claude Code key is refused on the Cursor endpoint, and the reverse.

4. Connect Codex CLI (beta)

Codex CLI on Windows is in beta, turned on per workspace: ask us at info@secguardrail.com to enable it. It is installed once per device by an administrator, through the Codex managed configuration, so developers and agents cannot switch it off.

  1. In Settings → Fleet deployment, create a deployment key, choose Windows and download the Codex CLI install script.
  2. On each device, in PowerShell opened with Run as administrator: powershell -NoProfile -ExecutionPolicy Bypass -File .\install-secguardrail-codex.ps1
  3. The script adds the SecGuardRail hooks to C:\ProgramData\OpenAI\Codex\requirements.toml. A file your company already has there is kept byte for byte, and the uninstall script puts it back. It ends with a live check and undoes everything if SecGuardRail did not deny and record a test action.
  4. The device appears under Agents as DEVICE-NAME (Codex) on its first event.

Codex's shell commands, apply_patch file edits (every file in the patch) and MCP tool calls are then checked before they run, with the same policies as Claude Code: a policy for Bash decides Codex's shell commands, and one for Edit or Write decides its file edits. Prompts with a credential are blocked, tool results are read for prompt injection, and the kill switch denies each tool call and blocks prompts.

When SecGuardRail cannot be reached, answers late or answers with an error, the hook itself answers by your fail mode per tool class (blocked by default for shell, file changes and MCP), before Codex's own timeout.

Why this matters: Codex's bypass flags and local config can switch the guard off unless requirements.toml pins it. See Codex CLI security for teams.

Not covered in the beta

  • The Codex desktop app and IDE extension: their hooks do not run today.
  • Hosted web search: it never reaches local hooks.
  • macOS and Linux: not tested yet.
  • If the hook process itself is killed, Codex runs the action (openai/codex#41979).
  • A local administrator can still edit requirements.toml; the silence alert marks a device Unprotected when its events stop.

5. Policy Check API (any agent)

Create a key in Settings → API Keys (sg_api_…), then call the API before your agent acts:

curl -X POST https://secguardrail.com/api/guardrail/check \
  -H "Authorization: Bearer sg_api_…" -H "Content-Type: application/json" \
  -d '{"agent":"billing-bot","tool":"send_email","input":{"to":"…"},"repo":"acme/api","branch":"main"}'

The reply has a verdict of allow, deny or hold, with reason, policy, risk_score and event_id. A hold also carries an approval; once a reviewer approves, the same call passes once.

When a deny or hold policy matches, it decides at once. When no policy matches, an AI analysis scores the risk. If that analysis is unavailable, the API answers 503 instead of guessing.

6. Policies

In Policies, each policy has a tool matcher, a match type and a verdict: Block, Hold for approval or Allow. The strictest matching verdict wins.

  • Match types: a command pattern, a file path pattern, or a condition.
  • Monitor mode: records what a policy would have decided without enforcing it, so you can try a rule safely.
  • Templates: ready-made packs, for example git safety and destructive shell commands.
  • History: every save is a new version; you can compare and restore.

Conditions

A condition can test the tool, the command, the path, where the call connects, the repo and branch, and any input argument:

tool.class = web AND destination NOT IN allowlist(*.acme.com, github.com)
tool.class = git AND branch MATCHES release/*
tool.name = mcp__gmail__send AND $.input.recipients.length > 50
Fieldstool.name, tool.class, tool.mcp_server, command, path, destination, repo, branch, $.input.<argument> (add .length for a list or text)
Operators= != > >= < <= IN NOT IN MATCHES (pattern with *) CONTAINS ~ (regular expression), combined with AND, OR, NOT and parentheses
Tool classesshell, file_read, file_write, mcp, web, git, agent, other. A shell command that reaches the network also counts as web, and a git command as git.

For MCP tools, match tool.class = mcp or tool.mcp_server; see MCP security for coding agents for allowlists and tool poisoning. For text planted in what the agent reads, see prompt injection in coding agents.

Claude Code and Cursor do not send the repository name, so repo conditions apply to Policy Check API calls. branch also works for git push commands.

7. Approvals

A Hold for approval policy pauses the action and opens a request in Approvals, with the full context. A reviewer approves or rejects it. If no one answers within the approval timeout set in Settings → General, the request expires. Alerts can go to Slack, routed by risk band and verdict (Settings → Notifications).

8. If SecGuardRail cannot decide

By default, shell commands, file changes and MCP tools fail closed: if SecGuardRail cannot be reached or cannot decide, they do not run. File reads fail open by default. You can change the mode per tool class in Settings → General; the setting is applied to the hook configuration you generate.

9. Audit log, export and integrity

  • Audit Log: every decision, with the agent, the tool, the policy, the reason and the reviewer.
  • Export: CSV or NDJSON. Each file ends with a summary that includes the SHA-256 of its rows, so anyone can check that the file was not changed.
  • Verify integrity: events are linked in a per-workspace SHA-256 hash chain. Audit Log → Evidence → Verify integrity names the first event that was changed, added or deleted outside the app. The chain is tamper-evident: it detects edits, it does not prevent them.
  • Retention and legal hold: keep events for 7, 30, 90 or 365 days (Settings → Data Retention). Events covered by a legal hold are never purged, and each purge is recorded in the chain.

Become a design partner

Design partners: Team plan free for 30 days, then 50% off for life, limited to 10 teams. We set it up with you on a 20-minute call.

Agents you use

0/1000

We store this to contact you. See Privacy.

Plans

  • Free

    $0

    • 1 developer, 1 workspace
    • 3 agent API keys
    • 10,000 agent events a month
  • Starter

    $50/mo

    • Up to 3 developers
    • Everything in Free
    • Approvals with timeout
  • Team

    $99/mo

    • Up to 10 developers
    • +$9 per extra developer
    • Everything in Starter
  • Business

    From $499/mo

    • Everything in Team
    • Agent discovery
    • Retention and legal hold
See full pricing

Guardrails for Claude Code, Cursor and Codex

Request access