A tool to capture and inspect Claude Code API requests, including system prompts, tools, and message context.
pip install mitmproxyRun mitmdump --version once to generate the CA certificate in ~/.mitmproxy/.
claude_proxy/
├── run.sh # Main runner script
├── env.sh # Environment setup (source this)
├── README.md # This file
├── src/
│ ├── capture.py # mitmproxy capture script
│ └── export.py # Export to readable text
└── output/ # Captured data goes here
├── claude_code_captured.json # Latest capture (raw)
├── claude_code_log.jsonl # History log
└── capture_*.txt # Exported readable files
./run.sh proxysource env.sh
claude "hello"
# ...or pin a specific model to capture that model's prompt + tools:
claude --model claude-fable-5 -p "say hi" # Fable 5 (headless)
claude --model claude-opus-4-8 -p "say hi" # Opus 4.8 (headless)
-pruns Claude Code in headless/print mode — non-interactive and easy to script. Interactiveclaudecaptures a richer tool set; headless mode sends a smaller deferred tool set plusToolSearch.
./run.sh summary # Quick summary
./run.sh export # Export to readable .txt
./run.sh view # Export and open in editor| Command | Description |
|---|---|
./run.sh proxy |
Start the mitmproxy server |
./run.sh setup |
Print environment variables to set |
./run.sh summary |
Show summary of captured data |
./run.sh export |
Export to readable text file |
./run.sh view |
Export and open in text editor |
./run.sh clean |
Remove all captured data |
./run.sh help |
Show help message |
Ready-to-read captures live in per-model folders:
| Folder | Model | Contents |
|---|---|---|
fable/ |
claude-fable-5 |
System prompt, tools (readable + raw), full request |
Each folder has its own README with capture details. Point Claude Code at a different
model with --model <id> and re-run the proxy to add more.
- Model: The Claude model being used
- System Prompt: Full system instructions sent to Claude
- Tools: All available tools with their JSON schemas
- Message Count: Number of messages in the conversation context
- Max Tokens: Token limit for the response
| File | Description |
|---|---|
output/claude_code_captured.json |
Raw JSON of the latest capture |
output/claude_code_log.jsonl |
Append-only log of all captures |
output/capture_*.txt |
Human-readable exports |
If you prefer not to use the runner script:
# Terminal 1: Start proxy
mitmdump -s src/capture.py --listen-port 8080
# Terminal 2: Set environment and run Claude
export HTTPS_PROXY=http://127.0.0.1:8080
export HTTP_PROXY=http://127.0.0.1:8080
export NODE_EXTRA_CA_CERTS=~/.mitmproxy/mitmproxy-ca-cert.pem
claude "your prompt"
# View results
python3 src/export.py --summary
python3 src/export.py- mitmproxy acts as a man-in-the-middle proxy
- Claude Code is configured to route traffic through the proxy
- The
NODE_EXTRA_CA_CERTSenvironment variable makes Node.js trust the proxy's certificate - The
capture.pyscript intercepts requests toapi.anthropic.comand extracts relevant data - Data is saved to JSON and can be exported to human-readable format
- Make sure the proxy is running (
./run.sh proxy) - Ensure
~/.mitmproxy/mitmproxy-ca-cert.pemexists - Re-run
mitmdump --versionto regenerate certificates
- Make sure you ran Claude while the proxy was active
- Check that environment variables are set:
echo $HTTPS_PROXY
- Find what's using it:
lsof -i :8080 - Kill it or use a different port in
src/capture.pyandenv.sh