DEV Community

Cover image for I built a pixel office for my Claude Code agents
Harpreet
Harpreet

Posted on

I built a pixel office for my Claude Code agents

I usually have three or four Claude Code sessions running at once. One fixes a test, one writes docs, one refactors something I'll regret. And one of them is always quietly sitting on a permission prompt in a terminal tab I'm not looking at.

So I built Claude Room: a little pixel-art office where every Claude Code session is a worker at a desk. When an agent edits a file, it types. When it runs a command, it walks to the server rack. When it needs your permission, it walks to your desk and waits in line.

Claude Room: tests pass and confetti falls, a commit rings a bell, a push launches a rocket

Nothing in it is faked. Every movement comes from a real Claude Code hook event. Here's how it works.

npx claude-room
Enter fullscreen mode Exit fullscreen mode

The whole thing in one picture

Claude Code ──hook──▶ emit.mjs ──HTTP POST──▶ local server ──WebSocket──▶ browser (PixiJS)
 (any session)        (tiny, silent)          localhost:4777               the office
Enter fullscreen mode Exit fullscreen mode

Four parts, each with one job:

  1. Hooks: Claude Code runs a command on every event.
  2. A tiny emitter script: forwards the event and gets out of the way.
  3. A local server: turns raw events into "what is this worker doing", stores history, and pushes updates.
  4. A PixiJS page: draws the office and animates the workers.

1. Hooks: Claude Code already tells you everything

Claude Code has hooks: commands it runs on events like SessionStart, PreToolUse, PostToolUse, PermissionRequest, SubagentStart and Stop. Each hook gets the event as JSON on stdin: the session id, the working folder, the tool name and its input.

Claude Room listens to 13 of them, all pointing at the same script:

{
  "hooks": {
    "PreToolUse": [
      { "matcher": "*", "hooks": [{ "type": "command", "command": "node ~/.claude-room/emit.mjs", "timeout": 5 }] }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

That's it. No API keys, no wrapping Claude Code, no screen scraping.

2. The emitter: the one rule is "Claude must not notice"

This was the most important design rule. A visualizer that slows down or breaks your coding agent is worse than useless. So the emitter:

  • never prints to stdout (hook output can be read by Claude Code),
  • never throws,
  • gives up after about a second,
  • exits 0 no matter what.

Here's the core of it, trimmed:

async function main() {
  try {
    const text = await readStdin();           // the hook event, with a 2 s cap
    if (!text.trim()) return;
    const body = JSON.stringify(shrinkPayload(JSON.parse(text)));
    await send(body);                         // POST to 127.0.0.1:4777/event, 1 s timeout
  } catch {
    // Intentionally silent: a visualizer must never disturb Claude Code.
  }
}

void main().finally(() => process.exit(0));
Enter fullscreen mode Exit fullscreen mode

shrinkPayload cuts huge tool inputs (think a 5,000-line file write) down before sending. If the office isn't running, the POST fails, and nothing happens: the session carries on exactly as before.

It's also bundled as a single standalone .mjs file with no dependencies, so starting it is as cheap as Node allows.

3. The server: from raw events to "what is this worker doing?"

Raw hook JSON isn't something you can animate. The server turns each event into a small RoomEvent with a kind (session start, tool start, needs boss…) and an activity.

The mapping from tools to office activities is just a table:

const DESCRIBERS = {
  Edit:      (i) => ({ kind: 'typing',    label: fileLabel('Editing', i) }),
  Write:     (i) => ({ kind: 'typing',    label: fileLabel('Writing', i) }),
  Read:      (i) => ({ kind: 'reading',   label: fileLabel('Reading', i) }),
  Grep:      (i) => ({ kind: 'searching', label: `Searching: ${i.pattern}` }),
  Bash:      (i) => ({ kind: 'terminal',  label: i.description ?? `$ ${i.command}` }),
  WebSearch: (i) => ({ kind: 'browsing',  label: `Searching web: ${i.query}` }),
  Task:      (i) => ({ kind: 'delegating', label: `Delegating: ${i.description}` }),
};
Enter fullscreen mode Exit fullscreen mode

typing means sit at your desk, reading means walk to the bookshelf, terminal means the server rack, browsing means look out of the window. MCP tools (mcp__…) get a courier who walks in with a parcel.

Every payload is validated with zod first (safeParse, never parse): hook payloads change between Claude Code versions, and a bad event should be dropped, not crash the office.

A few things I learned here:

  • Projects come from the working folder. Agents running in a git worktree (repo/.claude/worktrees/agent-123) first showed up as their own fake project. Now they're folded back into the real repo.
  • Store events, not state. Events go into SQLite. The office state is rebuilt from them, which makes replay, "while you were away" and weekly stats almost free.
  • Redact early. Commands can contain secrets. API_KEY=… shows as API_KEY=*** before it ever reaches the page.

4. WebSocket: boring on purpose

The browser opens one WebSocket. On connect it gets a "hello" with the current state, then small updates as events arrive.

The interesting part was keeping it healthy for days in a background tab:

  • A heartbeat every 25 s. A laptop that went to sleep leaves "zombie" connections. A client that didn't answer the last ping gets dropped, and the page reconnects and gets a fresh hello.
  • A cap on queued bytes. A frozen tab that stops reading would otherwise grow the server's memory forever. Over 4 MB queued, that client is dropped.
const deliver = (ws, data) => {
  if (ws.readyState !== ws.OPEN) return;
  if (ws.bufferedAmount > MAX_BUFFERED_BYTES) return void ws.terminate();
  ws.send(data);
};
Enter fullscreen mode Exit fullscreen mode

5. PixiJS: a 1080×810 office

The page is a fixed 1080×810 world drawn with PixiJS 8 and scaled to fit, which keeps pixel art crisp at any size. A Director turns room events into what each Character should do: walk to a spot, sit, type, wave, queue at the boss desk.

Some details that made it feel alive:

  • The boss queue. A PermissionRequest sends the worker to your desk with a speech bubble: "Can I run: npm test?" Several waiting agents form an actual line.
  • Reactions to real events. Tests pass: confetti. git commit: a bell. git push: a rocket past the window. On a break, two agents chat at the coffee machine about what they really did ("Finally got the tests green").
  • A stuck detector. If the same command fails three times within ten minutes, the same file keeps getting edited between failures, or a working agent goes quiet for ten minutes, the worker gets a red "!" and the monitor says why.
  • Worlds drawn in code. Besides the painted classic office there's a space station, a snowy cabin and a neon loft. Each is one recipe file (palette, walls, furniture, lighting, outfits) rendered into a pixel buffer. No image files.

Privacy: everything stays on your machine

The server binds to 127.0.0.1 by default. Nothing is sent anywhere unless you turn on an opt-in like the GitHub panel. The installer shows exactly what it will add to ~/.claude/settings.json, makes a backup, and asks first. There's also a Claude Code plugin that writes nothing to your settings at all.

The fun part: I built it with Claude Code

Most of Claude Room was written by Claude Code itself, with me reviewing. The best moment: one night I left a multi-agent workflow running (44 agents implementing, reviewing and fixing features one PR at a time) and watched them in Claude Room while they built the next features of Claude Room.

Try it

npx claude-room
Enter fullscreen mode Exit fullscreen mode

Then start (or restart) Claude Code in any project and your agents walk in. There's also a live demo in the browser with no install.

Claude Room is an unofficial community project, not affiliated with Anthropic.

I'd love to hear what you'd want your agents' office to show. Drop a comment!

Top comments (0)