All posts

Writing

All posts
4 minClaude CodeDeveloper toolsProductivity

How I built two Claude Code mods to stay focused

Why a Pomodoro timer and a context meter ended up inside Claude Code, and how I built them to stay at the edge of my attention.

Two things kept pulling me out of the work in Claude Code. One was time: a focus timer in another app meant looking away from the session to check it. The other was context: it fills up quietly in the background, and you usually find out when auto-compaction interrupts you in the middle of something.

Neither problem needed a new app. Both needed a small piece of information in the place I was already looking, so I built two mods that put it right above the prompt: Tamatem for time and Syaq for context.

#Tamatem: the timer sits with the work

Tamatem (طماطم, Arabic for tomatoes) is a Pomodoro timer. It began as a mod called pomo, and I renamed it on the day I first published it. You start a focus block with one command, and a small band counts it down while you work:

text
/tamatem start 25 fix login bug
🧠 fix login bug   ████████████████████▌░░░░░░░░░░░░░░░░░░░░  12:30  ● ◐ ○ ○

Each dot is a round: ● a focus block done, ◐ the one running, ○ one to come. When the block ends, the band puts the next step first, so there’s no command to remember and no decision to make:

text
🔔 fix login bug done   ████████████████████████████████████  ● ● ○ ○
today 🍅🍅🍅  ·  /tamatem break for 5 min  ·  Stand up and stretch.

From there, /tamatem break starts the break, /tamatem continue starts another block on the same task, and /tamatem stats shows the tomatoes and focused time you’ve built up.

#Syaq: context you can see coming

Syaq (سياق, Arabic for context) came two days later. It shows how full the context is, what’s filling it and where auto-compaction will start, along with your usage limits and the current model.

The full view at 35%: the context bar split into coloured categories, a legend with each one's tokens and share, and the model, rate limits and session cost underneath
The full view, mid-session: messages are the biggest share.

The point is to choose when to compact, so the interruption stops being a surprise. When the context passes a threshold you set, 60% by default, Syaq offers /compact in the prompt box, where Tab and then Enter runs it, and shows a toast. It does this once each time the threshold is crossed.

The slim view at 62%, with a yellow badge and "run /compact"
The slim view past the threshold.

After a compaction, the bar shows what was freed and drains back down. Then the nudge stays away until the context fills up again.

After /compact: what was freed, and the bar draining back down.

#A focus tool shouldn’t need your focus

A mod that lives on screen all day can easily become the next distraction, so I built both around the same rule: stay at the edge of your attention until there’s something to do.

  • Tamatem has no colours and doesn’t blink. The time left and the next step read at normal weight, and the rest is dim.
  • Syaq starts as one line. Its first version opened on the full panel, and the same day I made the slim view the default. The full view is one /syaq full away.
  • Syaq keeps still while Claude is working. A change during a turn plays once the turn ends, so the panel doesn’t move while the spinner runs.
  • The nudge comes once. It doesn’t repeat until the context has filled up again.

#How they’re built

Both are Claude Code hooks modules written in TypeScript, and neither runs a separate process. Each one subscribes to the few events it needs: Tamatem uses three hooks and Syaq uses eight. They register a command, react to changes, and draw above the prompt.

The hook that matters most for living alongside other mods is ui.render. This is the start of Tamatem’s, lightly trimmed:

TypeScript
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
  const shown = await read($, view)
  if (!shown || e.props.hasSurvey) return next(e)

  const { Box, Text } = $.ui.resolve(e)
  // Pass the band on, so what another mod or the engine draws there stacks
  // under tamatem's instead of being hidden while a block runs.
  const below = await next(e)

With nothing to show, it steps aside. Otherwise it asks for whatever would have been drawn there and renders that underneath its own band. Syaq follows the same pattern, which is why the two can run together without either one hiding the other.

Syaq has a little more to react to. session.measure refreshes the panel when the context changes, session.compact shows what a compaction freed, turn.start and turn.complete keep the panel still during a turn, and prompt.suggest puts /compact in the prompt box without touching a suggestion from another plugin.

For the rest, I leaned on what Claude Code already provides: its clock for Tamatem’s countdown, its usage figures for Syaq’s limits, and its store and toasts for both.

#Try them

At the prompt of a Claude Code terminal session:

text
/plugin install tamatem --marketplace hassanhafezzz/tamatem
/plugin install syaq --marketplace hassanhafezzz/syaq

Answer y to add each marketplace, then pick a scope. User scope loads the mod in every session. Syaq needs Claude Code 2.1.310 or later.

Tamatem Syaq
Band or panel terminal and desktop app terminal
Everywhere else a toast when a block ends, and /tamatem the toast and the /compact suggestion

The code is on GitHub, under the MIT licence: hassanhafezzz/tamatem and hassanhafezzz/syaq. Issues and pull requests are welcome.

Thanks for reading.