Claude Code & CloakDoor quickstart
Step-by-step quickstart to connect Claude Code, Codex, Grok Build, OpenCode, Goose, Hermes, and any OpenAI/Anthropic coding agent to Regents Cloak's localhost gateway (127.0.0.1:8742) with Secret Tripwire, reversible PII masking, per-app rail selection, Claude model alias mapping, limits, curl verification, and cloak CLI.
On this page
- Overview
- 1. Prerequisites & Lifecycle
- 2. Generate, Copy, Rotate, or Revoke an App Key
- Option A: 1-Click Connect (Detected on This Mac)
- Option B: Manual Key Creation & Setup Presets
- Rotate, Pause, or Revoke a Key
- 3. Per-App Rail Selection & Smart Failover Guarantee
- Switch one connected app between local and cloud
- 4. Auth Environment Variables (ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN)
- 5. Privacy Shield Controls & Local Access Scope
- 6. Model Availability & Claude Model Alias Mapping
- 7. CloakDoor API Limits & Streaming Behavior
- 8. Bundled cloak CLI Install & Verification (curl + Secret Tripwire)
- Put the bundled cloak CLI on your PATH
- Verify CloakDoor with curl
- Test the Secret Tripwire with a fake token
- 9. Pasteable Setup Prompt for Coding Agents
- Related Docs
Overview
Regents Cloak includes CloakDoor, a localhost-only Anthropic Messages and OpenAI Chat Completions gateway at http://127.0.0.1:8742 (acceptLocalOnly = true, cross-site browser Origin headers rejected). Use it to run Claude Code, Codex, Grok Build, OpenCode, Goose, Hermes, Cline, Aider, or any Anthropic/OpenAI SDK through Cloak's Universal Privacy Shield (Secret Tripwire + reversible alias masking + opt-in on-device NewmeanPII), per-app Spend Guardrails, and all 5 routing rails (Local ($0), NEAR TEE, Venice, Boundless / Tempo, and zkAPI Anon).
Terminology map:Local AI is Cloak's offline chat mode (
⌘1), Local ($0) is the zero-costCloakDoorrail, andLocal Mac onlyis the master Security Profile (Settings → General → Allowed connections) that hard-blocks all cloud chat modes, cloudCloakDoorrails, wallets, and network serving.
1. Prerequisites & Lifecycle
- App running & unlocked:
Cloak.appmust be running in your macOS menu bar with your Keychain unlocked forhttp://127.0.0.1:8742to listen (you can customize the port under Settings → Advanced). - When you do NOT need to press Start:
Local ($0), directNEAR TEE, and directVeniceHTTPS (Tor toggled off) work immediately without starting Tor or the Linux microVM. - When you DO need to press Start: Tor-routed
Venice,Boundless (Tempo USDC.e), andzkAPI Anonrequire pressing Start in the menu bar (or runningcloak start) to launch bundled Tor (0.4.9.16), the NIC-less Linux microVM, and the localQwen 3.5 9Bprompt rewriter. - Security Profile changes need no restart: Switching Settings → General → Allowed connections (
Local Mac only,zkAPI only, orCloud allowed) takes effect immediately insideSupervisorandCloakDooron the very next request—no app restart required.
2. Generate, Copy, Rotate, or Revoke an App Key
Open Settings → Connected Apps inside Regents Cloak.
Option A: 1-Click Connect (Detected on This Mac)
If Claude Code, Codex, Grok Build, OpenCode, or Goose is installed on your Mac, Cloak shows it under Settings → Connected Apps → Detected on This Mac:
- Click Connect next to Claude Code.
- Cloak automatically:
- Revokes any previous duplicate key with the exact same name (
Claude Code) and issues a fresh scopedcloak-<64 hex>key (only its SHA-256 hash is persisted on disk). - Saves a reversible backup of
~/.claude/settings.json. - Merges
ANTHROPIC_BASE_URL=http://127.0.0.1:8742,ANTHROPIC_API_KEY=cloak-<64 hex>, andCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1into~/.claude/settings.jsonwithout overwriting unrelated keys.
- Revokes any previous duplicate key with the exact same name (
- Click Test next to Claude Code to verify live loopback authentication (
200 OK, latency in ms, model count, and Privacy Shield status) without spending cloud tokens. - Click Disconnect at any time to restore your backed-up
~/.claude/settings.jsonand revoke Cloak's key.
Option B: Manual Key Creation & Setup Presets
- Under Settings → Connected Apps → Apps, click Connect an app….
- Type an app name (or click a quick chip:
Claude Code,Codex,Grok Build,OpenCode,Goose) and click Create Key. - Copy the displayed
cloak-<64 hex>key immediately—Cloak displays the raw key only once (it stores only the SHA-256 fingerprint). - Pick a segmented setup preset (
Claude Code,OpenCode,Goose, orOpenAI / Other) to copy the exact launch command or config snippet:- Claude Code preset:
ANTHROPIC_BASE_URL=http://127.0.0.1:8742 ANTHROPIC_API_KEY=<key> CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 claude - OpenCode preset:
opencode.json@ai-sdk/openai-compatibleprovider block pointing athttp://127.0.0.1:8742/v1 - Goose preset:
GOOSE_PROVIDER=openai OPENAI_HOST=http://127.0.0.1:8742 OPENAI_BASE_PATH=v1/chat/completions OPENAI_API_KEY=<key> goose session - OpenAI / Other preset:
OPENAI_BASE_URL=http://127.0.0.1:8742/v1 OPENAI_API_KEY=<key>
- Claude Code preset:
- Click Done, then optionally click Rules… next to your app to customize its destination, model override, project terms, or spend caps.
Rotate, Pause, or Revoke a Key
- Pause / Resume: Click Pause next to an app in Settings → Connected Apps → Apps to block that single app's requests immediately without deleting its key or affecting other apps.
- Revoke: Click the trash icon (Remove) next to the app to invalidate its
cloak-<64 hex>key immediately. - Rotate: Remove the app and click Connect an app… (or click Connect under Detected on This Mac, which revokes any existing key of the same name and replaces it with a new key).
3. Per-App Rail Selection & Smart Failover Guarantee
You do not need to switch your global Security Profile to Local Mac only just to keep one tool local:
- Global default: Set Settings → Connected Apps → Default for all apps to any rail allowed by your Security Profile (
Local ($0),NEAR TEE,Venice · Base,Boundless · Tempo, orzkAPI Anon). - Per-app override: In Settings → Connected Apps → Apps, click Rules… next to an app (for example,
Claude Code), then set:- Run with: Choose
Local ($0)(or a specific cloud rail) independently of other apps and independently of Cloak's Chat window. - Model override: Pin a specific model ID on that rail (leave blank for
Auto). - Allowed fallback routes: Optionally select explicit backup routes if the primary route is unavailable.
- Spending limits: Set per-request, daily, and monthly USD caps (enforced by fail-closed
SpendLedger). - Project Profile: Link a Saved Project Profile (Settings → Local Models → Projects) to attach its Private Terms to this app's Privacy Shield scans.
- Run with: Choose
Smart Private Cloud Failover guarantee: Cloak's opt-in Smart Failover only activates when an app's primary route is a cloud rail (primary.isCloud == true). Smart Failover can never jump off Local ($0) to a cloud rail. An app bound to Local ($0) stays 100% on-device unless you explicitly check a cloud route inside that app's Rules… → Allowed fallback routes.
Switch one connected app between local and cloud
In Settings → Connected Apps, click Pin beside Claude Code or another connected app. Open the Cloak menu in the macOS menu bar and find the app under Private cloud through Cloak. If prompted, choose a cloud provider for that app.
Switch private cloud off to keep that app’s new requests on this Mac. Switch it on to restore its saved cloud rules. Your other apps keep their own settings. To stop requests from every connected app, click Pause apps.
4. Auth Environment Variables (ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN)
CloakDoor accepts your cloak-<64 hex> key in either header:
x-api-key: cloak-...(sent by Claude Code whenANTHROPIC_API_KEYis set)Authorization: Bearer cloak-...(sent by Claude Code whenANTHROPIC_AUTH_TOKENis set, and by OpenAI SDKs)
# Standard launch (works cleanly when no claude.ai OAuth session takes precedence)
ANTHROPIC_BASE_URL=http://127.0.0.1:8742 \
ANTHROPIC_API_KEY=cloak-<64-hex> \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude
# Recommended if you already have a saved claude.ai OAuth login in Claude Code:
# setting ANTHROPIC_AUTH_TOKEN guarantees Claude Code sends Bearer auth to CloakDoor
# instead of colliding with an existing claude.ai OAuth session.
ANTHROPIC_BASE_URL=http://127.0.0.1:8742 \
ANTHROPIC_AUTH_TOKEN=cloak-<64-hex> \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude
- Why
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1is included: It disables Claude Code's background telemetry, update checks, and error-reporting pings to Anthropic's servers so Claude Code's traffic stays directed tohttp://127.0.0.1:8742.
5. Privacy Shield Controls & Local Access Scope
All Privacy Shield controls live under Settings → Connected Apps → Privacy Shield (Chat & Connected Apps) and apply across Chat cloud rails, CloakDoor, and the Guest Agent Box:
| Control | Where to configure | Behavior on Local ($0) | Behavior on Cloud rails |
|---|---|---|---|
| Secret Tripwire | Settings → Connected Apps → Privacy Shield | Scans outbound request JSON when enabled (except requests explicitly rerouted locally via Tripwire); traffic never leaves your Mac | Scans pre-send for PEM keys, API tokens, JWTs, wallet keys, BIP-39 seeds, PGP blocks, Bearer headers, and .env secrets. Pops the interactive Privacy Tripwire HUD to Block (HTTP 400 secret_blocked), Scrub & Send, or Reroute Local ($0) |
| Reversible alias masking & Private Terms | Settings → Connected Apps → Privacy Shield (+ per-project terms in Settings → Local Models → Projects) | Applies deterministic masking & alias restoration when enabled | Masks emails, paths, ETH addresses, ENS names, non-loopback IPs, and custom Private/Project Terms; restores aliases in human-facing reply prose, never in tool_calls arguments or blocked secrets |
On-device Neural PII (NewmeanPII, 12.1 MB) | Settings → Connected Apps → Privacy Shield → On-device Neural PII Detector (off by default; click Download Model) | Automatically skipped on Local ($0) so local inference never blocks on cloud PII availability | Runs pure-C arm64 NEON NER locally (~10–15 ms). On inspection error defaults to Block cloud sends (HTTP 503 neural_pii_unavailable). Switching On inspection error to Degraded (regex-only) falls back to deterministic regex + Private Terms and emits the HTTP response header X-Cloak-Privacy-Mode: degraded-regex-only |
Local Prompt Rewriter (Qwen 3.5 9B) | Settings → Connected Apps → Privacy Shield → Rewrite wording | Skipped on Local ($0) | Paraphrases role == "user" text on Tor cloud rails (Venice, Boundless, zkAPI); skipped on NEAR TEE. System/tool/assistant blocks pass unchanged |
| Local Access (approved folders, PDFs, OCR, Voice, Calendar/Reminders/Contacts) | Settings → Local Access | Not available to CloakDoor (Local AI Chat only) | Not available to CloakDoor (zero code path outside Local AI Chat) |
Important header detail:
X-Cloak-Privacy-Mode: degraded-regex-onlyis an HTTP response header emitted by CloakDoor when you have explicitly selected Degraded (regex-only) under Settings → Connected Apps → Privacy Shield → On-device Neural PII Detector → On inspection error and Neural PII fell back to regex-only mode. Clients do not need to sendX-Cloak-Privacy-ModeinANTHROPIC_CUSTOM_HEADERS.
6. Model Availability & Claude Model Alias Mapping
When an app sends a model ID to CloakDoor, Cloak resolves it in strict order:
- Per-app Model override (Rules… → Model override) or global Default model (if listed on the chosen rail).
- Exact model ID match against that rail's live
/v1/modelslist. - Automatic alias fallback on
/v1/messages: Any unknown Claude alias (such asclaude-sonnet-4-6,claude-opus-4-6,claude-haiku-4-5, or dated variants) maps cleanly to the rail's active/preferred default model so Claude Code works without manual model-ID rewrites.
| CloakDoor Rail | Serves actual Anthropic Claude models? | Models available (GET /v1/models) | How Claude aliases (claude-sonnet-*, claude-opus-*, claude-haiku-*) resolve |
|---|---|---|---|
Local ($0) | No (100% offline open models) | Active downloaded local model (Inkling 2 Mini MLX / Ora vision GGUF / nanoattention, Qwen 3.5 4B, Qwen 3.8 27B, Qwen 3.8 Flash Next) or selected loopback server (Ollama, LM Studio, mlx-serve, Splash, TensorFold) | Maps automatically to your active / first ready local model on this Mac |
NEAR TEE | No (NEAR Confidential TEE open-weight catalog) | Qwen 3.8 27B (default), GLM 5.3 Flash, DeepSeek V4.1 Flash, Qwen 3.6 35B A3B, NEAR AI Red | Maps automatically to the active NEAR TEE default model (Qwen 3.8 27B) |
Venice · Base | No on Private/TEE tiers (open-weight Private & TEE models) | Venice's provider-reported Private and TEE models (Cloak blocks non-private downgrades) | Maps automatically to your preferred Venice Private/TEE model |
Boundless · Tempo | Yes | Boundless frontier catalog including Anthropic Claude models (e.g. anthropic/claude-sonnet-4-6, anthropic/claude-opus-4-6) — check live IDs via GET /v1/models | Exact match passes through; unknown Claude aliases map to your preferred Boundless model |
zkAPI Anon | Yes | Open Anonymity catalog including Tier 25 Anthropic Claude Sonnet & Claude Opus models (requires $5+ ETH deposit for Tier 25) — check live IDs via GET /v1/models | Exact match passes through; unknown Claude aliases map to your preferred zkAPI model |
7. CloakDoor API Limits & Streaming Behavior
| Parameter / Capability | Exact CloakDoor Limit / Behavior |
|---|---|
| Bind address & CORS | 127.0.0.1:8742 (acceptLocalOnly = true); requests carrying a browser Origin header are rejected |
| Supported endpoints | GET /v1/models, POST /v1/messages (including ?beta=true), POST /v1/messages/count_tokens (local estimate, zero network), POST /v1/chat/completions. (POST /v1/responses returns HTTP 404.) |
| Max request body | 8 MiB (HTTP 413 request_too_large) |
| Max messages per request | 4,096 messages |
| Max rewritten transcript | 8 MiB |
Max model ID length | 256 UTF-8 bytes |
n and store parameters | n must be omitted or 1; store: true is rejected (HTTP 400) |
| Images & files | Inline data: URLs (image_url) and file_data only; remote URLs and file_id references are rejected (HTTP 400) |
SSE streaming (stream: true) | Accepted on /v1/messages and /v1/chat/completions. Buffered SSE: Cloak waits for the full completion so reversible alias restoration and SpendLedger settlement complete atomically, then returns a valid Anthropic SSE sequence (message_start → content_block_* → message_delta → message_stop) or OpenAI SSE chunk + [DONE] |
| Activity log retention | Latest 20 requests kept in memory only (Original vs. Sent user text + What Cloak sent cloud receipts); never written to disk |
8. Bundled cloak CLI Install & Verification (curl + Secret Tripwire)
Put the bundled cloak CLI on your PATH
Regents Cloak bundles its signed CLI inside the app bundle at /Applications/Cloak.app/Contents/MacOS/cloak:
# Symlink into /usr/local/bin (or ~/.local/bin without sudo)
sudo ln -sf /Applications/Cloak.app/Contents/MacOS/cloak /usr/local/bin/cloak
# Verify CLI & supervisor state
cloak status
cloak crypto-status --json
Available cloak subcommands (all accept --json):
| Command | What it does |
|---|---|
cloak status | Show running/paused state, active model, release, and next action |
cloak start | Launch Cloak if closed and start Tor + NIC-less microVM + local rewriter (enforces active Security Profile) |
cloak pause / cloak resume / cloak stop | Pause, re-verify and resume, or stop background helpers |
cloak verify | Run the 5-step startup verification check and stop again |
cloak doctor | Inspect Mac hardware, sandboxed workers, and installed parts |
cloak crypto-status | Report local ML-DSA-65 (FIPS 204) release key readiness and NEAR rustls hybrid X25519MLKEM768 TLS posture |
cloak verify-release --checksums <file> --signature <sig> [--dmg <path> | --app-binary <path>] | Verify a release checksums.json and artifact against its ML-DSA-65 signature |
Verify CloakDoor with curl
Replace cloak-... with the key you copied from Settings → Connected Apps:
# 1. List models available on this app's configured rail (zero token spend)
curl -fsS http://127.0.0.1:8742/v1/models \
-H "Authorization: Bearer cloak-..."
# 2. Smoke-test Anthropic Messages (/v1/messages)
curl -fsS http://127.0.0.1:8742/v1/messages \
-H "x-api-key: cloak-..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 64,
"messages": [{"role": "user", "content": "Reply with exactly: CLOAK_OK"}]
}'
Test the Secret Tripwire with a fake token
Send an obviously synthetic private key block to confirm Privacy Shield blocks it pre-send (you should see HTTP 400 with secret_blocked, or the interactive Privacy Tripwire HUD on cloud rails, plus an entry in Settings → Connected Apps → Recent Activity):
curl -i http://127.0.0.1:8742/v1/messages \
-H "x-api-key: cloak-..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 32,
"messages": [{"role": "user", "content": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtest\n-----END PRIVATE KEY-----"}]
}'
9. Pasteable Setup Prompt for Coding Agents
Paste these 3 lines into Claude Code, OpenCode, Goose, or Aider to wire your local environment cleanly to CloakDoor:
Configure this project's local AI client to route through Regents Cloak at http://127.0.0.1:8742 (Anthropic Messages: ANTHROPIC_BASE_URL=http://127.0.0.1:8742 with ANTHROPIC_AUTH_TOKEN=cloak-... and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1; OpenAI clients: base_url=http://127.0.0.1:8742/v1).
Ask me to paste my scoped cloak-<64-hex> key from Regents Cloak → Settings → Connected Apps rather than hardcoding credentials in tracked git files.
Verify connectivity with `curl -fsS http://127.0.0.1:8742/v1/models -H "Authorization: Bearer $CLOAK_KEY"` and confirm the active model list before running tasks.