Contents

🍸 Landed here by accident? One of the agents in this post lives on IRC, which in 2026 still works just fine: click here and go back to 1995 → — and why I keep doing IRC things is written here.

On a Raspberry Pi at home a handful of Claude Code sessions run in tmux and never quit. One is bridged to IRC, one is a study assistant on Telegram, one looks after the kids’ Batocera box, one triages the alarms of my server. Each of them has to hear things: a message in a channel, a voice note, a disk filling up.

Claude Code has a tool for that, Monitor: run a command, every line it prints becomes an event. But a Monitor expires after half an hour, so a session that listens all day re-arms each watch twice an hour, and each re-arm costs a turn for nothing. Four streams, four sessions: that’s a lot of tokens to stay where you already were.

So I wrote watchd with Claude Code: a mod, Claude Code’s own plugin format with a hooks module, that runs the watches for as long as the session lives.

How it works

You don’t configure it, you ask. The plugin ships a skill, so in any session:

watch the nginx error log and tell me about 5xx

Claude writes the watch, tries the command by hand, checks that it started, and keeps it quiet: every line a watch prints is something the model reads, so the filtering happens in the command, not in the model. What it writes ends up in the project’s .claude/watchd.json:

{
  "watches": [
    { "name": "irc", "argv": ["bash", "tools/tail-irc.sh"] },
    { "name": "tg",  "command": "tail -F -n0 bot.stdout.log | grep --line-buffered '^MSG '",
      "seen": ["python3", "claude-tgbot/hooks/turn.py", "--seen", "var/tgbot"] }
  ]
}

Every line a watch prints reaches the model, prefixed with the watch’s name. The file is re-read every five seconds: add an entry and it starts, remove it and it stops. A watch that dies is restarted; one that keeps dying is given up, and both are reported. The status line says watchd 5/5, and /watchd lists each watch with its state, its traffic and its last line.

graph LR irc[IRC bridge] --> watchd tg[Telegram bridge] --> watchd alarms[alarms] --> watchd watchd -->|idle: a new turn| model[Claude] watchd -->|busy: between tool calls| model watchd -.->|seen| tg

Deaf for fifteen minutes

The first version handed every event to Claude Code as a plugin prompt. It worked well while the sessions were mostly idle, then one night the study assistant went into a long turn, capturing anatomy screenshots in a browser, and went deaf: fifteen minutes of messages, nobody home.

The reason is in the API’s own docs: a plugin prompt is “a turn of its own, once the session is idle”. While a turn runs it waits in a queue. And my code waited for each submit before sending the next, so the first queued prompt held back every line behind it.

The fix is a hook. After each batch of tool calls Claude Code runs PostToolBatch, and a hook there can hand the model extra context before its next request. So now watchd keeps track of whether a turn is running: idle, it submits a prompt as before; busy, it holds the lines and gives them to the model after the next batch of tools. Nothing is interrupted, the model reads the message at the first break and decides whether it matters.

The 👀

The Telegram bridge puts a 👀 on every message once the agent has read it, so whoever wrote knows they’ve been heard. It hooked the moment a prompt is submitted, and the moment a turn ends. Events delivered between tool calls pass through neither, so the 👀 arrived at the end of the turn, which on a long turn means never, as far as the person waiting is concerned.

Now each watch can name a seen command: watchd runs it with the lines it has just delivered on its stdin, and the bridge reacts right then. Two things broke on the way. The reaction ran in a detached child, which died with the process watchd had spawned, so the 👀 was recorded and never sent. And the end-of-turn fallback scanned the last 512 KB of the transcript for anything that looked like a message, so an agent that had merely grepped another bot’s log reacted to that bot’s messages, while a real message delivered early in a turn heavy with screenshots fell out of the window. Now it reads back to the start of the current turn, and only what was actually handed to the model.

Measured afterwards: a message sent to an idle session gets its 👀 in under a second; during a turn, at the end of the tool call that was running, five seconds in my test.

The structural fix that isn’t there

Tracking the turn by hand is fragile: when the mod reloads, the new code doesn’t know whether a turn is already running. The clean way out would be to let Claude Code’s own queue decide, the way it does for messages between sessions, which get into a running turn by themselves. So I tried having the session send each event to itself. The answer was unambiguous:

'vjt-claude-88' is this session itself — "vjt-claude-88" is the name other
sessions use to message YOU; there is no one else by that name to send to.

There’s no call that says whether a turn is running, no way to take back a queued prompt, and no messaging yourself. So watchd keeps tracking the turn, and the gap stays where it is: only when the mod reloads, which it does only when its files change. I can live with that.

The other bug of the night

The same night, the Telegram permission buttons, the ones an agent uses to ask me whether it may run something, froze the study assistant for nine minutes. I tapped “always” five times and nothing happened. The handler that writes the answer for the waiting hook existed; nobody called it. Every tap went out as a plain event, the hook waited for a file that never came. Three lines to fix, and a reminder that writing a function and wiring it are two different things.

Try it

watchd is on GitHub, MIT: vjt/claude-watchd. The repository is its own plugin marketplace, so it’s one line at the prompt of any Claude Code session:

/plugin install watchd --marketplace vjt/claude-watchd

Then ask the session to watch something. It does nothing in a project with no watches, so it’s safe to install everywhere.

🍸 IRC is still there, and it’s one of the places these agents listen. If you want to see what it looks like today: grappa.chat — pick a name, click a room, and you’re in 1995 without installing anything. The reason for all of this is written here.