Agent skill
tmux
Remote control tmux sessions for interactive CLIs, background tasks, and services.
Install this agent skill to your Project
npx add-skill https://github.com/Dwsy/agent/tree/main/skills/tmux
SKILL.md
tmux Skill
Core Concepts
Socket: /tmp/pi-tmux-sockets/pi.sock (private, no conflicts with personal tmux)
Session Naming: pi-{category}-{name}-{timestamp}
- Categories:
task(temporary),service(long-running),agent(agent-specific)
Session States: running | idle | exited
Persistence: /tmp/pi-tmux-sessions.json
Auto-cleanup: Inactive sessions > 24h removed (configurable)
CLI Commands
bun ~/.pi/agent/skills/tmux/lib.ts <command>
create <name> <command> [category] # Create session, prints monitoring command
list [filter] # List sessions with status
status <id> # Session details
send <id> <keys> # Send keystrokes (literal mode, safe)
capture <id> [lines] # Capture pane output (default: 200)
kill <id> # Terminate session
cleanup [hours] # Remove old sessions (default: 24h)
attach <id> # Print attach command
sync # Sync session state with tmux
TUI: bun ~/.pi/agent/skills/tmux/tui.ts (visual management, shortcuts: r/n/c/s/a/k/q)
TypeScript API
import { TmuxManager } from "~/.pi/agent/skills/tmux/lib.ts";
const tmux = new TmuxManager({ autoCleanup: false }); // optional config
// Session lifecycle
const session = await tmux.createSession(name, command, category);
await tmux.killSession(session.id);
// Output handling
const output = await tmux.capturePane(target, lines);
const success = await tmux.waitForText(target, pattern, { timeout: 60 });
// State management
const sessions = await tmux.listSessions(filter);
const status = await tmux.getSessionStatus(id);
await tmux.sync();
await tmux.cleanup(hours);
Key Rules
-
Always print monitoring command after session creation:
tmux -S /tmp/pi-tmux-sockets/pi.sock attach -t {session-id} -
Use
sendfor interactive tools (Python REPL, gdb, databases):bash# Python REPL: always use PYTHON_BASIC_REPL=1 bun ~/.pi/agent/skills/tmux/lib.ts create python "PYTHON_BASIC_REPL=1 python3 -q" task bun ~/.pi/agent/skills/tmux/lib.ts send pi-task-python-* "print('Hello')" -
Category selection:
task: compilation, testing, temporary operationsservice: dev servers, databases, persistent servicesagent: training, data processing, agent-specific tasks
-
Safe key injection:
senduses literal mode (-l), no shell escaping needed -
Session recovery: Run
syncif session not found
Helper Scripts
# Wait for text pattern with timeout
./scripts/wait-for-text.sh -t session:0.0 -p 'pattern' [-F] [-T 20] [-i 0.5] [-l 2000]
# List sessions with metadata
./scripts/find-sessions.sh -S "$SOCKET"
./scripts/find-sessions.sh --all
Requirements
- tmux (Linux/macOS)
- Bun runtime
- Bash (helper scripts)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
undo-redo
Use the undo_redo tool to rewind or reapply buffered file changes or inspect diffs without UI navigation. Use when you need to adjust or verify changes in the current session history.
exa
使用 Exa.ai API 进行高质量的互联网搜索。需要 EXA_API_KEY 环境变量。
backend-unit-test
后端单元测试技能。触发场景: - 用户要求运行/创建单元测试 - 用户要求验证数据 - 用户要求用 Maven 运行测试 - 关键词:test, maven test, junit, springboot test, 单元测试, 测试验证 核心:不改 pom,用 reactor 模式运行。
mermaid-flow-image
将流程需求整理为可渲染的 Mermaid(简化版/详细版),并通过 Kroki 生成可发送的高分辨率 PNG 图片。适用于“把架构流程画出来并直接发图”的场景。
web-browser
Allows to interact with web pages by performing actions such as clicking buttons, filling out forms, and navigating links. It works by remote controlling Google Chrome or Chromium browsers using the Chrome DevTools Protocol (CDP). When Claude needs to browse the web, it can use this skill to do so.
ralph-loop-gen
任务管理系统模板生成器 - 根据用户输入或JSON配置生成完整的任务管理结构(模板生成器,非直接执行器)
Didn't find tool you were looking for?