Skip to main content

Overview

Claude Code can call Fiddler Guardrails from its HTTP hooks, so every prompt a developer submits and every response Claude gives is checked for secrets and personally identifiable information (PII). No gateway or proxy is involved: each developer’s Claude Code calls Fiddler directly.
  • Prompts are checked on the UserPromptSubmit hook. A flagged prompt is blocked and never reaches the model.
  • Responses are checked on the Stop and SubagentStop hooks, after Claude finishes its turn. A flagged response gets a rewrite request: Claude is told what was found and asked to answer again without it. The developer has already seen the original response, so this flags it after the fact rather than preventing it.
Requires Fiddler 26.30 or later and Claude Code v2.1.295 or later. Earlier Fiddler releases either don’t have the endpoint (it returns HTTP 404) or let content Fiddler can’t check through by default; see Failure and Oversize Modes.

How It Works

Every hook posts its JSON input to the same URL. Fiddler reads the hook_event_name field, checks the one piece of text that event carries, and replies with hook output that Claude Code acts on.

Prerequisites

  • An Org Admin in Fiddler, to create the service account below.
  • A Fiddler URL whose hostname resolves to a public IP address. Claude Code refuses HTTP hooks to private addresses; see Network Requirements.
  • Claude Code v2.1.295 or later on each developer machine.

Quick Start

1

Create a service account key

In Fiddler, create a service account with Entire Org access and only the guardrails:invoke capability, then create an API key for it. An Entire Org key with guardrails:invoke can call Fiddler Guardrails and nothing else, so it can’t read your data.Make the key available to Claude Code as an environment variable, for example:
2

Add the hooks to your Claude Code settings

Add this hooks block to ~/.claude/settings.json, replacing <your-fiddler-url>. To roll it out to everyone, put it in managed settings instead; see Roll Out to Your Organization.
Claude Code fills in $FIDDLER_GUARDRAILS_API_KEY only because it’s listed in allowedEnvVars. "onFailure": "block" blocks the prompt when Fiddler can’t be reached or returns an error; without it, the prompt goes to the model unchecked. onFailure has no effect on Stop and SubagentStop.
3

Verify

Check that the key and URL work by sending the payload Claude Code would send for a prompt that contains an API key:
Expected output:
Then start Claude Code and submit the same prompt. Claude Code shows the reason and doesn’t send the prompt to the model. Right after a Fiddler deployment, the first checks can time out while the models start; see Timeouts.

What Gets Checked

UserPromptSubmit also fires on turns Claude Code starts itself, such as scheduled tasks, /loop iterations, a background subagent reporting back, and a message from another session. Those prompts are checked too, and can be blocked, for example as “could not be checked” while the models start. These aren’t checked:
  • Tool input and output, such as file contents Claude reads, command output, and MCP tool results.
  • The expanded content of a slash command or skill. The hook receives the command as typed, such as /deploy staging, so the skill’s content and any shell output it injects reach the model unchecked.
  • The contents of files attached with @ mentions. In Claude Code v2.1.311 the hook receives the mention, such as @.env, not the file contents.
  • Text Claude writes between tool calls. Only the final response of a turn reaches the Stop hook.
  • A subagent report delivered through the SubagentHandback tool. last_assistant_message holds only the subagent’s closing text.
  • Any other hook event. Fiddler returns {} for events it doesn’t check, so registering the URL on them has no effect.
Hooks can’t edit text, so a check whose default action is to redact (PII and secrets) blocks instead.

Check Behavior

By default, the endpoint runs the PII and secrets checks with Fiddler’s server-side defaults; see Guardrails and the secrets tutorial.

Header-Based Configuration

Set these in the hook’s headers, next to Authorization. They apply to every call from that hook, so you can configure UserPromptSubmit and Stop differently. x-fiddler-pii-mode and x-fiddler-secrets-mode are accepted but make no difference here, since both redact and block become a block. Naming a subset turns the others off. x-fiddler-guardrails: secrets runs only the secrets check, so an email address in a prompt is allowed. The PII override headers still apply when x-fiddler-guardrails is absent.

Reduce False Positives

The PII model’s default entity list includes broad types such as person names, which everyday coding prompts trip: a first name, a UUID, or a phrase like “use a subagent to” can be flagged. Limit PII to the entity types you care about with x-fiddler-pii-entities, for example:
The default list also includes a secret entity, so a key is often reported by both checks, as in secrets (Anthropic API Key), PII (secret).

What Developers and Claude See

Reasons name the category and never the text that was found:
A blocked prompt never reaches the model, but Claude Code can still keep it in local files such as the session transcript and prompt history. A hook keeps a secret away from the model, not off the developer’s disk.
Every flagged response gets a rewrite request, including when the hook input’s stop_hook_active is true. Claude Code ends a loop of rewrite requests itself: after 8 consecutive stop-hook continuations it ends the turn, and the count resets whenever Claude calls a tool. CLAUDE_CODE_STOP_HOOK_BLOCK_CAP changes the cap.

Failure and Oversize Modes

Two independent settings decide what happens to text Fiddler couldn’t check. Both default to closed.
  • x-fiddler-failure-mode: a check couldn’t complete, for example because it timed out or the detector returned an error.
  • x-fiddler-oversize-mode: the text is too long to check, either over the scan limit (50,000 characters by default) or rejected by the detector as too long.
x-fiddler-failure-mode: open doesn’t let oversized text through; set x-fiddler-oversize-mode: open for that. A response is never blocked because Fiddler couldn’t check it: the developer has already seen it, and there is nothing for Claude to fix. Long text under open. Developers often paste a file or a log and ask a question at the end, so for text over the limit Fiddler checks the beginning and the end. A secret or email address in the middle of a long paste isn’t found. If your deployment has per-message scanning turned on, the PII and secrets checks read the whole text with no limit. Long text then isn’t blocked under closed just for its length. Ask your Fiddler administrator whether it is on. To change the defaults for every hook at once, a self-hosted administrator can set the Helm values ingestionLlm.guardrailsFailureMode and ingestionLlm.guardrailsOversizeMode. Headers on a hook override them.

Timeouts

Two timeouts apply:
  • Claude Code’s hook timeout, in seconds. UserPromptSubmit defaults to 30. A hook that times out counts as a failure: the prompt goes ahead unchecked, or is blocked with "onFailure": "block".
  • Fiddler’s x-fiddler-timeout, 12 seconds by default. A check that doesn’t finish in time follows x-fiddler-failure-mode.
Keep the hook timeout above x-fiddler-timeout, with room to spare: 30 seconds or more with the default of 12. A request can run a few seconds past x-fiddler-timeout, and if your deployment has per-message scanning turned on, a check of text over 50,000 characters can take up to twice x-fiddler-timeout. If Claude Code gives up first, the hook counts as a failure instead of following x-fiddler-failure-mode. A warm check takes about a second. Right after a Fiddler deployment, checks can reach x-fiddler-timeout while the models start, and prompts are blocked as “could not be checked” until they’re ready.

Roll Out to Your Organization

Put the hooks block in Claude Code managed settings so it applies on every developer machine. Developers can’t remove hooks deployed this way, and disableAllHooks set outside managed settings doesn’t turn them off. These managed settings restrict which hooks run:
  • allowedHttpHookUrls: Claude Code runs an HTTP hook only if its URL is on this list.
  • httpHookAllowedEnvVars: Claude Code fills in only these environment variables in hook headers.
  • allowManagedHooksOnly: blocks hooks from user, project, local, and plugin settings, so only the hooks you deploy run.
With the setup on this page (x-fiddler-failure-mode at its closed default and "onFailure": "block" on UserPromptSubmit), every developer’s prompts are blocked while Fiddler can’t answer: during an outage, while the models start after an upgrade, or once the shared key has expired or been revoked. Rotate the key well before it expires, and decide deliberately whether prompts should be blocked or allowed when Fiddler is unavailable.
Distributing the key. Every developer machine needs the service account key, either in its environment or in the managed settings env block. A key copied to many laptops is likely to leak eventually. It can only call Fiddler Guardrails, but guardrail calls aren’t rate limited, so a leaked key could use your deployment’s guardrail capacity. That capacity is shared with your other guardrail integrations, such as LiteLLM and AgentGateway, so heavy use of a leaked key could slow or block their traffic too.
  • Use a service account and key for this purpose only, and one per team where practical.
  • Rotate the key well before it expires: an expired key blocks every developer’s prompts.
  • If a key leaks, follow Respond to a Leaked Key.

Network Requirements

Claude Code refuses to call an HTTP hook whose hostname resolves to a private or link-local address, such as 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, or 100.64.0.0/10. The hook fails with ERR_HTTP_HOOK_BLOCKED_ADDRESS, even over a VPN and even when the URL is in allowedHttpHookUrls. Only loopback addresses are exempt. This behavior was observed in Claude Code v2.1.309 and isn’t described in Anthropic’s documentation. If your Fiddler deployment is reachable only on private addresses, give it a hostname that resolves to a public IP address. Access can still be restricted to your corporate network by a firewall.

Data Handling

The endpoint checks the text in the request and returns a decision. It writes no prompt, response, or detection to any Fiddler datastore, and a decision produces no span or record in the Fiddler UI. Fiddler’s logs contain no prompt or response text: they record IDs, the event and the decision, plus detection counts, check names and scores. To see Claude Code sessions in Fiddler, add Claude Code Monitoring or the Fiddler Claude Code Plugin.

Troubleshooting

Prompts go through without being checked Run /hooks in Claude Code to confirm the hooks loaded, and check that the hostname resolves to a public IP address (see Network Requirements). Without "onFailure": "block", any hook failure lets the prompt through: a timeout, a connection error, or an HTTP error from Fiddler. HTTP 403 with “API key scope does not permit this operation” The key belongs to an Entire Org service account without the guardrails:invoke capability. Add the capability to the service account. HTTP 403 with “Guardrails is not enabled for this cluster”, or HTTP 404 Guardrails isn’t enabled on your deployment, the deployment predates Fiddler 26.29, or it’s a free-tier deployment. Contact your Fiddler administrator. HTTP 403 with a Specific Projects key Keys of Specific Projects service accounts can’t call guardrails. Use an Entire Org service account with guardrails:invoke. HTTP 401 The Authorization header is missing or the key is wrong. Check that the variable is set where Claude Code runs and listed in allowedEnvVars. Prompts are blocked as “could not be checked” A check didn’t finish within x-fiddler-timeout (failure_mode=closed), or the prompt was too long to check (oversize_mode=closed): over 50,000 characters with per-message scanning off, or rejected by the detector as too long. Right after a deployment, wait for the models to start. For long prompts, see Failure and Oversize Modes. Everyday prompts are blocked for PII See Reduce False Positives.

Endpoint Reference

Authentication: Authorization: Bearer <api-key>. The key can be an Entire Org service account key with guardrails:invoke (recommended), or the API key of a user who is an Org Admin or Org Member. Don’t put a user’s API key in hook settings: it carries all of that user’s access to Fiddler data. The request body is the hook input Claude Code sends. Fiddler reads hook_event_name, prompt (UserPromptSubmit), last_assistant_message (Stop, SubagentStop), and session_id and prompt_id for its logs. It ignores every other field, including cwd and transcript_path. Response bodies:

Known Limitations

Next Steps