Tmux cli

From sammcj/agentic-coding · View interactive version

Tmux cli is an AI agent skill from the GitHub repository sammcj/agentic-coding. CLI utility to help when running ongoing interactive CLI sessions or using tmux to communicate with other CLI Agents. Use when you are asked to ssh to remote machines, or need to use interactive CLI tools that require ongoing input.

How to use this skill

Skill file

tmux-cli

Instructions

Remote SSH hosts (default pattern)

When you need to run more than one command on a remote host over SSH, do NOT issue repeated one-off ssh host 'cmd' calls - each re-authenticates and needs its own approval. Open ONE persistent session and drive it. This is the default for any multi-command remote work.

  1. Reuse an existing session rather than spawning a new one each task (windows accumulate otherwise): check tmux-cli status / tmux-cli list_panes, reuse its pane if healthy, and only tmux-cli launch "zsh" if none exists. Note the returned pane id.
  2. Arm auto-cleanup on the pane BEFORE connecting, so nothing lingers if the task is abandoned:
  1. Connect with keepalive so a dropped link tears itself down: ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no user@host.
  2. After connecting, set the same idle timeout on the remote shell (busybox ash and bash both honour it): export TMOUT=1800.
  3. Run work with send + wait_idle + capture. Only the pane's ssh uses the network / SSH auth; tmux-cli itself only talks to the local tmux socket.
  4. Tear it down explicitly when done: tmux-cli cleanup kills the managed session; tmux-cli kill --pane=<id> kills a single pane. Do not leave idle sessions behind - the timeouts above are a backstop, not a substitute for cleanup.

Key Commands

Execute with Exit Code Detection

Use tmux-cli execute when you need to know if a shell command succeeded or failed:

tmux-cli execute "make test" --pane=2
# Returns JSON: {"output": "...", "exit_code": 0}

tmux-cli execute "npm install" --pane=ops:1.3 --timeout=60
# Returns exit_code=0 on success, non-zero on failure, -1 on timeout

This is useful for:

Note: execute is for shell commands only, not for agent-to-agent chat.

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.