8000 GitHub - kamatthews/switcher · GitHub
[go: up one dir, main page]

Skip to content
kamatthewsPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

switcher

agent-switcher

One tmux screen for managing Claude agents. One tmux session holds every agent: a list on the left shows who needs your input, who has finished and is ready for review, who is working and who is done, and the agent you pick appears on the right as its real, live conversation. Each agent keeps running when you look away, and a waiting agent is one chord away.

Install

You need tmux (psmux on Windows), Python 3.12 and uv. Ghostty is recommended on Linux and macOS (the chords below use it).

Linux macOS Windows
Multiplexer tmux tmux psmux
Chords ctrl+super+arrows (Ghostty), ctrl+b then an arrow, ctrl+shift+arrows the same; Super is Command ctrl+alt+shift+arrows
Idle sleep, history view, switcher awake yes yes not yet
Notifications notify-send osascript toast
Install below below "On Windows" below

On macOS, Homebrew gives you all of it: brew install tmux uv jq and brew install --cask ghostty (jq is for the status-line snippet).

Install straight from GitHub, pinned to a release tag:

uv tool install git+https://github.com/kamatthews/switcher.git@v2.3.0
switcher setup

switcher setup creates an empty roster at ~/.config/blur-agents/roster.json and prints two optional snippets: the Ghostty keybinds (only if Ghostty is installed; otherwise it explains the ctrl+b and ctrl+shift+arrow keys, with the Terminal.app mappings on macOS) and the status line. For each it asks before touching your files, and the default answer is No. It never overwrites an existing roster or edits your tmux config, and it is safe to run again. --seed-roster FILE starts from a roster you already have.

To update, install the newer tag (add --force), then switcher restart.

From a clone, to work on it

git clone https://github.com/kamatthews/switcher.git
cd switcher
./install.sh

install.sh installs the clone in editable mode, so a git pull and switcher restart pick up changes, then runs switcher setup. It takes --seed-roster FILE.

On Windows

The switcher runs natively on Windows with psmux, a tmux clone that takes the same commands (it also installs itself as tmux). From PowerShell:

winget install marlocarlo.psmux
uv tool install --editable . --python 3.12   # from a clone; open a new terminal afterwards so PATH has psmux
switcher setup

What is different:

  • The switcher runs its own psmux server (-L switcher, or SWITCHER_SOCKET), started with PowerShell as its shell, so every pane command is PowerShell. A psmux server someone else started might use bash, which reads them wrongly.
  • The chords are ctrl+alt+shift+arrows (and ctrl+alt+shift+d to demote), typed as they are. Windows keeps ctrl+win+arrows for virtual desktops, and no terminal config is needed. Each chord starts PowerShell and then Python, so it takes about half a second.
  • Ending an outside session with A is a hard stop (Windows has no SIGTERM). Claude saves each message as it goes, so an idle agent resumes whole, and A asks before ending one that is working.
  • Agents never go to sleep: idle sleep, the history view of a sleeper and switcher awake are not on Windows yet. The stand-in needs a POSIX terminal, and the process tree is not read there.
  • ctrl+b then an arrow, and ctrl+shift+arrows, are not bound: nobody has tried them on psmux.
  • Notifications are Windows toasts. The status-line snippet works as it is in Git Bash with jq.
  • psmux applies some commands a moment after answering them (kill-pane, bind-key), so the tests wait for effects.

Use it

Command What it does
switcher up start the session (every agent in your roster resumes its conversation) and attach
switcher attach attach again from any terminal
switcher down end the session and every agent in it (--keep-terminal spares the agent you are typing in)
switcher restart start the list again (after a git pull, say); every agent keeps running
switcher status list the panes

From inside tmux, run NO_ATTACH=1 switcher up: the session is built either way, but tmux refuses to attach one session inside another.

If the list on the left closes (it crashed, or its pane was killed), the agents keep running. Run NO_ATTACH=1 switcher up from any shell inside tmux, or plain switcher up from a terminal outside tmux. It rebuilds the list around the agents that are still there and starts none of them a second time. If the right-hand side closes instead, the list puts the "Pick a session" placeholder back on its own.

Keys in the list

Key Does
↑ ↓ or j k move; the right-hand side follows
Enter go to that agent
Esc go back to the agent you were in, or clear the filter
Enter / Space on a group fold or unfold it
/ filter by name, group or folder
p pin or unpin in Active
D done with it: demote out of Active until the agent does new work
A / X add or remove an agent
G move the agent to another group
n notifications on or off
? the full key list

Chords from anywhere

These work from inside any conversation. They need the Ghostty keybinds from the install step. On macOS, Super is the Command key, so ctrl+super+↓ is ctrl+cmd+↓.

Chord Does
ctrl+super+↓ back to the list; press again to preview the next agent down (it skips group headers and wraps)
ctrl+super+← / → previous / next active agent
ctrl+super+↑ next agent that needs your input, then the next ready for review
ctrl+super+d done with the agent on screen: demote it out of Active and show the next Active agent (in the list, the same as D)

What the dots mean

The same four states as the Claude mobile app, plus asleep. Active lists them in this order, newest activity first within each, and groups use the same order:

Dot State
orange needs your input: a question or a permission prompt
violet ready for review: it finished a turn and you have not looked at it since
green working
grey done, and you have seen it
☾ (grey) asleep: done and unneeded for an hour, so its Claude was stopped to free memory (see below)

An agent counts as seen once it has been on the right-hand side, even as a preview while you move through the list, or once you demote it. The list remembers this in ~/.cache/blur-agents/review.json, so a restart keeps it. An agent that was already idle when the list first saw it counts as done.

No Ghostty, or a terminal that cannot send those chords (macOS Terminal.app has no Command modifier)? The tmux prefix does the same in any terminal: ctrl+b then ↓, ←, → or ↑. Like tmux's own prefix+arrows, ← → ↑ repeat: press the arrow again within half a second to keep walking, no second ctrl+b needed. In any tmux session other than the switcher's, prefix+arrows still move between panes as usual.

ctrl+shift+arrow does the same with no prefix. iTerm2, Kitty and WezTerm send it as is. Terminal.app sends a plain arrow until you map it: Terminal → Settings → Profiles → your profile → Keyboard, then + four times, each with the Control and Shift modifiers and the action "Send Text":

Key Send Text
Cursor Left \033[1;6D
Cursor Right \033[1;6C
Cursor Up \033[1;6A
Cursor Down \033[1;6B

Outside the switcher's session, ctrl+shift+arrows go on to the program as usual.

Sleeping agents

An agent that has been grey for an hour goes to sleep. Its Claude process exits, which frees roughly 0.5 GB with its MCP servers, and a stand-in takes its pane. The stand-in shows the agent's last screen, frozen, with a strip that says when it fell asleep and a prompt box below it. Its row in the list gets ☾ in place of the grey dot.

  • Type to wake it. Write in the stand-in's box and press Enter: the agent starts again with its whole conversation and your text as its first prompt. Esc wakes it with nothing sent. The box has no / commands or autocomplete. Just looking at a sleeper, even in the slot, does not wake it.

  • Scroll back through its conversation. It is drawn the way Claude Code draws a live one, and read from the agent's conversation file, so it reaches back past compactions (a live Claude keeps no tmux scrollback, which is why the frozen screen alone can't). Scrolling never wakes it, and the file is only read when you first scroll.

    Key Does
    mouse wheel, PgUp / PgDn scroll
    ↑ / ↓ jump to the previous / next prompt or incoming bridge message; ↓ past the newest returns to the last screen
    Home / End the oldest line / back to the last screen
    ctrl+o expand each tool call and long prompts, or fold them again, as in Claude Code
    ctrl+s summary: only your prompts, bridge messages, and how each piece of work ended (folded; ctrl+o shows it whole). ctrl+s again shows everything

    What it adds to Claude Code's own view, for reading back:

    • a time on every prompt, and a line where the day changes;
    • the prompt you are reading under stays pinned on the top row once it scrolls off;
    • bridge messages as their own lines, ← in and → out, coloured by intent (ASK amber, FYI teal, DONE green);
    • the recaps (※) and turn times (✻) Claude Code records, and each compaction with its trigger and size;
    • a run of tool calls as one grey line that names the files edited; a background command that failed is red.
  • A bridge ASK wakes it by itself, with /bridge:bridge-inbox as its first prompt. An FYI or DONE waits until it wakes for another reason. A bridge wake notice for a turn the agent subscribed to also wakes it.

  • What never sleeps: an agent that needs input, is ready for review, is working, is in the slot, or has a background shell or Monitor running. The hour counts from when it went grey or from when you last looked at it, whichever is later.

  • switcher awake [DURATION|off] lets an agent keep itself awake (default 4h), for a long run nothing else shows, such as a test-station lease. The flag runs out by itself; running it again extends it. switcher setup offers a Claude Code rule (switcher/extras/awake-rule.md) that tells agents about it.

  • Restarts: sleepers stay asleep across a list restart, switcher down and up, and a reboot: up starts their stand-ins, not their Claude. Removing an agent with X forgets that it was asleep.

While an agent sleeps, ~/.claude/bridge/sessions/<session id>.asleep says so, which bridge's who shows.

Adding agents

Press A. Pick a Claude session that is already running somewhere else to move it into the switcher, or choose "new agent in a folder" to start one. Either way you can put it in a group, and its conversation resumes if you restart. You can also use switcher add NAME FOLDER from a shell. New agents start with --dangerously-skip-permissions; set "permissions": "normal" on a roster entry to change that.

Groups

The list shows Active agents first, then one collapsible section per group, then Other. Press G to move an agent to another group (or make a new one). Groups are stored as a group field on each roster entry, so you can edit ~/.config/blur-agents/roster.json by hand too.

Usage line and the status-line snippet

The bottom of the list shows your account and 5-hour and 7-day usage, like 5h 17% 4h40m 7d 49% 2d09h. The model and context-% columns come from the same place. They need one small addition to your Claude Code status-line script: switcher/extras/statusline-snippet.sh (switcher setup prints it and can append it for you). Without it those columns stay empty and the usage line says "no data yet"; everything else works.

6E59 Ghostty keybinds

tmux cannot see the Super key, so Ghostty sends each ctrl+super chord as ctrl+alt+shift, which the switcher binds. Add these lines to ~/.config/ghostty/config (switcher setup offers to). Ghostty on macOS reads that file too, alongside ~/Library/Application Support/com.mitchellh.ghostty/config:

keybind = ctrl+super+left=csi:1;8D
keybind = ctrl+super+right=csi:1;8C
keybind = ctrl+super+up=csi:1;8A
keybind = ctrl+super+down=csi:1;8B
keybind = ctrl+super+d=csi:100;8u

On GNOME, ctrl+super+d is also one of the three "show desktop" keys, so GNOME takes it before Ghostty sees it. Free just that one (super+d and ctrl+alt+d still show the desktop):

gsettings set org.gnome.desktop.wm.keybindings show-desktop "['<Super>d', '<Primary><Alt>d']"

macOS

The switcher runs the same on macOS, sleep included. The differences are underneath: it reads the process table with ps (macOS has no /proc), and the "waiting" notifications go through osascript instead of notify-send. The first notification may make macOS ask whether your terminal can send notifications; allow it in System Settings → Notifications if you missed the prompt.

Development

uv run pytest -q runs the tests (if your shell still has PYTHONPATH or SWITCHER_BIN from the old switcher, use env -u PYTHONPATH -u SWITCHER_BIN uv run pytest -q). They use private tmux servers and a throwaway HOME, so they never touch your running session or config.

Releasing

The git tag is the version. Add a ## [X.Y.Z] section to CHANGELOG.md, commit, then push an annotated vX.Y.Z tag.

Licence

MIT, see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0