
cc-gateway-ai-proxy
Deploy and configure CC Gateway, a reverse proxy that normalizes Claude Code device fingerprints and telemetry for privacy-preserving API proxying
- Installs
- 714
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/trending-skills --skill cc-gateway-ai-proxy- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads cc-gateway-ai-proxy automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
CC Gateway — AI API Identity Gateway
Skill by ara.so — Daily 2026 Skills collection.
CC Gateway is a TypeScript reverse proxy that sits between Claude Code clients and the Anthropic API. It normalizes 40+ device fingerprint dimensions (device ID, email, environment, RAM, headers, and system prompt content) to a single canonical identity, manages OAuth token refresh centrally, and prevents telemetry leakage from multi-machine setups.
Architecture Overview
Client (Claude Code + env vars + Clash)
└─► CC Gateway (rewrite + auth inject + SSE passthrough)
└─► api.anthropic.com (single canonical identity)
Gateway also contacts:
platform.claude.com (OAuth token refresh only)
Three-layer defense:
| Layer | Mechanism |
|---|---|
| Env vars | Route CC traffic to gateway, disable side channels |
| Clash rules | Block any direct Anthropic connections at network level |
| Gateway | Rewrite all 40+ fingerprint dimensions in-flight |
Installation
Prerequisites
- Node.js 18+ or Docker
- A machine that has previously logged into Claude Code (for OAuth token extraction)
Clone and Install
git clone https://github.com/motiful/cc-gateway.git
cd cc-gateway
npm install
Generate Identity and Tokens
# Create a stable canonical identity (device_id, email, env profile)
npm run generate-identity
# Create a bearer token for a specific client machine
npm run generate-token my-laptop
npm run generate-token work-desktop
Extract OAuth Token (from a logged-in machine)
# macOS — copies refresh_token from Keychain
bash scripts/extract-token.sh
Configure
cp config.example.yaml config.yaml
Edit config.yaml:
# config.yaml
identity:
device_id: "GENERATED_DEVICE_ID" # from generate-identity
email: "canonical@example.com"
platform: "darwin"
arch: "arm64"
node_version: "20.11.0"
shell: "/bin/zsh"
home: "/Users/canonical"
working_directory: "/Users/canonical/projects"
memory_gb: 16 # canonical RAM value
oauth:
refresh_token: "EXTRACTED_REFRESH_TOKEN" # from extract-token.sh
clients:
- name: my-laptop
token: "GENERATED_CLIENT_TOKEN"
- name: work-desktop
token: "ANOTHER_CLIENT_TOKEN"
server:
port: 8443
tls: false # true for production with certs
Starting the Gateway
# Development (no TLS, hot reload)
npm run dev
# Production build
npm run build && npm start
# Docker Compose (recommended for production)
docker-compose up -d
Docker Compose Example
# docker-compose.yml
version: "3.8"
services:
cc-gateway:
build: .
ports:
- "8443:8443"
volumes:
- ./config.yaml:/app/config.yaml:ro
restart: unless-stopped
environment:
- NODE_ENV=production
Verification
# Health check
curl http://localhost:8443/_health
# Show before/after rewrite diff (requires client token)
curl -H "Authorization: Bearer YOUR_CLIENT_TOKEN" \
http://localhost:8443/_verify
Client Machine Setup
On each machine running Claude Code, set these environment variables:
# ~/.bashrc or ~/.zshrc
# Route all Claude Code API traffic through the gateway
export ANTHROPIC_BASE_URL="https://gateway.your-domain.com:8443"
# Disable side-channel telemetry (Datadog, GrowthBook, version checks)
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# Skip browser OAuth — gateway handles authentication
export CLAUDE_CODE_OAUTH_TOKEN="gateway-managed"
# Authenticate to the gateway with the per-machine token
export ANTHROPIC_CUSTOM_HEADERS="Proxy-Authorization: Bearer YOUR_CLIENT_TOKEN"
Or use the interactive setup script:
bash scripts/client-setup.sh
Then just run claude — no login prompt required.
Clash Rules (Network-Level Blocking)
Add to your Clash configuration to block any direct Anthropic connections:
# clash-rules.yaml excerpt
rules:
- DOMAIN,gateway.your-domain.com,DIRECT # Allow your gateway
- DOMAIN-SUFFIX,anthropic.com,REJECT # Block direct API calls
- DOMAIN-SUFFIX,claude.com,REJECT # Block direct OAuth
- DOMAIN-SUFFIX,claude.ai,REJECT # Block Claude web
- DOMAIN-SUFFIX,datadoghq.com,REJECT # Block Datadog telemetry
- DOMAIN-SUFFIX,statsig.com,REJECT # Block feature flags
See clash-rules.yaml in the repo for the full template.
What Gets Rewritten
| Layer | Field | Transformation |
|---|---|---|
| Identity | device_id | → canonical ID from config |
| Identity | email | → canonical email |
| Environment | env object (40+ fields) | → entire object replaced |
| Process | constrainedMemory (physical RAM) | → canonical value |
| Process | rss, heapTotal, heapUsed | → randomized in realistic range |
| Headers | User-Agent | → canonical CC version string |
| Headers | Authorization | → real OAuth token (injected) |
| Headers | x-anthropic-billing-header | → canonical fingerprint |
| Prompt text | Platform, Shell, OS Version | → canonical values |
| Prompt text | /Users/xxx/, /home/xxx/ | → canonical home prefix |
| Leak fields | baseUrl | → stripped |
| Leak fields | gateway provider field | → stripped |
TypeScript Usage Examples
Custom Rewriter Extension
// src/rewriters/custom-field-rewriter.ts
import { RequestRewriter } from '../types';
export const customFieldRewriter: RequestRewriter = {
name: 'custom-field-rewriter',
rewriteBody(body: Record<string, unknown>, config: CanonicalConfig): Record<string, unknown> {
// Strip any custom analytics fields your org adds
const { __analytics, __session_debug, ...cleaned } = body as any;
// Normalize any additional identity fields
if (cleaned.metadata?.user_id) {
cleaned.metadata.user_id = config.identity.device_id;
}
return cleaned;
},
rewriteHeaders(headers: Record<string, string>, config: CanonicalConfig): Record<string, string> {
return {
...headers,
'x-custom-client': 'canonical',
};
}
};
Programmatic Gateway Start
// scripts/start-with-monitoring.ts
import { createGateway } from '../src/gateway';
import { loadConfig } from '../src/config';
async function main() {
const config = await loadConfig('./config.yaml');
const gateway = await createGateway(config);
gateway.on('request', ({ clientId, path }) => {
console.log(`[${new Date().toISOString()}] ${clientId} → ${path}`);
});
gateway.on('rewrite', ({ field, before, after }) => {
console.log(`Rewrote ${field}: ${before} → ${after}`);
});
gateway.on('tokenRefresh', ({ expiresAt }) => {
console.log(`OAuth token refreshed, expires: ${expiresAt}`);
});
await gateway.listen(config.server.port);
console.log(`Gateway running on port ${config.server.port}`);
}
main().catch(console.error);
Token Generation (Programmatic)
// scripts/provision-client.ts
import { generateClientToken, addClientToConfig } from '../src/auth';
async function provisionNewMachine(machineName: string) {
const token = await generateClientToken(machineName);
await addClientToConfig('./config.yaml', {
name: machineName,
token,
created_at: new Date().toISOString(),
});
console.log(`Client token for ${machineName}:`);
console.log(token);
console.log('\nAdd to client machine:');
console.log(`export ANTHROPIC_CUSTOM_HEADERS="Proxy-Authorization: Bearer ${token}"`);
}
provisionNewMachine(process.argv[2] ?? 'new-machine');
Key npm Scripts
| Command | Purpose |
|---|---|
npm run dev | Start with hot reload (development) |
npm run build | Compile TypeScript to dist/ |
npm start | Run compiled production build |
npm test | Run rewriter test suite (13 tests) |
npm run generate-identity | Create canonical device profile |
npm run generate-token <name> | Create per-client bearer token |
Common Patterns
Multiple Machines, One Identity
# On gateway server — generate once
npm run generate-identity
# → device_id: abc-123, email: canonical@proxy.local
# Provision each machine
npm run generate-token laptop-home # → token-aaa
npm run generate-token laptop-work # → token-bbb
npm run generate-token desktop # → token-ccc
# All three machines present as the same device to Anthropic
Rotating the Canonical Identity
# Generate a new identity (e.g., after a suspected flag)
npm run generate-identity --force
# Update config.yaml with new device_id
# Restart gateway — all clients immediately use new identity
docker-compose restart cc-gateway
Checking for New Telemetry Fields After CC Updates
# After a Claude Code update, use _verify to diff
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8443/_verify | jq '.unrewritten_fields'
# Monitor Clash logs for new endpoints
# Any REJECT hits on new domains = new hardcoded endpoints
Troubleshooting
claude still prompts for browser login
- Ensure
CLAUDE_CODE_OAUTH_TOKEN=gateway-managedis exported - Verify
ANTHROPIC_BASE_URLpoints to your running gateway - Check gateway logs:
docker-compose logs -f cc-gateway
401 Unauthorized from gateway
- Confirm
ANTHROPIC_CUSTOM_HEADERScontainsProxy-Authorization: Bearer <token> - Verify the token in config.yaml matches the one set in env var
- Run
curl -H "Authorization: Bearer $TOKEN" http://localhost:8443/_health
OAuth token expired
# Re-extract from a logged-in machine
bash scripts/extract-token.sh
# Paste new refresh_token into config.yaml
docker-compose restart cc-gateway
MCP servers bypassing gateway
MCP uses mcp-proxy.anthropic.com which ignores ANTHROPIC_BASE_URL. Add to Clash:
- DOMAIN,mcp-proxy.anthropic.com,REJECT
Requests reaching Anthropic directly (Clash not blocking)
- Check Clash is running:
clash -v - Verify rules are loaded: look for REJECT entries in Clash dashboard
- Test:
curl https://api.anthropic.com— should fail if Clash is active
Gateway rewrite not applying to a new field
After a Claude Code update, new telemetry fields may not be covered. Check /_verify for unrewritten_fields, then open an issue or add a custom rewriter (see Custom Rewriter Extension above).
Caveats
- MCP servers — hardcoded endpoint, use Clash to block if not needed
- CC updates — monitor Clash REJECT logs after every Claude Code update for new endpoints
- Refresh token lifetime — if the OAuth refresh token expires, re-run
extract-token.sh - ToS — do not use for account sharing; intended for managing your own devices under one subscription
- Alpha — test with a non-primary account before production use
FAQ
What does the cc-gateway-ai-proxy skill do?
Deploy and configure CC Gateway, a reverse proxy that normalizes Claude Code device fingerprints and telemetry for privacy-preserving API proxying
How do I install cc-gateway-ai-proxy?
Run npx skills add https://github.com/reason-machines/trending-skills --skill cc-gateway-ai-proxy in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/cc-gateway-ai-proxy/ (personal) or .claude/skills/cc-gateway-ai-proxy/ (project).
Which AI agents can use cc-gateway-ai-proxy?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is cc-gateway-ai-proxy safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains cc-gateway-ai-proxy?
It is published by reason-machines in reason-machines/trending-skills. It has 714 recorded installs.
More from reason-machines/trending-skills
openclaw-control-center
reason-machines/trending-skills
Local-first, security-first control center for OpenClaw agents — visibility dashboard with readonly defaults, token attribution, collaboration tracing, and safe write operations.
inkos-multi-agent-novel-writing
reason-machines/trending-skills
Multi-agent CLI system for autonomous novel writing, auditing, and revision with human review gates
claude-hud-statusline
reason-machines/trending-skills
A Claude Code plugin that displays a real-time HUD showing context usage, active tools, running agents, and todo progress in your terminal statusline.
understand-anything-knowledge-graph
reason-machines/trending-skills
Turn any codebase into an interactive knowledge graph using Claude Code skills — explore, search, and ask questions about any project visually.
agency-agents-ai-specialists
reason-machines/trending-skills
A collection of specialized AI agent personalities for Claude Code, Cursor, Aider, Windsurf, and other AI coding tools — covering engineering, design, marketing, sales, and more.
agent-browser-automation
reason-machines/trending-skills
Headless browser automation CLI for AI agents using native Rust binary with Chrome DevTools Protocol
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.