A bash script that installs sing-box to automatically route Claude Code traffic through your proxy server using TUN-level interception. Works seamlessly with 1Password integration or manual credential entry.
Repository: github.com/AbdelElrafa/claude-code-proxy-installer
- π 1Password Integration: Automatically pulls proxy credentials from 1Password
- π Manual Mode: Option to enter credentials manually (stored securely)
- π― Per-Application Routing: Only Claude traffic goes through proxy, other apps unaffected
- π Auto-Start: Wrapper script automatically starts proxy if not running
- π‘οΈ TUN-Level Interception: Uses sing-box for reliable traffic interception (works even when Claude ignores env vars)
- π Logging: View Claude traffic logs in real-time
- π Automatic PATH Setup: Adds
~/binto your PATH automatically
- sing-box: Installs and configures sing-box, a universal proxy platform
- TUN Interface: Creates a virtual network interface that intercepts traffic at the system level
- Process Matching: Routes only Claude processes (
claude,com.anthropic.claude-code) through proxy - Auto-Start: Wrapper script ensures proxy is running before launching Claude
- macOS (Linux support coming soon)
- Claude Code installed at
~/.local/bin/claude - Homebrew (for installing sing-box)
- For 1Password mode: 1Password CLI (
op) installed and signed in - For manual mode: No additional requirements
-
Create a 1Password item named
Claude Code Proxywith these custom fields:host- Proxy server hostname/IP (required)port- Proxy server port number (required)username- Proxy username (optional)password- Proxy password (optional)type- Proxy type:socks5orhttp(optional, defaults tosocks5)
-
Install:
curl -fsSL https://raw.githubusercontent.com/AbdelElrafa/claude-code-proxy-installer/main/install-claude-code-proxy.sh | bash -
Restart your terminal or run:
source ~/.zshrc
-
Use Claude:
claude
The proxy will automatically start if not running (may prompt for sudo password).
-
Install with manual mode:
curl -fsSL https://raw.githubusercontent.com/AbdelElrafa/claude-code-proxy-installer/main/install-claude-code-proxy.sh | bash -s -- --manual -
Enter your proxy credentials when prompted:
- Proxy type (
socks5orhttp, defaults tosocks5) - Host
- Port
- Username (optional)
- Password (optional)
- Proxy type (
-
Restart your terminal or run:
source ~/.zshrc
-
Use Claude:
claude
If you don't have 1Password CLI installed:
# macOS (requires Homebrew)
curl -fsSL https://raw.githubusercontent.com/AbdelElrafa/claude-code-proxy-installer/main/install-claude-code-proxy.sh | bash -s -- --install-op
# With auto-yes (no prompts)
curl -fsSL https://raw.githubusercontent.com/AbdelElrafa/claude-code-proxy-installer/main/install-claude-code-proxy.sh | bash -s -- --install-op --yesThe installer creates a claude-proxy command for managing the proxy:
# Start proxy (foreground, shows logs)
claude-proxy start
# Start proxy in background
claude-proxy start-bg
# Stop proxy
claude-proxy stop
# Restart proxy
claude-proxy restart
# Check if proxy is running
claude-proxy status
# View Claude traffic logs
claude-proxy logs
# View all logs
claude-proxy logs-all
# Test proxy connection
claude-proxy test
# Regenerate config from 1Password (1Password mode only)
claude-proxy regenerateUpdate the fields in your 1Password item "Claude Code Proxy", then regenerate the config:
claude-proxy regenerateOr restart the proxy:
claude-proxy restartOption 1: Edit the config file directly:
nano ~/.claude-proxy-configThen restart the proxy:
claude-proxy restartOption 2: Re-run installer with --manual:
curl -fsSL https://raw.githubusercontent.com/AbdelElrafa/claude-code-proxy-installer/main/install-claude-code-proxy.sh | bash -s -- --manualThe script expects Claude at ~/.local/bin/claude. If it's elsewhere, you'll need to modify the installer script.
- Ensure you're signed into 1Password CLI:
op signin - Create an item named exactly
Claude Code Proxy - Add custom fields:
host,port(required),username,password,type(optional)
Install 1Password CLI:
- macOS:
brew install --cask 1password-cli - Linux: Follow 1Password CLI installation guide
-
Check config validity:
sing-box check --config ~/.config/sing-box/config.json -
Check logs:
cat ~/.config/sing-box/sing-box.log -
Try starting manually:
sudo sing-box run --config ~/.config/sing-box/config.json
-
Verify proxy is running:
claude-proxy status
-
Check logs for Claude process detection:
claude-proxy logs
-
Verify process name matches:
- Check if Claude binary path matches:
~/.local/share/claude/versions/* - The config matches processes named
claudeorcom.anthropic.claude-code
- Check if Claude binary path matches:
-
Ensure
~/binis in your PATH:echo $PATH | grep -q "$HOME/bin" && echo "β In PATH" || echo "β Not in PATH"
-
Restart your terminal or source your shell config:
source ~/.zshrc
-
Verify:
which claude # Should show ~/bin/claude
The proxy requires sudo to create the TUN interface. You'll be prompted for your password when:
- Starting the proxy manually:
claude-proxy start - Auto-starting via the wrapper:
claude
~/bin/claude- Wrapper script (auto-starts proxy)~/bin/claude-proxy- Proxy management script~/.config/sing-box/config.json- sing-box configuration~/.config/sing-box/sing-box.log- Proxy logs~/.claude-proxy-config- Manual credentials (manual mode only)
To remove everything:
# Stop proxy
claude-proxy stop
# Remove scripts
rm ~/bin/claude
rm ~/bin/claude-proxy
# Remove config and logs
rm -rf ~/.config/sing-box
# Remove manual credentials (if using manual mode)
rm ~/.claude-proxy-config
# Uninstall sing-box (optional)
brew uninstall sing-box- β
Proxy credentials are stored securely:
- 1Password mode: Credentials stay in 1Password (encrypted)
- Manual mode: Config file has
600permissions (owner read/write only)
- β Only Claude traffic is routed through proxy (other apps unaffected)
- β TUN-level interception works even when apps ignore environment variables
β οΈ Manual credentials are stored in plaintext (but with restricted permissions)β οΈ Proxy requiressudoto create TUN interface (standard for VPN-like tools)
- sing-box: Universal proxy platform using TUN interface for system-level interception
- Process Matching: Uses
process_nameandprocess_path_regexto match Claude processes - DNS Hijacking: Intercepts DNS requests to prevent leaks
- Strict Routing: Only matched processes go through proxy, everything else uses direct connection
For issues or questions, contact your team lead or IT support.
Internal use only.