sandgardenhq/sgai/run-long-running-processes-in-tmux
Claude Code and agent skill by sandgardenhq/sgai
- community
Checking that the SKILL.md file is still in the repository.
Guide for using tmux to manage detached sessions for long-running processes, including lifecycle management, cleanup, startup, verification, and output capture; When you need to run servers or long-running commands in the background, send commands to them, capture output, handle TTY requirements, or manage session lifecycle with error handling
Install
npx vskill@latest install sandgardenhq/sgai/run-long-running-processes-in-tmuxSKILL.md
Run Long Running Processes in Tmux
Overview
Tmux allows running processes in detached sessions, providing pseudo-terminals for processes requiring TTY, and tools to interact with them without attaching. Enhanced with complete session lifecycle management including cleanup, startup verification, and output capture.
When to Use
Use when:
- Running servers or daemons in background
- Processes need TTY but you want detached execution
- Need to send commands or signals to running processes
- Capturing output from detached sessions
- Managing long-running tasks in automation scripts
- Testing server processes or managing background services
- Need session cleanup and conflict resolution
Core Pattern
- Cleanup existing sessions: tmux kill-session -t name 2>/dev/null || true
- Start detached session: tmux new-session -d -s name "command"
- Verify startup: tmux capture-pane -t name -S - -p | grep -q "expected_output"
- Interact: tmux send-keys -t name "command" C-m
- Capture: tmux capture-pane -t name -S - -p > file
- Monitor: tmux attach -t name (when needed)
Quick Reference
| Command | Purpose | Example | |||||
|---|---|---|---|---|---|---|---|
| kill-session -t name 2>/dev/null | true | Cleanup existing | tmux kill-session -t server 2>/dev/null | true | |||
| new-session -d -s name "cmd" | Start detached | tmux new-session -d -s server "python -m http.server" | |||||
| capture-pane -t name -S - -p | Verify startup | tmux capture-pane -t server -S - -p | grep -q "Serving" | ||||
| send-keys -t name "cmd" C-m | Send command | tmux send-keys -t server "echo test" C-m | |||||
| capture-pane -t name -S - -p > file | Capture output | tmux capture-pane -t server -S - -p > log.txt | |||||
| attach -t name | Reattach | tmux attach -t server | |||||
| kill-session -t name | Stop session | tmux kill-session -t server |
Implementation
Session Lifecycle Management
Starting Detached Sessions
For processes requiring TTY, tmux provides PTYs automatically.
Session Verification
Sending Commands
Note: Process must accept stdin as commands. May need delays for shell readiness.
Capturing Output
Text only, may lose colors unless -e flag used.
Common Mistakes
- Forgetting -d flag (attaches instead of detaching)
- Wrong pane syntax (session:window.pane)
- Assuming processes can receive commands if not shell-based
- Not handling TTY requirements (tmux usually covers)
- Losing sessions on reboot (use supervisors)
- Not cleaning up existing sessions before starting new ones
- Forgetting to verify session startup before proceeding
- Not handling session conflicts in automation scripts
Real-World Impact
Enables background execution of servers, automated testing, and remote process management without keeping terminals open. Enhanced lifecycle management reduces repetitive session management tasks and provides reliable server testing workflows with proper error handling and cleanup.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcmd/sgai/skel/.sgai/skills/run-long-running-processes-in-tmux/SKILL.md
Popularity
- Repository stars
- 113
- Repository forks
- 6
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 27 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sandgardenhq/sgai/run-long-running-processes-in-tmux)