Skip to content

juancgarza/claude-code-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Proxy

A high-performance reverse proxy for intercepting AI coding assistant CLI traffic, with a real-time Next.js dashboard for observability.

Supported CLIs:

  • Claude Code → Anthropic API
  • Codex CLI → OpenAI API

Architecture

Claude Code CLI → Go Proxy (localhost:8080) → api.anthropic.com
Codex CLI       →            ↓              → api.openai.com
                        WebSocket broadcast
                              ↓
                    Next.js Dashboard (localhost:3000)

The proxy auto-detects the provider based on request headers.

Quick Start

1. Start the Go Proxy

cd proxy
go mod tidy
go run .

The proxy listens on:

  • :8080 - HTTP proxy endpoint
  • :8081 - WebSocket server for dashboard

2. Start the Dashboard

cd dashboard
npm install
npm run dev

Dashboard available at http://localhost:3000

3. Configure Your CLI

For Claude Code:

export ANTHROPIC_BASE_URL=http://localhost:8080
claude

For Codex CLI:

Important: Codex must be logged in with an API key, not ChatGPT OAuth. ChatGPT OAuth won't work through the proxy due to how OPENAI_BASE_URL changes Codex's behavior.

# First, log in with an API key (one-time setup)
codex logout  # if currently logged in via ChatGPT
codex login --api-key

# Then set the proxy URL and run
export OPENAI_BASE_URL=http://localhost:8080
codex

You can run both CLIs simultaneously - the proxy auto-detects the provider based on request headers.

Features

  • Real-time streaming: Watch SSE events as they arrive
  • Request/Response inspection: View headers, body, and parsed JSON
  • Token tracking: Monitor input/output token usage per request
  • Dark theme: Easy on the eyes during long sessions
  • Auto-reconnect: Dashboard reconnects automatically if proxy restarts

Project Structure

damascus/
├── proxy/                    # Go reverse proxy
│   ├── main.go              # Entry point
│   ├── proxy.go             # Reverse proxy logic
│   ├── sse.go               # SSE stream parser
│   ├── store.go             # In-memory request storage
│   ├── websocket.go         # WebSocket server
│   └── types.go             # Shared types
├── dashboard/               # Next.js dashboard
│   └── src/app/
│       ├── page.tsx         # Main dashboard
│       ├── components/      # UI components
│       └── hooks/           # WebSocket hook
└── README.md

Security Notes

  • API keys are automatically redacted in the dashboard
  • The proxy only stores requests in memory (clears on restart)
  • WebSocket accepts connections from any origin (development mode)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •