docs: refresh README and demo assets (#178)

* docs: refresh README and demo assets

Co-authored-by: Talon <talon@users.noreply.github.com>

* docs: refine README structure

Co-authored-by: Talon <talon@users.noreply.github.com>

* docs: replace demo with real Codex trace

Co-authored-by: Talon <talon@users.noreply.github.com>

* docs: polish README media layout

Co-authored-by: Talon <talon@users.noreply.github.com>

* docs: update star history chart embed

Co-authored-by: Talon <talon@users.noreply.github.com>

* docs: expand viewer feature list

Co-authored-by: Talon <talon@users.noreply.github.com>

---------

Co-authored-by: liaohch3 <liaohch3@gmail.com>
Co-authored-by: Talon <talon@users.noreply.github.com>
This commit is contained in:
liaohch3
2026-05-17 14:09:54 +08:00
committed by GitHub
parent f10011e3c0
commit 7fa0e40271
15 changed files with 211 additions and 226 deletions
Binary file not shown.
Binary file not shown.
+27
View File
@@ -67,6 +67,33 @@
"contributions": [
"doc"
]
},
{
"login": "devtalker",
"name": "devtalker",
"avatar_url": "https://avatars.githubusercontent.com/u/23204195",
"profile": "https://github.com/devtalker",
"contributions": [
"code"
]
},
{
"login": "dingyaguang117",
"name": "Yaguang Ding",
"avatar_url": "https://avatars.githubusercontent.com/u/1930778",
"profile": "https://github.com/dingyaguang117",
"contributions": [
"code"
]
},
{
"login": "sephymartin",
"name": "Sephy",
"avatar_url": "https://avatars.githubusercontent.com/u/299891",
"profile": "https://github.com/sephymartin",
"contributions": [
"code"
]
}
]
}
+82 -94
View File
@@ -5,30 +5,64 @@
[![Python version](https://img.shields.io/pypi/pyversions/claude-tap.svg)](https://pypi.org/project/claude-tap/)
[![License](https://img.shields.io/github/license/liaohch3/claude-tap.svg)](https://github.com/liaohch3/claude-tap/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/liaohch3/claude-tap?style=social)](https://github.com/liaohch3/claude-tap/stargazers)
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg)](#contributors)
[中文文档](README_zh.md)
Intercept and inspect all API traffic from [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), [Gemini CLI](https://github.com/google-gemini/gemini-cli), [Kimi CLI](https://github.com/MoonshotAI/kimi-cli), [OpenCode](https://opencode.ai), [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent), [Hermes Agent](https://github.com/NousResearch/hermes-agent), or [Cursor CLI](https://cursor.com/cli). See exactly how they construct system prompts, manage conversation history, select tools, and use tokens — in a beautiful trace viewer.
`claude-tap` is a local proxy and trace viewer for AI coding agents. Run your CLI through it, then inspect the real API traffic: system prompts, conversation history, tool schemas, tool calls, streaming responses, token usage, and request diffs.
![Demo](docs/demo.gif)
It works with [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), [Gemini CLI](https://github.com/google-gemini/gemini-cli), [Kimi CLI](https://github.com/MoonshotAI/kimi-cli), [OpenCode](https://opencode.ai), [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent), [Hermes Agent](https://github.com/NousResearch/hermes-agent), and [Cursor CLI](https://cursor.com/cli).
![Light Mode](docs/viewer-light.png)
<p align="center">
<img src="docs/demo.gif" alt="claude-tap demo showing a real Codex trace" width="100%">
<br>
<sub>Open a real agent run, inspect every request, and compare how context changes between turns.</sub>
</p>
<details>
<summary>Dark Mode / Diff View</summary>
<table>
<tr>
<td width="33%" align="center">
<img src="docs/viewer-light.png" alt="Light mode trace viewer" width="100%">
<br>
<sub>Light viewer overview</sub>
</td>
<td width="33%" align="center">
<img src="docs/viewer-dark.png" alt="Dark mode trace viewer" width="100%">
<br>
<sub>Dark mode for long review sessions</sub>
</td>
<td width="33%" align="center">
<img src="docs/diff-modal.png" alt="Structured diff modal" width="100%">
<br>
<sub>Structured diff across adjacent requests</sub>
</td>
</tr>
</table>
![Dark Mode](docs/viewer-dark.png)
![Structural Diff](docs/diff-modal.png)
![Character-level Diff](docs/billing-header-diff.png)
## Why use it
</details>
- 👀 **See the exact context**: inspect prompts, messages, tool definitions, tool calls, tool results, streaming chunks, and token usage.
- 🔎 **Debug behavior with evidence**: compare adjacent requests and pinpoint which prompt, message, tool, or parameter changed.
- 📦 **Share one portable artifact**: each run writes a JSONL trace and a self-contained HTML viewer for review or archiving.
- 🔒 **Keep traces on your machine**: no hosted dashboard is required, and common auth headers are redacted before recording.
- 🧩 **Use one workflow across clients**: trace Claude Code, Codex CLI, Gemini CLI, Kimi CLI, OpenCode, Pi, Hermes Agent, and Cursor CLI.
> **OpenClaw:** If you are integrating claude-tap with OpenClaw, read the [OpenClaw setup guide](docs/guides/OPENCLAW_README.md). Simplified Chinese version: [OpenClaw 设置指南](docs/guides/OPENCLAW_README.zh.md).
## Supported Clients
| Client | Typical use |
|--------|-------------|
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Anthropic API or Claude-compatible gateways such as DeepSeek / GLM |
| [Codex CLI](https://github.com/openai/codex) | OpenAI API key mode or ChatGPT subscription OAuth |
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google OAuth / Code Assist traffic |
| [Kimi CLI](https://github.com/MoonshotAI/kimi-cli) | Kimi Code or Moonshot Open Platform |
| [OpenCode](https://opencode.ai) | Multi-provider OpenCode sessions |
| [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) | Pi sessions, including OpenAI Codex OAuth providers |
| [Hermes Agent](https://github.com/NousResearch/hermes-agent) | Multi-provider Hermes TUI or gateway sessions |
| [Cursor CLI](https://cursor.com/cli) | Cursor Agent sessions plus readable local transcript import |
## Install
Requires Python 3.11+ and the client you want to trace: [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (default), [Codex CLI](https://github.com/openai/codex) for `--tap-client codex`, [Gemini CLI](https://github.com/google-gemini/gemini-cli) for `--tap-client gemini`, [Kimi CLI](https://github.com/MoonshotAI/kimi-cli) for `--tap-client kimi`, [OpenCode](https://opencode.ai) for `--tap-client opencode`, [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) for `--tap-client pi`, [Hermes Agent](https://github.com/NousResearch/hermes-agent) for `--tap-client hermes`, or [Cursor CLI](https://cursor.com/cli) for `--tap-client cursor`.
Requires Python 3.11+ and the client you want to trace.
```bash
# Recommended
@@ -42,7 +76,7 @@ Upgrade: `claude-tap update`, `uv tool upgrade claude-tap`, or `pip install --up
## Quick Start
Run the client you want to inspect through `claude-tap`:
Run the client you want to inspect through `claude-tap`. Flags after `--` are passed to the selected client.
```bash
# Claude Code
@@ -67,8 +101,6 @@ claude-tap --tap-client pi -- --model openai-codex/gpt-5.3-codex-spark -p "hello
claude-tap --tap-client cursor -- -p --trust --model auto "hello"
```
Flags that are not `--tap-*` are forwarded to the selected client after `--`.
<details>
<summary>Claude Code examples</summary>
@@ -105,16 +137,14 @@ export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_EFFORT_LEVEL=max
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
```
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- --permission-mode bypassPermissions
claude-tap -- --permission-mode bypassPermissions
```
Set `ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic` only for direct Claude Code usage. When capturing with `claude-tap`, use `--tap-target` for the DeepSeek upstream.
`claude-tap` reads the DeepSeek upstream from `ANTHROPIC_BASE_URL`, then launches Claude Code against the local proxy. Use `--tap-target https://api.deepseek.com/anthropic` only as a manual override.
</details>
@@ -260,88 +290,38 @@ claude-tap --tap-client cursor -- -p --trust --model auto --continue "continue"
</details>
## Guides and Integrations
- [OpenClaw setup guide](docs/guides/OPENCLAW_README.md) for integrating `claude-tap` with OpenClaw. Simplified Chinese version: [OpenClaw 设置指南](docs/guides/OPENCLAW_README.zh.md).
- [Claude Code with DeepSeek API](docs/guides/deepseek-claude-code.md) for routing Claude Code through DeepSeek's Anthropic-compatible API. Simplified Chinese version: [Claude Code 搭配 DeepSeek API](docs/guides/deepseek-claude-code.zh.md).
- [Client support matrix](docs/support-matrix.md) for exact environment variables, proxy modes, and URL rewrite rules.
<details>
<summary>Browser preview, export, and proxy-only mode</summary>
<summary>Viewer, export, and advanced options</summary>
```bash
# 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
# Live viewer while a 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
# Browse saved traces 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:
```bash
open .traces/*/trace_*.html
```
You can also regenerate a self-contained HTML viewer from an existing JSONL trace:
```bash
# Regenerate a self-contained HTML viewer from JSONL
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:
```bash
# Claude Code
claude-tap --tap-no-launch --tap-port 8080
# In another terminal:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 claude
# Anthropic Python SDK (or any custom agent built on it)
claude-tap --tap-no-launch --tap-port 8080
# In your agent process:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 python your_agent.py
# 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"'
# Kimi CLI
claude-tap --tap-client kimi --tap-no-launch --tap-port 8080
# In another terminal:
KIMI_BASE_URL=http://127.0.0.1:8080 kimi
# Gemini CLI (reverse mode only)
claude-tap --tap-client gemini --tap-proxy-mode reverse --tap-no-launch --tap-port 8080
# In another terminal:
GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8080 GOOGLE_VERTEX_BASE_URL=http://127.0.0.1:8080 gemini
```
### Common Combos
```bash
# Trace Claude Code with live viewer and auto-accept
claude-tap --tap-live -- --dangerously-skip-permissions
# Trace Codex (OAuth) with live viewer and full auto
claude-tap --tap-client codex --tap-target https://chatgpt.com/backend-api/codex --tap-live -- --full-auto
# Save traces to a custom directory
# Store traces in another directory, or keep fewer sessions
claude-tap --tap-output-dir ./my-traces
# Keep only the last 10 trace sessions
claude-tap --tap-max-traces 10
# Start only the proxy for custom setups
claude-tap --tap-no-launch --tap-port 8080
# Disable auto-open of the generated viewer after exit
claude-tap --tap-no-open
```
In proxy-only mode, start your client in another terminal and point its base URL or proxy settings at the local proxy. Use the [client support matrix](docs/support-matrix.md) for exact wiring.
### CLI Options
All flags are forwarded to the selected client, except these `--tap-*` ones:
@@ -366,8 +346,7 @@ All flags are forwarded to the selected client, except these `--tap-*` ones:
## Viewer Features
<details>
<summary>Trace viewer capabilities</summary>
### Trace viewer capabilities
The viewer is a single self-contained HTML file (zero external dependencies):
@@ -382,8 +361,6 @@ The viewer is a single self-contained HTML file (zero external dependencies):
- **Copy helpers** — one-click copy of request JSON or cURL command
- **i18n** — English, 简体中文, 日本語, 한국어, Français, العربية, Deutsch, Русский
</details>
## Architecture
![Architecture](docs/architecture.png)
@@ -408,7 +385,13 @@ The viewer is a single self-contained HTML file (zero external dependencies):
### Star History
[![Star History Chart](https://api.star-history.com/svg?repos=liaohch3/claude-tap&type=Date)](https://www.star-history.com/#liaohch3/claude-tap&Date)
<a href="https://www.star-history.com/?repos=liaohch3%2Fclaude-tap&type=date&legend=bottom-right">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&theme=dark&legend=top-left" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&legend=top-left" />
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&legend=top-left" />
</picture>
</a>
### Contributors
@@ -426,6 +409,11 @@ Thanks goes to these contributors:
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oxkrypton"><img src="https://avatars.githubusercontent.com/u/154910746?s=100" width="100px;" alt="0xkrypton"/><br /><sub><b>0xkrypton</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=oxkrypton" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/googs1025"><img src="https://avatars.githubusercontent.com/u/86391540?s=100" width="100px;" alt="CYJiang"/><br /><sub><b>CYJiang</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=googs1025" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/TITOCHAN2023"><img src="https://avatars.githubusercontent.com/u/138754853?s=100" width="100px;" alt="陈展鹏"/><br /><sub><b>陈展鹏</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=TITOCHAN2023" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/devtalker"><img src="https://avatars.githubusercontent.com/u/23204195?s=100" width="100px;" alt="devtalker"/><br /><sub><b>devtalker</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=devtalker" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dingyaguang117"><img src="https://avatars.githubusercontent.com/u/1930778?s=100" width="100px;" alt="Yaguang Ding"/><br /><sub><b>Yaguang Ding</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=dingyaguang117" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sephymartin"><img src="https://avatars.githubusercontent.com/u/299891?s=100" width="100px;" alt="Sephy"/><br /><sub><b>Sephy</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=sephymartin" title="Code">💻</a></td>
</tr>
</tbody>
</table>
+82 -94
View File
@@ -5,30 +5,64 @@
[![Python version](https://img.shields.io/pypi/pyversions/claude-tap.svg)](https://pypi.org/project/claude-tap/)
[![License](https://img.shields.io/github/license/liaohch3/claude-tap.svg)](https://github.com/liaohch3/claude-tap/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/liaohch3/claude-tap?style=social)](https://github.com/liaohch3/claude-tap/stargazers)
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg)](#贡献者)
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg)](#贡献者)
[English](README.md)
拦截并查看 [Claude Code](https://docs.anthropic.com/en/docs/claude-code)、[Codex CLI](https://github.com/openai/codex)、[Gemini CLI](https://github.com/google-gemini/gemini-cli)、[Kimi CLI](https://github.com/MoonshotAI/kimi-cli)、[OpenCode](https://opencode.ai)、[Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent)、[Hermes Agent](https://github.com/NousResearch/hermes-agent) 或 [Cursor CLI](https://cursor.com/cli) 的所有 API 流量。看清它们如何构造 system prompt、管理对话历史、选择工具、优化 token 用量——通过一个美观的 trace 查看器
`claude-tap` 是给 AI 编程 agent 用的本地代理和 trace 查看器。把 CLI 通过它启动,就能看到真实 API 流量:system prompt、对话历史、工具 schema、工具调用、流式响应、token 用量和请求 diff
![演示](docs/demo_zh.gif)
它支持 [Claude Code](https://docs.anthropic.com/en/docs/claude-code)、[Codex CLI](https://github.com/openai/codex)、[Gemini CLI](https://github.com/google-gemini/gemini-cli)、[Kimi CLI](https://github.com/MoonshotAI/kimi-cli)、[OpenCode](https://opencode.ai)、[Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent)、[Hermes Agent](https://github.com/NousResearch/hermes-agent) 和 [Cursor CLI](https://cursor.com/cli)
![亮色模式](docs/viewer-zh.png)
<p align="center">
<img src="docs/demo_zh.gif" alt="claude-tap 演示:真实 Codex trace" width="100%">
<br>
<sub>打开一次真实 agent 运行,检查每个请求,并对比上下文如何在多轮之间变化。</sub>
</p>
<details>
<summary>暗色模式 / Diff 视图</summary>
<table>
<tr>
<td width="33%" align="center">
<img src="docs/viewer-zh.png" alt="亮色模式 trace 查看器" width="100%">
<br>
<sub>亮色模式总览</sub>
</td>
<td width="33%" align="center">
<img src="docs/viewer-dark.png" alt="暗色模式 trace 查看器" width="100%">
<br>
<sub>适合长时间 review 的暗色模式</sub>
</td>
<td width="33%" align="center">
<img src="docs/diff-modal.png" alt="结构化 Diff 弹窗" width="100%">
<br>
<sub>相邻请求之间的结构化 Diff</sub>
</td>
</tr>
</table>
![暗色模式](docs/viewer-dark.png)
![结构化 Diff](docs/diff-modal.png)
![字符级 Diff](docs/billing-header-diff.png)
## 为什么用它
</details>
- 👀 **看见真实上下文**:检查 prompt、messages、工具定义、工具调用、工具结果、流式 chunk 和 token 用量。
- 🔎 **用证据定位问题**:对比相邻请求,明确是哪段 prompt、消息、工具或参数发生了变化。
- 📦 **留下可分享证据**:每次运行都会写入 JSONL trace,并生成自包含 HTML 查看器,方便 review 或归档。
- 🔒 **数据留在本机**:不依赖云端 dashboard;常见认证 header 会在记录前自动脱敏。
- 🧩 **覆盖主流编码 CLI**:同一套流程可用于 Claude Code、Codex CLI、Gemini CLI、Kimi CLI、OpenCode、Pi、Hermes Agent 和 Cursor CLI。
> **OpenClaw** 如果你要在 OpenClaw 中集成 claude-tap,请阅读 [OpenClaw 设置指南](docs/guides/OPENCLAW_README.zh.md)。英文版见 [OpenClaw setup guide](docs/guides/OPENCLAW_README.md)。
## 支持的客户端
| 客户端 | 典型用途 |
|--------|----------|
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | Anthropic API,或 DeepSeek / GLM 等 Claude 兼容网关 |
| [Codex CLI](https://github.com/openai/codex) | OpenAI API 密钥模式,或 ChatGPT 订阅 OAuth |
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Google OAuth / Code Assist 的多 Google 端点流量 |
| [Kimi CLI](https://github.com/MoonshotAI/kimi-cli) | Kimi Code 或 Moonshot Open Platform |
| [OpenCode](https://opencode.ai) | 多提供方 OpenCode 会话 |
| [Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent) | Pi 会话,包括 OpenAI Codex OAuth 提供方 |
| [Hermes Agent](https://github.com/NousResearch/hermes-agent) | 多提供方 Hermes TUI 或 gateway 会话 |
| [Cursor CLI](https://cursor.com/cli) | Cursor Agent 会话,并导入可读的本地 transcript |
## 安装
需要 Python 3.11+ 以及要追踪的客户端[Claude Code](https://docs.anthropic.com/en/docs/claude-code)(默认)、[Codex CLI](https://github.com/openai/codex)`--tap-client codex` 时)、[Gemini CLI](https://github.com/google-gemini/gemini-cli)`--tap-client gemini` 时)、[Kimi CLI](https://github.com/MoonshotAI/kimi-cli)`--tap-client kimi` 时)、[OpenCode](https://opencode.ai)`--tap-client opencode` 时)、[Pi](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent)`--tap-client pi` 时)、[Hermes Agent](https://github.com/NousResearch/hermes-agent)`--tap-client hermes` 时)、或 [Cursor CLI](https://cursor.com/cli)`--tap-client cursor` 时)
需要 Python 3.11+以及要追踪的客户端。
```bash
# 推荐
@@ -42,7 +76,7 @@ pip install claude-tap
## 快速开始
`claude-tap` 启动你想观察的客户端
`claude-tap` 启动你想观察的客户端`--` 后面的参数会透传给所选客户端。
```bash
# Claude Code
@@ -67,8 +101,6 @@ claude-tap --tap-client pi -- --model openai-codex/gpt-5.3-codex-spark -p "hello
claude-tap --tap-client cursor -- -p --trust --model auto "hello"
```
`--tap-*` 参数会在 `--` 后透传给所选客户端。
<details>
<summary>Claude Code 更多示例</summary>
@@ -104,16 +136,14 @@ export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_EFFORT_LEVEL=max
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
```
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- --permission-mode bypassPermissions
claude-tap -- --permission-mode bypassPermissions
```
直接运行 Claude Code 时才设置 `ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic`;通过 `claude-tap` 捕获时用 `--tap-target` 指定 DeepSeek 上游
`claude-tap` 会从 `ANTHROPIC_BASE_URL` 读取 DeepSeek 上游,再把 Claude Code 指向本地代理。只有手动覆盖时才需要 `--tap-target https://api.deepseek.com/anthropic`
</details>
@@ -257,88 +287,38 @@ claude-tap --tap-client cursor -- -p --trust --model auto --continue "continue"
</details>
## 集成与指南
- [OpenClaw 设置指南](docs/guides/OPENCLAW_README.zh.md):在 OpenClaw 中集成 `claude-tap`。英文版见 [OpenClaw setup guide](docs/guides/OPENCLAW_README.md)。
- [Claude Code 搭配 DeepSeek API](docs/guides/deepseek-claude-code.zh.md):让 Claude Code 走 DeepSeek 的 Anthropic 兼容 API。英文版见 [Claude Code with DeepSeek API](docs/guides/deepseek-claude-code.md)。
- [客户端支持矩阵](docs/support-matrix.md):查看各客户端对应的环境变量、代理模式和 URL 改写规则。
<details>
<summary>浏览器预览、导出和纯代理模式</summary>
<summary>查看器、导出和高级选项</summary>
```bash
# 禁用退出后自动打开 HTML 查看器(默认开启)
claude-tap --tap-no-open
# 实时模式 — 客户端运行时在浏览器中实时查看
# 客户端运行时打开实时查看器
claude-tap --tap-live
claude-tap --tap-live --tap-live-port 3000 # 固定实时查看器端口
# 独立 Dashboard — 不启动客户端,直接浏览历史 trace
# 不启动客户端,直接浏览历史 trace
claude-tap dashboard
claude-tap dashboard --tap-output-dir ./my-traces --tap-live-port 3000
```
客户端退出后,也可以手动打开生成的查看器
```bash
open .traces/*/trace_*.html
```
也可以从已有 JSONL trace 重新生成自包含 HTML 查看器:
```bash
# 从已有 JSONL trace 重新生成自包含 HTML 查看器
claude-tap export .traces/2026-02-28/trace_141557.jsonl -o trace.html
# 或:
claude-tap export .traces/2026-02-28/trace_141557.jsonl --format html
```
### 纯代理模式
仅启动代理,不自动启动客户端 — 适用于自定义场景或在另一个终端手动连接:
```bash
# Claude Code
claude-tap --tap-no-launch --tap-port 8080
# 在另一个终端:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 claude
# Anthropic Python SDK(或任何基于它构建的自定义 Agent)
claude-tap --tap-no-launch --tap-port 8080
# 在你的 Agent 进程中:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 python your_agent.py
# Codex CLIOAuth
claude-tap --tap-client codex --tap-target https://chatgpt.com/backend-api/codex --tap-no-launch --tap-port 8080
# 在另一个终端:
OPENAI_BASE_URL=http://127.0.0.1:8080/v1 codex -c 'openai_base_url="http://127.0.0.1:8080/v1"'
# Codex CLIAPI Key
claude-tap --tap-client codex --tap-no-launch --tap-port 8080
# 在另一个终端:
OPENAI_BASE_URL=http://127.0.0.1:8080/v1 codex -c 'openai_base_url="http://127.0.0.1:8080/v1"'
# Kimi CLI
claude-tap --tap-client kimi --tap-no-launch --tap-port 8080
# 在另一个终端:
KIMI_BASE_URL=http://127.0.0.1:8080 kimi
# Gemini CLI(仅 reverse 模式)
claude-tap --tap-client gemini --tap-proxy-mode reverse --tap-no-launch --tap-port 8080
# 在另一个终端:
GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8080 GOOGLE_VERTEX_BASE_URL=http://127.0.0.1:8080 gemini
```
### 常用组合
```bash
# 追踪 Claude Code:实时查看器 + 自动批准
claude-tap --tap-live -- --dangerously-skip-permissions
# 追踪 Codex(OAuth):实时查看器 + 全自动
claude-tap --tap-client codex --tap-target https://chatgpt.com/backend-api/codex --tap-live -- --full-auto
# 自定义 trace 输出目录
# 自定义 trace 输出目录,或限制保留数量
claude-tap --tap-output-dir ./my-traces
# 仅保留最近 10 次 trace
claude-tap --tap-max-traces 10
# 只启动代理,给自定义场景使用
claude-tap --tap-no-launch --tap-port 8080
# 退出后不自动打开生成的查看器
claude-tap --tap-no-open
```
纯代理模式下,可以在另一个终端启动客户端,并把它的 base URL 或代理配置指向本地代理。具体接法见 [客户端支持矩阵](docs/support-matrix.md)。
### CLI 选项
除以下 `--tap-*` 参数外,所有参数均透传给所选客户端:
@@ -363,8 +343,7 @@ claude-tap --tap-max-traces 10
## 查看器功能
<details>
<summary>Trace 查看器能力</summary>
### Trace 查看器能力
查看器是一个自包含的 HTML 文件(零外部依赖):
@@ -379,8 +358,6 @@ claude-tap --tap-max-traces 10
- **复制助手** — 一键复制请求 JSON 或 cURL 命令
- **多语言** — English, 简体中文, 日本語, 한국어, Français, العربية, Deutsch, Русский
</details>
## 架构
![架构图](docs/architecture.png)
@@ -405,7 +382,13 @@ claude-tap --tap-max-traces 10
### Star 历史
[![Star History Chart](https://api.star-history.com/svg?repos=liaohch3/claude-tap&type=Date)](https://www.star-history.com/#liaohch3/claude-tap&Date)
<a href="https://www.star-history.com/?repos=liaohch3%2Fclaude-tap&type=date&legend=bottom-right">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&theme=dark&legend=top-left" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&legend=top-left" />
<img alt="Star History Chart" src="https://api.star-history.com/chart?repos=liaohch3/claude-tap&type=date&legend=top-left" />
</picture>
</a>
### 贡献者
@@ -423,6 +406,11 @@ claude-tap --tap-max-traces 10
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oxkrypton"><img src="https://avatars.githubusercontent.com/u/154910746?s=100" width="100px;" alt="0xkrypton"/><br /><sub><b>0xkrypton</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=oxkrypton" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/googs1025"><img src="https://avatars.githubusercontent.com/u/86391540?s=100" width="100px;" alt="CYJiang"/><br /><sub><b>CYJiang</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=googs1025" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/TITOCHAN2023"><img src="https://avatars.githubusercontent.com/u/138754853?s=100" width="100px;" alt="陈展鹏"/><br /><sub><b>陈展鹏</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=TITOCHAN2023" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/devtalker"><img src="https://avatars.githubusercontent.com/u/23204195?s=100" width="100px;" alt="devtalker"/><br /><sub><b>devtalker</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=devtalker" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dingyaguang117"><img src="https://avatars.githubusercontent.com/u/1930778?s=100" width="100px;" alt="Yaguang Ding"/><br /><sub><b>Yaguang Ding</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=dingyaguang117" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sephymartin"><img src="https://avatars.githubusercontent.com/u/299891?s=100" width="100px;" alt="Sephy"/><br /><sub><b>Sephy</b></sub></a><br /><a href="https://github.com/liaohch3/claude-tap/commits?author=sephymartin" title="Code">💻</a></td>
</tr>
</tbody>
</table>
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 KiB

After

Width:  |  Height:  |  Size: 282 KiB

+9 -18
View File
@@ -2,7 +2,7 @@
This guide shows how to run Claude Code through DeepSeek's Anthropic-compatible API while capturing the traffic with `claude-tap`.
DeepSeek's official Claude Code guide points Claude Code at `https://api.deepseek.com/anthropic` and uses `deepseek-v4-pro[1m]` for the main Claude Code model. When you capture the session with `claude-tap`, keep the DeepSeek auth and model environment variables, but let `claude-tap` set Claude Code's `ANTHROPIC_BASE_URL` to the local proxy and pass the real DeepSeek endpoint as `--tap-target`.
DeepSeek's official Claude Code guide points Claude Code at `https://api.deepseek.com/anthropic` and uses `deepseek-v4-pro[1m]` for the main Claude Code model. When you capture the session with `claude-tap`, keep that same Claude Code environment. `claude-tap` reads the DeepSeek upstream from `ANTHROPIC_BASE_URL`, then launches Claude Code against the local proxy.
Simplified Chinese version: [Claude Code 搭配 DeepSeek API](deepseek-claude-code.zh.md).
@@ -20,33 +20,23 @@ export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_EFFORT_LEVEL=max
```
For direct Claude Code usage without `claude-tap`, also set the DeepSeek base URL from the official guide:
```bash
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
```
For `claude-tap` capture, do not rely on a pre-existing `ANTHROPIC_BASE_URL`; reverse proxy mode overwrites it for the launched Claude Code process.
`claude-tap` uses the current `ANTHROPIC_BASE_URL` as the real upstream target before it overwrites the launched Claude Code process with the local proxy URL. Use `--tap-target` only when you want to override that detected upstream.
## Capture With claude-tap
Run `claude-tap` with an explicit DeepSeek Anthropic upstream:
Run `claude-tap` normally:
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- --permission-mode bypassPermissions
claude-tap -- --permission-mode bypassPermissions
```
For a one-off non-interactive smoke test:
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- \
--permission-mode bypassPermissions \
-p 'Use Bash to run pwd, then reply with DEEPSEEK_CLAUDE_TAP_OK.'
@@ -64,9 +54,7 @@ If the upstream request fails with `SSLCertVerificationError` while direct `curl
```bash
# macOS/Homebrew examples often use /etc/ssl/cert.pem.
SSL_CERT_FILE=/etc/ssl/cert.pem claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic
SSL_CERT_FILE=/etc/ssl/cert.pem claude-tap
```
On Debian/Ubuntu, the system CA bundle is usually `/etc/ssl/certs/ca-certificates.crt`.
@@ -77,6 +65,8 @@ Claude Code 2.1.128 and 2.1.131 can send `metadata.user_id` as a JSON string. De
DeepSeek may return `404` for Claude Code's `/v1/models?limit=1000` preflight. Claude Code continues as long as `/v1/messages` succeeds. In the validation run below, `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` was set to reduce unrelated startup traffic.
`claude-tap` redacts common authentication headers such as `Authorization` and `x-api-key`, but it does not globally scrub prompts, request bodies, or tool output. Do not put secrets in prompts, script output, or files that the agent may read into the trace.
## Verified Run
Validated on 2026-05-06 with:
@@ -85,7 +75,8 @@ Validated on 2026-05-06 with:
- Claude Code `2.1.131`
- `deepseek-v4-pro[1m]` for main Claude Code turns
- `deepseek-v4-flash` for Claude Code title/auxiliary turns
- `claude-tap --tap-proxy-mode reverse --tap-target https://api.deepseek.com/anthropic`
- `ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic`
- `claude-tap`
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`
The serial tmux run produced:
+7 -18
View File
@@ -2,7 +2,7 @@
本文说明如何让 Claude Code 通过 DeepSeek 的 Anthropic 兼容 API 运行,并用 `claude-tap` 捕获这条流量。
DeepSeek 官方 Claude Code 集成会把 Claude Code 指向 `https://api.deepseek.com/anthropic`,主模型使用 `deepseek-v4-pro[1m]`。如果同时使用 `claude-tap`需要保留 DeepSeek 的认证和模型环境变量,但不要让 Claude Code 直接连接 DeepSeek;应由 `claude-tap` 把 Claude Code 指向本地代理,并通过 `--tap-target` 指定真实 DeepSeek 上游
DeepSeek 官方 Claude Code 集成会把 Claude Code 指向 `https://api.deepseek.com/anthropic`,主模型使用 `deepseek-v4-pro[1m]`。如果同时使用 `claude-tap`继续保留这套 Claude Code 环境即可。`claude-tap` 会先从 `ANTHROPIC_BASE_URL` 读取 DeepSeek 上游,再把 Claude Code 指向本地代理
English version: [Claude Code with DeepSeek API](deepseek-claude-code.md).
@@ -20,33 +20,23 @@ export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_EFFORT_LEVEL=max
```
如果不使用 `claude-tap`,直接运行 Claude Code,还需要设置 DeepSeek 官方文档中的 base URL
```bash
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
```
如果要用 `claude-tap` 捕获流量,不要依赖已经存在的 `ANTHROPIC_BASE_URL`reverse proxy 模式会为被启动的 Claude Code 进程改写它
`claude-tap` 会在改写被启动的 Claude Code 进程之前,把当前 `ANTHROPIC_BASE_URL` 作为真实上游目标。只有想手动覆盖时才需要传 `--tap-target`
## 使用 claude-tap 捕获
用显式 DeepSeek Anthropic 上游启动
正常启动 `claude-tap`
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- --permission-mode bypassPermissions
claude-tap -- --permission-mode bypassPermissions
```
一次性非交互 smoke test
```bash
claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic \
-- \
--permission-mode bypassPermissions \
-p 'Use Bash to run pwd, then reply with DEEPSEEK_CLAUDE_TAP_OK.'
@@ -70,9 +60,7 @@ claude-tap export .traces/2026-05-06/trace_153111.jsonl -o trace.html
```bash
# macOS/Homebrew 常见路径是 /etc/ssl/cert.pem。
SSL_CERT_FILE=/etc/ssl/cert.pem claude-tap \
--tap-proxy-mode reverse \
--tap-target https://api.deepseek.com/anthropic
SSL_CERT_FILE=/etc/ssl/cert.pem claude-tap
```
Debian/Ubuntu 的系统 CA bundle 通常是 `/etc/ssl/certs/ca-certificates.crt`
@@ -93,7 +81,8 @@ DeepSeek 对 Claude Code 启动时的 `/v1/models?limit=1000` 预检可能返回
- Claude Code `2.1.131`
- Claude Code 主对话模型:`deepseek-v4-pro[1m]`
- Claude Code 标题和辅助调用模型:`deepseek-v4-flash`
- `claude-tap --tap-proxy-mode reverse --tap-target https://api.deepseek.com/anthropic`
- `ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic`
- `claude-tap`
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`
真实 tmux 串行运行结果:
+2 -1
View File
@@ -1,6 +1,6 @@
---
owner: claude-tap-maintainers
last_reviewed: 2026-05-14
last_reviewed: 2026-05-17
source_of_truth: AGENTS.md
---
@@ -16,6 +16,7 @@ Simplified Chinese version: [支持矩阵](support-matrix.zh.md).
| Client | Auth Mode | Target | strip_path_prefix | Transport | Status |
|--------|-----------|--------|-------------------|-----------|--------|
| Claude Code | API Key | `https://api.anthropic.com` | none | HTTP/SSE | Verified |
| Claude Code | Claude-compatible gateway (`ANTHROPIC_BASE_URL` env or Claude settings) | Custom Anthropic-compatible upstream | none | HTTP/SSE | Unit-tested; DeepSeek real E2E verified |
| Codex CLI | API Key (`OPENAI_API_KEY`) | `https://api.openai.com` | none | HTTP/SSE | Verified |
| Codex CLI | API Key (`OPENAI_API_KEY`) | `https://api.openai.com` | none | WebSocket | Verified |
| Codex CLI | OAuth (`codex login`) | `https://chatgpt.com/backend-api/codex` | `/v1` | HTTP/SSE | Verified |
+2 -1
View File
@@ -1,6 +1,6 @@
---
owner: claude-tap-maintainers
last_reviewed: 2026-05-14
last_reviewed: 2026-05-17
source_of_truth: AGENTS.md
---
@@ -16,6 +16,7 @@ English version: [Support Matrix](support-matrix.md).
| 客户端 | 认证方式 | 上游目标 | strip_path_prefix | 传输 | 状态 |
|--------|----------|----------|-------------------|------|------|
| Claude Code | API Key | `https://api.anthropic.com` | 无 | HTTP/SSE | 已验证 |
| Claude Code | Claude 兼容网关(`ANTHROPIC_BASE_URL` 环境变量或 Claude settings | 自定义 Anthropic 兼容上游 | 无 | HTTP/SSE | 单测覆盖;DeepSeek 真实 E2E 已验证 |
| Codex CLI | API Key (`OPENAI_API_KEY`) | `https://api.openai.com` | 无 | HTTP/SSE | 已验证 |
| Codex CLI | API Key (`OPENAI_API_KEY`) | `https://api.openai.com` | 无 | WebSocket | 已验证 |
| Codex CLI | OAuth (`codex login`) | `https://chatgpt.com/backend-api/codex` | `/v1` | HTTP/SSE | 已验证 |
Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 KiB

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 KiB

After

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 KiB

After

Width:  |  Height:  |  Size: 391 KiB