Skip to content

Conversation

@Richard-Weiss
Copy link

Adds support for tracing Claude when installed as a native binary (Bun-compiled) instead of Node.js. Uses a reverse proxy approach since the --require interceptor only works with Node.

  • Detect native binaries via magic bytes, use HTTP reverse proxy for interception
  • Add optional --include-sensitive-headers that logs bearer token and other credentials
  • Cross-platform support (Windows/macOS/Linux) (Only Ubuntu tested so far)

I only tested it on Ubuntu Server so would be nice if someone on Mac and Windows were to test it before any possible merge.
Should resolve #37 and #48.

Richard-Weiss-claude and others added 2 commits January 23, 2026 20:07
- Detect native binaries (ELF/Mach-O/PE) via magic bytes
- Use HTTP reverse proxy with ANTHROPIC_BASE_URL for compiled Claude
- Add optional --include-sensitive-headers flag to disable header redaction

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Use 'where' instead of 'which' on Windows
- Handle 'where' returning multiple lines
- Skip bash wrapper detection on Windows
- Add Windows paths (.local/bin/claude.exe, %APPDATA%/npm/claude.cmd)
- Add missing paths (~/.claude/bin/claude, /opt/homebrew/bin/claude)

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Richard-Weiss
Copy link
Author

I tested it on Win 10. Got some issues because of the Claude Code NPM dependency, so kicked that out. After that having to run build in Git Bash because of cp commands in the build script.
Auto open of the HTML also has issues because of start.
image

But, the reverse proxy approach worked there too, so seems "good enough" to me for the scope of this PR.
image

@gmarcus
Copy link

gmarcus commented Feb 7, 2026

Hi @Richard-Weiss Thanks for putting up this PR.

I just tried on a Mac with Claude Code v2.1.34 (native installer).

~/Development/ai/test-intent-by-augment $ claude-trace claude
Claude Trace
Starting Claude with traffic logging

Using Claude binary: /Users/glenn/.local/share/claude/versions/2.1.34
Detected native binary
Using reverse proxy mode for native binary

Logs will be written to:
  JSONL: /Users/glenn/Development/ai/test-intent-by-augment/.claude-trace/log-2026-02-07-15-57-04.jsonl
  HTML:  /Users/glenn/Development/ai/test-intent-by-augment/.claude-trace/log-2026-02-07-15-57-04.html
Reverse proxy started at http://127.0.0.1:50937

^[[I
╭─── Claude Code v2.1.34 ──────────────────────────────────────────────────────────────────────────────────╮
│                                             │ Tips for getting started                                   │
│                Welcome back!                │ Run /init to create a CLAUDE.md file with instructions fo… │
│                                             │ ────────────────────────────────────────────────────────── │
│                                             │ Recent activity                                            │
│                   ▐▛███▜▌                   │ No recent activity                                         │
│                  ▝▜█████▛▘                  │                                                            │
│                    ▘▘ ▝▝                    │                                                            │
│            Opus 4.6 · Claude API            │                                                            │
│   ~/Development/ai/test-intent-by-augment   │                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

❯ hello                                                                                                     
                                   
⏺ Hello! How can I help you today?                                                                          
                                                                                                          
❯ /exit                                                                                                     
  ⎿  Catch you later!                                                                                     
                                                                                                            
────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯                                                                                                           
────────────────────────────────────────────────────────────────────────────────────────────────────────────
  Opus 4.6 | [=---------] 10.0% | 0.42K in / 0.09K out | main | test-intent-by-augment  ◯ IDE disconnected  
                                                                                                            
Resume this session with:
claude --resume 1704fd37-b09d-4491-9be1-98e07457e57e
Logged 0 request/response pairs

Claude session completed
~/Development/ai/test-intent-by-augment $ 

Note that ^[[I just under the Reverse proxy started...

When session finished, reported Logged 0 request/response pairs

Is there a way to run with debugging output so I can provide you more info?

@Richard-Weiss
Copy link
Author

@gmarcus Seems to be intentional with this line:

// Check message count filter (only log if > 2 messages)
if (!this.config.includeAllRequests && parsedRequestBody?.messages) {
	if (parsedRequestBody.messages.length <= 2) {
		return;
	}
}

I don't have strong opinions when it comes to the default here, just something Claude did.
You can try passing the --include-all-requests flag or sending more messages. I might actually remove it since often you just want the system message parts, etc., and you send just a single message for that.

Can you try it with that first and if it works I can adjust that afterward?

@gmarcus
Copy link

gmarcus commented Feb 7, 2026

@Richard-Weiss

I tried both ways

  • sent two messages - WORKS
  • --include-all-requests - WORKS
~/Development/ai/test-intent-by-augment $ claude-trace claude
Claude Trace
Starting Claude with traffic logging

Using Claude binary: /Users/glenn/.local/share/claude/versions/2.1.34
Detected native binary
Using reverse proxy mode for native binary

Logs will be written to:
  JSONL: /Users/glenn/Development/ai/test-intent-by-augment/.claude-trace/log-2026-02-07-16-12-42.jsonl
  HTML:  /Users/glenn/Development/ai/test-intent-by-augment/.claude-trace/log-2026-02-07-16-12-42.html
Reverse proxy started at http://127.0.0.1:52652

^[[I
╭─── Claude Code v2.1.34 ──────────────────────────────────────────────────────────────────────────────────╮
│                                             │ Tips for getting started                                   │
│                Welcome back!                │ Run /init to create a CLAUDE.md file with instructions fo… │
│                                             │ ────────────────────────────────────────────────────────── │
│                                             │ Recent activity                                            │
│                   ▐▛███▜▌                   │ No recent activity                                         │
│                  ▝▜█████▛▘                  │                                                            │
│                    ▘▘ ▝▝                    │                                                            │
│            Opus 4.6 · Claude API            │                                                            │
│   ~/Development/ai/test-intent-by-augment   │                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

❯ hello                                                                                                     
                       
⏺ Hello! How can I help you today?                                                                          
                                                                                                          
❯ another hello                                                                                             
                                                                                                          
⏺ Hey there! What can I do for you?                                                                         
                                                                                                          
❯ /exit                                                                                                     
  ⎿  See ya!                                                                                                
                                                                                                            
────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯                                                                                                           
────────────────────────────────────────────────────────────────────────────────────────────────────────────
  Opus 4.6 | [=---------] 10.0% | 0.71K in / 0.16K out | main | test-intent-by-augment  ◯ IDE disconnected  
                                                                                                            
Resume this session with:
claude --resume 7def9823-5b10-47ff-a2aa-be39fd032b01
Logged 2 request/response pairs
Opening .claude-trace/log-2026-02-07-16-12-42.html in browser

Claude session completed
~/Development/ai/test-intent-by-augment $ 

What do you think is causing those bad chars ^[[I on launch?

@Richard-Weiss
Copy link
Author

@gmarcus Nice, thanks for testing. I've been wondering about that ^[[I thing too. I see it when I launch Claude Code over a bash function sometimes too, not even with claude-trace. I'll look into it and get back to you.
I'll change that default first though.

@Richard-Weiss
Copy link
Author

Richard-Weiss commented Feb 7, 2026

@gmarcus Claude said this, sounds reasonable:
image

There is a CC issue here for example:
anthropics/claude-code#18363

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-trace fails on mac os newest version

3 participants