using-tmux-for-interactive-commands
Controls interactive CLI tools (vim, git rebase -i, REPLs) through tmux detached sessions and send-keys. Use when running tools requiring terminal interaction, programmatic editor control, or orchestrating Claude Code sessions. Triggers include "interactive command", "vim", "REPL", "tmux", or "git rebase -i".
What this skill does
# Using tmux for Interactive Commands ## Quick Reference (30 seconds) Interactive CLI tools (vim, REPLs, git rebase -i) require real terminals. Use tmux detached sessions with `send-keys` and `capture-pane`. ### Essential Commands | Task | Command | | -------------- | ----------------------------------------- | | Start session | `tmux new-session -d -s <name> <command>` | | Send input | `tmux send-keys -t <name> 'text' Enter` | | Capture output | `tmux capture-pane -t <name> -p` | | Stop session | `tmux kill-session -t <name>` | | List sessions | `tmux list-sessions` | ### Core Pattern ```bash tmux new-session -d -s edit vim file.txt # Start detached sleep 0.3 # Wait for init tmux send-keys -t edit 'i' 'Hello' Escape ':wq' Enter # Interact tmux kill-session -t edit # Cleanup ``` ### When to Use | Use tmux | Don't use | | ------------------------- | -------------------------------------- | | vim, nano, editors | Simple non-interactive commands | | Python/Node REPLs | Commands that accept stdin redirection | | git rebase -i, git add -p | One-shot commands | | Full-screen apps (htop) | | --- ## Implementation Guide (5 minutes) ### Workflow 1. **Create detached session** with interactive command 2. **Wait briefly** (100-500ms) for initialization 3. **Send input** via `send-keys` 4. **Capture output** via `capture-pane -p` 5. **Repeat** steps 3-4 as needed 6. **Terminate** session when done ### Special Keys | Key | tmux name | | --------- | ----------------------------- | | Return | `Enter` | | ESC | `Escape` | | Ctrl+C | `C-c` | | Ctrl+X | `C-x` | | Arrows | `Up`, `Down`, `Left`, `Right` | | Space | `Space` | | Backspace | `BSpace` | ### Working Directory ```bash tmux new-session -d -s git -c /path/to/repo git rebase -i HEAD~3 ``` --- ## Common Patterns ### Python REPL ```bash tmux new-session -d -s py python3 -i tmux send-keys -t py 'import math' Enter tmux send-keys -t py 'print(math.pi)' Enter tmux capture-pane -t py -p tmux kill-session -t py ``` ### Vim Editing ```bash tmux new-session -d -s vim vim /tmp/file.txt sleep 0.3 tmux send-keys -t vim 'i' 'New content' Escape ':wq' Enter ``` ### Interactive Git Rebase ```bash tmux new-session -d -s rebase -c /repo git rebase -i HEAD~3 sleep 0.5 tmux capture-pane -t rebase -p tmux send-keys -t rebase 'Down' 'Home' 'squash' Escape ':wq' Enter ``` ### Node REPL ```bash tmux new-session -d -s node node tmux send-keys -t node 'const x = 42' Enter tmux send-keys -t node 'console.log(x * 2)' Enter tmux capture-pane -t node -p tmux kill-session -t node ``` --- ## Common Mistakes ### Not Waiting After Start **Problem:** Blank screen on immediate capture **Fix:** ```bash tmux new-session -d -s sess command sleep 0.3 # Let command initialize tmux capture-pane -t sess -p ``` ### Forgetting Enter Key **Problem:** Commands typed but not executed **Fix:** Always explicitly send `Enter` ### Wrong Session Name **Problem:** Session not found **Fix:** Use `tmux list-sessions` to verify names ### Not Escaping Special Characters **Problem:** Shell interprets characters **Fix:** Use single quotes: `tmux send-keys -t s 'echo "hello"' Enter` --- ## Advanced: Claude Code Orchestration ### Start Claude Code in tmux ```bash tmux new-session -d -s claude -c /project/path claude sleep 2 # Claude Code takes longer to start tmux capture-pane -t claude -p # See initial state ``` ### Send Prompts ```bash tmux send-keys -t claude "Fix all TypeScript errors" Enter sleep 30 # Wait for processing tmux capture-pane -t claude -p # Check progress ``` ### Graceful Exit ```bash tmux send-keys -t claude '/exit' Enter sleep 1 tmux kill-session -t claude ``` --- ## Works Well With **Skills**: bash-optimizer, github **Tools**: tmux, vim, git --- ## Reference - [tmux man page](https://man7.org/linux/man-pages/man1/tmux.1.html) - [Full examples](reference.md)
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.