From tmux-claude
Fork a new tmux window that runs a command with status tracking, log capture, and wait-for-completion polling. Use when the user requests 'fork tmux', 'fork a window', 'fork to run X', 'side task: <task>', 'fork session', 'fork this session', 'rewind session', or 'rewind to'. Requires an active tmux session ($TMUX). Supports forking the current Claude session with full context preservation, and rewinding to a previous conversation state. Prefer the `tmux` skill's `window-new` for lightweight fire-and-forget window creation; use fork-tmux when you need a tracked session.
How this skill is triggered — by the user, by Claude, or both
Slash command
/tmux-claude:fork-tmuxThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Fork a new **tmux window** that runs a command, with lifecycle management layered on top (session ID, status file, log capture for non-interactive commands, and polling helpers). Specialized for tmux — requires `$TMUX` to be set.
Fork a new tmux window that runs a command, with lifecycle management layered on top (session ID, status file, log capture for non-interactive commands, and polling helpers). Specialized for tmux — requires $TMUX to be set.
When to use this skill vs. the tmux skill:
tmux skill's window-new → lightweight, fire-and-forget window creationfork-tmux (this skill) → tracked session: you get a session_id you can status/wait/cleanup on, plus automatic log files for non-interactive commandsFollow the Instructions, execute the Workflow, based on the Cookbook.
ENABLE_RAW_CLI_COMMANDS: true ENABLE_CLAUDE_CODE: true ENABLE_GEMINI_CLI: true ENABLE_SESSION_FORK: true
$TMUX must be set). The script exits with code 2 otherwise.Cookbook to determine which recipe applies.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py — never a bare relative path.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py to understand the tooling.Cookbook section below to determine which recipe applies.fork_tmux.py fork using the syntax from the cookbook, adding --cwd <path> if a working directory was specified and --name <name> following the Window Naming rules below.Always pass --name when invoking fork_tmux.py fork. If the user specified a name, use it. Otherwise, generate a short, descriptive name from the task context:
style-review, quiz-gen, deploy-staging)lecture-update not claude, build-images not npm)Examples:
| User request | --name |
|---|---|
| "fork tmux to run the tests" | run-tests |
| "fork with claude to review the PR" | pr-review |
| "fork to run npm install" | npm-install |
| "fork session to fix the style violations" | fix-style |
| "fork tmux with gemini to analyze the logs" | log-analysis |
Extract the working directory from phrases like:
--cwd /path/to/dir--cwd /path/to/dir--cwd /path/to/dir--cwd /path/to/dirIf no working directory is specified, omit --cwd (defaults to current directory).
DO NOT execute fork_tmux.py until you have:
NEVER skip directly to fork_tmux.py. The cookbook contains critical syntax requirements that differ between raw CLI commands and Claude Code invocations.
If you skip the cookbook, you will likely use incorrect syntax (e.g., claude code "..." instead of claude "..."), causing the forked window to fail silently.
ENABLE_RAW_CLI_COMMANDS is true.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/cookbook/cli-command.mdENABLE_CLAUDE_CODE is true.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/cookbook/claude-code.mdENABLE_GEMINI_CLI is true.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/cookbook/gemini-cli.mdENABLE_SESSION_FORK is true.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/cookbook/claude-code-fork-session.mdENABLE_SESSION_FORK is true.${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/cookbook/claude-code-rewind-session.mdForked tmux sessions create files in /tmp/fork-tmux-status/:
| File | Purpose |
|---|---|
<session_id>.json | Status tracking (running/completed, exit code, timestamps, window name) |
<session_id>.log | Full stdout/stderr output (non-interactive commands only) |
<session_id>.sh | Wrapper script that ran inside the tmux window |
Note: Interactive commands (Claude, Gemini, vim, nvim, nano, htop, top) are auto-detected and run without stdout piping to preserve their TUI interfaces. Status tracking (exit code) still works, but no log file is created.
For Claude commands, the status file also includes claude_session_id and claude_session_file (path to the JSONL conversation history). These fields are null for non-Claude commands.
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py status <session_id>
# Example output:
# {
# "status": "completed",
# "exit_code": 1,
# "completed_at": "1234567890.123",
# "session_id": "abc12345",
# "log_file": "/tmp/fork-tmux-status/abc12345.log",
# "claude_session_id": "a1b2c3d4-...",
# "claude_session_file": "/home/user/.claude/projects/-home-user-project/a1b2c3d4-....jsonl"
# }
If the tmux window is closed without the wrapper script updating the status file, status detects the missing window and reports "status": "completed" with "detection": "tmux_window_gone" and exit_code: null.
# View the full command output
cat /tmp/fork-tmux-status/<session_id>.log
# Or resolve the path via status output
cat "$(python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py status <session_id> | jq -r .log_file)"
| Exit Code | Meaning |
|---|---|
0 | Command succeeded |
1 | General error |
127 | Command not found |
130 | Terminated by Ctrl+C |
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py status <session_id>cat /tmp/fork-tmux-status/<session_id>.logRemove status, log, and wrapper-script files when no longer needed:
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-tmux/scripts/fork_tmux.py cleanup <session_id>
# Output: {"status_removed": true, "log_removed": true, "script_removed": true, "session_id": "abc12345"}
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub alxlenc/alx-skills --plugin tmux-claude