claude-code-proxy
v0.0.10
Published
Start a local Claude Peek proxy and open it in the browser.
Downloads
65
Maintainers
Readme
Claude Code Proxy
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.
Features
- 🔍 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
Installation
npm install -g claude-code-proxyUsage
Starting the Proxy
claude-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
How It Works
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
Interface Features
Main Interface
- Conversation: Display current session's input and output
- Global Tool Set: Show all available tool definitions
- Guessed System Prompts: Intelligently identified system prompts
Function Buttons
- Create New Log: Create a new log session
- Choose Example: Select historical session records
- Navigation Buttons: Switch between multiple sessions
Data Display
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
Project Structure
claude-code-proxy/
├── bin/
│ └── main.js
├── script/
│ ├── main.js
│ └── alternateFile.js
├── public/
│ ├── index.html
│ └── parser.js
├── messages/
│ └── messages.log
└── package.jsonTechnical Implementation
CLI Modification
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
Data Interception
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 Format
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":[...]}Security Notice
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
System Requirements
- Node.js >= 18
- Claude Code CLI installed (
@anthropic-ai/claude-code) - Supported OS: macOS, Linux, Windows
Troubleshooting
Claude Code Not Found
Make sure Claude Code CLI is properly installed:
npm install -g @anthropic-ai/claude-codePermission Issues
On macOS/Linux, you may need administrator privileges:
sudo claude-code-proxyReset Claude Code
To restore original Claude Code:
- Find the
cli.bakfile in the installation directory - Rename it to
cli.js
Development
Local Development
git clone https://github.com/your-username/claude-code-proxy.git
cd claude-code-proxy
npm install
npm linkContributing
- 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
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Venus Shan
Important Notes
⚠️ Important Reminder:
- 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
Changelog
v0.0.3
- Added session management functionality
- Improved web interface design
- Optimized log parser performance
v0.0.2
- Fixed tool call recording issues
- Added Markdown rendering support
v0.0.1
- Initial release
- Basic API interception functionality
