一键导入
tmux-automation
Run commands in detached tmux sessions and programmatically send input, capture output, and manage sessions
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Run commands in detached tmux sessions and programmatically send input, capture output, and manage sessions
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Facilitate structured brainstorming sessions to generate, explore, and refine ideas before committing to requirements. Use when the user has a vague concept, wants to explore possibilities, needs creative solutions, or is in the early ideation phase. Do NOT use when the requirements are already clear and the user is ready to plan implementation (use create-prd or prd-to-tasks instead).
Interview the human-in-the-loop to clarify ambiguous requests before taking action. Use when the user's request is vague, missing key details, or has multiple valid interpretations. Do NOT use when the request is clear and unambiguous, or when the clarification can be resolved by reading code, docs, or a quick web search.
Read a tasks.json file, resolve the dependency graph, and delegate each task to specialized expert agents using the Mixture of Experts (MoE) orchestration pattern. Use when a tasks.json exists and the user wants to start implementing, or says "implement the tasks," "build it," or "execute the plan." Do NOT use when no tasks.json exists (run prd-to-tasks first), for a single straightforward task (just do it directly), or when the user wants manual control over each step.
Convert a Product Requirements Document (PRD) into a structured tasks.json file with tasks, dependencies, priorities, and estimated effort. Use when a PRD exists and the user wants to break it down into implementable tasks, or says "turn this into tasks," "create issues from the PRD," or "what are the next steps?" Do NOT use when there is no PRD or when the user wants to skip planning and start coding immediately.
Create a Product Requirements Document (PRD) from recent discussions, conversations, or accumulated context. Use when the user wants to formalize requirements, document what was discussed, or create a spec to guide implementation. Do NOT use for technical implementation specs (use SPEC.md from project-files) or for already-implemented features (use CHANGELOG.md).
Research and explore codebases to build context before making changes. Use when starting work on an unfamiliar project, investigating a bug, planning a feature, or when you need to understand how something works.
| name | tmux-automation |
| description | Run commands in detached tmux sessions and programmatically send input, capture output, and manage sessions |
Use this skill when you need to:
# Basic detached session
tmux new-session -d -s <session-name> "<command>"
# With working directory
tmux new-session -d -s <session-name> -c /path/to/dir "<command>"
# Simple shell session (no command)
tmux new-session -d -s <session-name>
# Send text and execute (note: Enter is separate argument)
tmux send-keys -t <session> 'echo "hello"' Enter
# Send special keys
tmux send-keys -t <session> C-c # Ctrl+C
tmux send-keys -t <session> Escape # ESC
tmux send-keys -t <session> Up # Arrow keys
tmux send-keys -t <session> Down
tmux send-keys -t <session> Tab
# Multiple keys in sequence
tmux send-keys -t <session> 'i' 'Hello World' Escape ':wq' Enter
# Capture visible pane content
tmux capture-pane -t <session> -p
# Capture entire scrollback
tmux capture-pane -t <session> -p -S -1000
# Check if session exists
tmux has-session -t <session> 2>/dev/null && echo "exists"
# Kill session when done
tmux kill-session -t <session>
# List all sessions
tmux ls
Sessions are referenced as:
session-name — session (window 0)session-name.0 — first window in sessionsession-name:0 — alternative syntax for windowsession-name.0.0 — specific pane (window 0, pane 0)# 1. Create detached session and wait for init
SESSION="my-session"
tmux new-session -d -s "$SESSION" "python manage.py shell"
sleep 0.3 # Wait for initialization
# 2. Send commands and capture output
tmux send-keys -t "$SESSION" 'from users.models import User' Enter
tmux send-keys -t "$SESSION" 'User.objects.count()' Enter
OUTPUT=$(tmux capture-pane -t "$SESSION" -p)
echo "$OUTPUT"
# 3. Clean up
tmux kill-session -t "$SESSION"
| Key | tmux send-keys value |
|---|---|
| Enter | Enter |
| Escape | Escape |
| Tab | Tab |
| Ctrl+C | C-c |
| Ctrl+D | C-d |
| Ctrl+X | C-x |
| Up/Down/Left/Right | Up, Down, Left, Right |
| Home | Home |
| End | End |
has-sessionSESSION="django-migrate"
tmux new-session -d -s "$SESSION" "python manage.py migrate"
sleep 2
tmux capture-pane -t "$SESSION" -p
tmux kill-session -t "$SESSION"
SESSION="python-repl"
tmux new-session -d -s "$SESSION" "python"
sleep 0.3
tmux send-keys -t "$SESSION" 'import json' Enter
tmux send-keys -t "$SESSION" 'print(json.dumps({"a": 1}))' Enter
tmux capture-pane -t "$SESSION" -p
tmux send-keys -t "$SESSION" 'exit()' Enter
tmux kill-session -t "$SESSION"
SESSION="dev-server"
tmux new-session -d -s "$SESSION" -c /project "npm run dev"
# Session persists, can check output anytime
tmux capture-pane -t "$SESSION" -p
# When done:
tmux kill-session -t "$SESSION"
| Problem | Solution |
|---|---|
| Blank screen on capture | Add sleep 0.3 after session creation |
| Command not executing | Send explicit Enter key as separate argument |
\n doesn't work | Use Enter not \n |
| Session not found | Check with tmux has-session -t <name> first |
| Keys sent to wrong window | Use session:window.pane format explicitly |