A live forecast of the context window, drawn above the prompt: a weather icon, the fill percentage, and a chart of the last turns.

A Claude Code mod that draws a live forecast of your context window in the band above the prompt. We're sharing it as the smallest of the three mods here: one hooks module that reads real usage figures and draws one line of UI.
☂ Showers 67% of context 134.4k / 200k last turns ▁▂█ ▲ +98.3k last turn
After each turn, the band shows:
| Used | Forecast |
|---|---|
| under 25% | ☀ Clear |
| 25–49% | ☁ Cloudy |
| 50–74% | ☂ Showers |
| 75–89% | ☇ Storm |
| 90% up | ↯ Compact soon |
The numbers are real, not estimated. After each main-loop turn, the mod calls $.session.usage() and reads context:
tokens: the input tokens the last response was answered over (uncached, cache-written and cache-read together),window: the context window of the session's model, andpercent: tokens over window.These are the same figures the status line shows (total_input_tokens, context_window_size, used_percentage). The call is free, because the mod doesn't ask for a breakdown, so it sends no token-count request.
| Hook | What it does |
|---|---|
session.start | Takes a first reading, so the band shows before the first turn. |
turn.complete | Takes a reading after each main-loop turn. Subagent turns are skipped. |
ui.render with {component: "AbovePrompt"} | Draws the band as one line. |
After the first turn, 18% full:

After reading four large files, 67% full:

After one more file, 81% full. Claude Code's own notice reads 90%, because it counts toward the auto-compact point (see the limitations):

Token Weather. A live forecast of your context window. A band above the prompt draws a small chart of context use for each turn, as weather icons. It's clear when the window is mostly empty, and stormy when it's nearly full. It uses
ui.renderon theAbovePromptcomponent, with theSvgelement, and it updates onturn.complete. I haven't confirmed which event or call gives the token counts, so that needs a check. Developers would share it because it looks good in a screenshot, and it answers "why did Claude forget that?" at a glance. The status line only shows text. A weekend build.
The build prompt, which picked this idea and two others by number:
implement 1,2,7. give me zips for them. test them in claude code and get me screenshots of what they look like when used.
$.session.usage(), which returns the same figures as the status line, so the mod shows real numbers rather than an estimate.Svg element. The terminal can't draw Svg, so the chart is a row of block characters.Requirements:
claude plugin validate passes on 2.1.285.AbovePrompt is drawn on the terminal surface only.No environment variables or configuration.
AbovePrompt competes for the same band.| Name | Version | License (SPDX) | Source |
|---|---|---|---|
| None |
hooks/token-weather.mjs 120 lines1// Token Weather: a live forecast of the context window, above the prompt.
2//
3// turn.complete: after each main-loop turn, read the context window's fill
4// from $.session.usage() (the same figures the status line shows) and keep
5// the last HISTORY readings.
6// session.start: take a first reading, so the band shows before any turn.
7// ui.render (AbovePrompt): one line: icon, forecast word, percent, tokens
8// used of the window, and a block-character chart of the recent turns.
9//
10// The host reads on(...) and $.noun.method(...) from source, so they are
11// spelled literally, and helpers that take $ are top-level functions.
12
13const HISTORY = 12;
14const BARS = "▁▂▃▄▅▆▇█";
15
16// Forecast bands, by percent of the window used.
17const FORECAST = [
18// Single-width text symbols, not emoji: they line up in every terminal font.
19 { upTo: 25, icon: "☀", word: "Clear", color: "yellow" },
20 { upTo: 50, icon: "☁", word: "Cloudy", color: "cyan" },
21 { upTo: 75, icon: "☂", word: "Showers", color: "blue" },
22 { upTo: 90, icon: "☇", word: "Storm", color: "magenta" },
23 { upTo: Infinity, icon: "↯", word: "Compact soon", color: "red" },
24];
25
26// Readings: { tokens, window, percent }, oldest first.
27let readings = [];
28
29export function register(on) {
30 on("session.start", async ($, e, next) => {
31 const result = await next(e);
32 readings = [];
33 await takeReading($);
34 return result;
35 });
36
37 on("turn.complete", async ($, e, next) => {
38 const result = await next(e);
39 if (e.agentId) {
40 return result;
41 }
42 await takeReading($);
43 return result;
44 });
45
46 on("ui.render", { component: "AbovePrompt" }, ($, e, next) => {
47 if (e.hasSurvey || readings.length === 0) {
48 return next(e);
49 }
50 const { Box, Text } = $.ui.resolve(e);
51 return band(Box, Text, e.bodyColumns ?? 80);
52 });
53}
54
55async function takeReading($) {
56 try {
57 const { context } = await $.session.usage();
58 if (!context || !context.window) {
59 return;
60 }
61 const tokens = context.tokens ?? 0;
62 const percent = Math.round(context.percent ?? (tokens / context.window) * 100);
63 // The session.start reading is 0 before any response; drop it once real readings arrive.
64 readings = readings.filter((r) => r.tokens > 0);
65 readings.push({ tokens, window: context.window, percent });
66 if (readings.length > HISTORY) {
67 readings = readings.slice(-HISTORY);
68 }
69 $.ui.invalidate("ui.render");
70 } catch {
71 // No reading this turn; the band keeps the last one.
72 }
73}
74
75function band(Box, Text, columns) {
76 const now = readings[readings.length - 1];
77 const f = forecastFor(now.percent);
78 const trend = trendWord();
79 const parts = [
80 Text({ color: f.color, bold: true, children: `${f.icon} ${f.word}` }),
81 Text({ children: ` ${now.percent}% of context` }),
82 Text({ dimColor: true, children: ` ${short(now.tokens)} / ${short(now.window)}` }),
83 ];
84 if (columns >= 60) {
85 parts.push(Text({ dimColor: true, children: " last turns " }));
86 parts.push(Text({ color: f.color, children: chart() }));
87 if (trend) {
88 parts.push(Text({ dimColor: true, children: ` ${trend}` }));
89 }
90 }
91 return Box({ flexDirection: "row", paddingX: 1, children: parts });
92}
93
94function forecastFor(percent) {
95 return FORECAST.find((band) => percent < band.upTo) ?? FORECAST[FORECAST.length - 1];
96}
97
98// Bars scale to the busiest reading shown, so growth shows at any fill level.
99function chart() {
100 const top = Math.max(...readings.map((r) => r.tokens), 1);
101 const bars = readings.map((r) => BARS[Math.min(BARS.length - 1, Math.floor((r.tokens / top) * (BARS.length - 1)))]);
102 return bars.join("");
103}
104
105function trendWord() {
106 if (readings.length < 2) {
107 return "";
108 }
109 const delta = readings[readings.length - 1].tokens - readings[readings.length - 2].tokens;
110 if (delta > 0) return `▲ +${short(delta)} last turn`;
111 if (delta < 0) return `▼ ${short(-delta)} last turn`;
112 return "steady";
113}
114
115function short(n) {
116 if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n % 1_000_000 === 0 ? 0 : 1)}M`;
117 if (n >= 1_000) return `${(n / 1_000).toFixed(n % 1_000 === 0 ? 0 : 1)}k`;
118 return String(n);
119}
120