A development tool for intercepting and visualizing Claude Code API requests. By hijacking Claude Code's network requests, it captures and displays all prompts and tool calls in real-time, helping developers understand and debug Claude Code's working mechanism.
- 🔍 API Request Interception: Automatically hijack Claude Code API calls
- 📊 Visual Interface: Intuitive web interface displaying all requests and responses
- 🛠️ Tool Call Analysis: Detailed recording and visualization of tool invocations
- 💬 Prompt Visualization: Clear display of system prompts and user messages
- 📝 Session Management: Support for recording and switching between multiple sessions
- 🎨 Beautiful UI: Modern dark theme interface
npm install -g claude-code-proxyclaude-code-proxyAfter running, it will automatically:
- Modify the globally installed Claude Code CLI file
- Start a local server (http://localhost:3000)
- Automatically open the browser to view the interface
The tool works through the following steps:
- CLI Hijacking: Modify Claude Code's
cli.jsfile, injecting interception code - Request Interception: Intercept
beta.messages.createAPI calls - Data Recording: Record all requests and responses to log files
- Visual Display: Parse and display data through a web interface
- Conversation: Display current session's input and output
- Global Tool Set: Show all available tool definitions
- Guessed System Prompts: Intelligently identified system prompts
- Create New Log: Create a new log session
- Choose Example: Select historical session records
- Navigation Buttons: Switch between multiple sessions
-
Input Panel:
- Model parameters (model, max_tokens, temperature)
- System messages
- Available tool list
- User messages
-
Output Panel:
- Response type and token usage
- AI response content (supports Markdown rendering)
- Tool call activity
- Other response fields
claude-code-proxy/
├── bin/
│ └── main.js
├── script/
│ ├── main.js
│ └── alternateFile.js
├── public/
│ ├── index.html
│ └── parser.js
├── messages/
│ └── messages.log
└── package.json
The tool automatically finds the globally installed @anthropic-ai/claude-code package and modifies its cli.js file:
- Backup the original file as
cli.bak - Format code using
js-beautify - Inject interception code into the constructor
- Reset executable permissions
The injected code will:
- Intercept
this.beta.messages.create()calls - Record input parameters to log files
- Intercept streaming and non-streaming responses
- Record tool call details
Log files use the following format:
---Session 2024-01-01T00:00:00.000Z---
2024-01-01T00:00:00.000Z uid=abc123 input: {"messages":[...],"tools":[...]}
2024-01-01T00:00:01.000Z uid=abc123 stream.final: {"text":"...","tools":[...]}
This tool is for development and debugging purposes only and modifies Claude Code installation files. Before using, please ensure:
- Understanding of how the tool works
- Use in development environments
- Regular backup of important data
- Node.js >= 18
- Claude Code CLI installed (
@anthropic-ai/claude-code) - Supported OS: macOS, Linux, Windows
Make sure Claude Code CLI is properly installed:
npm install -g @anthropic-ai/claude-codeOn macOS/Linux, you may need administrator privileges:
sudo claude-code-proxyTo restore original Claude Code:
- Find the
cli.bakfile in the installation directory - Rename it to
cli.js
git clone https://github.com/your-username/claude-code-proxy.git
cd claude-code-proxy
npm install
npm link- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Venus Shan
- This tool modifies Claude Code installation files
- Only recommended for use in development environments
- Please backup important data before use
- Data recorded by the tool may contain sensitive information, please handle with care