CLI and Claude Code plugin / Node 18+ / no dependencies

A wrapper, a hook and a trivia bank

Trivia while a build or Claude Code runs, then straight back to work

Put dt in front of a slow command and the terminal shows a trivia question until the command ends, then hands back its output and exit code untouched. The Claude Code plugin does the same for an agent: its hooks note when a tool call or a subagent starts and stops, and a companion pane asks questions once the work has run for 10 seconds.

At a glance

What it does
dt <command> wraps any command; commands under 5 s, piped output and dumb terminals see no trivia. The plugin registers 9 hook events and opens a tmux pane by itself. 550 questions in 23 categories, flags and outlines drawn in the terminal.
How it is tested
72 Node tests in CI on Linux and macOS under Node 18, 20 and 22 (16 new). Three live claude -p runs on Claude Code 2.1.323, one of them recorded below. One hook call takes 46.5 ms at p50 and 48.9 ms at p95, and hooks run async, so Claude Code never waits on them.
Limits
An interactive Claude Code session owns its terminal, so the trivia needs a second pane (tmux opens one for you). The companion does not see the model thinking unless you ask it to, and it cannot see a permission prompt waiting on you.

Recorded session

A real 25-second wait on Claude Code, replayed frame by frame

This is the companion pane. In another process, Claude Code ran headless and was asked to run sleep 24 && echo build ok. The plugin's PreToolUse hook wrote the call down; after 10 seconds the companion put up a question (the QWERTY layout), then two more as keys were pressed, and when PostToolUse arrived it printed the land-back line with the tool and its duration.

downtime companion --once, 92 x 24loading
Loading the recording...

Captured 2026-11-13 with tmux capture-pane -e every 200 ms while claude -p (Claude Code 2.1.323, model haiku, plugin loaded with --plugin-dir) ran on an Apple M4. Keys were sent with tmux send-keys by the recording script. The frames, timings and keys are in session.json; this page only replays them. Arrow keys step through frames when the slider has focus.

How the plugin knows

Nine hook events fold into one small file per session

An interactive Claude Code session owns its terminal, so dt cannot draw over it. The plugin's hooks/hooks.json runs node "${CLAUDE_PLUGIN_ROOT}/bin/downtime" hook on each event below. The hook reads the event JSON from stdin, takes a lock (parallel tool calls fire parallel hooks), updates ~/.downtime/claude/<session>.json, prints nothing and exits 0. Every hook is async, so a slow disk can never hold Claude Code up. The companion polls those files every 400 ms.

EventWhat the hook records
PreToolUseA tool call starts: its name and one line of its input (the command, file or pattern), never a file's contents.
PostToolUse, PostToolUseFailureThe call ends. Async hooks can land out of order, so an end that arrives first leaves a marker that cancels its start.
SubagentStart, SubagentStopA subagent works, keyed by its agent id.
UserPromptSubmit, Stop, StopFailureThe turn begins and ends, for the optional "turn" trigger that also counts the model thinking.
SessionEndThe session file is deleted.

The recording found a second, smaller bug: the footer's "running: ..." label was truncated to the screen width minus a fixed 30 columns, so after an answer, when the hint text grows, the long Claude Code label wrapped onto a new line. It is now cut to whatever the hints leave, and a test renders the question at 92 columns before and after an answer. The replay above is the run after the fix.

The first live run found a real bug. Claude launched a subagent through the Agent tool, the tool returned in 6 ms, and the main Stop event fired while the subagent was still running its own 8-second Bash call. The first version cleared everything on Stop, so the companion would have handed you back early. Stop now keeps subagents and their tools, and a test pins it.

Install

One package, two ways in

npm install -g github:lyhjeremy/downtime-cli
dt npm run build

The wrapper. Node 18 or newer, no dependencies.

claude plugin marketplace add lyhjeremy/downtime-cli
claude plugin install downtime@downtime-cli
downtime companion          # in a second pane; inside tmux this is automatic

The Claude Code plugin. The repository is its own marketplace. downtime config set claude.thresholdSeconds 20 waits longer; claude.trigger turn also counts the model thinking.

I checked the install path on Claude Code 2.1.323: claude plugin validate passes, and a local-marketplace install with --scope project into a throwaway CLAUDE_CONFIG_DIR lists the plugin as enabled. That config had no login, so the live runs loaded the same folder with claude -p --plugin-dir, which installs nothing. Inside tmux, a run with a 22-second Bash call opened a 16-line pane about 5 seconds after the threshold, and the pane closed itself when the call ended.

The wrapper

It stays out of the way when it should

dt runs the command with its output held back and the keyboard handed to the trivia. A command that ends inside 5 seconds prints exactly what it would have printed bare. Piped output, CI, TERM=dumb and DOWNTIME_DISABLE=1 turn it into a transparent pass-through. The exit code always comes back, and CI checks that exit 42 survives. Past 32 MB of held output it stops the game and streams instead. The plugin reuses this session loop as is: the companion swaps the child-process runner for one that watches the hook files and emits the same two events.

Limits

What it can't do

The companion only sees what the hooks report. With the default trigger it counts tool calls and subagents, so a long stretch of the model thinking shows nothing; the turn trigger covers that but also fires on short answers. A permission prompt waiting on you looks like a running tool. Outside tmux you open the second pane yourself. If Claude Code is killed mid-call the end event never comes, so entries older than 30 minutes are ignored. The hook costs about 47 ms of Node start-up per event, off Claude's critical path because it runs async, but it is CPU all the same. The tmux pane takes the keyboard focus when it opens.

Next

What I would do next

  • Read the Notification hook's permission prompts so the companion can say "Claude is waiting on you" and stop the round.
  • Learn how long each command usually takes and pick a question that fits the wait.
  • Open the pane without taking focus when Claude Code is mid-prompt, and measure whether people answer more or fewer questions that way.
Code
Node ES modules, no dependencies. src/claude/ holds the hook, the activity state and the companion.
Tests
72 with node --test; CI matrix Ubuntu and macOS by Node 18, 20, 22.
Benchmark
node bench/hook_latency.mjs: 60 runs, p50 46.5 ms, p95 48.9 ms, Apple M4, Node 26.

Fill the next wait