A transparent privacy proxy for Claude Code. Intercepts API calls, detects and aliases PII in your prompts before they reach Anthropic, then restores the original values in Claude's response — all without changing how you use Claude.
This is a work in progress ATM
Claude Code → ninjaproxy (localhost:3456) → api.anthropic.com
- Intercept — ninjaproxy sits between Claude Code and the Anthropic API via
ANTHROPIC_BASE_URL - Sanitize — names, emails, URLs, mentions, and org names in your latest message are replaced with stable aliases (
PERSON_1,EMAIL_1, etc.) before the request is forwarded - Rehydrate — aliases in Claude's response are swapped back to the originals before Claude Code receives them
The round-trip is fully transparent. You type normally, Claude responds normally, and PII never leaves your machine in plaintext.
yarn install
yarn build
node dist/cli.js installinstall does two things:
- Starts the ninjaproxy daemon via launchd (auto-restarts on crash, starts on login)
- Sets
ANTHROPIC_BASE_URL=http://127.0.0.1:3456in~/.claude/settings.json
ninjaproxy install # build, start daemon, configure Claude Code
ninjaproxy uninstall # stop daemon, remove from Claude Code settings
ninjaproxy start # start the daemon
ninjaproxy stop # stop the daemon
ninjaproxy status # show running state and PID# Health check
curl http://127.0.0.1:3456/health
# Live logs — shows what gets sanitized per request
tail -f ~/.ninjaproxy/proxy.logEach request logs the alias map when PII is detected:
[sanitize] PERSON_1=Dennis Marchand, EMAIL_1=dennis@gmail.com
| Alias | Matches |
|---|---|
EMAIL_n |
Email addresses |
URL_n |
HTTP/HTTPS URLs |
MENTION_n |
@-mentions |
ORG_n |
Company names (Inc, LLC, Corp, etc.) |
PERSON_n |
Title Case two-word names |
Detection runs only on the latest user message per request. Previous turns in the conversation are not re-scanned.
Name detection is broad. The PERSON regex matches any Title Case two-word phrase. In conversations that include code, markdown, or structured content, you'll see false positives — section headers, library names, and similar patterns can all fire. Emails and URLs are matched precisely; names are not.
Only your typed messages are protected. ninjaproxy sanitizes what you type, not the full context Claude Code sends. Tool results, file contents, and system prompt injections pass through unmodified. If a file you read into the conversation contains a name or email, Anthropic will see it.
No cross-session memory. Aliases are assigned fresh each request. A name aliased in a previous Claude Code session won't carry over.
Detection is intentionally regex-based. A third-party PII detector will replace
src/detect.tsin a future iteration.
src/
types.ts — shared types
detect.ts — entity detection (regex, span-blocking)
alias.ts — alias assignment (stable, per-request counters)
rewrite.ts — text replacement and rehydration
proxy.ts — HTTP proxy server (port 3456)
daemon.ts — launchd daemon manager
installer.ts — patches ~/.claude/settings.json
cli.ts — CLI entry point
~/.ninjaproxy/
proxy.log — daemon stdout/stderr
~/Library/LaunchAgents/
com.ninjaproxy.daemon.plist
node dist/cli.js uninstallStops the daemon, removes the plist, and restores the original ANTHROPIC_BASE_URL in ~/.claude/settings.json (or removes it if there was none).