# Claude Accounts A Herdr mod for running Claude Code as several accounts. The window's head shows a 5h and 7d gauge for every account, then a 26 px chip naming the account the focused Claude Code agent runs under; clicking the chip opens a 300 px popup listing every account with its email and 5h/7d usage, with rows to make one the account new sessions start under, resume the current session as another account in a pane beside it, or add an account. The same logic is a shell command, `cca`, so an SSH session from a phone can list accounts and start Claude Code under any of them. Everything is an ink-grey console with one amber accent; the amber radio marks the account new sessions open as. ![Claude Accounts](preview.png) ## What you see - **Chip** (26 px tall, radius 13, `#11141c`, 1 px `#1d212b` hairline, hover `#161a24`): 3 px left and 10 px right padding, 6 px gaps, tooltip "Claude accounts". A 20 px round avatar (`#1a1e28`, the account name's first letter, Nunito 11 px bold `#eef0f5`), the account name (Nunito 13 px semibold `#eef0f5`) and "▾" (Nunito 10 px, `#7a8296`). The chip role fills a 44 px tall head block: each account's gauges (the name in Nunito 12 px bold, `#eef0f5` on the focused pane's account else `#7a8296`; 8 px; the 5h gauge; 8 px; the 7d gauge), a 1 × 16 px `#1d212b` divider between accounts, 16 px gaps, then the chip, all right-aligned with 20 px on the right. A gauge is the label (Nunito 11 px bold `#7a8296`), 4 px, a 44 × 4 px bar (radius 2, `#1d212b` track, fill `#a3a9b8` or `#e5484d` from 90 %, 1 px `#07080d` ticks at 11, 22 and 33 px), 4 px, the percentage (Geist Mono 12 px, `#eef0f5` on the focused pane's account else `#a3a9b8`, `#e5484d` from 90 %) and, from 90 %, `↻ HH:MM` (Geist Mono 12 px, `#7a8296`). Every group is `flex_none`, so nothing shrinks: the block wants about 410 px for one account and about 290 px more for each further account, and a narrower block cuts off the leftmost gauges. - **Rail avatars** (40 px each, radius 20, stacked from the bottom with 8 px gaps and 8 px below the last): one per account. Three fixed ring slots, 3 px wide, at radius 18.5, 14 and 9.5 (4.5 px apart, so 1.5 px of gap; the outermost touches the 40 px edge), filled from the outside: the 5h window in the outer slot and the 7d window in the next, so a ring keeps its size and place whatever the count, and fewer windows only leave the inner slots empty. Every track is drawn in full (`#c4c8d2`) so each avatar keeps the same outer edge, and the used part runs clockwise from 12 o'clock in `#5b9cf5`, or `#e5484d` from 90 %. A window with no usage file leaves its track empty. The middle is a 7.5 px radius disc (`#1a1e28`, hover `#161a24`) with the label's first letter in uppercase (Nunito 10 px semibold): the account of the focused Claude Code pane goes first (on top) with its disc filled amber `#f2a93b` (no hover change) and its letter in `#07080d`; with no Claude Code pane focused, or before the read for the pane focused now has come back, the list order stays and no disc is amber; otherwise `#eef0f5` on the account new sessions open as and `#7a8296` on the others. The tooltip is `label · 5h 12% · 7d 9%`, `label · 5h –` for a window that has no file, `label · 5h 92% ↻ 14:30` (the weekday when the reset is more than a day away) once a window is at 90 % or more, then ` · this pane` on the focused pane's account and ` · new sessions` on the global default; a read failure puts the error there instead. Clicking opens the same popup as the chip. - **Popup** (300 px wide, radius 10, `#11141c`, 1 px `#1d212b` frame and shadow; 6 px padding): - a 24 px header, "New sessions open as" (Nunito 11 px semibold `#7a8296`), 8 px inset; - one 44 px row per account, 8 px side padding, radius 8, 8 px gaps, hover `#161a24`, tooltip `New sessions open as `; a 14 px column with a 12 px radio (1.5 px ring, `#3a404e`; amber `#f2a93b` with a 6 px dot on the account new sessions open as), a 20 px round avatar (`#1a1e28`, first letter, Nunito 10 px bold), then two lines: the account name (Nunito 13 px bold `#eef0f5`) with a `this pane` badge (Geist Mono 10 px `#7a8296`) when it is the focused pane's account, and the signed-in email (Geist Mono 11 px `#7a8296`, truncated; "not signed in" when none); right-aligned `5h 12% · 7d 9%` (Geist Mono 10.5 px `#7a8296`; the 5h percentage turns `#e5484d` at 100 %; a window used 90 % or more adds ` ↻HH:MM`; "no usage yet" when the account has no usage file), replaced on hover by a 16 px pencil that opens an inline rename (Nunito 13 px input, with `↩ save · esc cancel` in an 18 px line below the row); - a 1 px `#1d212b` divider, 6 px above and below, 2 px inset; - when the focused agent is a local Claude Code process with a session file, a 24 px "Continue this session as" header (Nunito 11 px semibold `#7a8296`) and one 32 px row per other account, 8 px side padding, radius 8, hover `#161a24`, tooltip `Resume this session as `: a 14 px spacer, a 20 px avatar (`#1a1e28`, first letter, Nunito 10 px bold), the name (Nunito 13 px bold `#a3a9b8`), and "resume in pane" at the right (Geist Mono 11 px `#7a8296`); - a 32 px "+ Add account…" row (30 px left and 8 px right padding, radius 8, Nunito 12 px semibold `#a3a9b8`), hover `#161a24`. - **Add account popup** (260 × 170, 14 px padding, 8 px gaps): "Add account" (Nunito 14 px bold `#eef0f5`), "Creates ~/.claude-accounts/" (Nunito 11 px `#7a8296`), a 32 px input (`#1a1e28`, 1 px `#1d212b`, Nunito 13 px), an error line in `#e5484d` when there is one, and two 30 px buttons at the right: Cancel (`#1a1e28` with a `#1d212b` border) and "Create" (`#f2a93b` with dark `#0b0d14` text). - **The shell** (`cca`) is text only: a marker `*`, the name (or `label (name)` when the account has a label), email, 5h and 7d cells, and "Most 5h headroom: ", about 60 columns. It colours only when stdout is a terminal and `NO_COLOR` is unset. ## How it behaves - **Reading accounts**: on start, every 30 s and whenever the focused agent's pid changes, the mod runs `cca --porcelain ` (no pid when no local Claude Code agent is focused) and parses its tab-separated lines: `C` the account of that process (from the last `CLAUDE_CONFIG_DIR=` token in `ps -E -ww -p -o command=`; no token or `$HOME/.claude` is `default`, `$HOME/.claude-accounts/` is ``; an id in `models.json` when the pane runs a custom model), `D` the global default for new sessions from `${XDG_STATE_HOME:-$HOME/.local/state}/herdr-tower/current` (`default` when absent or unusable), `A` an account and its email from `~/.claude.json` / `/.claude.json` (`oauthAccount.emailAddress`, else "not signed in"), `U` the five_hour and seven_day used percentage and reset epoch from `${XDG_STATE_HOME:-$HOME/.local/state}/herdr-tower/usage/.json` (8 tab fields; the last two carry the Fable window and are not read), `L` an account's display label from `${XDG_STATE_HOME:-$HOME/.local/state}/herdr-tower/labels` (shown as `label (name)`), and `S` the focused pid's session id and cwd from `$HOME/.claude/sessions/.json`. The other line kinds the vendored `cca` can print (`P`, `M`, `X`, `V`, `Q`, `Y`) are ignored. A failed read keeps the last table; a `cca` that cannot be run (exit 127 or a rejected `exec`) shows `?` on the chip with tooltip `cca not found: ` and a one-line error row in the popup instead of the table. A read asked for while another read is running — a `cca use` or a rename right after a timer read — runs as soon as that read ends instead of being dropped until the next 30 s tick. - **Spent windows**: a window whose reset epoch is in the past counts as 0 % and has no reset time. The reset time is shown only once a window is at 90 % or more. - **Most 5h headroom**: the lowest live 5h percentage among accounts with a five-hour window; `cca ls` names it and `cca ls --json` sets `best`. The popup draws no headroom mark; its amber radio is the account new sessions open as. - **Clicking the chip**: opens the accounts popup above the layout, sized `12 + 24 + 44 × accounts + (13 + 24 + 32 × resumeRows when a session is known) + 13 + 32 + 18`, and hands it the chip's own table so the popup renders filled at once. - **Clicking an account row**: runs `cca use ` and leaves the popup open so the radio moves; a failure shows its message in a red line below the account rows. The name must pass `^[A-Za-z0-9_-]+$`, and running agents keep their own account. (The default account must run with the variable unset: set to `~/.claude`, Claude Code reads `~/.claude/.claude.json` rather than `~/.claude.json` and starts empty. `CCA_ACCOUNT` makes a new agent started from the add form or a resume row win over the shell hook's global default.) - **Clicking a resume row**: closes the popup and runs `pane.split {direction: "right", argv: ["sh","-lc","cd '' || exit 1; exec claude --resume "]}` beside the focused pane, so the old pane keeps running. The id must pass a UUID test and `cwd` must be present; `` is `unset CLAUDE_CONFIG_DIR; CCA_ACCOUNT=default` for `default` and `CLAUDE_CONFIG_DIR="$HOME/.claude-accounts/" CCA_ACCOUNT=` otherwise. `pane.split` has no folder argument, so the shell `cd`s first; `|| exit 1` ends that shell when the `cd` fails, so a stale `cwd` cannot resume the session in the wrong folder (an `&&` chain would not do it: the default env's `;` ends the chain). When the focused pane belongs to a space on another Herdr machine the row refuses with "Accounts live on this computer: focus one of its panes first." in the red line below the account rows, because a split of that pane would start Claude on the other machine. - **Clicking "+ Add account…"**: opens the add form. Create rejects anything but `A-Z a-z 0-9 _ -`, the reserved `default`, the command names `ls`, `add`, `share` and `help`, and any name starting with `-` (` is a cca command.`); on success it closes both popups and opens the new account the same way, ready for `claude`'s login. An invalid or existing name stays in the form with the reason (exit codes 2, 3, 4, 5 from `cca --porcelain-add`). When the focused pane belongs to a space on another Herdr machine, Create refuses with "Accounts live on this computer: focus one of its panes first." in the form's error line, because the new agent would start on the other machine. - **`cca`**: - `cca` / `cca ls` lists `default` first, then every `~/.claude-accounts/*` whose name is valid, marks the current shell's account (from its own `CLAUDE_CONFIG_DIR`), and prints "Most 5h headroom: " (or `–`). - `cca [args…]` validates the name, requires the account folder, sets or unsets `CLAUDE_CONFIG_DIR`, exports `CCA_ACCOUNT=` so the choice outranks the shell hook, and `exec`s `claude` with the remaining arguments, so `cca work -c` continues the latest conversation in the current folder as `work`. - `cca use ` makes `` the global default for every session started afterwards, writing the name as one line to `${XDG_STATE_HOME:-$HOME/.local/state}/herdr-tower/current` through a temp file and `mv`. Exit 0 on success, 2 for a bad or reserved name, 3 when `~/.claude-accounts/` does not exist (`default` always does). `cca current` prints that default, or `default` when the file is missing, invalid, or names a since-deleted account. Running sessions are never changed. - `cca shell-init` prints a `claude()` function for zsh, bash and sh. With `CLAUDE_CONFIG_DIR` and `CCA_ACCOUNT` both unset it reads the choice file with the shell's builtin `read` (no process is started) and runs the real `claude` with `CLAUDE_CONFIG_DIR="$HOME/.claude-accounts/"` when the name is an existing non-default account, otherwise unchanged. `cca ` and the mod's rows export `CCA_ACCOUNT`, so an explicit choice wins over the default. - `cca ls --json` prints one line of JSON for tidemark: `{"current":"","accounts":[{"name","email","five_hour":{"used","resets_at"},"seven_day","updated_at","best"}]}`. `used` is a percentage and periods are epoch seconds; a window past its reset reads `used` 0 with `resets_at` kept; `email` is `null` when not signed in; `updated_at` is `null` without a usage file; `best` is the most 5h headroom, by the table's first-lowest rule; `current` is the global default. It escapes strings, needs no terminal, and prints valid JSON with no accounts or usage files. - `cca add ` makes the folder and links everything in `~/.claude` into it except `.credentials.json`, `.claude.json`, `shell-snapshots`, `statsig`, `ide`, `debug`, `backups`, `telemetry`, `cache`, `transcripts`, `jobs`, `logs`, `daemon*`, `.session-stats.json`, `.last-*` and `*.lock`. It first creates the shared history entries under `~/.claude` (`projects`, `file-history`, `todos`, `plans`, `tasks`, `teams`, `paste-cache`, `session-env`, `sessions`, and `history.jsonl` as a file) so Claude Code cannot keep a private copy. Any failure removes the half-made folder. - `cca share [--dry-run] ` walks the same shared entries in an account made before sharing existed. A real directory is merged into `~/.claude` with `cp -Rn` (never overwriting), `history.jsonl` is appended, the account's original is moved to `.pre-share-`, and the entry is replaced by a symlink to `~/.claude`. An entry absent in the account is simply linked; an existing symlink to `~/.claude/` is reported as already shared and skipped, while a link anywhere else is an error (` links elsewhere: `) and is left alone. Before a merge or append, `share` checks that `.pre-share-` is free, so a failure cannot leave a second copy of `history.jsonl` behind on a rerun. `--dry-run` prints the plan and changes nothing. - `cca codex use ` / `cca codex add ` make a `~/.codex-accounts/` login the default for new Codex sessions or create one; `cca shell-init` prints a `codex()` function beside `claude()` that applies it through `CODEX_HOME`. - `cca help` prints the commands; `cca --porcelain [pid]`, `cca --porcelain-add `, `cca --porcelain-add-codex `, `cca --porcelain-add-model