惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
D
DataBreaches.Net
U
Unit 42
P
Proofpoint News Feed
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
博客园 - Franky
博客园_首页
IT之家
IT之家
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
cctrace: a local profiler for AI coding agents (Claude Co...
AgentZ · 2026-06-02 · via DEV Community

I once asked Claude Code to do a moderately complex refactor. Seven or eight minutes in, the terminal was still scrolling.

I couldn't tell where it was stuck. No Bash error, the model was still producing output — it was just slow. Was it re-reading the same file dozens of times? Waiting on IO in some command? Stuck in a loop? Terminal output is all past tense: it scrolls by and it's gone. When the task finally finished, I still couldn't say where the time went.

Then I tried cctrace. Same task, but afterwards I opened the waterfall timeline. One glance: a single Bash tool call had hung for almost two minutes, with batches of fast Read calls before and after it, and a dozen tool results in between. The problem went from "no idea" to "oh, it's right there."

cctrace does one simple thing: it turns a whole agent session into a waterfall timeline you can actually read.

cctrace waterfall timeline

1. The stuff you can't see

When you run a non-trivial task with Claude Code or Codex, the terminal keeps scrolling. It looks busy, but you can't really tell:

  • Which tool call took the longest — was Read chewing through a pile of files, or was bash waiting on a command?
  • When was the model thinking, and when was it actually stuck?
  • When did it fan out a subagent, and how many levels deep?
  • A conversation turn ran for five minutes — where did the wall-clock time actually go?

The terminal can't answer any of this. Claude Code has no built-in profiler. The transcript files have the data, but it's line-by-line JSON you have to correlate by hand. ccglass records are a different format again. Process-level events are yet another thing. Three sources, scattered.

2. How cctrace solves it

The approach: wrap a layer around the agent before you launch it.

cctrace claude -- claude

After that one command, cctrace watches three sources at the same time:

  1. the agent process itself (process layer)
  2. writes to the transcript file (transcript layer)
  3. ccglass trace records (ccglass layer)

All three feed into a single Event / Session model. A heuristic pass correlates related events across sources, tagging each link with one of four confidence levels (exact / likely / possible / unknown).

Then it starts a local web server (default 127.0.0.1:43179), prints the URL, and you open the waterfall timeline in your browser.

No background daemon, no telemetry — data is only written to JSONL files on local disk.

3. What you actually see

The waterfall timeline

Events are grouped by request turn on the left; every event (user input, model reply, tool call, tool result) sits on one shared time axis. There's a density overview across the whole session up top, so you can jump to the busiest stretch. Drag horizontally to zoom, scroll vertically for the rest.

Single-event detail

cctrace event detail

Click any tool operation to see:

  • arguments and output
  • duration (start / end timestamp)
  • correlation IDs (which events it's linked to, with the four-level confidence tag)
  • the raw event JSON

"Why was this tool call so slow?" or "which later event consumed this call's result?" — click in and look.

Replay

Every session is a JSONL file on disk. After a run, any time:

cctrace view <session-id>

reopens it — no need to re-run the agent. Since it's JSONL, you can also just grep, jq, or pipe it into something else.

4. Using it

Install

With Go 1.22+:

go install github.com/androidZzT/cctrace/cmd/cctrace@latest

macOS / Linux only.

Record a Claude Code session

cctrace claude -- claude

The CLI prints the local web UI URL; open it in your browser.

Record a Codex session

cctrace codex -- codex

Same recording pipeline — switching agents is just changing the first argument.

Replay a saved session

cctrace view <session-id>

5. A few design trade-offs

The code is split by responsibility:

cmd/cctrace                 CLI entry point
└── internal/
    ├── app                 wires up CLI parsing, collection, persistence, server
    ├── trace               shared Event / Session model
    ├── store               writes sessions and events to JSONL in a session dir
    ├── collectors          process / transcript / ccglass → trace events
    ├── correlate           heuristic event correlation + four-level confidence
    └── server              local web UI + event JSON API

Why Go?
A single binary to ship — no Python environment, no Node. go install and you're done, no package-manager conflicts. For a CLI tool whose whole job is wrapping other processes, that constraint is very practical.

Why JSONL instead of SQLite?
JSONL is grep/jq-able directly, diffing two sessions is straightforward, and it pipes nicely into other tools. You don't need a dedicated viewer to read your own data.

How is correlation confidence computed?
It's heuristic — time-proximity plus event-type. For API request/response events, it looks for the nearest candidate parent within a time window (candidate types are limited to ToolCall / AgentTurn / Skill / Subagent), marks it likely if found, unknown if not. Confidence is a four-level enum (exact / likely / possible / unknown), not a numeric score. Edge cases can slip through, but a miss shows up as unknown rather than a false likely.

Does collection slow the agent down?
cctrace is a thin wrapper; collection is asynchronous and doesn't do blocking work on the agent's critical path.

6. Wrapping up

cctrace isn't trying to be a big all-in-one debugging platform. It does one thing: make the Claude Code / Codex session you're already running observable. One Go binary, MIT licensed.

It's early days — the correlation, the UI, and the set of supported event types all have room to grow. If you use Claude Code or Codex, I'd love an issue telling me what you most want to see clearly, or a PR to build it together. A star helps too if you find it useful.

GitHub: https://github.com/androidZzT/cctrace

Acknowledgement: cctrace reads traces exported by ccglass (by @jianshuo, MIT) as one of its event sources, and the cctrace <agent> -- <cmd> ergonomics are inspired by its wrap-and-inspect approach. If you want to see exactly what your agent sends to the model, ccglass is well worth a look.