| name | session-orchestration |
| description | Use when managing multiple iTerm2 sessions, creating split layouts, navigating session hierarchies, or orchestrating terminal workflows across panes. |
| allowed-tools | ["Bash","Read","Grep"] |
Session Orchestration
Guidance for managing iTerm2 sessions using the it2 CLI tool.
When to Use
- Creating multi-pane terminal layouts for development workflows
- Managing multiple concurrent terminal sessions
- Navigating and organizing sessions across windows and tabs
- Sending commands to specific sessions programmatically
- Setting up reproducible terminal environments
When NOT to Use
- For simple single-session terminal operations (just use the terminal directly)
- When iTerm2 is not the active terminal emulator
- For remote server management (use SSH directly, then optionally it2 for local orchestration)
Quick Start
it2 session list
it2 session current
it2 session split --horizontal -q
it2 session split --vertical -q
it2 session send-text "$SESSION_ID" "echo hello"
Core Concepts
Session Identification
Sessions are identified by UUIDs (e.g., A81F7ED5-3F4B-4504-8F14-6C98F9422F72). Use the first 8 characters as shorthand for display purposes.
CURRENT_SID=$ITERM_SESSION_ID
it2 session list --format json
Session Hierarchy
Sessions exist within a hierarchy: Window → Tab → Session (Pane)
it2 session lookup tab "$SID"
it2 session lookup window "$SID"
it2 session lookup siblings "$SID"
Split Operations
The -q flag returns only the new session ID (quiet mode), essential for scripting.
NEW_SID=$(it2 session split --horizontal -q)
it2 session send-text "$NEW_SID" "cd /path/to/project && npm start"
Layout Patterns
Development Layout (3 panes)
MAIN=$ITERM_SESSION_ID
EDITOR=$(it2 session split --vertical -q)
LOGS=$(it2 session split --horizontal -q)
it2 session send-text "$EDITOR" "vim ."
it2 session send-text "$LOGS" "tail -f logs/*.log"
Badge Sessions for Identification
Always include the session ID prefix in badges for automation:
it2 session set-badge "$SID" "$(echo $SID | cut -c1-8)\nServer"
Session State Inspection
it2 session get-info "$SID" --format json
it2 session has-shell-integration "$SID"
it2 session get-screen "$SID"
it2 session get-buffer "$SID" --lines 100
Best Practices
- Always use
-q flag when capturing session IDs from split operations
- Check session dimensions before splitting:
it2 session get-info --format json | jq .grid_size
- Use badges to label sessions for visual identification
- Verify target session state before sending commands: check screen contents first
- Chain commands with
&& or ; when sending multiple commands
Advanced Usage
See references/hierarchy.md for session hierarchy navigation.
See references/layouts.md for complex layout recipes.
See workflows/multi-project.md for multi-project setups.