DEV Community

Patric
Patric

Posted on

TRACE Part 2: What Happens Before You Even Write a Single Line of Code

TRACE Part 2: What Happens Before You Even Write a Single Line of Code

Continued from: I built a token cost tracker for Claude Code – and it changed the way I think about AI development

An innocent start

Imagine you open a new project, launch Claude Code, and type:

“Hey, I'm just starting a new project. I want to set up a REST API using Express and TypeScript. Can you help me with that?”
Harmless. A normal start. You expect a short answer, maybe a directory structure, a few commands.
What you don’t see: Before Claude even says a word, the model has already consumed thousands of tokens. Not from your question. Not from the answer. But simply from the initial startup.

The numbers no one talks about

I ran the same initial prompt on two different models and compared the results.
Claude Sonnet 4.6:

Category Tokens
System Prompt 6,100
System Tools 8,100
MCP Tools 141
Memory Files 905
Skills 721
Messages 2,300
Total ~18,100

Claude Opus 4.7:

Category Tokens
System Prompt 8,400
System Tools 11,500
MCP Tools 251
Memory Files 1,200
Skills 721
Messages 3,600
Total ~25,700

+42% more tokens – for the exact same prompt, on a fresh project without a single line of code.
This is not a mistake. This is the new tokenizer in Opus 4.7.

What a Tokenizer Difference Means in Practice

Anthropic has introduced a new tokenizer with Claude Opus 4.7. The same text is split into more token units than with older models. That sounds technically abstract—but the effects are concrete:
Every single turn in a session carries this base load.
For Turn 1, it’s 18k vs. 25k tokens. By Turn 50, the entire conversation history up to that point is loaded as input—and the tokenizer difference multiplies with every subsequent turn.
A 100-turn session on Opus 4.7 costs more not just because Opus is more expensive per token. It costs more because it structurally generates more tokens—even if you do the same thing as on Sonnet 4.6.

Why /context and /cost alone aren’t enough

Claude Code has built-in visibility tools:

  • /context shows the current context window usage by category
  • /cost shows the current session’s consumption so far Both are useful. But both are pull mechanisms—you have to actively remember to call them. You already have to suspect that something is wrong. What happens in reality? You’re working. You’re writing code. You’re in the flow. You don’t call /cost. TRACE is a push mechanism. It comes to you. During the live session, TRACE displays in real time:
  • Current token count and cost
  • Session health – green, yellow, or red
  • Context window utilization as a visual bar
  • A notification when you cross the warning threshold – before it gets expensive And new since the first version: a Cost Efficiency Section that shows you what the same session would have cost on the baseline model.

The Daily Tokenizer Check

TRACE runs an automatic check early every morning: It sends a fixed reference text to both models—the current one and the baseline model—and calculates the ratio.
The result for Sonnet 4.6 vs. Opus 4.7:

{
  "current_model": "claude-sonnet-4-6",
  "baseline_model": "claude-opus-4-7",
  "current_tokens": 407,
  "baseline_tokens": 521,
  "ratio": 0.7812
}
Enter fullscreen mode Exit fullscreen mode

Sonnet 4.6 uses 22% fewer tokens than Opus 4.7 for the same text. The dashboard shows you this difference—not as an abstract number, but as a concrete cost savings for your last week.

What’s been added since the first article

TRACE has evolved since the first article:

  • Activity Section with GitHub-style heatmap – streaks, active days, average cost per session
  • Cost Efficiency Section – Comparison of current model vs. baseline, potential savings per week
  • Configurable monthly budget – Adjustable directly in the dashboard
  • Tokenizer Ratio Check – Daily automatic comparison via Anthropic count_tokens API
  • VS Code Simple Browser Integration – Dashboard directly in VS Code
  • Unified Installerbash install.sh automatically detects whether it’s a first-time installation, adding a project, or an update

An Insight into Visibility

The difference between Sonnet 4.6 and Opus 4.7 isn’t just a price difference. It’s a structural difference in how the model processes text. This difference is invisible—until you start measuring.
That is the real message of TRACE: Not “here are your costs,” but “here’s what happened while you were working—and you wouldn’t see it otherwise.”
/context and /cost show you the moment. TRACE shows you the progression.

TRACE is open source under the MIT license: github.com/MyPatric69/trace
If you find it useful: a star helps. If you have questions or find a bug: an issue helps more.

Top comments (0)