Skip to main content

Trace AI CLI API requests via local reverse and forward proxies. Inspect system prompts, messages, tools, and token usage.

Project description

claude-tap

PyPI version PyPI downloads Python version License GitHub stars All Contributors

中文文档

Intercept and inspect API traffic from Claude Code, Codex CLI, OpenCode, or Cursor CLI. See exactly how they construct system prompts, manage conversation history, select tools, and use tokens — in a beautiful trace viewer.

Demo

Light Mode

Dark Mode / Diff View

Dark Mode Structural Diff Character-level Diff

OpenClaw: If you are Openclaw and integrating claude-tap with OpenClaw, also read the dedicated setup guide.

Install

Requires Python 3.11+ and the CLI you want to trace: Claude Code, Codex CLI, OpenCode, or Cursor CLI.

# Recommended
uv tool install claude-tap

# Or with pip
pip install claude-tap

Upgrade: uv tool upgrade claude-tap or pip install --upgrade claude-tap

Quick Start

Run the client you want to inspect through claude-tap:

# Claude Code
claude-tap

# Claude Code with live browser viewer
claude-tap --tap-live

# Codex CLI
claude-tap --tap-client codex

# Cursor CLI
claude-tap --tap-client cursor -- -p --trust --model auto "hello"

Flags that are not --tap-* are forwarded to the selected client after --.

Claude Code examples
# Pass flags through to Claude Code
claude-tap -- --model claude-opus-4-6
claude-tap -c    # continue last conversation

# Skip all permission prompts (auto-accept tool calls)
claude-tap -- --dangerously-skip-permissions

# Live viewer + skip permissions + specific model
claude-tap --tap-live -- --dangerously-skip-permissions --model claude-sonnet-4-6
Codex CLI auth modes and examples

Codex CLI supports two authentication modes with different upstream targets:

Auth Mode How to authenticate Upstream target Notes
OAuth (ChatGPT subscription) codex login https://chatgpt.com/backend-api/codex Default for ChatGPT Plus/Pro/Team users
API Key Set OPENAI_API_KEY https://api.openai.com (default) Pay-per-use via OpenAI Platform

claude-tap auto-detects the Codex target from your auth state when possible.

# OAuth users (ChatGPT Plus/Pro/Team) — auto-detected after `codex login`
claude-tap --tap-client codex

# If auto-detection cannot read your Codex auth file, specify the target explicitly
claude-tap --tap-client codex --tap-target https://chatgpt.com/backend-api/codex

# API Key users — default OpenAI API target works out of the box
claude-tap --tap-client codex

# With specific model
claude-tap --tap-client codex -- --model codex-mini-latest

# Full auto-approval (skip all permission prompts)
claude-tap --tap-client codex -- --full-auto

# OAuth + full auto + live viewer
claude-tap --tap-client codex --tap-live -- --full-auto
Cursor CLI examples

Cursor CLI uses forward proxy mode by default. Use --model auto on free plans, and omit --mode ask when you want tool calls.

claude-tap --tap-client cursor -- -p --trust --model auto "hello"
claude-tap --tap-client cursor -- -p --trust --model auto --continue "continue"
Browser preview, export, and proxy-only mode
# Disable auto-open of HTML viewer after exit (on by default)
claude-tap --tap-no-open

# Live mode — real-time viewer opens in browser while client runs
claude-tap --tap-live
claude-tap --tap-live --tap-live-port 3000    # fixed port for live viewer

# Standalone dashboard — browse trace history without launching a client
claude-tap dashboard
claude-tap dashboard --tap-output-dir ./my-traces --tap-live-port 3000

When the client exits, you can also manually open the generated viewer:

open .traces/*/trace_*.html

You can also regenerate a self-contained HTML viewer from an existing JSONL trace:

claude-tap export .traces/2026-02-28/trace_141557.jsonl -o trace.html
# or:
claude-tap export .traces/2026-02-28/trace_141557.jsonl --format html

Proxy-only mode

Start the proxy without launching a client — useful for custom setups or connecting from a separate terminal:

# Claude Code
claude-tap --tap-no-launch --tap-port 8080
# In another terminal:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 claude

# Codex CLI (OAuth)
claude-tap --tap-client codex --tap-target https://chatgpt.com/backend-api/codex --tap-no-launch --tap-port 8080
# In another terminal:
OPENAI_BASE_URL=http://127.0.0.1:8080/v1 codex -c 'openai_base_url="http://127.0.0.1:8080/v1"'

# Codex CLI (API Key)
claude-tap --tap-client codex --tap-no-launch --tap-port 8080
# In another terminal:
OPENAI_BASE_URL=http://127.0.0.1:8080/v1 codex -c 'openai_base_url="http://127.0.0.1:8080/v1"'

Run claude-tap --help for all options. Flags that are not --tap-* are forwarded to the selected client.

Viewer Features

Trace viewer capabilities

The viewer is a single self-contained HTML file (zero external dependencies):

  • Structural diff — compare consecutive requests to see exactly what changed: new/removed messages, system prompt diffs, character-level inline highlighting
  • Path filtering — filter by API endpoint (e.g., /v1/messages only)
  • Model grouping — sidebar groups requests by model, with Claude-family priority ordering
  • Token usage breakdown — input / output / cache read / cache creation
  • Tool inspector — expandable cards with tool name, description, and parameter schema
  • Search — full-text search across messages, tools, prompts, and responses
  • Dark mode — toggle light/dark themes (respects system preference)
  • Keyboard navigationj/k or arrow keys
  • Copy helpers — one-click copy of request JSON or cURL command
  • i18n — English, 简体中文, 日本語, 한국어, Français, العربية, Deutsch, Русский

Architecture

Architecture

How it works

How it works:

  1. claude-tap starts a reverse or forward proxy and spawns the selected client
  2. Base URL clients are pointed at the reverse proxy; clients without base URL support use proxy/CA environment variables
  3. SSE and WebSocket streams are forwarded as chunks/messages arrive with low proxy overhead
  4. Each request-response pair or WebSocket session is recorded to a dated trace_*.jsonl
  5. On exit, a self-contained HTML viewer is generated
  6. Live mode (optional) broadcasts updates to browser via SSE

Key features: 🔒 Common auth headers auto-redacted · ⚡ Low-overhead streaming · 📦 Self-contained viewer · 🔄 Real-time live mode

Community

Star History

Star History Chart

Contributors

Thanks goes to these contributors:

liaohch3
liaohch3

💻 📖 🚧 ⚠️
BKK
BKK

💻
YoungCan-Wang
YoungCan-Wang

💻
0xkrypton
0xkrypton

💻
CYJiang
CYJiang

💻
陈展鹏
陈展鹏

📖

Contributing

Contributions are welcome. Start with CONTRIBUTING.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_tap-0.1.47.tar.gz (24.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_tap-0.1.47-py3-none-any.whl (93.9 kB view details)

Uploaded Python 3

File details

Details for the file claude_tap-0.1.47.tar.gz.

File metadata

  • Download URL: claude_tap-0.1.47.tar.gz
  • Upload date:
  • Size: 24.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_tap-0.1.47.tar.gz
Algorithm Hash digest
SHA256 d0e90d6053d237839df49991c06cf4843b3961671a2d8f77d39a0d71bedf2196
MD5 0a181cc1eb1674a00aead140aaffbdaa
BLAKE2b-256 262d9245414cd99b057792f6374c3eae11e9cafb3538ab14b1321494643e84a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_tap-0.1.47.tar.gz:

Publisher: publish.yml on liaohch3/claude-tap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_tap-0.1.47-py3-none-any.whl.

File metadata

  • Download URL: claude_tap-0.1.47-py3-none-any.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for claude_tap-0.1.47-py3-none-any.whl
Algorithm Hash digest
SHA256 ab9b9563257c6f725aad99c5cd0e2cb913fd07da80886e4fa0dd94dfcf0479a6
MD5 8fc57008311bb019984b03c4648392be
BLAKE2b-256 3ae1fb647dfd613090c07d0d3036d95992434b78f183af864b376bca4e745b99

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_tap-0.1.47-py3-none-any.whl:

Publisher: publish.yml on liaohch3/claude-tap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page