Predicts how long Claude's turn will take and gives you push-ups to do while you wait, in a bar above the prompt. Local only: no model calls, no tokens.

A Claude Code mod for waiting on Claude. It predicts how long the turn will take and gives you push-ups to do in the meantime, in a bar above the prompt.
It makes no model calls, so it uses no tokens. Everything runs locally.
While Claude works. A figure does push-ups, the bar fills as the predicted time passes, and the title tells you how many to do ("Do 8 push-ups") and the pill counts how many you should have done by now (3/8).
If the turn runs long. When the first set's time is up, a new set starts and the bar resets: "Set 2: 15 push-ups". A new set follows every minute for as long as the turn runs, and every finished rep counts.
When it ends. The row turns green and shows the set you finished and your total for today. It stays until you press ✕ or send your next prompt.
These images are rendered from the mod's own drawing code (tools/generate-previews.mjs), so they match the real row. In Claude Code's terminal the same row is drawn in text with a █░ bar. In the desktop app the figure and the bar animate.
3/8) and the time left. Past the prediction it rolls into a new 60-second set, again and again. When the turn ends it shows what you did and your total for today.Needs Claude Code 2.1.287 or later.
claude plugin marketplace add Risdon8/push-ups
claude plugin install push-ups@push-ups
Restart Claude Code or run /reload-plugins.
/pushups totals: this session, today, last 7 days, all time /pushups mode show the current mode /pushups mode easy one per 6s of wait, up to 20 a set /pushups mode medium one per 4s, up to 30 (default) /pushups mode hard one per 2.5s, up to 60 /pushups mode extreme one per 1.5s, up to 100, a different variation each set
The limits are per set. In extreme mode each set is a different variation (standard, wide-grip, diamond, pike, spiderman, archer, clap); harder ones ask for fewer reps.
claude plugin validate . claude plugin test .
MIT licensed.
hooks/register.tsx 392 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Result, Run } from '../types'
5
6// Push-ups for the wait. The prediction is the median of recent turns of the
7// same size, kept in $.store across sessions. No model is called, so no tokens.
8
9const run = atom({ plugin: 'push-ups', key: 'run' } as const, null)
10const now = atom({ plugin: 'push-ups', key: 'now' } as const, 0)
11const result = atom({ plugin: 'push-ups', key: 'result' } as const, null)
12const session = atom({ plugin: 'push-ups', key: 'session' } as const, 0)
13
14const HISTORY = 10
15const MIN_SAMPLES = 3
16const DEFAULT_MS = { short: 15_000, medium: 30_000, long: 45_000 }
17const MIN_PREDICT_MS = 8_000
18const MAX_PREDICT_MS = 90_000
19// Milliseconds of wait per push-up, and the most one set asks for. The first
20// set covers the predicted wait; once it runs out, a new set starts every SET_MS.
21const MODES = {
22 easy: { ms: 6_000, max: 20 },
23 medium: { ms: 4_000, max: 30 },
24 hard: { ms: 2_500, max: 60 },
25 extreme: { ms: 1_500, max: 100 },
26}
27const SET_MS = 60_000
28// Extreme rotates through these, one per set. `slow` stretches the time each rep
29// takes, so harder variations ask for fewer reps.
30const VARIATIONS = [
31 { name: '', slow: 1 },
32 { name: 'wide-grip ', slow: 1 },
33 { name: 'diamond ', slow: 1.4 },
34 { name: 'pike ', slow: 1.4 },
35 { name: 'spiderman ', slow: 1.8 },
36 { name: 'archer ', slow: 2 },
37 { name: 'clap ', slow: 2 },
38]
39const MIN_PUSHUPS = 2
40const TICK_MS = 1_000
41
42const CLAY = '#D97757'
43const DONE = '#5fbf8f'
44
45type Bucket = keyof typeof DEFAULT_MS
46type Mode = keyof typeof MODES
47
48const bucketOf = (text: string): Bucket => {
49 const n = text.trim().length
50 return n < 80 ? 'short' : n < 300 ? 'medium' : 'long'
51}
52
53const fmtSec = (ms: number): string => `${Math.max(0, Math.round(ms / 1000))}s`
54
55const median = (xs: number[]): number => {
56 const sorted = [...xs].sort((a, b) => a - b)
57 return sorted[Math.floor(sorted.length / 2)]
58}
59
60const history = async ($: EngineInterface, bucket: Bucket | 'all'): Promise<number[]> => {
61 const past = await $.store.get(`hist:${bucket}`)
62 return Array.isArray(past) ? past.filter((x): x is number => typeof x === 'number') : []
63}
64
65const isMode = (x: unknown): x is Mode => typeof x === 'string' && x in MODES
66
67async function readMode($: EngineInterface): Promise<Mode> {
68 const mode = await $.store.get('mode')
69 return isMode(mode) ? mode : 'medium'
70}
71
72const pad = (n: number): string => String(n).padStart(2, '0')
73
74const dayKey = (ms: number): string => {
75 const d = new Date(ms)
76 return `day:${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
77}
78
79const asCount = (x: unknown): number => (typeof x === 'number' && Number.isFinite(x) ? x : 0)
80
81/** Adds finished push-ups to today's count and the all-time total; answers today's count. */
82async function logReps($: EngineInterface, reps: number): Promise<number> {
83 const key = dayKey(await $.clock.now())
84 const today = asCount(await $.store.get(key)) + reps
85 await $.store.set(key, today)
86 await $.store.set('all', asCount(await $.store.get('all')) + reps)
87 return today
88}
89
90async function statsText($: EngineInterface, sessionCount: number): Promise<string> {
91 const mode = await readMode($)
92 const nowMs = await $.clock.now()
93 let week = 0
94 for (let i = 0; i < 7; i++) week += asCount(await $.store.get(dayKey(nowMs - i * 86_400_000)))
95 const today = asCount(await $.store.get(dayKey(nowMs)))
96 const all = asCount(await $.store.get('all'))
97 return [
98 `push-ups, ${mode} mode (one per ${MODES[mode].ms / 1000}s of wait, up to ${MODES[mode].max} a set${mode === 'extreme' ? ', varied' : ''}, a new set every minute)`,
99 `this session ${sessionCount}`,
100 `today ${today}`,
101 `last 7 days ${week}`,
102 `all time ${all.toLocaleString('en-US')}`,
103 ].join('\n')
104}
105
106// ---------------------------------------------------------------------------
107// What the band shows for one moment: running, past the prediction, or done.
108
109type View = {
110 phase: 'running' | 'done'
111 ratio: number
112 reps: number
113 total: number
114 title: string
115 pill: string
116 right: string
117}
118
119type PushSet = { index: number; reps: number; lengthMs: number; name: string }
120
121const setAt = (r: Run, index: number): PushSet => {
122 const v = r.varied ? VARIATIONS[(r.offset + index) % VARIATIONS.length] : { name: '', slow: 1 }
123 const lengthMs = index === 0 ? r.predictedMs : SET_MS
124 const reps = Math.min(r.max, Math.max(MIN_PUSHUPS, Math.round(lengthMs / (r.repMs * v.slow))))
125 return { index, reps, lengthMs, name: v.name }
126}
127
128/** Where `elapsed` falls in the run's sets: the current set, its progress, and the totals so far. */
129export const progress = (r: Run, elapsed: number) => {
130 let start = 0, asked = 0, done = 0
131 for (let index = 0; ; index++) {
132 const set = setAt(r, index)
133 if (elapsed < start + set.lengthMs) {
134 const ratio = Math.max(0, elapsed - start) / set.lengthMs
135 const reps = Math.min(set.reps, Math.floor(ratio * set.reps))
136 return { set, ratio, reps, left: start + set.lengthMs - elapsed, asked: asked + set.reps, done: done + reps }
137 }
138 start += set.lengthMs
139 asked += set.reps
140 done += set.reps
141 }
142}
143
144export const viewOf = (r: Run | null, res: Result | null, t: number): View | null => {
145 if (res !== null) {
146 return { phase: 'done', ratio: 1, reps: res.total, total: res.total, title: 'Nice work', pill: res.reps < res.total ? `✓ ${res.reps}/${res.total}` : `✓ ${res.reps}`, right: `${res.today.toLocaleString('en-US')} today` }
147 }
148 if (r === null) return null
149 const p = progress(r, Math.max(0, t - r.startedAt))
150 const what = `${p.set.name}push-ups`
151 const title = p.set.index === 0 ? `Do ${p.set.reps} ${what}` : `Set ${p.set.index + 1}: ${p.set.reps} ${what}`
152 return { phase: 'running', ratio: p.ratio, reps: p.reps, total: p.set.reps, title, pill: `${p.reps}/${p.set.reps}`, right: `${fmtSec(p.left)} left` }
153}
154
155// ---------------------------------------------------------------------------
156// Desktop: the whole row is one SVG (the dithered bar of savvy-progress, with a
157// small figure doing push-ups). Terminal: the same row in text.
158
159const H = 24
160const BAR_H = 16
161const CELL = 3
162const FIG_W = 32
163const FONT = "-apple-system,BlinkMacSystemFont,'SF Pro Text','Segoe UI',sans-serif"
164
165const xml = (s: string): string =>
166 s.replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c] ?? c)
167
168const noise = (a: number, b: number): number => {
169 const x = Math.sin(a * 127.1 + b * 311.7) * 43758.5453
170 return x - Math.floor(x)
171}
172
173// Rough advance of system UI text, in em; enough to size the title's slot.
174const charEm = (ch: string): number =>
175 /[\s.,:;'|!il1()[\]]/.test(ch) ? 0.3 : /[A-Z@%]/.test(ch) ? 0.72 : 0.56
176
177const textWidth = (s: string, size: number): number => [...s].reduce((w, ch) => w + charEm(ch) * size, 0)
178
179/** A side-on figure: hands and feet stay on the floor, the shoulder rises and falls. */
180const figure = (color: string, isMoving: boolean): string => {
181 const fx = 28, fy = 21, hx = 5, sx = 8
182 const up = 15.5, down = 19
183 const head = (ys: number) => {
184 const dx = sx - fx, dy = ys - fy, len = Math.hypot(dx, dy)
185 return { cx: +(sx + (dx / len) * 5).toFixed(2), cy: +(ys + (dy / len) * 5).toFixed(2) }
186 }
187 const a = head(up), b = head(down)
188 const anim = (attr: string, v1: number, v2: number) => isMoving
189 ? `<animate attributeName="${attr}" values="${v1};${v2};${v1}" keyTimes="0;.5;1" calcMode="spline" keySplines=".4 0 .6 1;.4 0 .6 1" dur="1.6s" repeatCount="indefinite"/>`
190 : ''
191 return `<rect class="k" x="0" y="22.2" width="${FIG_W}" height="1.6" rx="0.8"/>
192<g stroke="${color}" stroke-width="2.2" stroke-linecap="round" fill="none">
193<line x1="${hx}" y1="${fy}" x2="${sx}" y2="${up}">${anim('y2', up, down)}</line>
194<line x1="${sx}" y1="${up}" x2="${fx}" y2="${fy}">${anim('y1', up, down)}</line>
195</g>
196<circle cx="${a.cx}" cy="${a.cy}" r="2.7" fill="${color}">${anim('cx', a.cx, b.cx)}${anim('cy', a.cy, b.cy)}</circle>`
197}
198
199export const rowSvg = (v: View, W: number): string => {
200 const color = v.phase === 'done' ? DONE : CLAY
201 const isDone = v.phase === 'done'
202 const BAR_X = Math.round(FIG_W + 10 + textWidth(v.title, 13) + 12)
203 const BAR_W = Math.max(60, W - BAR_X - 74)
204 const y0 = (H - BAR_H) / 2
205 const fillW = Math.round(BAR_W * v.ratio)
206 const dots: string[] = []
207
208 // Dithered fill: sparse at the start, dense toward the head.
209 const cols = Math.floor(fillW / CELL)
210 const rows = Math.floor(BAR_H / CELL)
211 for (let c = 0; c < cols; c++) {
212 const density = 0.35 + 0.6 * Math.pow(c / Math.max(1, cols), 1.2)
213 for (let r = 0; r < rows; r++) {
214 if (noise(c, r) < density) dots.push(`<rect class="t${Math.floor(noise(r, c) * 4)}" x="${c * CELL + 1}" y="${r * CELL + 1}" width="2" height="2"/>`)
215 }
216 }
217
218 // One tick per push-up still to do.
219 const ticks: string[] = []
220 for (let i = 1; i < v.total; i++) {
221 const x = Math.round((BAR_W * i) / v.total)
222 if (x > fillW + 4) ticks.push(`<rect x="${x}" y="${BAR_H / 2 - 4}" width="1.5" height="8" rx="0.75"/>`)
223 }
224
225 const pillW = Math.round(18 + v.pill.length * 6.6)
226 const pillX = Math.max(0, Math.min(BAR_W - pillW, fillW - pillW))
227
228 return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
229<style>
230.t{fill:#1f1f1f}.m{fill:#8a8a8a}.k{fill:#e4e4e2}.tk{fill:#b4b4b0}
231@media (prefers-color-scheme: dark){.t{fill:#ececec}.m{fill:#9a9a9a}.k{fill:#2c2c2c}.tk{fill:#5a5a5a}}
232.t0,.t1,.t2,.t3{animation:tw ${isDone ? 3.2 : 2.2}s ease-in-out infinite}
233.t1{animation-duration:${isDone ? 3.8 : 2.8}s;animation-delay:-.7s}.t2{animation-duration:${isDone ? 4.4 : 1.9}s;animation-delay:-1.3s}.t3{animation-duration:${isDone ? 3.5 : 3.3}s;animation-delay:-.4s}
234@keyframes tw{0%,100%{opacity:1}50%{opacity:${isDone ? 0.8 : 0.3}}}
235@media (prefers-reduced-motion: reduce){.t0,.t1,.t2,.t3{animation:none}}
236</style>
237<defs><clipPath id="c"><rect x="0" y="0" width="${BAR_W}" height="${BAR_H}" rx="${BAR_H / 2}"/></clipPath></defs>
238${figure(color, !isDone)}
239<text class="t" x="${FIG_W + 10}" y="${H / 2 + 4.5}" font-family="${FONT}" font-size="13" font-weight="500">${xml(v.title)}</text>
240<g transform="translate(${BAR_X},${y0})">
241<rect class="k" width="${BAR_W}" height="${BAR_H}" rx="${BAR_H / 2}"/>
242<g clip-path="url(#c)">
243<g fill="${color}">${dots.join('')}</g>
244<g class="tk">${ticks.join('')}</g>
245</g>
246<rect x="${pillX}" width="${pillW}" height="${BAR_H}" rx="${BAR_H / 2}" fill="${color}"/>
247<text x="${pillX + pillW / 2}" y="${BAR_H / 2 + 4}" text-anchor="middle" font-family="${FONT}" font-size="11" font-weight="600" fill="#ffffff">${xml(v.pill)}</text>
248</g>
249<text class="m" x="${W - 2}" y="${H / 2 + 4.5}" text-anchor="end" font-family="${FONT}" font-size="12.5" font-variant-numeric="tabular-nums">${xml(v.right)}</text>
250</svg>`
251}
252
253const barText = (ratio: number, width: number): string => {
254 const filled = Math.round(width * ratio)
255 return '█'.repeat(filled) + '░'.repeat(Math.max(0, width - filled))
256}
257
258// ---------------------------------------------------------------------------
259
260let ticking: { cancel: () => void } | null = null
261let activeTurn = ''
262
263function stopTicking() {
264 if (ticking) ticking.cancel()
265 ticking = null
266}
267
268function tick($: EngineInterface) {
269 ticking = $.clock.after(TICK_MS, async () => {
270 ticking = null
271 if (!activeTurn) return
272 const t = await $.clock.now()
273 await update($, now, () => t)
274 if (activeTurn) tick($)
275 })
276}
277
278export const register: Register = on => {
279 on('turn.start', async ($, e, next) => {
280 const r = await next(e)
281 stopTicking()
282
283 const bucket = bucketOf(e.text)
284 // This prompt size's own turns first, then every turn so far, then a default.
285 const own = await history($, bucket)
286 const every = await history($, 'all')
287 const guess = own.length >= MIN_SAMPLES ? median(own) : every.length >= MIN_SAMPLES ? median(every) : DEFAULT_MS[bucket]
288 const predictedMs = Math.min(MAX_PREDICT_MS, Math.max(MIN_PREDICT_MS, guess))
289 const modeName = await readMode($)
290 const mode = MODES[modeName]
291 const startedAt = await $.clock.now()
292
293 activeTurn = e.turnId
294 await update($, result, () => null)
295 await update($, now, () => startedAt)
296 await update($, run, () => ({ turnId: e.turnId, startedAt, predictedMs, bucket, repMs: mode.ms, max: mode.max, varied: modeName === 'extreme', offset: startedAt % VARIATIONS.length }))
297 tick($)
298 return r
299 })
300
301 on('turn.complete', async ($, e, next) => {
302 const r = await next(e)
303 if (e.agentId || e.turnId !== activeTurn) return r
304
305 activeTurn = ''
306 stopTicking()
307 const mine = await read($, run)
308 await update($, run, () => null)
309 if (mine === null) {
310 await update($, result, () => null)
311 return r
312 }
313
314 // Only the push-ups the wait covered count, whether the turn finished early, ran on or was interrupted.
315 const { done: reps, asked } = progress(mine, Math.max(0, e.durationMs))
316 if (!e.isAborted) {
317 for (const key of [mine.bucket, 'all'] as const) {
318 const hist = [...(await history($, key)), e.durationMs].slice(-HISTORY)
319 await $.store.set(`hist:${key}`, hist)
320 }
321 }
322 if (reps === 0) {
323 await update($, result, () => null)
324 return r
325 }
326
327 const today = await logReps($, reps)
328 await update($, session, n => n + reps)
329 await update($, result, () => ({ tookMs: e.durationMs, predictedMs: mine.predictedMs, total: asked, reps, today }))
330 return r
331 })
332
333 on('session.start', async ($, e, next) => {
334 await $.command.register({
335 name: 'pushups',
336 description: 'Push-up totals for this session, today, the week and all time; mode easy|medium|hard|extreme (push-ups)',
337 argumentHint: '[mode easy|medium|hard|extreme]',
338 })
339 return next(e)
340 })
341
342 on('command.run', { command: 'pushups' }, async ($, e) => {
343 const words = String(e.args ?? '').trim().split(/\s+/).filter(Boolean)
344 if (words[0] === 'mode') {
345 if (!isMode(words[1])) return { text: `push-ups is in ${await readMode($)} mode; /pushups mode easy, medium, hard or extreme changes it` }
346 await $.store.set('mode', words[1])
347 return { text: `push-ups set to ${words[1]}: one per ${MODES[words[1]].ms / 1000}s of wait, up to ${MODES[words[1]].max} a set${words[1] === 'extreme' ? ', with a different variation each set' : ''}` }
348 }
349 return { text: await statsText($, await read($, session)) }
350 })
351
352 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
353 const r = await read($, run)
354 const res = await read($, result)
355 if (e.props.hasSurvey) return next(e)
356
357 const view = viewOf(r, res, await read($, now))
358 if (view === null) return next(e)
359
360 const ui = $.ui.resolve(e)
361 const { Box, Text, Button } = ui
362 const dismiss = view.phase === 'done'
363 ? <Button key="pu-dismiss" label="✕" plain role="dismiss" onPress={() => update($, result, () => null)} />
364 : null
365 const alt = `${view.title}: ${view.pill}, ${view.right}`
366
367 if ('Svg' in ui) {
368 const { Svg } = ui
369 const width = Math.max(180, Math.min(1600, (e.props.bodyColumns || 100) * 8 - 48))
370 return (
371 <Box flexDirection="row" alignItems="center" gap={1}>
372 <Svg source={rowSvg(view, width)} alt={alt} width={width} height={H} />
373 {dismiss}
374 </Box>
375 )
376 }
377
378 const color = view.phase === 'done' ? DONE : CLAY
379 const cols = e.props.bodyColumns
380 const barW = Math.max(6, Math.min(40, cols - 36))
381 return (
382 <Box flexDirection="row" gap={2}>
383 <Text color={color}>▣ <Text bold>{view.title}</Text></Text>
384 <Text color={color}>{barText(view.ratio, barW)}</Text>
385 <Text bold>{view.pill}</Text>
386 <Text dimColor>{view.right}</Text>
387 {dismiss}
388 </Box>
389 )
390 })
391}
392types/index.d.ts 9 lines1export type Run = { turnId: string; startedAt: number; predictedMs: number; bucket: 'short' | 'medium' | 'long'; repMs: number; max: number; varied: boolean; offset: number }
2export type Result = { tookMs: number; predictedMs: number; total: number; reps: number; today: number }
3
4declare module 'claude-code' {
5 interface PluginState {
6 'push-ups': { run: Run | null; now: number; result: Result | null; session: number }
7 }
8}
9