$ show musistudio/claude-code-router
Claude Code Router (CCR) is a cross-platform desktop application built with Electron and React that functions as a local gateway and router for AI agent traffic. It intercepts requests from local AI agents (Claude Code, Codex, ZCode) and routes them to various LLM providers (OpenAI, Anthropic, DeepSeek, etc.) through a configurable proxy. The application manages API keys, routing rules, fallback strategies, and provides detailed usage observability via a system tray and dashboard. It supports complex features like Fusion models (combining base models with tools), IM bot relay integrations (WeChat, Slack, etc.), and deep linking for provider provisioning. The architecture follows a standard Electron pattern with a Main process handling system-level tasks (proxy, SQLite storage, process management) and a Renderer process for the React UI. Data persistence relies on SQLite for configuration and usage logs. The codebase demonstrates significant engineering effort in handling cross-platform differences (macOS/Windows/Linux) for proxy installation, certificate management, and agent profile injection. While the code is well-structured with clear separation of concerns, it carries medium technical drift due to heavy reliance on native dependencies (better-sqlite3) and OS-specific commands for proxy and certificate management.
The LLM identified 4 files worth highlighting for reuse:
Implements a unified profile management abstraction that dispatches to agent-specific handlers (Claude Code, Codex, ZCode). It handles file I/O, backup/restore, and wrapper script generation for injecting configurations into local agents. This component is reusable for any agent integration requiring config file manipulation and environment injection.
Provides logic to standardize token usage metrics across different LLM provider protocols (OpenAI, Anthropic, Gemini). It handles edge cases like cache token subtraction and reasoning token tracking. This is a reusable utility for any system aggregating usage data from heterogeneous AI APIs.
Manages the MITM proxy service, including HTTPS interception, certificate authority generation, and network traffic capture. It handles server lifecycle, certificate trust verification across OS platforms, and request routing. This component encapsulates complex network security logic for traffic inspection.
Defines a standard structure for provider configuration including aliases, endpoints, auth types, and capabilities. It serves as a registry for supported providers and enables consistent validation and deep-link provisioning. This pattern allows for easy extension of supported providers without modifying core logic.