npm package: @suncreation/crush-auth-proxy
Description: Claude Code Auth Proxy for Crush CLI — Use your Claude Max subscription (OAuth) instead of API keys
Author: suncreation
Latest version: 1.1.7

# @suncreation/crush-auth-proxy

Use your **Claude Max subscription** (OAuth) with [Crush CLI](https://github.com/charmbracelet/crush) — no separate Anthropic API key needed.

This proxy sits between Crush and Anthropic's API, injecting Claude Code OAuth credentials so you can use your existing Claude Max plan.

## Quick Start

```bash
# One command does everything: login + crush config + auto-start
npx @suncreation/crush-auth-proxy setup
```

That's it! Now use Crush:

```bash
crush run --model anthropic/claude-opus-4-6 "Hello!"
```

The proxy auto-starts on boot. No manual configuration needed.

## Commands

| Command | Description |
|---------|-------------|
| `setup` | **All-in-one**: OAuth login + crush.json config + auto-start service |
| `setup-token` | OAuth login only — opens browser, saves token locally |
| `setup-crush` | Configure `crush.json` only (adds anthropic provider) |
| `install-service` | Install platform auto-start service (macOS: launchd, Linux: systemd, Windows: Task Scheduler) |
| `uninstall-service` | Remove auto-start service |
| `start` | Start proxy as background daemon (port 18080) |
| `stop` | Stop the daemon |
| `restart` | Restart the daemon |
| `status` | Check if proxy is running + token validity |
| `logs` | Tail daemon logs |

### Options

| Option | Description |
|--------|-------------|
| `--port <n>` | Custom port (default: 18080) |
| `--debug` | Enable detailed request/response logging |
| `--foreground` | Run in foreground instead of daemon |

## How It Works

The proxy replicates Claude Code's authentication mechanism:

1. **OAuth PKCE Flow** — Authenticates via `claude.ai` using the same client credentials as Claude Code
2. **Request Transformation** — Rewrites headers (User-Agent, auth), adds required beta flags, prefixes tool names with `mcp_`
3. **System Prompt Injection** — Prepends the Claude Code system prompt identifier
4. **Response Streaming** — Strips `mcp_` prefixes from streamed responses
5. **Token Auto-Refresh** — Automatically refreshes expired OAuth tokens

## Per-User Storage

All config is stored in `~/.config/crush-auth-proxy/`:

```
~/.config/crush-auth-proxy/
  ├── claude-oauth-token.json   # Your OAuth tokens (chmod 0600)
  ├── crush-auth-proxy.mjs      # Stable copy for auto-start service
  ├── proxy.pid                 # Daemon PID
  └── proxy.log                 # Daemon logs
```

## Uninstall

```bash
npx @suncreation/crush-auth-proxy uninstall-service
npx @suncreation/crush-auth-proxy stop
rm -rf ~/.config/crush-auth-proxy
```

## Requirements

- Node.js >= 18
- macOS / Linux / Windows
- A Claude Max subscription (claude.ai account)
- [Crush CLI](https://github.com/charmbracelet/crush) installed

**Platform-specific auto-start:**
- macOS: launchd (built-in)
- Linux: systemd (user service)
- Windows: Task Scheduler

## Supported Models

All Anthropic models available through your Claude Max subscription, including:

- `anthropic/claude-opus-4-6`
- `anthropic/claude-sonnet-4-5-20250514`
- `anthropic/claude-haiku-3-5-20241022`
- And more

## License

MIT