SLOPSHOPPER

focus-clock

Run a 25-minute focus countdown with pause, reset, and a toast.

newpanecommandtoasttimer
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · focus-clock
│ ┃ Focus Clock ✕ › fix the failing auth test and add an audit log call │ ┃ Focus Clock │ ┃ ⏺ Read(src/auth.ts) │ ┃ Run a 25-minute focus countdown with pause, ⎿ Read 6 lines │ ┃ reset, and a toast. ⏺ Update(src/auth.ts) │ ┃ ⎿ Added 2 lines, removed 1 line │ ┃ 25:00 ⏺ Bash(bun test) │ ┃ ⎿ 3 pass, 1 fail │ ┃ Ready or paused. │ ┃ ● Done. refresh now rejects expired claims and logs an audit event. │ ┃ s: Start [ Reset 25 minutes ] │ ✻ Worked for 42s · done 4:20 PM │ │ › /focus-clock │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · Focus Clock
Focus Clock Run a 25-minute focus countdown with pause, reset, and a toast. 25:00 Ready or paused. s: Start [ Reset 25 minutes ]
README

Focus Clock

Run a 25-minute focus countdown with pause, reset, and a toast.

Use it when: Keep a work interval visible during a long task.

Focus Clock render preview

Screenshot of this mod's render tree in the fixture preview, with sample data. This is not a capture of the Claude Code application. How previews are made.

Install and open

claude plugin marketplace add whyashthakker/awesome-claude-code-mods
claude plugin install focus-clock@awesome-claude-code-mods

Run /reload-plugins in an existing session, then /focus-clock. Use Tab and Enter to operate controls; Esc closes the pane. Terminal and Desktop Code tab supported; pane UI is unavailable in claude -p and the VS Code chat panel.

Try the source without installing:

claude --plugin-dir ./mods/focus-clock

Access and behavior

Uses a local clock and a completion toast. No files, network, or persistence.

Module variables reset on hot reload. Diagnostic history begins when the mod loads and lasts until reload or process exit; it does not reconstruct earlier activity. All display output is bounded; viewers may truncate long content to 9,000 characters. Relative file paths and Git commands use the session working directory.

Verify

Tested with Claude Code 2.1.288. Minimum documented mods version: 2.1.287. The API can change; validate against your installed version.

claude plugin validate mods/focus-clock --strict
claude plugin test mods/focus-clock

Tests cover plugin commands, pane isolation, both UI surfaces, and the behavior described in tests/register.test.ts. Drawing tests validate element trees; they do not verify pixels painted by the native apps. Validation details.

MIT licensed. No runtime packages or build step required.

Source 2 files
hooks/register.js 45 lines
1import { clean, text, code, row, frame, bar, pretty, bounded, entries, safePath } from './ui.js'
2const ID = "focus-clock"
3let remaining=25*60, running=false, last=0
4export function register(on) {
5  on('session.start', async ($, e, next) => {
6
7$.clock.every(1000,async()=>{
8 if(!running)return
9 const now=await $.clock.now()
10 remaining=Math.max(0,remaining-(now-last)/1000);last=now
11 if(remaining===0){running=false;$.ui.toast('Focus interval finished. Take a break.')}
12 $.ui.invalidate('ui.render')
13})
14
15    await $.command.register({name:ID, description:"Run a 25-minute focus countdown with pause, reset, and a toast.", immediate:true, argumentHint:""})
16    return next(e)
17  })
18  on('command.run', {command:"focus-clock"}, async ($, e) => {
19
20    await $.ui.open({id:ID,title:"Focus Clock",focus:true,closeOnEscape:true})
21    return {}
22  })
23
24  on('ui.render', {component:'Pane'}, async ($, e, next) => {
25    if(e.requestId !== ID) return next(e)
26    const E = $.ui.resolve(e)
27    try {
28      const body = await draw($, E)
29      return frame(E,"Focus Clock","Run a 25-minute focus countdown with pause, reset, and a toast.",body)
30    } catch(error) {
31      return frame(E,"Focus Clock",'Unable to inspect this data.',[text(E,error.message,{color:'yellow'}),E.Button({key:'refresh',label:'Refresh',onPress:()=>$.ui.invalidate('ui.render')})])
32    }
33  })
34}
35async function draw($, E) {
36  const refresh = E.Button({key:'refresh',label:'Refresh',hotkey:'r',plain:true,onPress:()=>$.ui.invalidate('ui.render')})
37
38const seconds=Math.ceil(remaining)
39return [text(E,Math.floor(seconds/60).toString().padStart(2,'0')+':'+(seconds%60).toString().padStart(2,'0'),{bold:true,color:'cyan'}),
40 text(E,running?'Focus interval is running.':'Ready or paused.'),
41 row(E,[E.Button({key:'start',label:running?'Pause':'Start',hotkey:'s',plain:true,onPress:async()=>{const now=await $.clock.now();if(running)remaining=Math.max(0,remaining-(now-last)/1000);last=now;running=!running;$.ui.invalidate('ui.render')}}),
42 E.Button({key:'reset',label:'Reset 25 minutes',onPress:()=>{running=false;remaining=1500;$.ui.invalidate('ui.render')}})])]
43
44}
45
hooks/ui.js 36 lines
1// Pure UI helpers. No engine access; each plugin contains its own copy.
2export function clean(value, limit = 9000) {
3  return String(value ?? '').replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, '').slice(0, limit)
4}
5export function text(E, value, props = {}) {
6  return E.Text({ ...props, children: [clean(value)] })
7}
8export function code(E, value, language = 'text') {
9  return E.Code({ source: clean(value), language })
10}
11export function row(E, children) {
12  return E.Box({ flexDirection: 'row', columnGap: 2, flexWrap: 'wrap', children })
13}
14export function frame(E, title, subtitle, children) {
15  return E.Box({ flexDirection: 'column', gap: 1, children: [
16    text(E, title, { bold: true, color: 'cyan' }),
17    text(E, subtitle, { dimColor: true }), ...children,
18  ] })
19}
20export function bar(percent, width = 24) {
21  const p = Math.max(0, Math.min(100, Number(percent) || 0))
22  const n = Math.round(p / 100 * width)
23  return '[' + '#'.repeat(n) + '-'.repeat(width - n) + '] ' + p.toFixed(1) + '%'
24}
25export function pretty(value) { return JSON.stringify(value, null, 2) }
26export function bounded(value, max = 9000) {
27  if (value.length > max) throw new Error('Input exceeds ' + max + ' characters. Use a smaller selection.')
28  return value
29}
30export function entries(value) { return value && typeof value === 'object' ? Object.entries(value) : [] }
31export function safePath(value) {
32  const path = value.trim()
33  if (!path || path.startsWith('-') || /[\x00-\x1f]/.test(path)) throw new Error('Enter a path without control characters or leading flags.')
34  return path
35}
36