Claude Code Plugins Reference
Terminology note: This document describes plugins (executables discovered and invoked by it2).
For the distinction between plugins, hooks, and tools, see taxonomy.md.
Overview
The it2 CLI includes a comprehensive suite of plugins and native commands specifically designed for automating and orchestrating Claude Code sessions. These enable detection, monitoring, and intelligent interaction with Claude sessions.
Native Session Commands
The current binary includes native session-state commands backed by the
sessionstate package. These commands are hidden from the default command
listing but remain directly invocable:
Core State Detection Commands
| Command | Purpose | Exit Codes |
|---|---|---|
it2 session get-state |
Comprehensive state analysis | 0=success |
it2 session is-active |
Check if session is actively working | 0=active, 1=idle |
it2 session has-modal |
Detect modal dialogs | 0=modal, 1=no modal |
it2 session suggest-action |
Suggest intervention action | 0=actionable, 1=wait/none |
it2 session claude-status |
Human-readable Claude status | 0=success |
Usage Examples
# Get comprehensive state with Claude detection
it2 session get-state E0A8 --agent=claude --format json
# Check if session is actively working
if it2 session is-active E0A8 --agent=claude; then
echo "Session busy, waiting..."
sleep 5
fi
# Detect modal and get type
modal=$(it2 session has-modal E0A8)
case "$modal" in
approval) echo "Approval needed" ;;
choice) echo "Selection needed" ;;
none) echo "No modal" ;;
esac
# Get suggested action and optionally execute it
it2 session suggest-action E0A8 --execute
# Human-readable status display
it2 session claude-status E0A8
Watch Command (Event-Driven Monitoring)
The watch command provides event-driven session monitoring with NDJSON output:
# Watch for state transitions
it2 session watch E0A8 --agent=claude
# Auto-execute suggested actions
it2 session watch E0A8 --agent=claude --auto-act
# Verbose output with full state on each transition
it2 session watch E0A8 --agent=claude --verbose
Output format (NDJSON):
{"timestamp":"2024-12-25T09:00:00Z","session_id":"E0A8...","state":"active","previous_state":"idle","action":"wait"}
{"timestamp":"2024-12-25T09:00:05Z","session_id":"E0A8...","state":"modal","previous_state":"active","modal_type":"approval","safe":true,"action":"modal:approve"}
Agent Detection
All state detection commands support the --agent flag:
--agent=claude- Use Claude Code detection patterns--agent=auto- Auto-detect the agent- (empty) - Use generic detection patterns
The shell-based plugins (it2-session-claude-has-modal, it2-session-claude-suggest-action) now delegate to these native commands when available, falling back to legacy implementation for older it2 versions.
Plugin Categories
1. Session Detection & Identification
it2-session-process-is-claude
Location: internal/embedded/plugins/it2-session-process-is-claude.sh
Purpose: Detect if a session process is running Claude Code
Usage:
it2-session-process-is-claude <session-id> <pid>
Returns:
"true"if the process is Claude Code- Empty string otherwise
Implementation: Checks process name using ps for "claude" substring
it2-session-is-claude-code
Location: it2-extensions/it2-session-is-claude-code/it2-session-is-claude-code.sh
Purpose: Detect Claude Code sessions by checking main process and parent chain
Usage:
it2-session-is-claude-code [session-id]
# Uses current session if no ID provided
Returns:
✅if Claude session detected- Exit code 0 on success, 1 otherwise
Features:
- Checks session PID and process name
- Traverses parent process chain (up to 3 levels)
- Debug mode available via
ITERM2_DEBUG=1
Example:
# Check current session
it2-session-is-claude-code
# Check specific session
it2-session-is-claude-code A1B2C3D4
# With debug output
ITERM2_DEBUG=1 it2-session-is-claude-code A1B2C3D4
2. Modal Detection & Interaction
it2-session-claude-has-modal
Location: internal/embedded/plugins/it2-session-claude-has-modal
Purpose: Detect modal dialogs in Claude sessions requiring user intervention
Usage:
it2-session-claude-has-modal <session-id>
Returns:
"approval"- "Do you want to proceed?" prompts"choice"- Numbered option selections with ❯ selector"confirmation"- Y/n, y/N, [y/n] prompts"input"- Text input requests"none"- No modal detected
Detection Patterns:
- Approval prompts: "Do you want to proceed?"
- Choice dialogs:
❯ 1. Yeswith numbered options - Confirmations:
(Y/n),(y/N),[y/n] - Input prompts: "Enter...", "Please enter", "Input:"
- Box dialogs:
╭─╮style with options - Edit acceptance: "⏵⏵ accept edits", "shift+tab to cycle"
Example:
MODAL=$(it2-session-claude-has-modal A1B2C3D4)
if [[ "$MODAL" == "approval" ]]; then
echo "Claude is waiting for approval"
fi
it2-session-claude-auto-approve
Location: internal/embedded/plugins/it2-session-claude-auto-approve
Purpose: Automatically approve safe Claude operations
Usage:
it2-session-claude-auto-approve <session-id> [--dry-run]
Returns:
"approved"- Modal was auto-approved"skipped"- Modal unsafe or requires human review"no-modal"- No modal detected"error"- Unable to process"approved-dry-run"- Would approve (dry-run mode)
Approval Actions by Modal Type:
- approval/choice: Sends
1+Return(selects first option) - confirmation: Sends
y(yes) - input: Always skipped (too risky)
Example:
# Auto-approve if safe
it2-session-claude-auto-approve A1B2C3D4
# Dry run to see what would happen
it2-session-claude-auto-approve A1B2C3D4 --dry-run
it2-session-claude-is-safe-operation
Location: internal/embedded/plugins/it2-session-claude-is-safe-operation
Purpose: Determine if a Claude operation is safe to auto-approve
Usage:
it2-session-claude-is-safe-operation <session-id>
Returns:
"safe"- Operation can be safely auto-approved"unsafe"- Operation requires human review"unknown"- Operation cannot be determined
Safe Operations:
- File reading:
cat,head,tail,ls,find,grep,less,more - Git read-only:
git status,git log,git diff,git show,git ls-files - Process inspection:
ps,top,htop,lsof,netstat,pgrep - System info:
uname,whoami,pwd,date,uptime,df,du,env - Package info:
npm ls,pip list,brew list,go list,cargo tree - Documentation:
--help,-h,man,info - Clipboard:
pbcopy,copy - it2 commands:
get-buffer,get-screen,get-contents
Unsafe Operations:
- File modifications:
rm,mv,cp,mkdir,chmod,chown,>,>> - Git destructive:
git add,git commit,git push,git merge,git rebase,git reset - Network:
curl,wget,ssh,scp,rsync,ftp - Package installs:
npm install,pip install,brew install,apt,yum - System mods:
sudo,su,kill,systemctl,mount - Process control:
&,nohup,screen,tmux,bg,fg
Context-Based Rules:
- Operations in
/tmp,/var/tmp,*test*,*demo*,*example*are more permissive - Commands with
--dry-run,--simulate,--preview,--checkflags are safe
Example:
SAFETY=$(it2-session-claude-is-safe-operation A1B2C3D4)
if [[ "$SAFETY" == "safe" ]]; then
it2-session-claude-auto-approve A1B2C3D4
else
echo "Human review required"
fi
3. Session State Detection
it2-session-is-at-prompt
Location: internal/embedded/plugins/it2-session-is-at-prompt
Purpose: Check whether the last non-empty screen line resembles a shell or REPL prompt
Usage:
it2-session-is-at-prompt <session-id>
Returns:
"true"with exit code 0 when a recognized prompt is found"false"with exit code 1 when no recognized prompt is found
Detection Logic:
- Reads the session screen and selects its last non-empty line.
- Removes ANSI color sequences and surrounding whitespace.
- Matches common shell, Python, Node.js, Julia, and IPython prompt suffixes.
This is a text-pattern heuristic. Use it2 session get-state --agent=claude
when agent-specific state classification is required.
Example:
if [[ "$(it2-session-is-at-prompt A1B2C3D4)" == "true" ]]; then
it2 session send-text A1B2C3D4 "continue"
fi
it2-session-has-no-queued-claude-messages
Location: internal/embedded/plugins/it2-session-has-no-queued-claude-messages
Purpose: Check if there are no queued/pending messages in Claude session
Usage:
it2-session-has-no-queued-claude-messages <session-id>
Returns:
"true"- No queued messages"false"- Messages queued or Claude is busy
Detected Busy Indicators:
- Processing: "thinking...", "generating", "processing"
- Spinners:
⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏characters - Status messages: "working on", "please wait", "one moment"
- Tool use:
<tool_use>, "Using tool", "Tool call", "Executing" - Streaming:
▌▍▎▏characters - Queue indicators: "X pending", "X queued", "messages in queue"
- Waiting states: "waiting for"
- Generation: "Generating response", "Composing", "Drafting"
- Ellipsis: Lines ending with
... - Approval dialogs: "Do you want to proceed?"
- Pagination: "continue", "show more", "load more" (when actively loading)
Example:
while [[ "$(it2-session-has-no-queued-claude-messages A1B2C3D4)" == "false" ]]; do
echo "Waiting for Claude to finish..."
sleep 1
done
echo "Claude is ready"
4. Intelligent Orchestration
it2-session-claude-suggest-action
Location: internal/embedded/plugins/it2-session-claude-suggest-action
Purpose: Analyze Claude session context and suggest appropriate interventions
Usage:
it2-session-claude-suggest-action <session-id> [--execute]
Returns:
"continue"- Session has incomplete todos, should send "continue""continue:milestone-breakdown"- Vague todos need breakdown"continue:test-build"- Test/build todos ready to run"tab"- Pending edits to accept"modal:approve"- Safe modal ready for approval"modal:approved"- Modal was auto-approved (--execute mode)"modal:review"- Unsafe modal needs human review"wait"- Session actively working"review:error"- Error state needs attention"none"- No intervention needed
Priority Decision Tree:
- Modals (highest priority) - Check for approval dialogs
- Edit acceptance - Check for "⏵⏵ accept edits" prompts
- Active work - Check for
⏺✳✽✶✢⚡🔄🔍indicators or "Generating/Processing" text - Incomplete todos - Check for
☐with specific patterns:- Vague monitoring → suggest milestone breakdown
- Test/build todos → suggest running them
- Generic → send "continue"
- Error states - Check for "Error", "Failed", "Exception"
- Idle without todos - No action needed
Example:
# Get suggestion
ACTION=$(it2-session-claude-suggest-action A1B2C3D4)
echo "Suggested action: $ACTION"
# Execute suggestion automatically
it2-session-claude-suggest-action A1B2C3D4 --execute
Automation Loop Example:
while true; do
ACTION=$(it2-session-claude-suggest-action A1B2C3D4 --execute)
echo "[$ACTION] at $(date)"
case "$ACTION" in
"modal:approved"|"continue:"*|"tab:sent")
echo "Action taken"
;;
"wait")
sleep 2
;;
"modal:review"|"review:error")
echo "Human attention needed!"
break
;;
"none")
echo "Session complete"
break
;;
esac
done
Plugin Architecture
Plugin Discovery
Plugins are loaded from multiple locations in priority order:
- Directories from
PATHenvironment variable (highest priority) - Directories from
IT2_PLUGIN_PATHS/--plugin-pathflag (middle priority) - Embedded plugins bundled in the it2 binary (lowest priority, fallback)
Integration with it2 Commands
Plugins are automatically invoked by it2 session list for session property enrichment:
# The "is-claude-in-progress" column uses:
# - it2-session-process-is-claude (detection)
# - it2-session-has-no-queued-claude-messages (status)
it2 session list
# Shows 🚧 flag for Claude sessions with work in progress
Plugin Development Guidelines
Required Structure:
#!/usr/bin/env bash
set -euo pipefail
SESSION_ID="${1:-}"
if [[ -z "$SESSION_ID" ]]; then
echo "Error: Session ID required" >&2
exit 1
fi
# Find it2 binary
IT2_BIN=""
if [[ -x "./it2" ]]; then
IT2_BIN="./it2"
elif [[ -x "$HOME/go/bin/it2" ]]; then
IT2_BIN="$HOME/go/bin/it2"
elif command -v it2 &> /dev/null; then
IT2_BIN="$(command -v it2)"
fi
# Plugin logic here...
Best Practices:
- Always validate session ID input
- Use
it2 session get-screenfor screen content analysis - Strip ANSI escape sequences:
sed 's/\x1b\[[0-9;]*m//g' - Return clear, parseable output
- Exit code 0 for success, 1 for failure
- Support
ITERM2_DEBUG=1for debugging
Real-World Usage Examples
Example 1: Auto-Approve Safe Operations
#!/bin/bash
# Monitor Claude session and auto-approve safe operations
SESSION_ID="$1"
while true; do
MODAL=$(it2-session-claude-has-modal "$SESSION_ID")
if [[ "$MODAL" != "none" ]]; then
RESULT=$(it2-session-claude-auto-approve "$SESSION_ID")
echo "[$(date '+%H:%M:%S')] Modal $MODAL: $RESULT"
fi
sleep 1
done
Example 2: Wait for Claude to Finish
#!/bin/bash
# Wait for Claude to complete current work
SESSION_ID="$1"
echo "Waiting for Claude to finish..."
while [[ "$(it2-session-has-no-queued-claude-messages "$SESSION_ID")" == "false" ]]; do
sleep 2
done
echo "Claude is ready!"
Example 3: Smart Claude Orchestration
#!/bin/bash
# Fully automated Claude orchestration
SESSION_ID="$1"
while true; do
# Let suggest-action make the decision and execute it
RESULT=$(it2-session-claude-suggest-action "$SESSION_ID" --execute)
echo "[$(date '+%H:%M:%S')] $RESULT"
case "$RESULT" in
"modal:review"|"review:error")
echo "⚠️ Human intervention required"
exit 1
;;
"none")
echo "✅ Work complete"
exit 0
;;
"wait")
sleep 3
;;
*)
sleep 1
;;
esac
done
Example 4: Multi-Claude Coordination
#!/bin/bash
# Coordinate multiple Claude sessions
CLAUDE_A="ABC12345"
CLAUDE_B="DEF67890"
# Send tasks to both Claudes
it2 session send-text "$CLAUDE_A" "Analyze the frontend code"
it2 session send-text "$CLAUDE_B" "Analyze the backend code"
# Monitor both sessions
while true; do
A_DONE=$(it2-session-has-no-queued-claude-messages "$CLAUDE_A")
B_DONE=$(it2-session-has-no-queued-claude-messages "$CLAUDE_B")
# Auto-approve any safe modals
it2-session-claude-auto-approve "$CLAUDE_A" 2>/dev/null
it2-session-claude-auto-approve "$CLAUDE_B" 2>/dev/null
if [[ "$A_DONE" == "true" ]] && [[ "$B_DONE" == "true" ]]; then
echo "Both Claudes finished!"
break
fi
sleep 2
done
Performance Considerations
Plugin Execution Time:
- Modal detection: ~50-100ms (screen content analysis)
- Safety analysis: ~100-200ms (regex matching)
- Auto-approve: ~150-300ms (detection + approval action)
- Suggest-action: ~200-400ms (full decision tree)
Caching Strategies:
# Cache screen content for multiple checks
SCREEN_CONTENT=$(it2 session get-screen "$SESSION_ID")
echo "$SCREEN_CONTENT" | grep -q "Do you want to proceed?"
Polling Recommendations:
- Modal detection: 1-2 second intervals
- Queue status: 2-3 second intervals
- Suggest-action: 3-5 second intervals
Troubleshooting
Plugin Not Found
# Check plugin search paths
echo $IT2_PLUGIN_PATHS
# Verify plugin is executable
it2 plugin list
# Add custom plugin path
it2 --plugin-path /path/to/plugins session list
Debug Mode
# Enable debug output
ITERM2_DEBUG=1 it2-session-is-claude-code A1B2C3D4
# Shows:
# [DEBUG] it2-session-is-claude-code: SESSION_ID=A1B2C3D4
# [DEBUG] Got PID from get-pid: 12345
# [DEBUG] Process name for PID 12345: node
# [DEBUG] Parent 1 PID 12344: claude
Common Issues
"Session not found" errors:
- Use full session IDs for variable commands
- Verify session exists:
it2 session list | grep <id>
Modals not detected:
- Check screen content directly:
it2 session get-screen <id> - Modal patterns may need updating for new Claude UI
Auto-approve not working:
- Verify modal is detected:
it2-session-claude-has-modal <id> - Check safety level:
it2-session-claude-is-safe-operation <id> - Ensure operation is in safe list
Plugin Development
To create a new Claude-related plugin:
- Create the plugin file:
mkdir -p ~/bin
touch ~/bin/it2-session-claude-my-feature
chmod +x ~/bin/it2-session-claude-my-feature
- Use the template:
#!/usr/bin/env bash
set -euo pipefail
SESSION_ID="${1:-}"
if [[ -z "$SESSION_ID" ]]; then
echo "Error: Session ID required" >&2
exit 1
fi
# Find it2 binary
IT2_BIN=""
if [[ -x "./it2" ]]; then
IT2_BIN="./it2"
elif command -v it2 &> /dev/null; then
IT2_BIN="$(command -v it2)"
fi
# Your plugin logic here
SCREEN=$($IT2_BIN session get-screen "$SESSION_ID" 2>/dev/null || echo "")
# Return result
echo "result"
- Test the plugin:
~/bin/it2-session-claude-my-feature A1B2C3D4
- Integrate with it2 (if needed):
- Ensure
~/binis inPATH, or pass--plugin-path ~/bin - Confirm discovery with
it2 plugin list
Summary
The shipped plugins cover process detection, prompt and modal heuristics,
session-state checks, and suggested interventions. The auto-approval and safety
classifiers are text-pattern heuristics; inspect their output and use dry-run
mode before enabling actions in an unattended workflow.