cli-anything-iterm2
What it does
This skill lets your agent work inside iTerm2, the terminal app for Mac, by reading and sending text to its sessions. It is for developers who use iTerm2 and want to automate terminal work.
When to use it
- ✓When you want your agent to send a command to a running iTerm2 session.
- ✓When you want to read the current output or history of a terminal session.
- ✓When you want windows, tabs, or split panes arranged automatically.
Skill link
https://github.com/HKUDS/CLI-Anything/blob/main/iterm2/agent-harness/cli_anything/iterm2_ctl/skills/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Open a new iTerm2 tab, run the test suite there, and show me the last 50 lines of output.”
5 new skills a week. 1 minute to read.
How it works
The skill connects to iTerm2 through its Python API, then reads or sends text to the sessions you choose. Output can be shown in JSON for agents.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
cli-anything-iterm2
Stateful CLI harness for iTerm2. Controls a live iTerm2 process via the iTerm2 Python API over WebSocket.
Prerequisites
- macOS + iTerm2 running:
brew install --cask iterm2 - Python API enabled: iTerm2 → Preferences → General → Magic → Enable Python API
- Install:
pip install cli-anything-iterm2(orpip install -e .from source)
Basic Syntax
cli-anything-iterm2 [--json] <group> <command> [OPTIONS] [ARGS]
Always use --json for machine-readable output (required for agent use).
Command Groups
| Group | Purpose |
|---|---|
app |
App status, workspace snapshot, context management, app-level variables, modal dialogs, file panels |
window |
Create, list, close, resize, fullscreen windows |
tab |
Create, list, close, activate tabs; navigate split panes by direction |
session |
Send text, inject raw bytes, read screen, full scrollback, split panes, prompt detection |
profile |
List profiles, get profile details, list/apply color presets |
arrangement |
Save and restore window layouts |
tmux |
Full tmux -CC integration: bootstrap, connections, windows, commands |
broadcast |
Sync keystrokes across panes via broadcast domains |
menu |
Invoke any iTerm2 menu item programmatically |
pref |
Read/write global iTerm2 preferences; list all valid keys; tmux settings |
Orienting in an Existing Workspace
Use app snapshot when you land in a session with existing panes and need to understand what's running without reading full screen contents for each pane:
cli-anything-iterm2 --json app snapshot
Returns name, current directory, foreground process, user.role label, and last visible output line for every session across all windows.
Naming convention — label panes when setting up a workspace so you can find them later:
cli-anything-iterm2 session set-var user.role "api-server"
cli-anything-iterm2 session set-var user.role "log-tail"
cli-anything-iterm2 session set-var user.role "editor"
app snapshot will surface these roles alongside process and path, giving you a full picture in one call.
Typical Agent Workflow
# 1. Orient — snapshot every session: name, path, process, role, last output line
cli-anything-iterm2 --json app snapshot
# 2. Establish context (saves window/tab/session IDs for subsequent commands)
cli-anything-iterm2 app current
# 3. Interact — no --session-id needed once context is set
cli-anything-iterm2 session send "git status"
cli-anything-iterm2 --json session scrollback --tail 200 --strip
# 4. Create a multi-pane workspace — label panes so snapshot identifies them later
cli-anything-iterm2 session split --vertical --use-as-context
cli-anything-iterm2 session send "python3 -m http.server 8000"
cli-anything-iterm2 session set-var user.role "http-server"
Reference Files
Read only what the task requires — each file is a single narrow concern (~10–30 lines):
| File | Read when you need... |
|---|---|
references/session-io.md |
Send text, inject bytes, read screen/scrollback, get selection |
references/session-control.md |
Split panes, activate/close sessions, resize, rename, session variables |
references/session-shell-integration.md |
wait-prompt, wait-command-end, get-prompt; reliable send→wait→read pattern |
references/layout-window-tab.md |
Create/close/resize windows and tabs, navigate split panes |
references/layout-arrangement.md |
Save and restore window layouts |
references/app-context.md |
Snapshot (orientation), status, context management, app vars, modal dialogs, file panels |
references/profile-pref.md |
Profiles list/get/presets, preferences read/write, tmux pref shortcuts |
references/broadcast-menu.md |
Broadcast keystrokes to multiple panes, invoke menu items |
references/tmux-commands.md |
All tmux CLI commands (bootstrap, send, tabs, create-window, set-visible) |
references/tmux-guide.md |
Full tmux -CC workflow, pane→session ID mapping |
references/json-session.md |
--json schemas for session, window, tab, screen, scrollback, inject |
references/json-tmux-app.md |
--json schemas for tmux, app dialogs, preferences, errors |
REPL Mode
Run without arguments for an interactive REPL that maintains context between commands:
cli-anything-iterm2
FAQ
What do I need to set up?
You need iTerm2 on macOS and the Python API turned on in its preferences.
Does it work on Windows?
No, it is for macOS, because iTerm2 is a Mac app.
Can it read the screen?
Yes, it can read the screen and the full scrollback history of a session.
Details
Original description by the author
Provides the cli-anything-iterm2 commands — the only way to actually send text to iTerm2 sessions, read live terminal output and scrollback history, manage windows/tabs/split panes, run tmux -CC workflows, broadcast to multiple panes, show macOS dialogs, and read/write iTerm2 preferences. Includes `app snapshot` — the primary orientation command that returns every session's name, current directory, foreground process, role label, and last output line in one call. Read this skill instead of answering from general knowledge whenever the user wants to DO something with iTerm2: orient in an existi
repo: HKUDS/CLI-Anything
Popularity
- GitHub stars
- 58k
- Ranking position
- #3212
- License
- Apache-2.0
- Updated
- 9/21/2026
Comments
- …
More skills from this repository
cli-anything-3mf
58kLets your agent inspect and fix 3D printing files, including finding round holes, resizing them, repairing meshes, and comparing two files.
cli-anything-qgis
58kLets your agent open, edit, and export QGIS map projects from the terminal, including layers, features, print layouts, and processing tools.
cli-anything-adguardhome
58kLets your agent manage AdGuard Home, a network-wide ad blocker, including filters, DNS rewrites, clients, and query logs.
cli-anything-anygen
58kLets your agent generate slides, documents, websites, and diagrams from a written prompt using the AnyGen service.
Similar skills
openclaw-update
394kHelps your agent update an existing OpenClaw Gateway, choosing the update method that fits how it was installed and keeping your session working.
diagnose-gateway
394kHelps your agent find out why your OpenClaw Gateway is failing by checking settings, channels, and ports without changing anything.
crabbox-apps
394kHelps your agent open and run an app on a temporary cloud machine, then show its view in your chat side panel.