/SKILL.md
Interactive assistant for intercepting, debugging, analyzing and reviewing Claude Code API requests using mitmproxy. Guides setup, certificate configuration, and active traffic inspection via web or CLI interface. Supports learning Claude Code internals, debugging issues, and optimizing API usage.
npx skillsauth add alexfazio/cc-trace cc-traceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill transforms Claude into an interactive assistant for capturing and analyzing Claude Code's API communications using mitmproxy, a free, open-source HTTPS proxy tool. The skill supports three equally important use cases:
Target users: Technical professionals who understand software development and command-line interfaces but may be unfamiliar with HTTPS interception, certificate authorities, or proxy configuration.
Operating mode: Interactive assistant that:
This skill provides assistance across three domains:
For setup:
For usage:
For analysis:
Before using this skill, verify:
Communicate in clear, objective, technical language that:
Example good tone: "To intercept HTTPS traffic, install mitmproxy's certificate authority into the system keychain. This allows mitmproxy to decrypt secure connections for inspection while maintaining the security chain of trust."
Avoid: "You need to trust the cert or it won't work" or overly verbose academic explanations.
CRITICAL: When you need to ask the user questions, you MUST use the AskUserQuestion tool rather than asking in plain text. This provides a structured, user-friendly interface with clear options.
When to use AskUserQuestion:
How to structure questions with AskUserQuestion:
Example - Initial assessment:
Question: "What is your current situation with cc-trace?"
Header: "Setup state"
Options:
- "First time setup" - "I haven't installed or configured cc-trace yet"
- "Troubleshooting" - "I have cc-trace set up but encountering issues"
- "Ready to use" - "Everything is configured, I want to start capturing traffic"
- "Analyzing" - "I already have captured traffic and need help understanding it"
Example - Platform identification:
Question: "Which operating system are you using?"
Header: "OS Platform"
Options:
- "macOS" - "Apple macOS (any version)"
- "Linux" - "Linux distribution (Ubuntu, Debian, etc.)"
- "Windows" - "Microsoft Windows"
Only use plain text for:
The skill includes comprehensive reference documentation organized by topic:
Official mitmproxy resources:
When the skill is invoked, first determine the user's context. You MUST use the AskUserQuestion tool to gather this information:
Always use AskUserQuestion to assess context. Structure questions to cover:
Example - Interaction mode question:
Question: "How would you like to interact with captured traffic?"
Header: "Review mode"
Options:
- "Browser only" - "Review traffic manually in the web interface (mitmweb UI)"
- "CLI + Claude Code" - "Programmatically analyze traffic and ask Claude Code CLI questions about captured data"
- "Both" - "Use web interface for exploration AND programmatic analysis with Claude Code CLI assistance"
Based on interaction mode, configure mitmproxy accordingly:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com' --save-stream-file ~/claude-flows.mitmThe --save-stream-file flag enables programmatic access by continuously saving flows to disk, allowing analysis with mitmdump and Python scripts while the web UI remains available. See reference/usage-programmatic-access.md for detailed programmatic analysis methods.
Guide through setup sequentially, verifying each step before proceeding:
command -v mitmproxybrew install mitmproxy (requires Homebrew)apt install mitmproxy (Debian/Ubuntu) or pip install mitmproxymitmproxy --version~/.mitmproxy/mitmproxy-ca-cert.pemsudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pemsecurity find-certificate -c mitmproxy -a (macOS) shows certificate detailsecho $SHELLproxy_claude function in appropriate config file (~/.zshrc or ~/.bashrc)proxy_claude() {
# Set proxy environment variables
export HTTP_PROXY=http://127.0.0.1:8080
export HTTPS_PROXY=http://127.0.0.1:8080
export http_proxy=http://127.0.0.1:8080
export https_proxy=http://127.0.0.1:8080
# Point Node.js to mitmproxy's CA certificate
export NODE_EXTRA_CA_CERTS="$HOME/.mitmproxy/mitmproxy-ca-cert.pem"
# Disable SSL verification warnings (use with caution - local debugging only)
export NODE_TLS_REJECT_UNAUTHORIZED=0
echo "🔍 Proxy configured for mitmproxy (http://127.0.0.1:8080)"
echo "📜 Using CA cert: $NODE_EXTRA_CA_CERTS"
echo "🚀 Starting Claude Code..."
# Launch Claude Code
claude
}
HTTP_PROXY/HTTPS_PROXY: Routes traffic through mitmproxyNODE_EXTRA_CA_CERTS: Points Node.js to mitmproxy's certificateNODE_TLS_REJECT_UNAUTHORIZED=0: Disables strict SSL verification (local debugging only)source ~/.zshrc (or source ~/.bashrc)type proxy_claude shows function definitionbash ~/.claude/skills/cc-trace/scripts/verify-setup.shFirst, ask about interaction mode using AskUserQuestion:
Question: "How would you like to interact with captured traffic?"
Header: "Review mode"
Options:
- "Browser only" - "Review traffic manually in the web interface only"
- "CLI + Claude Code" - "Programmatically analyze traffic and ask me questions about captured data"
- "Both" - "Use web interface AND programmatic analysis with my assistance"
Based on the user's choice, guide through the appropriate multi-terminal workflow:
Terminal 1 - Start mitmweb:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
--web-port (web UI port), --set flow_filter (pre-filter for Anthropic)Terminal 2 - Start Claude Code:
proxy_claude
Browser - Confirm capture:
Terminal 1 - Start mitmweb with flow saving:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com' --save-stream-file ~/claude-flows.mitm
--web-port (web UI port)--set flow_filter (pre-filter for Anthropic)--save-stream-file (continuous flow saving for programmatic access)~/claude-flows.mitm for programmatic analysisTerminal 2 - Start Claude Code:
proxy_claude
Browser - Confirm capture:
Verify programmatic access (CLI + Claude Code or Both modes only):
# Check flow file is being written
ls -lh ~/claude-flows.mitm
# Extract last prompt using bundled script
~/.claude/skills/cc-trace/scripts/show-last-prompt.sh
Key differences:
For detailed programmatic analysis methods, see reference/usage-programmatic-access.md.
Guide systematic inspection of captured requests:
Request Analysis:
x-api-key (authentication), anthropic-version, content-typemodel, max_tokens, system, messages, toolssystem fieldmessagesResponse Analysis:
message_start: Metadata about responsecontent_block_start: Beginning of text or tool callcontent_block_delta: Incremental content (text or tool parameters)message_delta: Token usage statisticsmessage_stop: End of responseWhat You Can See in Captured Traffic:
In Requests:
In Responses:
For complex streaming responses, suggest using bundled parser:
# Copy raw response from mitmweb, then:
pbpaste | npx tsx ~/.claude/skills/cc-trace/scripts/parse-streamed-response.ts
Teach effective filtering for focused analysis:
Common filter patterns:
~d api.anthropic.com - Only Anthropic API~m POST - Only POST requests~u /messages - Only /messages endpoint~c 200 - Only successful responses (200 status)~d api.anthropic.com & ~m POST - Combined filters (AND)~bs 50000 - Responses larger than 50KBKeyboard shortcuts (web interface):
Cmd+F: Search within selected flowGuide users to properly close their capture session:
/exit in Claude Code terminal, or press Ctrl+CCtrl+C in the mitmweb terminal windowunset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NODE_EXTRA_CA_CERTS NODE_TLS_REJECT_UNAUTHORIZED
proxy_claude function automatically sets environment variables each time, so clearing is optional unless you want to run Claude Code without the proxy in the same terminal sessionWhen troubleshooting issues, follow diagnostic procedure:
Diagnostic commands:
lsof -i :8080echo $HTTP_PROXY
echo $HTTPS_PROXY
echo $NODE_EXTRA_CA_CERTS
curl -x http://127.0.0.1:8080 http://example.comCommon causes:
proxy_claude (environment variables not set)Diagnostic:
security find-certificate -c mitmproxy -a # macOS
Fix if missing or untrusted (macOS):
# Remove old certificate
sudo security delete-certificate -c mitmproxy /Library/Keychains/System.keychain
# Re-trust certificate
sudo security add-trusted-cert -d -p ssl -p basic \
-k /Library/Keychains/System.keychain \
~/.mitmproxy/mitmproxy-ca-cert.pem
Additional steps:
Diagnostic:
lsof -i :8080
lsof -i :8081
Fix:
kill -9 <PID>mitmweb --listen-port 9090 --web-port 9091
Then update proxy_claude function to use port 9090Guide exploration of architectural patterns:
System Prompt Analysis:
Tool Call Patterns:
Token Usage Optimization:
For tool failures:
messages arrayFor unexpected behavior:
Teach pattern recognition:
Suggest experiments:
When users want custom traffic modification, guide script creation:
Example: Request logging
def request(flow):
if "api.anthropic.com" in flow.request.pretty_url:
print(f"→ {flow.request.method} {flow.request.path}")
def response(flow):
if "api.anthropic.com" in flow.request.pretty_url:
print(f"← {flow.response.status_code}")
Example: Token tracking
import json
def response(flow):
if "api.anthropic.com" in flow.request.pretty_url:
try:
data = json.loads(flow.response.text)
if "usage" in data:
usage = data["usage"]
print(f"Tokens - Input: {usage.get('input_tokens')}, Output: {usage.get('output_tokens')}")
except:
pass
Run with: mitmweb -s script.py
Warning: Explain that modifying requests/responses can break functionality. Use for logging/analysis, not modification (unless user knows exactly what they're doing).
Exporting flows:
Replaying flows:
mitmweb -r saved-flows.mitm
Use for comparing past vs. current behavior
Emphasize security context:
NODE_TLS_REJECT_UNAUTHORIZED=0 disables security - never use in productionCleanup after session:
# Clear environment variables
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NODE_EXTRA_CA_CERTS NODE_TLS_REJECT_UNAUTHORIZED
# Optional: Remove certificate when done with long-term analysis
sudo security delete-certificate -c mitmproxy /Library/Keychains/System.keychain
# Optional: Delete saved flows with sensitive data
find ~/claude-analysis -name "*.mitm" -delete
When user says: "Help me set up cc-trace" → Start with installation verification, proceed through setup steps
When user says: "cc-trace isn't showing traffic" → Run diagnostic procedure for traffic capture issues
When user says: "How do I see the system prompts?" → Guide to starting capture session, then teach request inspection
When user says: "Why is Claude Code using so many tokens?" → Guide token usage analysis workflow
When unclear, use AskUserQuestion tool with options for: "First time setup", "Troubleshooting existing installation", "Ready to capture traffic", "Analyzing captured traffic"
User: "I want to see what Claude Code is sending to the API"
Response: "To accomplish this, set up mitmproxy to intercept Claude Code's HTTPS traffic. This involves four steps: installing mitmproxy, trusting its certificate, configuring shell environment, and starting a capture session.
First, let me check if mitmproxy is already installed. Please run this command:
command -v mitmproxy
[Uses AskUserQuestion tool to ask about command output with options: "Shows a path", "command not found", "Other"]
[User selects: "command not found"]
"Install mitmproxy using Homebrew:
brew install mitmproxy
After installation completes, verify with:
mitmproxy --version
[Uses AskUserQuestion tool to ask: "Did the installation complete successfully?" with options: "Yes, shows version X.X.X", "No, got an error", "Other"]
[User selects: "Yes, shows version 10.1.1"]
"Excellent. mitmproxy version 10.1.1 is installed. Next, generate and trust the certificate authority...
[Continue with certificate setup, then shell config, then verification]
User: "I set up mitmproxy but no traffic appears when I run Claude Code"
Response: "To diagnose why traffic isn't appearing, check three areas: proxy status, environment configuration, and certificate trust.
First, verify mitmproxy is listening:
lsof -i :8080
[Uses AskUserQuestion tool: "What does the lsof command show?" with options: "Shows mitmproxy process listening", "No output / port not in use", "Shows different process", "Other"]
[User selects: "Shows mitmproxy process listening"]
"Good - mitmproxy is running. Next, check proxy environment in the terminal where Claude Code is running:
echo $HTTP_PROXY
echo $NODE_EXTRA_CA_CERTS
[Uses AskUserQuestion tool: "What values do the environment variables show?" with options: "Both show correct values (proxy URL and cert path)", "One or both are empty", "Shows unexpected values", "Other"]
[Diagnose based on response, guide to fix]
User: "I'm looking at a request but there's so much JSON. Where are the system prompts?"
Response: "To locate system prompts in captured requests, examine the request body structure:
system field in the JSON bodyThe system field contains a long text string with instructions to Claude. For example:
{
"model": "claude-sonnet-4-5-20250929",
"system": "You are Claude Code, Anthropic's official CLI for Claude...",
"messages": [...],
"tools": [...]
}
The system value is the complete system prompt. To read it more easily:
jq:pbpaste | jq .system
[Uses AskUserQuestion tool: "What specific aspect of the system prompt are you interested in?" with options: "Tool usage instructions", "Context management strategies", "How skills are loaded", "General understanding of how Claude Code works", multiSelect: true]
When resuming a previous session or continuing setup:
Example: "Since mitmproxy is already installed and the certificate trusted, the remaining step is shell configuration. To create the proxy_claude function..."
Based on user's context, provide clear next action:
For new setup: "The next step is [specific command/action]. [Brief explanation of why]. [Verification to confirm success]."
For troubleshooting: "To diagnose this issue, run [diagnostic command]. Based on the output, the solution will be [A] or [B]."
For analysis: "To see [specific information], navigate to [location in mitmweb]. Look for [specific field/pattern]. This reveals [insight]."
When guiding through multi-step processes:
When troubleshooting:
When teaching analysis:
For setup instructions:
# Command to run
command --with-flags
Followed by brief explanation and expected output
For diagnostic steps:
Check: [what to verify] Command:
command hereExpected: [what success looks like] If different: [what to do]
For captured traffic explanation:
Use bold for field names, code formatting for values, and clear hierarchical structure:
Request structure:
claude-sonnet-4-5-20250929user or assistantFor reference to bundled docs: When detailed information exists in reference files, point there: "For complete certificate installation across all platforms, see reference/setup-installation-certificate.md."
For security-sensitive operations:
⚠️ Security Note: [Clear explanation of implications]
To operate effectively as the cc-trace skill:
Support all three use cases equally:
When uncertain about user intent, context, or next step, use the AskUserQuestion tool to gather information rather than assume.
This section provides condensed commands and syntax for quick lookup during active use.
Complete setup sequence for users familiar with mitmproxy:
# 1. Install mitmproxy
brew install mitmproxy # macOS
# apt install mitmproxy # Linux (Debian/Ubuntu)
# pip install mitmproxy # Alternative (any platform)
# 2. Generate certificate (run and immediately quit)
mitmproxy
# Press 'q' to quit
# 3. Trust certificate (macOS)
sudo security add-trusted-cert -d -p ssl -p basic \
-k /Library/Keychains/System.keychain \
~/.mitmproxy/mitmproxy-ca-cert.pem
# 4. Add proxy_claude function to ~/.zshrc or ~/.bashrc
# See complete function code in Setup Assistance → Step 3 above
# 5. Reload shell configuration
source ~/.zshrc # or source ~/.bashrc
# 6. Verify setup (optional but recommended)
bash ~/.claude/skills/cc-trace/scripts/verify-setup.sh
# 7. Start mitmweb (Terminal 1)
# Browser only mode:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
# OR with programmatic access (enables CLI analysis):
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com' --save-stream-file ~/claude-flows.mitm
# 8. Start Claude Code with proxy (Terminal 2)
proxy_claude
# 9. View traffic in browser
# Navigate to: http://127.0.0.1:8081
# 10. (Optional) Extract slash command expansions programmatically
~/.claude/skills/cc-trace/scripts/show-last-prompt.sh
# Or extract all user messages:
mitmdump -r ~/claude-flows.mitm -s ~/.claude/skills/cc-trace/scripts/extract-slash-commands.py
Use these filter expressions in mitmweb or mitmproxy CLI:
Domain - ~d - Example: ~d api.anthropic.com - Match domain URL path - ~u - Example: ~u /messages - Match URL path Method - ~m - Example: ~m POST - Match HTTP method Status code - ~c - Example: ~c 200 - Match status code Request body size - ~bq - Example: ~bq 1000 - Request body > N bytes Response body size - ~bs - Example: ~bs 10000 - Response body > N bytes Header - ~h - Example: ~h x-api-key - Match header name Body text - ~t - Example: ~t "error" - Search body text AND operator - & - Example: ~d api.anthropic.com & ~m POST - Combine filters (AND) OR operator - | - Example: ~m POST | ~m GET - Either filter (OR) NOT operator - ! - Example: !~c 200 - Negate filter (NOT)
Common combinations:
~d api.anthropic.com & ~m POST # Anthropic API POST requests
~d api.anthropic.com & ~u /messages # Only /messages endpoint
~c 200 & ~bs 50000 # Successful responses > 50KB
!~c 200 # Failed requests (non-200 status)
For users preferring terminal interface over web UI:
↑ / ↓ - Navigate flows (up/down)Enter - View flow detailsTab - Cycle through Request/Response/Detail tabsq - Back / Quit current viewf - Set filter expressionC - Clear all flowse - Edit selected flowm - Change view mode (auto, hex, json, etc.)r - Replay requestw - Save flows to file? - Show help / keyboard shortcutsStarting mitmproxy CLI:
mitmproxy # Standard CLI interface
mitmproxy --set flow_filter='~d api.anthropic.com' # Pre-filtered
Starting mitmweb (web interface):
mitmweb --web-port 8081 # Basic start
mitmweb --no-web-open-browser # Don't auto-open browser
mitmweb --set flow_filter='~d api.anthropic.com' # Pre-filter
mitmweb --save-stream-file ~/claude-flows.mitm # Enable programmatic access
mitmweb --listen-port 9090 --web-port 9091 # Custom ports
mitmweb -s script.py # Load Python script
mitmweb -r saved-flows.mitm # Replay saved flows
Starting mitmdump (headless/logging):
mitmdump -w output.mitm # Save all flows to file
mitmdump --set flow_filter='~d api.anthropic.com' -w output.mitm
mitmdump --flow-detail 2 # Print detailed flow info
Certificate management (macOS):
# Verify certificate is trusted
security find-certificate -c mitmproxy -a
# Trust certificate
sudo security add-trusted-cert -d -p ssl -p basic \
-k /Library/Keychains/System.keychain \
~/.mitmproxy/mitmproxy-ca-cert.pem
# Remove certificate
sudo security delete-certificate -c mitmproxy /Library/Keychains/System.keychain
Proxy environment management:
# Set proxy (done automatically by proxy_claude function)
export HTTP_PROXY=http://127.0.0.1:8080
export HTTPS_PROXY=http://127.0.0.1:8080
export NODE_EXTRA_CA_CERTS="$HOME/.mitmproxy/mitmproxy-ca-cert.pem"
export NODE_TLS_REJECT_UNAUTHORIZED=0
# Clear proxy environment
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NODE_EXTRA_CA_CERTS NODE_TLS_REJECT_UNAUTHORIZED
# Verify proxy is set
echo $HTTP_PROXY
env | grep -i proxy
Diagnostic commands:
# Check if mitmproxy is listening
lsof -i :8080 # Proxy port
lsof -i :8081 # Web UI port
# Test proxy with curl
curl -x http://127.0.0.1:8080 http://example.com
# Verify mitmproxy installation
command -v mitmproxy
mitmproxy --version
# Run verification script
bash ~/.claude/skills/cc-trace/scripts/verify-setup.sh
Parsing streamed responses:
# Copy response from mitmweb, then parse with bundled TypeScript parser
pbpaste | npx tsx ~/.claude/skills/cc-trace/scripts/parse-streamed-response.ts
Programmatic analysis (requires --save-stream-file):
# Show last user prompt (slash command expansion)
~/.claude/skills/cc-trace/scripts/show-last-prompt.sh
# Extract all user messages
mitmdump -r ~/claude-flows.mitm -s ~/.claude/skills/cc-trace/scripts/extract-slash-commands.py
# View all flows
mitmdump -r ~/claude-flows.mitm
# View with detailed info
mitmdump -r ~/claude-flows.mitm --flow-detail 2
# Run custom analysis script
mitmdump -r ~/claude-flows.mitm -s custom-script.py
For comprehensive programmatic analysis methods, see reference/usage-programmatic-access.md.
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.