| name | claude-code-integration |
| description | Use when working with Claude Code sessions in iTerm2 - detecting Claude sessions, checking their status, linking sessions, or coordinating multiple Claude instances. |
| allowed-tools | ["Bash","Read","Grep"] |
Claude Code Integration
Guidance for interacting with Claude Code sessions running in iTerm2.
When to Use
- Detecting which iTerm2 sessions are running Claude Code
- Checking the status of Claude Code sessions (idle, working, waiting for input)
- Coordinating multiple Claude Code sessions
- Monitoring Claude Code session activity
- Setting up multi-agent Claude Code workflows
When NOT to Use
- For general terminal automation (use session-orchestration skill instead)
- When not working with Claude Code specifically
- For Claude API interactions (this is for the CLI tool in terminals)
Quick Start
it2 session list --format json | jq '.[] | select(.name | contains("claude"))'
it2 session claude "$SESSION_ID"
it2 session claude-status "$SESSION_ID"
it2 session has-modal "$SESSION_ID"
Detecting Claude Code Sessions
By Process Name
it2 session list --format json | jq -r '.[] |
select(.foreground_job.command | test("claude"; "i")) | .session_id'
By Session State
it2 session get-state "$SID"
Claude Session Indicators
A session is likely running Claude Code if:
- Process name contains "claude" or "node" (Claude Code's runtime)
- Screen content shows Claude Code UI elements (╭─, tool use blocks, etc.)
- Session has specific environment variables set
Session Status Detection
Modal Detection
Claude Code shows modal dialogs for permissions, confirmations, etc.
if it2 session has-modal "$SID"; then
echo "Session has pending modal"
fi
Activity Detection
it2 session is-active "$SID"
it2 session suggest-action "$SID"
Session Linking
Link iTerm2 sessions to their Claude Code session files:
it2 session claude "$SID"
Multi-Claude Workflows
Setting Up Parallel Claude Sessions
MAIN=$ITERM_SESSION_ID
RESEARCH=$(it2 session split --vertical -q)
IMPLEMENT=$(it2 session split --horizontal -q)
it2 session set-badge "$MAIN" "$(echo $MAIN | cut -c1-8)\nMain"
it2 session set-badge "$RESEARCH" "$(echo $RESEARCH | cut -c1-8)\nResearch"
it2 session set-badge "$IMPLEMENT" "$(echo $IMPLEMENT | cut -c1-8)\nImplement"
it2 session send-text "$RESEARCH" "claude --continue"
it2 session send-text "$IMPLEMENT" "claude"
Monitoring Multiple Sessions
it2 session watch --all
Screen Content Analysis
Getting Claude's Output
it2 session get-screen "$SID"
it2 session get-buffer "$SID" --lines 200
Parsing Claude UI Elements
Claude Code's TUI has recognizable patterns:
╭─ / ╰─ - Message box borders
● - Working indicator
? - Question/prompt indicator
- Tool use blocks with specific formatting
Best Practices
- Always check for modals before sending input to Claude sessions
- Use badges with session ID prefix for visual tracking
- Monitor state before automated interactions
- Verify screen content matches expected state before proceeding
- Use quiet flags (
-q) when capturing session IDs for scripts
- Include response hints when messaging other sessions - always tell them how to respond back (see workflows/multi-agent.md)
Advanced Usage
See references/state-detection.md for detailed state analysis.
See references/ui-patterns.md for parsing Claude Code output.
See workflows/multi-agent.md for coordinating multiple Claude instances.