Claude Code Mods: Build a Token Weather Plugin
Anthropic now ships a small, official sample called Token Weather that draws a live forecast of your Claude Code context window in the band above the prompt, and it is the fastest way to learn what the newly public “mods” system can do. In any serious AI agent framework comparison, Claude Code’s mods stand out because they run inside your coding agent with the same filesystem access it has, which is both the feature and the risk. This guide walks through what a mod is, what Token Weather actually shows, how to install it in three commands, and how to start writing your own.
The timing matters. For most of its life, extending Claude Code meant writing a hook or a custom slash command and wiring it up by hand. Mods formalize that into something shareable: a mod is just a Claude Code plugin, published as a Git repository with a marketplace file, so installing one takes a few typed commands and a reload instead of editing JSON by hand. If you already maintain configuration for your coding agent, this is the change worth a weekend afternoon.
What a Claude Code mod actually is
A mod is a plugin that packages one or more Claude Code extension points. The two that matter most here are hooks and the plugin metadata that registers them. A hook is a script Claude Code runs automatically when a specific event fires — PreToolUse, PostToolUse, SessionStart, Stop, and a handful of others. Token Weather uses a single Stop hook, which fires after every response, right before Claude Code hands control back to you.
The packaging is the part that used to be annoying. A mod lives in a directory that contains a .claude-plugin/ folder with a plugin.json manifest, one or more hooks/ scripts, and a README.md. When someone shares that directory as a GitHub repo with a .claude-plugin/marketplace.json file, the repo becomes a marketplace. Anyone can install from it with a single command, and the author can push updates the way they would any other repo. There is no central registry and no review step to speak of.
Anthropic’s phrasing is worth quoting because it doubles as a warning: “A mod is code that runs inside Claude Code on your machine, with the same access Claude Code has, and it’s written by its publisher, not Anthropic.” That means you should read a mod’s repo the same way you would read a package you were about to pip install into a production environment.
Why mods make Claude Code one of the best AI tools 2026
The practical reason mods push Claude Code toward the top of any “best AI tools 2026” list is that they collapse the distance between “I wish my agent did X” and “my agent does X.” Three things drive that.
First, there is nothing new to learn. A mod uses the exact hook system that has shipped in Claude Code for years, so the skills you already have — a little TypeScript or Python, some knowledge of the transcript format — transfer directly. Second, distribution is a Git push. Your marketplace is just a repository, so shipping a fix to your whole team is git push plus a /reload-plugins on their side. Third, mods compose. Token Weather is intentionally the smallest of the three official samples, but the same pattern scales to full workflow plugins that run linters, gate commits, or inject project-specific instructions.
There is a comparison worth making explicit. In a VS Code extension, you write against an IDE API and publish through a marketplace with review. In a LangChain-style framework, you build against a library API and inherit its abstractions. A Claude Code mod sits closer to the shell: it is a thin script that observes events and can read the same files Claude Code reads. That is a lower abstraction, which is exactly why it feels fast for small, personal automation.
What Token Weather actually shows
Token Weather answers the question every long coding session eventually raises: how full is my context window, and how fast is it filling up? It renders one line of UI above the prompt after each turn, reading real usage figures rather than estimates.
The display looks roughly like this, with the values pulled from the live session:
☂ Showers 67% of context 134.4k / 200k ▁▂█ ▲ +98.3k last turn
The percentage is the share of the full window that is in use. The raw numbers show tokens used against the configured window size. The small sparkline plots how much each recent turn added, and the trailing figure shows the delta from the previous turn — the +98.3k example is a turn that read in a large file or a batch of context. The weather metaphor is a thin layer of polish over a genuinely useful signal: a rapid upward trend is your cue to /compact, delegate to a subagent, or clear stale files before Claude Code decides for you.
One detail is easy to misread. Claude Code’s own “context used” notice counts against its auto-compact threshold, which is lower than the full window. Token Weather reports against the full window, so the two numbers will not match. The mod’s README calls this out, and it is the kind of small discrepancy that matters when you are trying to predict when compaction will kick in.
How to install Token Weather in three commands
The official sample lives in the anthropics/claude-code-playground repository under claude-code/mods/token-weather. To install it, you treat that repo as a marketplace. Inside a Claude Code session, run:
/plugin marketplace add anthropics/claude-code-playground
/plugin install token-weather@anthropics
/reload-plugins
The first command registers the repo as a marketplace. The second installs the specific mod from that marketplace using the name@marketplace convention. The third loads it. If the mod does not appear after reloading, restart Claude Code — the README and the official blog both note that a restart clears occasional plugin-loading quirks.
There are also community mods that solve the same problem differently. SomSamantray/Claude-Code-Token-Limit renders a status box after each response with context percentage, estimated turns remaining, and daily and weekly token budgets pulled from Claude Code’s own transcript log. It adds configurable budget limits and a badge for Anthropic’s off-peak promotions. It is a reasonable alternative if you want a token-budget view rather than a trend view, and it is MIT-licensed.
How the hook reads the numbers
The interesting implementation detail is that Token Weather does not call any external API and does not estimate anything. The Stop hook reads the session transcript that Claude Code writes locally as JSONL, extracts the real token counts from the last response, and prints the forecast line to stderr, where the UI picks it up.
This is a useful pattern to copy. A Stop hook that emits to stderr appears in the interface; exit code 2 surfaces stderr as an error message, and plain stdout on a successful exit is sent to the debug log rather than the transcript. If you have ever written a Claude Code hook and wondered why your print() output vanished, this is why: stdout goes to the debug log, and only stderr (or exit code 2) reaches the user-visible surface.
For the forecast trend line, the mod keeps a short rolling buffer of the last few turns’ usage and draws the sparkline from that. You do not need GPU access or a vector database; the entire thing is a script, a manifest, and a few screenshots in a README.
Building your own mod from the skeleton
The fastest way to write your own mod is to copy the Token Weather directory and swap the hook logic. The minimal structure looks like this:
my-mod/
├── .claude-plugin/
│ └── plugin.json
├── hooks/
│ └── stop.py
└── README.md
The plugin.json manifest declares the hook and the command it runs. A minimal manifest looks like this:
{
"name": "token-weather",
"version": "1.0.0",
"hooks": [
{
"event": "Stop",
"matcher": "*",
"hooks": [
{ "type": "command", "command": "python3 hooks/stop.py" }
]
}
]
}
A hook entry names the event (Stop), a matcher pattern, and a list of hooks with a type of command and a command string pointing at your script. Keep the script’s working directory in mind: Claude Code runs hook commands from a working directory you can configure, and your script should read file paths through the environment or arguments rather than assuming a location. For a Stop hook that prints a one-line summary, the script itself can be under twenty lines — read the last line of the transcript, parse the token count, print the formatted line to stderr, and exit zero.
Start with something that prints a single line on Stop, verify it surfaces in the band above the prompt, then layer in the real logic. The debugging loop is fast because reloading a plugin is one command and there is no build step.
Who should use this
Use mods like Token Weather if you run long Claude Code sessions on large codebases and have been surprised by compaction at a bad moment. The forecast line gives you the early signal to compact on your own terms. You should also explore mods if your team has repeated, fiddly workflow steps — a lint pass, a commit message convention, a mandatory checklist — that you currently enforce by hand. Those are exactly the hooks-and-manifest pattern mods were built for.
Who should NOT use this
Skip mods if you treat Claude Code as a turnkey tool and do not want to audit third-party code that runs with your agent’s filesystem access. Also skip them if your sessions are short enough that context pressure never becomes a real constraint; a context forecast is noise when you are never close to the limit. And if your workflow already leans on a heavier orchestration layer that manages context, compaction, and subagents for you, a one-line hook may duplicate what that layer does.
Limitations and caveats
The biggest caveat is security. Mods are arbitrary code written by their publisher, and they inherit Claude Code’s access to your machine. Anthropic’s own guidance is to read the repo before installing, and there is no mandatory review process to rely on. The second caveat is that Token Weather reports against the full window, not the auto-compact threshold, so the number will differ from Claude Code’s built-in notice — a source of confusion until you internalize it. Third, mods are still young. The official playground ships three small samples, and the community ecosystem is sparse compared to VS Code extensions, so you should expect to write more of what you need yourself. Finally, the forecast is a trailing indicator: it tells you how fast context filled up, not how fast the next turn will fill it, so treat it as a trend signal rather than a precise predictor.