Integrations/Claude Code
Live

GuardEntry × Claude Code

Point Claude Code (terminal CLI or the VS Code extension) at GuardEntry's gateway to get real cost telemetry on your own sessions — and, opportunistically, cache-and-model-tier savings as they ship — plus policy enforcement on risky tool calls via a lightweight hook. Pick either capability, or both, from a single API key.

Gateway — Reduce Token Costs

Claude Code's full request — system prompt, conversation history, tool definitions — is proxied through GuardEntry using your own Anthropic API key, on every turn. Real, per-org token/cost telemetry; model-tier routing and prompt caching land in later phases.

APR — Enforce Security Policy

A PreToolUse hook evaluates each tool call against your Agent Policy before it runs — block or require approval on risky actions, fail-open if GuardEntry is unreachable.

Prerequisites

  • Claude Code — terminal CLI, and/or the VS Code extension
  • A GuardEntry API key — mint one from the setup wizard
  • (Gateway only) Your organization's own Anthropic API key on file under Settings → AI Provider — the gateway forwards using it, so GuardEntry never eats inference cost
1

Mint a scoped API key

Use the setup wizard — it asks which capability you want (gateway, APR, or both) and labels the key accordingly, so it's easy to identify and rotate later from your API keys list.

GatewayReduce token costs
2

Point Claude Code at the gateway

Claude Code reads ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN once at process startup — restart Claude Code after saving this config. The VS Code extension and the terminal CLI use different configuration surfaces — don't conflate them.

VS Code extension — add to VS Code's own user settings, a separate file from anything named settings.json under .claude. On Windows this lives at %APPDATA%\Code\User\settings.json:

  1. Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette.
  2. Type Preferences: Open User Settings (JSON) and select it from the list.
  3. Paste the block below into the file that opens.
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://app.guardentry.ai/api/gateway" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "ge_gw_<your-key>" }
  ]
}

Terminal CLI — add to Claude Code CLI's own config, ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json, e.g. C:\Users\you\.claude\settings.json) — under its env block (not shell export — Claude Code subprocesses don't inherit shell env vars):

  1. Open the file in a text editor — if it doesn't exist yet, create it first: mkdir -p ~/.claude && touch ~/.claude/settings.json.
  2. If the file already has content, merge the "env" key below into your existing JSON as a sibling key — don't replace the rest of the file.
  3. If it's empty, paste the block below as-is.
{ "env": {
    "ANTHROPIC_BASE_URL": "https://app.guardentry.ai/api/gateway",
    "ANTHROPIC_AUTH_TOKEN": "ge_gw_<your-key>"
} }
APREnforce security policy
3

Install the PreToolUse hook

Run this in a terminal — macOS/Linux Terminal, or Git Bash/WSL on Windows (not PowerShell or cmd — the install path and hook command use Unix shell syntax). curl ships by default on macOS and most Linux distributions; Git Bash and WSL both include it too. Installing to ~/.local/bin (rather than /usr/local/bin) avoids needing admin/root rights — on Windows Git Bash in particular, /usr/local/bin needs elevation and curl fails with Failure writing output to destination without it.

mkdir -p ~/.local/bin && curl -fsSL https://app.guardentry.ai/fastgrc-hook.sh -o ~/.local/bin/guardentry-hook && chmod +x ~/.local/bin/guardentry-hook
  1. Open (or create) Claude Code CLI's config — ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json): mkdir -p ~/.claude && touch ~/.claude/settings.json. Only the same file as the Terminal CLI env block above — not VS Code's user settings, which is a separate file entirely.
  2. If it already has content — including that Terminal CLI env block, if you set that up too — merge the "hooks" key below in as a sibling key. Don't overwrite the rest of the file.
  3. If it's empty, paste the block below as-is.
{
  "hooks": {
    "PreToolUse": [{
      "matcher": ".*",
      "hooks": [{ "type": "command", "command": "GUARDENTRY_API_KEY=ge_k1_your_key ~/.local/bin/guardentry-hook" }]
    }]
  }
}

Using the gateway too? The same script also handles a PostToolUse event that prints a running savings summary directly in your Claude Code session — register it alongside PreToolUse with the same key, throttled to once every 5 minutes. The setup wizard generates the combined config automatically.

4

Verify the connection

Restart Claude Code and run a prompt (or trigger a tool call, for the APR hook). The setup wizard's verify step turns green as soon as GuardEntry sees a call from your key — gateway traffic shows up in Tokenomics, APR decisions show up in the audit log.

Troubleshooting

⚠️curl: (23) Failure writing output to destination — you're installing to /usr/local/bin, which needs admin/root rights (common on Windows Git Bash, where it maps under Program Files). Use the ~/.local/bin command above instead — no elevation required.
⚠️Config changes don't seem to take effect — both ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are read once at process startup — fully restart Claude Code (quit and reopen the terminal / reload the VS Code window) after editing settings.
⚠️503 from the gateway — your organization has no Anthropic API key on file. Add one under Settings → AI Provider; the gateway forwards using it and never eats inference cost itself.
⚠️Tool search behaves oddly behind the gateway — Claude Code disables tool search by default when ANTHROPIC_BASE_URL points at a custom endpoint. Set ENABLE_TOOL_SEARCH=true once you've confirmed the gateway forwards tool blocks correctly.
⚠️PreToolUse hook never blocks anything — the hook fails open if GUARDENTRY_API_KEY is unset, curl fails, or the request times out (5s). Check the key is embedded directly in the hook command string, not a shell export.