
CLI Anything for iTerm2
FreeControl and automate iTerm2 sessions via CLI commands.
Free · Opens the source repo
What CLI Anything for iTerm2 does
CLI Anything for iTerm2 is a powerful command-line interface tool designed to interact with iTerm2 on macOS. It leverages the iTerm2 Python API over WebSocket to provide a comprehensive set of commands that allow users to manage terminal sessions, windows, and tabs efficiently. With this skill, developers and designers can send text to iTerm2 sessions, read live terminal output, manage split panes, and automate workflows using tmux integration. The tool is particularly useful for those who work extensively in terminal environments and need to streamline their processes.
The skill provides a variety of command groups, including app, window, tab, session, profile, arrangement, tmux, broadcast, and menu. Each group serves a specific purpose, such as creating and managing windows and tabs, broadcasting keystrokes across multiple panes, or handling session preferences. This structure allows users to quickly find the commands they need based on their tasks, making it an efficient tool for terminal management.
One of the standout features is the app snapshot command, which gives users a quick overview of all active sessions, including their names, current directories, foreground processes, and last output lines. This is particularly beneficial when navigating complex terminal setups with multiple panes. Additionally, the REPL mode allows for interactive command execution while maintaining context, which enhances usability for frequent tasks.
Overall, CLI Anything for iTerm2 is ideal for developers and designers looking to optimize their terminal workflows, automate repetitive tasks, and gain better control over their terminal environments. Whether you are managing multiple projects or simply want to enhance your iTerm2 experience, this skill provides the necessary tools to do so effectively.
When to use it
Use this skill when you need to interact with iTerm2 sessions programmatically, manage multiple panes, or automate workflows using tmux.
When not to use it
This skill is not suitable for users who do not use iTerm2 or those who prefer graphical interfaces over command-line tools.
What you can build with it
Automating Terminal Workflows
Set up automated tasks in iTerm2 by sending commands and managing sessions without manual intervention.
Managing Multiple Panes
Easily create and control multiple terminal panes for simultaneous tasks, enhancing productivity.
Snapshotting Workspace State
Quickly get an overview of all active sessions and their statuses to orient yourself in complex terminal setups.
How to install CLI Anything for iTerm2
View source1. Install with the skills CLI
npx skills add hkuds/cli-anything/skills --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by hkudscli-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
Frequently asked questions about CLI Anything for iTerm2
Similar skills
Turborepo
Optimized build system for JavaScript/TypeScript monorepos.
Azure Pipelines Validation
Streamline your Azure DevOps pipeline changes locally.
Azure Developer CLI
Streamline your Azure project workflows with best practices.
Azure Container Registry CLI
Manage Azure Container Registry resources with ease.
Aspire
Build and orchestrate polyglot distributed applications seamlessly.
Vercel CLI
Manage and deploy Vercel projects from the command line.
