Automatisation des fenêtres tmux

VérifiéPrudence

Automatise les sessions terminal dans les fenêtres tmux avec les outils MCP. Idéal pour lancer des processus en arrière-plan, surveiller des serveurs, ou exécuter des commandes interactives.

Spar Skills Guide Bot
DeveloppementIntermédiaire
28/07/2026
Claude Code
#tmux#terminal-automation#background-processes#mcp#interactive-debugging

Recommandé pour

Synthèse automatique

Automatise des sessions terminal dans des fenêtres tmux via les outils MCP du serveur orchestrator : création de fenêtres, envoi de commandes, capture de sortie et gestion des processus.

Points forts

  • Utilise des identifiants de fenêtre stables (@3) qui restent valides malgré la création ou la fermeture d'autres fenêtres
  • Workflow fichier avec tmux_run_and_read et le placeholder __OUTPUT_FILE__ pour récupérer une sortie propre plutôt que de parser le pane
  • tmux_wait_idle permet d'attendre la fin d'une commande avant capture, avec délégation possible à un subagent tmux-runner pour économiser le contexte
  • Couvre les cas interactifs : prompts CLI, commandes sudo, debuggers pdb/gdb, serveurs de longue durée

Limites

  • Dépend entièrement du serveur MCP orchestrator et de tmux installés et configurés
  • Le subagent tmux-runner et l'appel Task avec model haiku décrits sont propres à Claude Code
  • tmux_wait_idle se fonde sur l'absence de changement de sortie, ce qui peut produire des faux positifs sur un processus silencieux ou très long
Quand l'utiliser

À utiliser lorsqu'un agent doit lancer et surveiller des processus longs, des serveurs, des builds ou des sessions de debug interactives dans des terminaux persistants.

Quand l'éviter

À éviter pour une commande ponctuelle dont la sortie tient dans un seul appel, ou dans un environnement sans tmux ni serveur MCP orchestrator.

Analyse de sécurité

Prudence
Score qualité88/100

The skill provides instructions for automating tmux windows to run commands, send keystrokes, and interact with CLI prompts. It does not contain malicious or obfuscated actions, but it does enable execution of arbitrary commands, including privileged operations via sudo, and could be used to send secrets if misused. This is legitimate terminal automation but warrants caution due to the power of the tools involved.

Points d'attention
  • •Uses tmux MCP tools to execute arbitrary shell commands, including sudo and interactive password prompts, which is powerful but intended for legitimate terminal automation.
Comment cette analyse est faite

Exemples

Monitor a dev server
Start the dev server in a tmux window, wait until it's listening, then show me the last 50 lines of output.
Interactive debugger session
Open a tmux window running python -m pdb on scripts/train.py, set a breakpoint at line 42, and report the local variables when it hits.
Parallel background builds
Run the frontend and backend builds in two separate tmux windows, wait for both to finish, and summarize any errors from each.

name: automating-tmux-windows description: 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 multiple terminal sessions. triggers: tmux, terminal automation, background process, interactive commands, sudo, debugger, pdb, gdb, long-running process, server monitoring

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

| Tool | Purpose | | -------------------------------------- | ------------------------------------- | | mcp__orchestrator__tmux_new_window | Create new window with command | | mcp__orchestrator__tmux_send | Send text/keys to window | | mcp__orchestrator__tmux_capture | Get window output | | mcp__orchestrator__tmux_list | List windows (JSON) | | mcp__orchestrator__tmux_kill | Close window | | mcp__orchestrator__tmux_interrupt | Send Ctrl+C | | mcp__orchestrator__tmux_wait_idle | Wait for idle (no output changes) | | mcp__orchestrator__tmux_select | Switch to window (bring to front) | | mcp__orchestrator__tmux_run_and_read | Run 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

| Parameter | Type | Default | Description | | --------- | ------ | ------- | ----------------------------------- | | command | string | "zsh" | Command to run (auto shell-wrapped) | | name | string | "" | Window name for status bar |

tmux_run_and_read

| Parameter | Type | Default | Description | | --------- | ------ | -------- | ------------------------------------------ | | command | string | required | Command with __OUTPUT_FILE__ placeholder | | name | string | "" | Window name for status bar | | timeout | int | 300 | Max seconds to wait |

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

tmux_wait_idle

| Parameter | Type | Default | Description | | -------------- | ------ | -------- | --------------------------- | | target | string | required | Window ID (e.g., "@3") | | idle_seconds | float | 2.0 | Seconds of no change = idle | | timeout | int | 60 | Max seconds to wait |

tmux_capture

| Parameter | Type | Default | Description | | --------- | ------ | -------- | ----------------------------- | | target | string | required | Window ID (e.g., "@3") | | lines | int | 100 | Lines 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

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/automating-tmux-windows-ms47vr19' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/automating-tmux-windows-ms47vr19/download' --output '.skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md.part' && mv '.skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md.part' '.skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Extrait original : 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

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md' && test -s '.skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/automating-tmux-windows' && cp -R '.skill-downloads/automating-tmux-windows-ms47vr19' '.claude/skills/automating-tmux-windows'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/automating-tmux-windows-ms47vr19'

openskills read 'automating-tmux-windows-ms47vr19'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/automating-tmux-windows-ms47vr19/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires