Skip to content
automating-tmux-windows logo

Automating tmux Windows

automating-tmux-windows

Automates terminal sessions in tmux windows using MCP tools. Use when launching background processes, monitoring builds/servers, sending commands to debuggers (pdb/gdb), interacting with CLI prompts, using interactive commands or commands that require sudo, or orchestrating parallel tasks across ...

SKILL.md

Full skill instructions

Automating tmux Windows

Control tmux windows programmatically: create windows, send commands, capture output, and manage processes. Each window gets full screen space for easier output tracking.

Note: These tools are provided by the orchestrator MCP server, which also includes AI CLI tools (see ai-orchestration skill).

Recommended: Use Subagent for Context Efficiency

To save context in the main conversation, delegate tmux operations to the tmux-runner subagent:

# Instead of calling tmux tools directly, use Task tool:
Task(
    subagent_type="tmux-runner",
    description="Run npm build",
    prompt="Run 'npm run build' in the project directory. Return success/​failure and any errors.",
    model="haiku"  # Fast and cheap for simple commands
)

When to use subagent:

  • Simple build/​test commands
  • Any command where you just need pass/​fail + output
  • Commands that don't need real-time monitoring

When to use direct tmux tools:

  • Long-running servers you need to monitor over time
  • Complex interactive debugging sessions
  • When you need the window to persist across multiple operations

Quick Reference

ToolPurpose
mcp__orchestrator__tmux_new_windowCreate new window with command
mcp__orchestrator__tmux_sendSend text/​keys to window
mcp__orchestrator__tmux_captureGet window output
mcp__orchestrator__tmux_listList windows (JSON)
mcp__orchestrator__tmux_killClose window
mcp__orchestrator__tmux_interruptSend Ctrl+C
mcp__orchestrator__tmux_wait_idleWait for idle (no output changes)
mcp__orchestrator__tmux_selectSwitch to window (bring to front)
mcp__orchestrator__tmux_run_and_readRun command, wait, return file output

Window Identifiers

Always use the window ID returned by tmux_new_window (e.g., "@3"). These IDs:

  • Never change when other windows are created or killed
  • Persist until the window itself is destroyed
  • Are the only reliable way to reference windows across operations

Window names are visible in the tmux status bar for easy identification.

Standard Workflow

# 1. Create window - SAVE THE RETURNED ID
# Can pass any command directly - non-shell commands are auto-wrapped in a shell
window_id = mcp__orchestrator__tmux_new_window(command="npm run build", name="build")  # Returns "@3"

# 2. Wait for completion
mcp__orchestrator__tmux_wait_idle(target=window_id, idle_seconds=2.0)  # Returns "idle" or "timeout"

# 3. Get output
output = mcp__orchestrator__tmux_capture(target=window_id, lines=50)

# 4. Optionally switch to window to view it
mcp__orchestrator__tmux_select(target=window_id)

# 5. Cleanup
mcp__orchestrator__tmux_kill(target=window_id)

File-Based Output Workflow

For commands that write to a file (cleaner than capturing pane output):

# Single call: run command, wait for completion, return file contents
# Use __OUTPUT_FILE__ placeholder - it gets replaced with a random /​tmp path
result = mcp__orchestrator__tmux_run_and_read(
    command="my-tool --output __OUTPUT_FILE__",
    name="my-task",
    timeout=300
)

Key differences from tmux_new_window:

  • Does NOT spawn a shell wrapper (command runs directly)
  • Waits for window to close (command exit) instead of idle detection
  • Returns file contents instead of pane capture
  • Auto-generates safe temp file path (replaces __OUTPUT_FILE__ placeholder)
  • Auto-cleans up window and output file

Use cases:

  • CLI tools with -o or --output flags that accept a path argument
  • Wrapper scripts that write results to a specified path

Parallel Windows

Create multiple windows for parallel tasks:

# Create named windows - commands run directly
logs_window = mcp__orchestrator__tmux_new_window(command="tail -f /​var/​log/​app.log", name="logs")
work_window = mcp__orchestrator__tmux_new_window(command="cd ~/​project && make", name="work")

# Capture from both
logs = mcp__orchestrator__tmux_capture(target=logs_window, lines=100)
output = mcp__orchestrator__tmux_capture(target=work_window, lines=50)

Interactive Commands

For commands requiring input (sudo, prompts, debuggers):

# Start interactive session
window_id = mcp__orchestrator__tmux_new_window(command="sudo apt update", name="sudo")

# Wait for password prompt
mcp__orchestrator__tmux_wait_idle(target=window_id, idle_seconds=1, timeout=10)

# Send password (if needed)
mcp__orchestrator__tmux_send(target=window_id, text="password")

# Wait for completion
mcp__orchestrator__tmux_wait_idle(target=window_id, idle_seconds=2, timeout=120)

Window Navigation

  • Use tmux_select to switch to a window programmatically
  • User can navigate with Ctrl+b n (next) / Ctrl+b p (previous)
  • Window names appear in tmux status bar

Tool Parameters

tmux_new_window

ParameterTypeDefaultDescription
commandstring"zsh"Command to run (auto shell-wrapped)
namestring""Window name for status bar

tmux_run_and_read

ParameterTypeDefaultDescription
commandstringrequiredCommand with __OUTPUT_FILE__ placeholder
namestring""Window name for status bar
timeoutint300Max seconds to wait

The __OUTPUT_FILE__ placeholder is replaced with an auto-generated /​tmp/​tmux_output_<uuid>.txt path.

tmux_wait_idle

ParameterTypeDefaultDescription
targetstringrequiredWindow ID (e.g., "@3")
idle_secondsfloat2.0Seconds of no change = idle
timeoutint60Max seconds to wait

tmux_capture

ParameterTypeDefaultDescription
targetstringrequiredWindow ID (e.g., "@3")
linesint100Lines to capture (max: 10000)

Safety

  • Cannot kill own window (server prevents this)
  • Use mcp__orchestrator__tmux_interrupt to stop runaway processes
  • Check is_claude field in mcp__orchestrator__tmux_list to identify your window
  • Always store and reuse the window ID from mcp__orchestrator__tmux_new_window
  • Target validation prevents command injection via window IDs

More Productivity & Planning skills

brainstorming logo
Productivity & Planning

brainstorming

Structured design dialogue that validates ideas before implementation begins.

295.4K 385.7K
View
ui-ux-pro-max logo
Productivity & Planning

ui-ux-pro-max

Comprehensive design intelligence for web and mobile UI/UX across 10 technology stacks.

133.1K 383.9K
View
writing-plans logo
Productivity & Planning

writing-plans

Comprehensive implementation plans for multi-step tasks, breaking down specs into bite-sized, testable steps.

295.4K 268K
View
using-superpowers logo
Productivity & Planning

using-superpowers

Introduction to the obra skills system with mandatory skill invocation rules and best practices.

295.4K 259.8K
View
executing-plans logo
Productivity & Planning

executing-plans

Execute a written implementation plan with critical review and task checkpoints.

295.4K 229.1K
View
dispatching-parallel-agents logo
Productivity & Planning

dispatching-parallel-agents

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View
using-git-worktrees logo
Productivity & Planning

using-git-worktrees

Isolated git worktrees with smart directory selection and safety verification.

295.4K 205.2K
View
webapp-testing logo
Productivity & Planning

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

179.7K 170.6K
View
content-strategy logo
Productivity & Planning

content-strategy

Plan searchable and shareable content that drives traffic, builds authority, and generates leads.

53.3K 150.9K
View
repo-intake-and-plan logo
Productivity & Planning

repo-intake-and-plan

README-first repository scanner that extracts commands and classifies reproduction candidates without executing them.

497 139.6K
View
marketing-ideas logo
Productivity & Planning

marketing-ideas

Brainstorm and prioritize marketing strategies tailored to your SaaS stage, budget, and goals.

53.3K 137.2K
View
site-architecture logo
Productivity & Planning

site-architecture

Plan and optimize your website's page hierarchy, navigation, URL structure, and internal linking.

53.3K 112.8K
View

Productivity AI tools

Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View
SaveDay logo
Productivity

SaveDay

Capture, organize, and utilize your knowledge effortlessly.

Free
View
Any Summary logo
Productivity

Any Summary

Instant Summaries of Audio & Video Interviews with AnySummary

Freemium
View
M
Productivity

Map This

Transform PDFs into engaging mind maps.

Freemium
View
ChatPDF logo
Productivity

ChatPDF

Chat with any PDF instantly

Free
View
I
Productivity

intellisay

Create an optimal daily plan using your voice

Paid
View
A
Productivity

Aurora AI

A productivity platform to centralize organizational knowledge and workflows with contextual AI assistance.

Paid
View
AskYourPDF logo
Productivity

AskYourPDF

AskYourPDF Pricing Plans: Tailored to Your Needs

Free
View