harness/plugins/subagents/claude/skills/cmux-subagent/SKILL.md
This skill should be used when the user asks to "launch a subagent in cmux", "run claude in a new pane", "open agent in cmux", "parallel agents", "cmux pane for claude", "split pane agent", or wants to spawn Claude Code instances in separate cmux panes for parallel, interactive work with bidirectional communication.
npx skillsauth add popoffvg/dotfiles cmux-subagentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Launch Claude Code agents in cmux split panes with bidirectional communication via Unix socket API. Unlike tmux's fragile screen-scraping, cmux provides typed send/read-screen commands for reliable inter-agent messaging.
Verify inside a cmux session:
echo "$CMUX_SURFACE_ID" # non-empty = inside cmux
If not inside cmux, fall back to the standard Agent tool.
| Action | Command |
|--------|---------|
| Create pane | cmux new-pane --type terminal --direction right --cwd "$(pwd)" |
| Send text | cmux send --surface surface:N 'message' |
| Press Enter | cmux send-key --surface surface:N enter |
| Read output | cmux read-screen --surface surface:N |
| List panes | cmux tree |
| Close pane | cmux close-surface --surface surface:N |
Interactive (default) — long-lived agent, user or orchestrator can chat:
cmux send --surface surface:N 'claude --dangerously-skip-permissions'
cmux send-key --surface surface:N enter
Non-interactive (-p) — fire-and-forget, prints result and exits:
cmux send --surface surface:N 'claude -p --dangerously-skip-permissions "<prompt>"'
cmux send-key --surface surface:N enter
Default to interactive unless the user explicitly asks for fire-and-forget.
--cwd)cmux new-pane --type terminal --direction right --cwd "$(pwd)"
# Returns: OK surface:N pane:N workspace:N
# Capture the surface ref (e.g., surface:3)
Direction options: right, left, up, down.
cmux send --surface surface:N 'claude --dangerously-skip-permissions'
cmux send-key --surface surface:N enter
Wait ~8s for Claude to initialize, then verify:
cmux read-screen --surface surface:N
# Look for the "❯" prompt indicating ready
# Send
cmux send --surface surface:N 'your message here'
cmux send-key --surface surface:N enter
# Wait and read — 5s is usually enough for short replies
sleep 5 && cmux read-screen --surface surface:N
Speed tips:
read-screen — check if the ❯ prompt reappeared (agent is done)Parse read-screen output for the idle prompt pattern:
❯
When you see an empty ❯ prompt at the bottom, the agent has finished responding.
# Graceful exit
cmux send --surface surface:N '/exit'
cmux send-key --surface surface:N enter
# Or force close
cmux close-surface --surface surface:N
| Agents | Strategy | Direction |
|--------|----------|-----------|
| 1 | Single split | right |
| 2 | Right + down | right, then down on second |
| 3+ | Separate per task | Multiple right/down splits |
| Flag | Purpose |
|------|---------|
| --dangerously-skip-permissions | Skip permission prompts |
| -p / --print | Non-interactive, print and exit |
| --allowedTools "Tool1 Tool2" | Restrict available tools |
| --model sonnet | Faster/cheaper model |
| --max-budget-usd 0.50 | Cap spending per agent |
| -w / --worktree | Isolate in git worktree |
# 1. Create pane
cmux new-pane --type terminal --direction right --cwd "$(pwd)"
# → surface:N
# 2. Launch interactive agent
cmux send --surface surface:N 'claude --dangerously-skip-permissions'
cmux send-key --surface surface:N enter
sleep 8
# 3. Send task
cmux send --surface surface:N 'Analyze the main module and list public functions'
cmux send-key --surface surface:N enter
sleep 5
# 4. Read response
cmux read-screen --surface surface:N
# 5. Send follow-up based on response
cmux send --surface surface:N 'Now write tests for the first 3 functions'
cmux send-key --surface surface:N enter
for topic in "auth flow" "database schema" "API endpoints"; do
OUTPUT=$(cmux new-pane --type terminal --direction right --cwd "$(pwd)")
SURFACE=$(echo "$OUTPUT" | grep -o 'surface:[0-9]*')
cmux send --surface "$SURFACE" "claude -p --dangerously-skip-permissions \"Analyze the $topic in this codebase. Write summary to /tmp/research-${topic// /-}.md\""
cmux send-key --surface "$SURFACE" enter
done
cmux new-pane --type terminal --direction right --cwd "$(pwd)"
# → surface:N
cmux send --surface surface:N 'claude -p -w --dangerously-skip-permissions "Refactor the auth module"'
cmux send-key --surface surface:N enter
$CMUX_SURFACE_ID. If empty, fall back to Agent tool or tmux skill.cmux tree to list valid surfaces.--type terminal when creating panes.cmux read-screen for error output.| Feature | cmux | tmux |
|---------|------|------|
| Send text | cmux send (typed, reliable) | send-keys (byte sequence, fragile) |
| Read output | cmux read-screen (clean) | capture-pane (screen-scrape artifacts) |
| Addressing | Stable surface:N refs | Session:window.pane (can shift) |
| Key events | send-key enter (explicit) | send-keys Enter (string matching) |
| API | Unix socket | tmux server protocol |
tools
Improve a whole CLAUDE.local.md — the private, per-project rules captured from user corrections. Wraps each conditional rule in a <task-relevant> block so it only surfaces for matching work, merges duplicates, generalizes one-off facts, drops stale entries, and routes raw project facts to engram. Use when the user says "improve claude.local", "clean up the local rules", "claude.local is bloated", or after the Stop hook has appended many rules.
testing
WM pipeline and conventions shared across all phases. Agents must read this before spec, impl, or verify work.
development
One entry point for spec writing, implementation, and bug fixing. Default is new (write spec → grill loop → produce notes → author TODO bodies). Other subcommands: verify (audit), revise (sync to shipped), prototype (settle a decision), code-map (diagram), impl (execute one TODO), fix (analyze cause, correct thoughts, fix behavior), help (this page). Invoke as /code <subcommand>.
development
Red-Green-Refactor cycle for bug fixes. Before fixing a bug, first write a failing test that reproduces it (Red), then make the minimal change to pass (Green), then clean up the code (Refactor). Use on any bug fix, error correction, failing test repair, or when user says "fix this bug".