modscode / Gallery / tokenbreak
tokenbreak
Opt-in ads for Claude Code: a banner above the prompt and a Theater pane while Claude works. Unofficial, not affiliated with Anthropic.
What it does
- Draws a band above the prompt, a pane, toasts
- Adds /ads
- Hooks session.attach, session.end, session.start, turn.complete and 2 more
- Keeps its own state between turns
- Calls the network
Good points
- Starts no processes
- Written in TypeScript
- Has a desktop-specific branch
- Handles errors
Code to start from
Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like tokenbreak by Tokenbreak (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/steven-3-tokenbreak/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Link, Button } = $.ui.resolve(e)
const href = '…'
const brand = '…'
const headline = '…'
const cta = '…'
return (
<Box flexDirection="column">
<Box borderStyle="round" paddingX={1}>
<Box flexDirection="row" gap={1} flexGrow={1}>
<Text>
▎
</Text>
<Text>
●
</Text>
<Box flexGrow={1} flexShrink={1}>
<Link href={`${href}`}>
<Text wrap="truncate-end">
<Text bold>
{brand}
</Text>
{" "}
{headline}
</Text>
</Link>
</Box>
<Link href={`${href}`}>
<Text bold>
{` ${cta} ↗ `}
</Text>
</Link>
<Box flexDirection="row" gap={1} marginLeft={1}>
<Text dimColor>
sponsored
</Text>
<Text dimColor>
·
</Text>
<Button label="✕" plain dimColor />
</Box>
</Box>
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Tokenbreak" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Link, Button } = $.ui.resolve(e)
const glyph = '…'
const brand = '…'
const headline = '…'
const href = '…'
const cta = '…'
return (
<Box flexDirection="column" gap={1}>
<Box flexDirection="row" gap={1}>
<Text bold>
{`${glyph} ${brand}`}
</Text>
<Text dimColor>
sponsored
</Text>
</Box>
<Text>
{headline}
</Text>
<Box flexDirection="row" gap={2}>
<Link href={`${href}`}>
<Text bold>
{` ${cta} ↗ `}
</Text>
</Link>
<Button label="🔊 mute" plain />
</Box>
<Text dimColor>
Closes when Claude finishes · /ads pause hides ads
</Text>
</Box>
)
})
on('session.start', async ($, e, next) => {
const latest = '…'
await $.ui.toast(`Tokenbreak ${latest} is required to keep earning. /ads update shows how.`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
plugins/tokenbreak/hooks/register.tsx lines 695–805 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.viewport !== undefined) {
run.seen = {
columns: e.viewport.columns,
rows: e.viewport.rows,
isFullscreen: e.viewport.isFullscreen,
maxRows: e.props.maxRows,
}
}
const until = await read($, pausedUntil)
const ad = currentBanner(await read($, ads), await read($, bannerIndex))
const state = await read($, updateState)
if (e.props.hasSurvey || until !== null || (ad === undefined && state.kind !== 'required')) {
run.drawnBanner = undefined
return next(e)
}
if (state.kind === 'required' || ad === undefined) {
// Too old to earn: the update notice takes the ad's place, and nothing is counted.
const { Box, Text } = $.ui.resolve(e)
run.drawnBanner = undefined
return (
<Box width={e.props.bodyColumns} marginTop={1} flexDirection="row" gap={1}>
<Text color={AD_YELLOW}>⬆</Text>
<Box flexGrow={1} flexShrink={1}>
<Text wrap="truncate-end">
<Text bold>Update Tokenbreak to keep earning.</Text>
{state.kind === 'required' ? ` Version ${state.latest} is out; you have ${MOD_VERSION}.` : ''}
</Text>
</Box>
<Text backgroundColor={tint(AD_YELLOW, 0.22)} color={AD_YELLOW} bold>
{' /ads update '}
</Text>
</Box>
)
}
run.drawnBanner = ad.id
const { Box, Text, Link, Button } = $.ui.resolve(e)
const Image = e.surface === 'terminal' && arePicturesOn() ? $.ui.resolve(e).Image : undefined
const style = await read($, bannerStyle)
const href = linkable(ad.clickUrl)
const accent = isHex(ad.accent) ? ad.accent : FALLBACK_ACCENT
const cta = ad.cta ?? 'Learn more'
// A logo only within LOGO_MAX_BYTES (parseBatch drops bigger ones): the band redraws
// constantly, and a small picture goes in one short piece that a redraw can't cut.
const mark =
Image !== undefined && ad.logo !== undefined ? (
<Image key="banner-logo" source={{ png: ad.logo.png }} columns={2} rows={1} alt={ad.glyph ?? ' '} />
) : (
<Text color={accent}>{ad.glyph ?? '●'}</Text>
)
// Brand and headline are one link, so the whole line opens the ad.
const words = (
<Text wrap="truncate-end">
<Text color={accent} bold>
{ad.brand}
</Text>
{' '}
{ad.headline}
</Text>
)
const action =
href === undefined ? undefined : style === 'pill' ? (
// The brand color on a dark tint of itself: reads as a button without a solid block of color.
<Link href={href}>
<Text backgroundColor={tint(accent, 0.22)} color={accent} bold>
{` ${cta} ↗ `}
</Text>
</Link>
) : (
<Link href={href}>
<Text color={accent} bold underline>
{`${cta} →`}
</Text>
</Link>
)
const row = (
<Box flexDirection="row" gap={1} flexGrow={1}>
{style === 'rule' && <Text color={accent}>▎</Text>}
{mark}
<Box flexGrow={1} flexShrink={1}>
{href === undefined ? words : <Link href={href}>{words}</Link>}
</Box>
{action}
<Box flexDirection="row" gap={1} marginLeft={1}>
<Text dimColor>sponsored</Text>
<Text dimColor>·</Text>
<Button key="hide" label="✕" plain dimColor onPress={() => void hideFor($, 3_600_000)} />
</Box>
</Box>
)
// marginTop keeps a blank row between the banner and the spinner or transcript above it.
return style === 'card' ? (
<Box width={e.props.bodyColumns} borderStyle="round" borderColor={accent} paddingX={1}>
{row}
</Box>
) : (
<Box width={e.props.bodyColumns} marginTop={1}>
{row}
</Box>
)
})plugins/tokenbreak/hooks/register.tsx lines 807–891 · Pane
on('ui.render', { component: 'Pane', requestId: 'tokenbreak-theater' }, async ($, e) => {
const showing = await read($, theater)
const list = await read($, ads)
const isSoundOn = await read($, theaterSound)
const ad = list.find(one => one.id === showing?.adId) ?? theaterOf(list)
const href = linkable(ad.clickUrl)
const accent = isHex(ad.accent) ? ad.accent : FALLBACK_ACCENT
const { Box, Text, Link, Button } = $.ui.resolve(e)
const isTextOnly = e.surface !== 'terminal' || !arePicturesOn()
// The same parts as the banner: brand in its color, a dim label, a button in the brand's color.
const card = (
<Box flexDirection="column" gap={1}>
<Box flexDirection="row" gap={1}>
<Text color={accent} bold>
{isTextOnly ? `${ad.glyph ?? '●'} ${ad.brand}` : ad.brand}
</Text>
<Text dimColor>sponsored</Text>
</Box>
<Text>{ad.headline}</Text>
<Box flexDirection="row" gap={2}>
{href !== undefined && (
<Link href={href}>
<Text backgroundColor={tint(accent, 0.22)} color={accent} bold>
{` ${ad.cta ?? 'Learn more'} ↗ `}
</Text>
</Link>
)}
{ad.audio !== undefined && (
// Mutes or unmutes; a mute is remembered. Sound always stops when the pane closes.
<Button
key="sound"
label={isSoundOn ? '🔊 mute' : '🔇 sound'}
plain
dimColor={!isSoundOn}
onPress={() => void toggleSound($, ad)}
/>
)}
</Box>
<Text dimColor>Closes when Claude finishes · /ads pause hides ads</Text>
</Box>
)
if (isTextOnly || e.surface !== 'terminal') {
run.drawnCut = undefined
return card
}
const { Image } = $.ui.resolve(e)
const cuts = hasVideo(ad) ? cutsOf(ad) : []
const art = cuts.length === 0 && ad.image === undefined ? theaterArt() : undefined
const shapes =
cuts.length > 0
? cuts.map(cut => ({ width: cut.width, height: cut.height }))
: [{ width: ad.image?.width ?? art?.width ?? 16, height: ad.image?.height ?? art?.height ?? 9 }]
// The cut and arrangement that show the biggest picture in this pane, tall or wide.
const layout = theaterLayout(e.props.bodyColumns, e.props.scroll.bodyRows, shapes)
const length = cuts.length > 0 ? lengthOf(ad, layout.shape) : 0
run.drawnCut = cuts.length > 0 ? { adId: ad.id, index: layout.shape } : undefined
// A video starts on its poster frame, or where playback is; playVideo swaps the rest in.
const source: ImageSource =
(length > 0 ? frameSource(ad, layout.shape, Math.max(0, run.frame ?? posterOf(length)) % length) : undefined) ??
(ad.image !== undefined ? { png: ad.image.png } : { rgba: art?.rgba ?? '', width: shapes[0]?.width ?? 16, height: shapes[0]?.height ?? 9 })
const picture = (
<Image key="theater-image" source={source} columns={layout.columns} rows={layout.rows} alt={`${ad.brand}: ${ad.headline}`} />
)
return layout.mode === 'side' ? (
<Box flexDirection="row" gap={2}>
{picture}
<Box flexDirection="column" flexGrow={1} flexShrink={1}>
{card}
</Box>
</Box>
) : (
<Box flexDirection="column" gap={1}>
<Box flexDirection="row" justifyContent="center">
{picture}
</Box>
{card}
</Box>
)
})Licence text (MIT)
MIT License Copyright (c) 2026 Steven Spivak Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
What its code calls
networkremembers
The design, read from code
Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.
What its code shows
Read from the source at commit 289c676eb19c on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.plugins/tokenbreak/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.2 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.plugins/tokenbreak/hooks/register.tsx:225 fetch(`${run.endpoint}/api/v1/ads?formats=${FORMATS.join); plugins/tokenbreak/hooks/register.tsx:261 fetch(`${run.endpoint}/api/v1/impressions`) |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs |
| Reads and sends | Whether it both reads files or environment variables and reaches the network.reaches the network, but reads no files and no environment variables |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add steven-3/tokenbreak/plugin install tokenbreak@tokenbreakThis installs the marketplace's latest commit, which may not be the one read here (289c676eb19c). Compare them before you install.
Ask Claude about it
With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:
Read the modscode design "steven-3-tokenbreak" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
✦ explain as pick how Claude answers×3 ● build3 ● build3 ● build▸ VideoAsk Claude…
-
Ask Claude…CIcross Bash · Classicmain · a1b2c3d · failed at 14:32Open the run on GitHubFix it fClose x
(no log available)
-
Ask Claude…GitHub inboxGitHubloading…Refresh rbuildbuildbuildClose xStealth IssuesNo open issues in this view.#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopenPull requestsNo open pull requests.#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopenChecks for #3Plain
-
Ask Claude…gh-pulser Refreshm buildf Fix ite Rerun failedl Next logy Copy loga Review with Claudeo Openx Removed Clear finished (3)c Clearz Undo (build)h Hide keyspending Detail only…KFailingKFailingKFailingKFailingKFailingKFailingKFailingKFailingKFailing3 buildNothing open. Press m to bring the list back.3 build3 build
-
Ask Claude…◉ Subcommands◆ acme/app● Backlog build▲ Backlog build⇄ Backlog build✗ Backlog buildPriorityBacklog 3%◌ syncing… r⚙ Set up build for the board◌ Reading the repo, its project and its issues…Couldn't read what setup needs: Item closed/issues check says what is missing and how to fix it.Projectnone is linked to buildFix login (#3)buildApply will:● Fix login Item closed● Fix login Item closed● Fix login Item closedarea labels to create: Off track updateWhich Status is whichInbox (folds)Inbox (folds)Inbox (folds)In the project's Workflows settings, by hand: · turn on Off track · turn off Inactive: it marks every closed issue Done, even an abandoned one; the board moves issues closed as comp… · new issues arrive with Status Todo, GitHub's default, so they skip the Inbox: open Item added to project and set it…↗ WorkflowsNo issue template has an Acceptance list.◌ Applying…build █████░░░ Off trackbuild █████░░░ Off tracklast 12 weeks✗ Setup needed⋯Fix loginSubcommandsSubcommands↗ example.comFix loginSubcommandsSubcommands↗ example.comFix loginSubcommandsSubcommands↗ example.com
-
Ask Claude…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava