SLOPSHOPPER

Token Weather

A live forecast of the context window, drawn above the prompt.

band
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · token-weather
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM ⛅ Cloudy 49% of context 97.4k / 200k last turns ██ steady ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
⛅ Cloudy 49% of context 97.4k / 200k last turns ██ steady ⟨Claude Code's own drawing⟩
README

🧩 Claude Code Mods

Live panes, prompt bands, status line entries, toasts, and hooks for Claude Code, each shipped as a plugin.

Release CI License: MIT

🚀 Install

/plugin marketplace add tartinerlabs/claude-code-mods
/plugin install <mod> --marketplace tartinerlabs/claude-code-mods

🧰 Mods

| | Mod | Where it shows | In one line | | :-: | --- | --- | --- | | ⏸ | auto-resume | Status line, toast | Picks a turn back up once a usage limit resets | | 🏷 | auto-session-name | Session title | Names each session from its first prompt and keeps the name current as the work moves on | | ⏱ | cache-clock | Band above the prompt | Counts down to the prompt cache going cold | | 📊 | limit-watch | Band above the prompt, toasts | Shows the 5-hour and weekly usage limits and the session's cost | | 🛫 | pr-pilot | Band above the prompt, toasts | Shows the branch's PR checks and merges it with /merge | | 📝 | release-notes | Band above the prompt, toast | Drafts App Store release notes for Xcode projects when the version is bumped | | 📱 | resource-watch | Band above the prompt, toast | Shows which session is using each simulator, Claude Design project or the Xcode app, and messages the other session on a clash | | 🗜 | smart-compact | Toast | Compacts between turns, sooner at checkpoints or when the cache is cooling | | ⛅ | token-weather | Band above the prompt | Forecasts how full the context window is |


⏸ auto-resume

When a turn stops on a usage limit, waits until the limit resets and sends continue. Typing a prompt yourself or running /auto-resume cancel stops the wait.

⏸ auto-resume in 1h 12m                                    ← status line
Usage limit reset, resuming                                 ← toast

<sub>📁 plugins/auto-resume</sub>

🏷 auto-session-name

Names each session from its first prompt using Haiku and can give it a prompt bar colour, so it is easy to find with claude -r after a crash. When the first prompt is short, such as continue or look at this, it titles the session again from the last four prompts on the fourth. Every eighth prompt it checks the title against the last four prompts and renames the session only when the work has moved to a different task; small shifts keep the title. Sessions already named with -n or /rename are left alone, and a rename stops any re-title. Set the color option to red, blue, green, yellow, purple, orange, pink or cyan to colour named sessions; default leaves the colour alone.

> fix the flaky retry test in the upload worker
                                    → session titled "Fix flaky upload retry test"

<sub>📁 plugins/auto-session-name</sub>

⏱ cache-clock

Draws a countdown above the prompt to when the prompt cache goes cold, with the last request's hit rate. Once cold, it shows how much the next turn re-writes. Set the ttl option to 1h when extended caching is on.

🔥 cache 3:42 left · 96% hit                                ← green, yellow under a minute
🧊 cache cold · next turn re-writes 84.3k                   ← red

<sub>📁 plugins/cache-clock</sub>

📊 limit-watch

Draws the 5-hour and weekly usage limits above the prompt with live reset countdowns, green under 60%, yellow to 80% and red past it. Toasts once a window passes 80% and again at 95%. Any other window the API reports, such as a gateway spend limit, shows under its own name. The session's cost so far follows the limits.

🕔 5h 42% · 2h17m  📅 7d 81% · 3d4h  💰 $2.36              ← band
7d limit at 81%, resets in 3d4h                             ← toast

<sub>📁 plugins/limit-watch</sub>

🛫 pr-pilot

Draws the current branch's open pull request above the prompt with its checks and whether it can merge, refreshed each minute and after every turn. Toasts when a run of checks finishes. /merge merges it with gh and deletes the branch, but only once every check has passed and nothing blocks it. On a gh-stack layer the band shows its place in the stack, and /merge merges the whole stack with gh stack merge once every unmerged layer has passed its checks and has no unpushed commits, then switches to the trunk and deletes every layer's branch, local and remote, once all of them have merged. Set the method option to merge (default), squash or rebase. Needs the GitHub CLI, signed in.

🔀 PR #42  ⏳ 3/5 checks  waiting                            ← band
PR #42  ✗ 1 failing: SonarCloud  blocked                     ← red
PR #42  ✓ 5/5 checks  ready · /merge                         ← green
PR #42  stack 2/3  ✓ 5/5 checks  ready · /merge              ← a gh-stack layer
PR #42 checks passed, ready to /merge                        ← toast

<sub>📁 plugins/pr-pilot</sub>

📝 release-notes

In an Xcode project, draws the app's MARKETING_VERSION and build above the prompt with the commits since the last release. When a turn, or anything between sessions, changes the version, Haiku drafts App Store "What's New" notes from those commits and a toast says where they went. With fastlane they go to fastlane/metadata/<locale>/release_notes.txt for the default locale, else en-US, else the first. Without fastlane they become a ## <version> section in CHANGELOG.md, and a section that is already there is left alone. The last release is the newest tag, or the commit that set the previous version when the repository has no tags. The first time it sees a repository it only records the version. /draft-release-notes drafts the notes again, replacing what is there.

📝 v2.4.0 (41)  12 commits since v2.3.0  notes drafted      ← band
Release notes for 2.4.0 drafted in fastlane/metadata/en-US/release_notes.txt   ← toast

<sub>📁 plugins/release-notes</sub>

📱 resource-watch

Shows which Claude Code session is using each shared thing on the machine, so parallel agents do not fight over one. Booted Apple simulators and Claude Design projects are the baseline; the Xcode app sits on top.

  • Simulators: in an Xcode project, or once the session has used one, every booted simulator with the sessions holding it. A session takes a simulator when simctl or xcodebuild names it by UDID or name, or uses booted or an Xcode MCP run while only one is booted; commands that only look, as simctl list or xcodebuild -showdestinations, do not count.
  • Claude Design: a project, on any claude-design tool call on it.
  • Xcode app: on Xcode MCP calls that change its shared state: switching scheme, run destination or test plan, opening or closing a workspace, building, running, testing or stopping.

A hold lasts the hold option's minutes (10 by default) after the last call, and ends with the session. Sessions share their holds as files in ~/.claude/resource-watch/, labelled by their project's folder. A simulator call on one another session holds is refused the first time: the holding session is asked, and the agent is told to wait for its reply, then repeat the call to go ahead, and never to switch to or create another simulator without asking you. The holder tells the waiting sessions once it is done: after StopProject or DeviceInteractionEndSession, when its hold runs out, or when it ends. For a Claude Design project or the Xcode app nothing is refused: it toasts, messages the holding session so its agent can reply asking it to wait, and tells its own agent who holds it; a session that ends tells the sessions it shared with.

📱 iPhone 18 Pro (iOS 27.2) · this session  🛠 the Xcode app · ⚠ also the web session   ← band
iPhone 18 Pro is in use by the web session; asked it, waiting                            ← toast

<sub>📁 plugins/resource-watch</sub>

🗜 smart-compact

Compacts the conversation between turns, never during one, weighing several factors against the context's fill. Past the threshold option (60, 70 default, or 80%) it compacts about ten seconds after a turn ends. It compacts sooner when compacting is cheapest or most worth it:

  • Checkpoints, 20 points lower: a turn that committed, opened or merged a PR (gh pr, gh stack), had a plan approved, finished its todo list, or switched branch or worktree. The summary is told what to keep for each, such as the approved plan verbatim. A checkpoint counts only until the next turn starts. Set checkpoints to off to ignore them.
  • Cache cooling, 20 points lower in the last minute before the prompt cache goes cold, so the summary still reads the conversation from cache. Once the cache is cold it does not compact sooner, since the summary would re-read the whole conversation uncached.
  • 5-hour limit, 10 points lower while it is at 80% or more.

Nothing takes it under the floor option (30, 40 default, or 50%), and it tries at most once per idle stretch. The ttl option defaults to auto: 1h on a subscription, 5m on an API key or cloud provider. Set it to 5m while a subscription draws on usage credits, or to 1h when you set a one-hour cache yourself.

Set continue to tasks to carry on after compacting while todos or tasks are still open. It sends Continue with the remaining tasks., unless the turn was interrupted or ended on a question.

Compacted at 52%: committed                                  ← toast
Compacted at 55%: cache cooling                              ← toast
Compacted at 74%: context high, 5h limit at 86%              ← toast
Compacted at 75%: context high; continuing                   ← toast

<sub>📁 plugins/smart-compact</sub>

⛅ token-weather

Draws a forecast of the context window above the prompt, with tokens used, a sparkline of the last 12 turns and the change since the last turn.

⛅ Cloudy  38% of context  76.4k / 200k   last turns ▁▂▂▃▄▄▅▆  ▲ +4.1k last turn

| 🌞 Clear | ⛅ Cloudy | ☔ Showers | ⚡ Storm | 🚨 Compact soon | | :-: | :-: | :-: | :-: | :-: | | under 25% | under 50% | under 75% | under 90% | 90% and up |

<sub>📁 plugins/token-weather</sub>


MIT © Tartiner Labs

Source 2 files
hooks/register.tsx 149 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { TokenWeatherReading } from '../types'
5
6const HISTORY = 12
7const BARS = '▁▂▃▄▅▆▇█'
8const FORECAST = [
9  { upTo: 25, icon: '🌞', word: 'Clear', color: 'yellow' },
10  { upTo: 50, icon: '⛅', word: 'Cloudy', color: 'cyan' },
11  { upTo: 75, icon: '☔', word: 'Showers', color: 'blue' },
12  { upTo: 90, icon: '⚡', word: 'Storm', color: 'magenta' },
13  { upTo: Infinity, icon: '🚨', word: 'Compact soon', color: 'red' },
14] as const
15
16// Held by the host, so the history survives a hot reload of this file.
17const readings = atom({ plugin: 'token-weather', key: 'readings' } as const, [])
18// The fill after the latest model request of the turn in flight; null between turns.
19const live = atom({ plugin: 'token-weather', key: 'live' } as const, null)
20
21export const register: Register = on => {
22  on('session.start', async ($, e, next) => {
23    const result = await next(e)
24    await takeReading($)
25
26    return result
27  })
28
29  on('turn.complete', async ($, e, next) => {
30    const result = await next(e)
31
32    // Main-loop turns only, not subagents.
33    if (!e.agentId) {
34      await takeReading($)
35    }
36
37    return result
38  })
39
40  // Each model request of a turn reports a new fill, so the band moves mid-turn.
41  on('turn.step', async function* ($, e, next) {
42    const result = yield* next(e)
43
44    if (!e.agentId) {
45      const reading = await measure($)
46
47      if (reading) {
48        await update($, live, () => reading)
49      }
50    }
51
52    return result
53  })
54
55  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
56    const history = await read($, readings)
57    const current = await read($, live)
58    const now = current ?? history.at(-1)
59
60    if (e.props.hasSurvey || now === undefined) {
61      return next(e)
62    }
63
64    const { Box, Text } = $.ui.resolve(e)
65    // Mid-turn, compare with where the turn began.
66    const prev = current ? history.at(-1) : history.at(-2)
67    const f = FORECAST.find(b => now.percent < b.upTo) ?? FORECAST[4]
68    const head = `${f.icon} ${f.word}`
69    // An emoji is two columns wide, whatever its `.length`.
70    const headWidth = 3 + f.word.length
71    const percent = `  ${now.percent}% of context`
72    const size = `  ${short(now.tokens)} / ${short(now.window)}`
73    const spark = sparkline(history)
74    const change = prev ? trend(now.tokens - prev.tokens, current ? 'this turn' : 'last turn') : ''
75    // Add the history only when the whole row fits the band, so it does not wrap.
76    const room = e.props.bodyColumns - 2
77    const isWide = headWidth + (percent + size + '   last turns ' + spark + change).length <= room
78    const hasSize = headWidth + (percent + size).length <= room
79    // Stack above whatever the plugins beneath draw, so other bands stay.
80    const below = await next(e)
81
82    return (
83      <Box flexDirection="column">
84        <Box flexDirection="row" paddingX={1}>
85          <Text color={f.color} bold>
86            {head}
87          </Text>
88          <Text wrap="truncate-end">{percent}</Text>
89          {hasSize && <Text dimColor>{size}</Text>}
90          {isWide && <Text dimColor>{'   last turns '}</Text>}
91          {isWide && <Text color={f.color}>{spark}</Text>}
92          {isWide && prev && <Text dimColor>{change}</Text>}
93        </Box>
94        {below}
95      </Box>
96    )
97  })
98}
99
100async function measure($: EngineInterface): Promise<TokenWeatherReading | undefined> {
101  const { context } = await $.session.usage()
102
103  if (!context?.window || context.tokens === undefined) {
104    return undefined
105  }
106
107  return {
108    tokens: context.tokens,
109    window: context.window,
110    percent: context.percent ?? Math.round((context.tokens / context.window) * 100),
111  }
112}
113
114async function takeReading($: EngineInterface) {
115  const reading = await measure($)
116
117  if (reading) {
118    await update($, readings, history => [...(history ?? []), reading].slice(-HISTORY))
119  }
120
121  await update($, live, () => null)
122}
123
124function sparkline(history: readonly TokenWeatherReading[]) {
125  const top = Math.max(...history.map(r => r.tokens), 1)
126
127  return history.map(r => BARS[Math.floor((r.tokens / top) * (BARS.length - 1))]).join('')
128}
129
130function trend(delta: number, span: string) {
131  if (delta === 0) {
132    return '  steady'
133  }
134
135  return delta > 0 ? `  ▲ +${short(delta)} ${span}` : `  ▼ ${short(-delta)} ${span}`
136}
137
138function short(n: number) {
139  if (n >= 1_000_000) {
140    return `${+(n / 1_000_000).toFixed(1)}M`
141  }
142
143  if (n >= 1_000) {
144    return `${+(n / 1_000).toFixed(1)}k`
145  }
146
147  return String(n)
148}
149
types/index.d.ts 8 lines
1export type TokenWeatherReading = { tokens: number; window: number; percent: number }
2
3declare module 'claude-code' {
4  interface PluginState {
5    'token-weather': { readings: TokenWeatherReading[]; live: TokenWeatherReading | null }
6  }
7}
8