What It Took to Actually Govern Claude Code Across Our Engineering Team TrueFoundry's engineering team implemented governance for Claude Code after an audit revealed 60+ engineers using the tool with no oversight, and two CVEs exposed critical vulnerabilities. The team found that repo-level `.claude/settings.json` files could execute arbitrary shell commands or redirect API traffic, leading them to route Claude Code through an AI Gateway to keep Anthropic keys off developer machines. TL;DR A few months ago our security team flagged something in an audit: we had 60+ engineers using Claude Code, and our "governance" for it was essentially nothing. API keys were in .bash profile files. There was no way to see what models people were hitting, what it was costing, or who had access to what. When someone left the company, we had no clean way to revoke their Claude Code access without hunting down which machine they'd set their key on. We'd done all the right things for Claude.ai — SSO, domain capture, admin console, the works. But Claude Code is a different beast. It's not a web app. It runs in a terminal with the developer's full filesystem permissions, and it authenticates with an API key, not a browser session. None of our web-layer controls touched it. The audit was uncomfortable. Then the CVEs made it urgent. In early 2026, Check Point Research published findings on two vulnerabilities in Claude Code — CVE-2025-59536 and CVE-2026-21852 — that made me realize we'd been thinking about this wrong. CVE-2025-59536 CVSS 8.7 : A malicious .claude/settings.json in a repository could execute arbitrary shell commands before Claude Code even showed a trust dialog. In earlier versions, hooks defined in that file ran at startup — before the user was asked to confirm anything. Cloning an attacker's repo and running claude in it was enough to get RCE on a developer's machine. CVE-2026-21852 CVSS 5.3 : This one hit differently. Claude Code uses an environment variable called ANTHROPIC BASE URL to decide where to send API requests. A malicious repo could override that via its settings file, redirecting all traffic — including the authentication header carrying the developer's API key — to an attacker-controlled server. The attacker proxies requests to the real Anthropic API so nothing looks broken. The developer notices nothing. The attacker has your key. Both are patched now CVE-2025-59536 in v1.0.111, CVE-2026-21852 in v2.0.65 . But the thing that stuck with me wasn't the specific vulnerabilities — it was the underlying assumption they exposed. We'd all been treating .claude/settings.json as passive config. It's not. In an agentic tool that can run shell commands and call external APIs, repo-level config is part of the execution layer. Same threat model as a malicious package.json postinstall script. We just weren't thinking about it that way yet. After the CVE disclosure, my team did a sweep of our repos and found three that had .claude/settings.json files with non-standard ANTHROPIC BASE URL overrides. None of them were malicious — developers had put them there for legitimate local testing. But they also would have redirected traffic for anyone else who cloned those repos. We removed them and added a CI check. Then we started working on the actual governance problem. This was the most embarrassing one to admit. Every developer using Claude Code had either: a Their own personal Anthropic key which meant their personal billing, no audit trail, and no way to revoke on offboarding b A shared team key that lived in a shared .env somewhere which is worse The fix seems obvious in retrospect — issue keys through the Anthropic Admin Console with explicit expiry, store them in AWS Secrets Manager or HashiCorp Vault, and never let them touch .bash profile or shell history. Rotate quarterly, revoke immediately on offboarding. But the deeper fix was routing Claude Code through a gateway so the Anthropic key never lived on developer machines at all. With AI Gateway https://www.truefoundry.com/docs/ai-gateway/claude-code , developers authenticate to the gateway with a scoped virtual key. The underlying Anthropic credential stays in the gateway's secrets manager. If a developer's machine is compromised, the attacker gets a gateway key that we can revoke from a dashboard — not a raw Anthropic API key with workspace-level access. That distinction matters more than it sounds. A stolen Anthropic key can access all workspace files, modify shared data, and run up API costs before you notice. A stolen gateway key gets you a revocable token with model-level and budget-level restrictions baked in. Before we set up the gateway, our "observability" for Claude Code was checking the Anthropic billing dashboard once a month and wincing. We had no idea: Setting ANTHROPIC BASE URL to point at a gateway is the single highest-leverage change you can make to a Claude Code deployment. One line of config gives you a centralized enforcement point for everything — not just observability, but model allowlisting, per-developer rate limits, fallback routing, and budget caps. export ANTHROPIC BASE URL=https://