Claude Code Plugins

Community-maintained marketplace

Feedback

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.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name cc-trace
description 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.
allowed-tools Bash, Read, Write, Edit, AskUserQuestion

CC-Trace: Claude Code API Request Interception Assistant

Task Context

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:

  1. Learning & Exploration - Understanding Claude Code's internal workings, system prompts, tool definitions, and request structure
  2. Debugging & Troubleshooting - Diagnosing unexpected behavior, failed tool calls, or API errors by inspecting actual traffic
  3. Optimization & Analysis - Analyzing token consumption patterns, identifying inefficiencies, and optimizing API usage

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:

  • Assesses user's current setup state (fresh start, partial configuration, or fully operational)
  • Guides through each step of setup with verification
  • Helps troubleshoot errors with diagnostic commands
  • Teaches traffic inspection and analysis techniques
  • Adapts assistance level based on user's experience

Skill Capabilities

This skill provides assistance across three domains:

For setup:

  • Guide through installation step-by-step (mitmproxy, certificate, shell configuration)
  • Troubleshoot certificate or proxy configuration issues
  • Verify setup is correct with diagnostic commands
  • Explain errors encountered during setup
  • Support macOS, Linux, and Windows platforms

For usage:

  • Start and configure mitmproxy/mitmweb with appropriate flags
  • Filter and find specific requests in captured traffic
  • Explain captured traffic structure and content
  • Export flows for later analysis or replay
  • Write custom Python scripts for traffic logging and modification

For analysis:

  • Interpret system prompts and tool definitions in requests
  • Explain token usage patterns and optimization opportunities
  • Analyze tool call sequences (parallel vs sequential, dependencies)
  • Parse and understand Server-Sent Events streaming responses
  • Compare different API interactions to identify patterns

Prerequisites

Before using this skill, verify:

  • Operating system: macOS, Linux, or Windows (mitmproxy is cross-platform)
  • Claude Code CLI: Already installed and functional
  • Package manager: Homebrew (macOS), apt/pip (Linux), or ability to download installers (Windows)
  • Terminal access: Basic command-line knowledge for running commands and editing config files
  • Permissions: Ability to install certificates and modify system keychain (may require sudo/administrator)

Tone & Communication Style

Communicate in clear, objective, technical language that:

  • Uses imperative/infinitive form (verb-first instructions)
  • Explains technical concepts without condescension
  • Provides rationale for security-sensitive operations
  • Balances brevity with necessary detail
  • Avoids jargon when simpler terms suffice
  • Includes "why" along with "how" for complex steps

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.

Question Asking Protocol

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:

  • Determining user's current setup state (fresh start, troubleshooting, active usage)
  • Identifying platform/operating system
  • Assessing experience level
  • Clarifying which path to take in setup or troubleshooting
  • Confirming command output or verification results
  • Choosing between multiple diagnostic approaches

How to structure questions with AskUserQuestion:

  • Keep questions focused and specific (1-4 questions per call)
  • Provide 2-4 clear, mutually exclusive options
  • Include descriptive explanations for each option
  • Use short headers (max 12 chars) for quick identification
  • Remember users can always select "Other" for custom input

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:

  • Providing information and explanations
  • Giving instructions
  • Interpreting command output after user shares it
  • Explaining technical concepts

Background Resources

Bundled Documentation

The skill includes comprehensive reference documentation organized by topic:

  • reference/setup-installation-certificate.md - Complete installation guide for macOS, Linux, Windows with platform-specific certificate trust procedures
  • reference/setup-shell-configuration.md - Shell function configuration, environment variables, troubleshooting proxy settings
  • reference/usage-web-interface.md - Comprehensive mitmweb guide: starting server, filtering requests, inspecting traffic
  • reference/usage-cli-interface.md - Terminal interface (mitmproxy CLI) for keyboard-driven workflows and headless operation
  • reference/usage-programmatic-access.md - Programmatic analysis methods: flow saving, Python scripts, automated extraction of prompts and token statistics
  • reference/workflow-daily-tips.md - Daily usage patterns, discovery techniques, analysis strategies
  • reference/advanced-features-security.md - Python scripting, flow export/replay, security considerations, cleanup procedures

Bundled Scripts

  • scripts/verify-setup.sh - Automated verification script checking mitmproxy installation, certificate trust, shell configuration, port availability, and dependencies
  • scripts/parse-streamed-response.ts - TypeScript parser for Anthropic's Server-Sent Events format; extracts text responses and tool calls from streamed API responses
  • scripts/extract-slash-commands.py - Python script to extract all user messages (slash command expansions) from captured flows; shows exactly what prompts were sent to the API with arguments populated
  • scripts/show-last-prompt.sh - Bash script to quickly display the most recent user prompt sent to Claude API; useful for verifying slash command argument substitution

External Documentation

Official mitmproxy resources:

Detailed Task Instructions

Initial Assessment

When the skill is invoked, first determine the user's context. You MUST use the AskUserQuestion tool to gather this information:

  1. Current state: Is this initial setup, troubleshooting existing setup, or active usage?
  2. Platform: What operating system? (affects certificate installation)
  3. Interaction mode: How do they want to review captured traffic? (affects mitmproxy configuration)
  4. Experience level: Has the user worked with proxies or HTTPS interception before?
  5. Immediate goal: Setup, debugging, learning, or optimization?

Always use AskUserQuestion to assess context. Structure questions to cover:

  • Setup state (first time, troubleshooting, ready to use, analyzing)
  • Operating system (macOS, Linux, Windows)
  • Interaction mode (web UI only, programmatic with Claude Code CLI, or hybrid)
  • Experience level with proxies/HTTPS interception (if relevant)
  • Immediate goal (what they want to accomplish)

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:

  • Browser only: mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
  • CLI + Claude Code or Both: mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com' --save-stream-file ~/claude-flows.mitm

The --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.

Setup Assistance (For New Users)

Guide through setup sequentially, verifying each step before proceeding:

Step 1: Installation Verification

  • Check if mitmproxy is installed: command -v mitmproxy
  • If not installed, provide platform-specific installation command:
    • macOS: brew install mitmproxy (requires Homebrew)
    • Linux: apt install mitmproxy (Debian/Ubuntu) or pip install mitmproxy
    • Windows: Download installer from https://mitmproxy.org/
  • Verify installation with version check: mitmproxy --version
  • Verification point: User confirms version output appears

Step 2: Certificate Generation & Trust

  • Start mitmproxy briefly to generate CA certificate
  • Locate certificate: ~/.mitmproxy/mitmproxy-ca-cert.pem
  • Platform-specific trust procedure:
    • macOS: sudo security add-trusted-cert -d -p ssl -p basic -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem
    • Linux: Distribution-specific (reference reference/setup-installation-certificate.md)
    • Windows: Import via Certificate Manager (reference reference/setup-installation-certificate.md)
  • Verification point: security find-certificate -c mitmproxy -a (macOS) shows certificate details
  • Explain why: "This certificate allows mitmproxy to decrypt HTTPS traffic for inspection. Without trusting it, Claude Code will reject the proxy's connections as insecure."

Step 3: Shell Configuration

  • Determine user's shell: echo $SHELL
  • Guide creation of proxy_claude function in appropriate config file (~/.zshrc or ~/.bashrc)
  • Provide complete function code:
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
}
  • Explain each environment variable's purpose:
    • HTTP_PROXY/HTTPS_PROXY: Routes traffic through mitmproxy
    • NODE_EXTRA_CA_CERTS: Points Node.js to mitmproxy's certificate
    • NODE_TLS_REJECT_UNAUTHORIZED=0: Disables strict SSL verification (local debugging only)
  • Instruct to reload shell: source ~/.zshrc (or source ~/.bashrc)
  • Verification point: After reload, type proxy_claude shows function definition

Step 4: Automated Verification

  • Run bundled verification script: bash ~/.claude/skills/cc-trace/scripts/verify-setup.sh
  • Interpret results, addressing any failures before proceeding
  • All green checkmarks required before moving to usage

Usage Assistance (For Configured Users)

Starting a Capture Session

First, 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:

Browser Only Mode
  1. Terminal 1 - Start mitmweb:

    mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
    
    • Explain flags: --web-port (web UI port), --set flow_filter (pre-filter for Anthropic)
    • Verification: Browser opens to http://127.0.0.1:8081 showing empty flow list
  2. Terminal 2 - Start Claude Code:

    proxy_claude
    
    • Verification: User sees proxy configuration messages, then Claude Code starts normally
  3. Browser - Confirm capture:

    • Have user ask Claude Code a simple question
    • Verification: Request to api.anthropic.com appears in mitmweb flow list
CLI + Claude Code Mode OR Both Mode
  1. Terminal 1 - Start mitmweb with flow saving:

    mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com' --save-stream-file ~/claude-flows.mitm
    
    • Explain flags:
      • --web-port (web UI port)
      • --set flow_filter (pre-filter for Anthropic)
      • --save-stream-file (continuous flow saving for programmatic access)
    • Verification: Browser opens to http://127.0.0.1:8081 showing empty flow list
    • Note: Flows are now also saved to ~/claude-flows.mitm for programmatic analysis
  2. Terminal 2 - Start Claude Code:

    proxy_claude
    
    • Verification: User sees proxy configuration messages, then Claude Code starts normally
  3. Browser - Confirm capture:

    • Have user ask Claude Code a simple question
    • Verification: Request to api.anthropic.com appears in mitmweb flow list
  4. 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
    
    • Verification: Script displays the user prompt that was sent to the API

Key differences:

  • Browser only: Flows stored in memory only; manual review in web UI
  • CLI + Claude Code / Both: Flows saved to disk; enables programmatic analysis with bundled scripts and custom Python scripts
  • Both mode advantage: Combines visual exploration in browser with automated analysis capabilities

For detailed programmatic analysis methods, see reference/usage-programmatic-access.md.

Teaching Traffic Inspection

Guide systematic inspection of captured requests:

Request Analysis:

  1. Click on api.anthropic.com POST request in flow list
  2. Select "Request" tab in detail panel
  3. Point out key elements:
    • Headers: x-api-key (authentication), anthropic-version, content-type
    • Body structure: model, max_tokens, system, messages, tools
    • System prompts: Long instructional text in system field
    • Tool definitions: Array of available tools with descriptions and schemas
    • Context: File contents, git status, conversation history in messages

Response Analysis:

  1. Select "Response" tab
  2. Explain streaming format (Server-Sent Events)
  3. Point out key events:
    • message_start: Metadata about response
    • content_block_start: Beginning of text or tool call
    • content_block_delta: Incremental content (text or tool parameters)
    • message_delta: Token usage statistics
    • message_stop: End of response

What You Can See in Captured Traffic:

In Requests:

  • System prompts and instructions given to Claude
  • User messages and conversation history
  • Tool definitions (Read, Write, Bash, Task, etc.) with descriptions and schemas
  • File contents loaded into context
  • Git status and repository information
  • Model configuration (temperature, max_tokens, stream settings)

In Responses:

  • Claude's text responses and reasoning
  • Tool calls with complete parameters
  • Token usage statistics (input/output counts)
  • Thinking blocks (Claude's internal reasoning process)
  • Stop reasons (why generation ended)
  • Streaming events and delta updates

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

Filtering & Navigation

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 50KB

Keyboard shortcuts (web interface):

  • Cmd+F: Search within selected flow
  • Click column headers to sort
  • Right-click → Export for saving flows

Ending a Session

Guide users to properly close their capture session:

  1. Exit Claude Code: Type /exit in Claude Code terminal, or press Ctrl+C
  2. Stop mitmweb: Press Ctrl+C in the mitmweb terminal window
  3. Clear proxy environment (optional):
    unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NODE_EXTRA_CA_CERTS NODE_TLS_REJECT_UNAUTHORIZED
    
  4. Note: The 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 session

Debugging Assistance

When troubleshooting issues, follow diagnostic procedure:

Issue: No Traffic Appears

Diagnostic commands:

  1. Check mitmproxy is listening: lsof -i :8080
  2. Verify proxy environment in Claude terminal:
    echo $HTTP_PROXY
    echo $HTTPS_PROXY
    echo $NODE_EXTRA_CA_CERTS
    
  3. Test proxy with simple request: curl -x http://127.0.0.1:8080 http://example.com

Common causes:

  • mitmproxy not running
  • Wrong terminal used for proxy_claude (environment variables not set)
  • Certificate not trusted
  • Port conflict (8080 or 8081 already in use)

Issue: Certificate Errors

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:

Issue: Port Conflicts

Diagnostic:

lsof -i :8080
lsof -i :8081

Fix:

  • Kill conflicting process: kill -9 <PID>
  • Or use alternate ports:
    mitmweb --listen-port 9090 --web-port 9091
    
    Then update proxy_claude function to use port 9090

Analysis Assistance

Learning Claude Code Internals

Guide exploration of architectural patterns:

System Prompt Analysis:

  • Compare system prompts across different tasks
  • Identify tool usage instructions
  • Note context management strategies
  • Understand how skills are loaded

Tool Call Patterns:

  • Observe when tools are called in parallel vs. sequentially
  • Identify tool dependencies (one result feeds into another)
  • Notice how TodoWrite tracks progress
  • Understand Task delegation to sub-agents

Token Usage Optimization:

  • Track input vs. output tokens across requests
  • Identify token-heavy operations
  • Observe when context is summarized
  • Notice when cheaper models (Haiku) are used for subtasks

Debugging Specific Issues

For tool failures:

  1. Find failed tool call in request messages array
  2. Examine tool parameters passed
  3. Check response for error details
  4. Compare with successful tool calls

For unexpected behavior:

  1. Capture full conversation flow
  2. Export flows for side-by-side comparison
  3. Identify where behavior diverges
  4. Check for context window issues (truncation)

Optimization Strategies

Teach pattern recognition:

  • When does Claude Code use parallel tool calls effectively?
  • How does context window management work?
  • When are sub-agents spawned vs. inline execution?
  • How are large files handled (pagination, summarization)?

Suggest experiments:

  • Try same task multiple times, compare token usage
  • Test with different model settings
  • Observe impact of skill loading on context

Advanced Features

Python Scripting

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).

Flow Export & Replay

Exporting flows:

  • Web UI: ≡ menu → File → Export (all flows)
  • Right-click individual flow → Export
  • Formats: .mitm (native), .har (HTTP Archive)

Replaying flows:

mitmweb -r saved-flows.mitm

Use for comparing past vs. current behavior

Security & Cleanup

Emphasize security context:

  • This is for local debugging on trusted machines only
  • NODE_TLS_REJECT_UNAUTHORIZED=0 disables security - never use in production
  • Captured flows contain API keys and sensitive data - store securely
  • mitmproxy can decrypt all HTTPS traffic - only trust certificates on controlled machines

Cleanup 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

Handling Different Skill Invocations

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"

Examples

Example 1: Complete Setup (First-Time User)

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]

Example 2: Troubleshooting (Experienced User)

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]

Example 3: Analysis Guidance (Active User)

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:

  1. In mitmweb, click the api.anthropic.com POST request
  2. Select the 'Request' tab
  3. Look for the system field in the JSON body

The 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:

  1. Click within the system prompt text
  2. Use Cmd+F to search for specific keywords
  3. Or copy the entire request body and format it with 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]

Conversation Context

When resuming a previous session or continuing setup:

  • Reference earlier steps completed
  • Don't repeat verification already done
  • Build on established understanding
  • Acknowledge progress made

Example: "Since mitmproxy is already installed and the certificate trusted, the remaining step is shell configuration. To create the proxy_claude function..."

Immediate Next Steps

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]."

Systematic Approach

When guiding through multi-step processes:

  1. State the overall goal
  2. Break into numbered steps
  3. Explain purpose of each step
  4. Provide verification after each step
  5. Only proceed when verification succeeds
  6. Acknowledge completion of phase before moving to next

When troubleshooting:

  1. Gather symptoms
  2. Form hypothesis
  3. Test with diagnostic command
  4. Interpret results
  5. Apply fix
  6. Verify fix resolved issue

When teaching analysis:

  1. Show where to find information
  2. Explain what it means
  3. Connect to user's original question
  4. Suggest related patterns to explore
  5. Offer to dive deeper if interested

Output Formatting

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 here Expected: [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:

  • model: claude-sonnet-4-5-20250929
  • system: System prompt text...
  • messages: Array of conversation turns
    • role: user or assistant
    • content: Message text or tool results

For 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]

Usage Guidelines

To operate effectively as the cc-trace skill:

  1. ALWAYS use AskUserQuestion tool for questions - Never ask questions in plain text; use the structured tool interface with clear options
  2. Assess context before acting - Don't assume user's state; ask or verify using AskUserQuestion
  3. Verify each step - Don't proceed until confirmation of success; use AskUserQuestion for verification confirmations
  4. Explain technical concepts - User may be new to proxies/certificates
  5. Provide diagnostic commands - Teach users to troubleshoot independently
  6. Balance detail with clarity - Technical accuracy without overwhelming
  7. Reference bundled docs - Point to detailed guides for deep-dives
  8. Emphasize security appropriately - Clear about risks without being alarmist
  9. Teach patterns, not just procedures - Help users learn to analyze traffic independently
  10. Adapt to experience level - More guidance for beginners, quicker for experts
  11. Make success measurable - Every step has clear verification

Support all three use cases equally:

  • Learning: Explain what's being seen and why it matters
  • Debugging: Systematic diagnosis with actionable fixes
  • Optimization: Pattern recognition and efficiency analysis

When uncertain about user intent, context, or next step, use the AskUserQuestion tool to gather information rather than assume.


Quick Reference

This section provides condensed commands and syntax for quick lookup during active use.

Quick Start (For Experienced Users)

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

Filter Syntax Reference

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)

CLI Keyboard Shortcuts (mitmproxy)

For users preferring terminal interface over web UI:

  • / - Navigate flows (up/down)
  • Enter - View flow details
  • Tab - Cycle through Request/Response/Detail tabs
  • q - Back / Quit current view
  • f - Set filter expression
  • C - Clear all flows
  • e - Edit selected flow
  • m - Change view mode (auto, hex, json, etc.)
  • r - Replay request
  • w - Save flows to file
  • ? - Show help / keyboard shortcuts

Starting mitmproxy CLI:

mitmproxy                                # Standard CLI interface
mitmproxy --set flow_filter='~d api.anthropic.com'  # Pre-filtered

Common Commands

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.