Skip to main content

unit tests

AgentCommandTab

A macOS menu bar app that lists the iTerm2 windows and tabs, and the tmux sessions and windows, where AI coding agents run (Claude Code, OpenAI Codex CLI, and others), shows what each agent is doing, and lets you rename, focus, reorder and move those tabs without interrupting the agents.

What it does

  • One tree of your agents: every iTerm2 window and tmux session with at least one agent tab, with its tabs below it, grouped by monitor when you have several. Tabs without an agent are left out.
  • What each agent is doing: a status dot and word per tab (asking a question or for permission, thinking, running a tool, running in the background, done, new, idle, paused, error), the context size in tokens and its share of the context window, and optionally when it started, how long it has run, its memory and CPU use. "Done" stays until you look at the tab, and a Claude Code session is "new" until you send it its first message. The menu bar icon counts the agents waiting for your answer.
  • Process rows: a tab whose agent started processes has an arrow that opens a row for each of them (right-click one for Info or Kill). The button at the top right collapses or expands all windows.
  • Control: double-click to bring a window or tab to the front; press and hold to peek at a tab; rename in place; drag tabs between windows and windows between monitors; start a new agent window or tab; duplicate a tab; type /compact or /clear into an agent waiting at its prompt; end an agent's process; pause agents (with every process they started) before going offline and resume them later, per tab, window or monitor from the right-click menu, or for the selected rows with the button at the bottom right. Select several rows (Command-click, Shift-click) to act on all their agents at once (a busy agent gets /compact or /clear when its turn ends), or to ask them to talk to each other: each gets your note and how to message the others.
  • Session info: right-click a tab row for "Session info", a window with the session's name and its agent's process ID, its age, tab, folder, conversation ID and file, context size, CPU and memory use, and command line, in text you can select and copy. "Copy contact info", below it, copies text to paste into another agent session so that it can message this one: a Claude Code session's name for the SendMessage tool, which only another Claude Code session has, or a Codex session's codex queue command, which any agent that can run commands can use.
  • Saved sessions: save Claude Code and Codex sessions before a reboot, or to come back to them later: right-click a tab row for "Save session", or a window or monitor row, or one of several selected rows, for "Save 3 sessions" (with the number it can save). "Restore sessions…", right below it (grayed out until something is saved) and in the menu bar icon's right-click menu once something is saved, opens the Saved sessions window: the saved sessions under the windows they were saved from, to restore, rename (double-click a name, or select its row and press Return, Command-R or Command-Shift-R) or delete. A restored session continues its conversation (--resume for Claude Code, resume for Codex, after the launch command in Settings) in its own tab when that tab waits at a shell prompt (iTerm2 brings its tabs back after a reboot; a tmux pane counts while its tmux session runs), else in a new tab beside the others of its window, else in a new window. A name you gave a tab or window goes back to it. A restored session leaves the list once its agent runs in its tab; one that couldn't be restored, or whose agent didn't start within 15 seconds, stays, and an alert says why.
  • Keyboard: Return shows the selected tab or window, Delete ends its agent (asking first), R, Command-R or Command-Shift-R renames it, the Right and Left arrows open and close a tab's process rows, Command-E or Command-Shift-E collapses or expands all windows, typing a name's first letters selects its row, Command-comma opens Settings, and Esc closes the list.
  • Sort and filter: sort by status, name, share of the context window, start time, memory or CPU use, or keep the tab order; hide the idle tabs with one click or Command-I (new ones stay).
  • Your choice of view: a dropdown under the menu bar icon, a sidebar that hides at the screen's edge or stays visible (optionally keeping iTerm2 windows out of its way), or a regular window (optionally always on top).
  • A shortcut from any app: Shift-Command-Tab (or Command-Fn-Tab, chosen in Settings) shows the list with the first agent waiting for your answer selected (or, while none is, the tab in front), and hides it when pressed again. While macOS's app switcher is open, the keys still go to it.

Requirements

  • macOS, with iTerm2 3.7 or later and iTerm2's Python API turned on (iTerm2 > Settings > General > Magic > Enable Python API), or tmux 3.2 or later, or both.
  • Python 3.10 or later (for an install with pip or pipx).

tmux

Agents running inside tmux, in any terminal app, are listed next to iTerm2's. Each tmux session is a window row, labeled "tmux:", and each of its tmux windows a tab row, judged by its first pane (as an iTerm2 tab is). The app reads the default tmux server (the one a plain tmux command uses) once a second.

Almost everything works as in iTerm2: the states, process rows, /compact and /clear, Talk to Each Other, rename, new tabs and windows, Duplicate, moving a tab within a session or into another session, and Close. Some differences:

  • tmux doesn't report agent states, so the app takes Claude Code's own report of each session, and for Codex the turn timer on its screen (a Codex approval request doesn't show as asking). Agent tools other than Claude Code and Codex aren't recognized in tmux.
  • A tmux session has no window of its own, so it is listed with the menu-bar monitor and can't be moved to another monitor, and a tab can't move between iTerm2 and tmux.
  • Showing a tab selects it in tmux and switches an attached client to its session, then brings that client's terminal to the front (its iTerm2 tab, or any other terminal app). With no client attached, the app says how to attach one.
  • The app can't tell which tab of a terminal app other than iTerm2 is in front, so a "done" tab whose tmux client runs there stays "done" until you show it from the list.
  • Agents in tmux can't be paused: tmux restarts a stopped pane's shell at once, which would then take the terminal from the agent.
  • Typing into an agent (/compact, /clear, Talk to Each Other) is refused in a tmux window with synchronize-panes on, since the keys would reach its other panes too, and while its pane is in copy mode, which would take the keys.

Install

The python3 that comes with macOS is too old (3.9), so install with pipx, which Homebrew installs along with a recent Python:

brew install pipx
pipx ensurepath                  # puts pipx's programs on your PATH; open a new terminal tab afterwards
pipx install agent-command-tab

Then, once:

  1. Turn on iTerm2's Python API: iTerm2 > Settings > General > Magic > Enable Python API.
  2. Start the app from an iTerm2 tab: agent-command-tab. iTerm2 asks whether to let it use the Python API: allow it. From then on, iTerm2 starts the app whenever iTerm2 starts.
  3. Click the "C" in the menu bar. If the list's bottom bar says the hooks aren't installed, click Install Hooks; for Codex, then type /hooks in Codex and approve them. Agent sessions started afterwards report to the app.
  4. Optionally, for the Shift-Command-Tab shortcut, give iTerm2 the Accessibility permission (System Settings > Privacy & Security > Accessibility).

If a Homebrew upgrade removes the Python version that pipx made the app's environment with, the app no longer starts, and a copy still running says in its bottom bar that the hooks can't run. pipx reinstall agent-command-tab fixes both.

From a clone of this repository:

python3 -m venv .venv && .venv/bin/pip install -e .

Use

agent-command-tab                # the menu bar app; restarts itself if iTerm2's connection drops
agent-command-tab dump-snapshot  # prints the current list as JSON
agent-command-tab install-hooks  # adds the app's hooks to Claude Code's and Codex's settings (remove-hooks takes them out)
agent-command-tab --version      # prints the installed version, for bug reports

Click the "C" in the menu bar to see the list, right-click it for Settings. The first time, iTerm2 asks whether to allow the app to use its Python API.

From its first start on, iTerm2 starts the app whenever iTerm2 starts: the app adds AgentCommandTab.scpt to iTerm2's AutoLaunch folder (~/Library/Application Support/iTerm2/Scripts/AutoLaunch), which starts the copy that added it, however you installed it. A script added by another copy is kept while that copy is still installed; once it is uninstalled, the copy you run next adds its own. Started that way, it has iTerm2's permissions, as when you start it from an iTerm2 tab, and writes its output to ~/Library/Logs/agent-command-tab.log. Turning off Settings > Launch AgentCommandTab whenever iTerm2 is started removes the script. Only one copy runs at a time; starting another prints that one is already running.

The app's hooks tell a crashed agent from one that ended normally (its row stays, gray and "exited", for 5 minutes), count Claude Code's background shells and agents, and tell when a Claude Code turn ends while one of those still runs. The list offers to install them (Install Hooks, at its bottom left) while an agent tool in it lacks them. The first time the app changes a settings file, it copies it to <file>.agent-command-tab-backup. Sessions started afterwards use them, and Codex asks you to approve them first: type /hooks in Codex.

The shortcut needs the Accessibility permission (System Settings > Privacy & Security > Accessibility), because it has to see the keys before macOS's app switcher does. macOS gives it to the app that starts AgentCommandTab, so started from iTerm2, turn it on for iTerm2. Until it is on, Settings show a button that opens that page.

Uninstall

pip and pipx remove only the app's own files, so first take out what it added elsewhere:

agent-command-tab clean-up-before-uninstalling   # stops the app, takes out its hooks and its iTerm2 AutoLaunch script
pipx uninstall agent-command-tab

Its settings stay in ~/Library/Application Support/agent-command-tab, and its log in ~/Library/Logs/agent-command-tab.log.

Development

.venv/bin/python -m unittest discover -s tests -p '*_tests.py'

dev/RELEASING.md describes how to publish a version.

License

MIT; see LICENSE. The app uses iTerm2's iterm2 Python package, which is licensed GPL-2.0-or-later. pip and pipx install it alongside as a separate package.

Metadata

Release files for agent-command-tab 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-command-tab 0.4.1
File Size Uploaded Provenance Actions
agent_command_tab-0.4.1.tar.gz 285.7 kB Without provenance Details for agent_command_tab-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-command-tab 0.4.1
File Interpreter ABI Platform Actions
agent_command_tab-0.4.1-py3-none-any.whl Python 3 none any Details for agent_command_tab-0.4.1-py3-none-any.whl

Total release size: 598.2 kB

Release files / agent_command_tab-0.4.1.tar.gz

Download URL agent_command_tab-0.4.1.tar.gz
Size 285.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d9f070756a82ea312342df41ce3c104a2a967ac92afbf724f5c5784b4c00f078
BLAKE2b-256 checksum
How to use checksums
8ad7dd54f7085e968644a519300b11f4c5819f365c3e1a8a620802e2d4142a96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Release files / agent_command_tab-0.4.1-py3-none-any.whl

Download URL agent_command_tab-0.4.1-py3-none-any.whl
Size 312.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d29f73588721710c7a6ca5a0ffa4d6909aa7b45c8fe7e21e9c0399fa7d654c5
BLAKE2b-256 checksum
How to use checksums
7de87c32ea7725ef80b3eee6c4dfeef92b5532dd3800dd3d12062d322957dc72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Security for agent-command-tab 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page