agentleFS
ph3on1xph3on1x/agent-plugins-skills/skills/cmux/SKILL.md

cmux

Skill0 starsChanged 17 days agoMITView on GitHub

This skill should be used when the user invokes /cmux or asks to spawn parallel Claude Code sessions in cmux terminal panes, monitor agent output, automate browsers in cmux, manage cmux notifications, or perform any cmux terminal management task. Requires CMUX_SOCKET_PATH environment variable to be set.

27 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use cmux-browser, cmux-markdown and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • manaflow-aiSkill

    cmux-browser

    Automate the browser inside cmux. Use for cmux browser, browser surface, webview, current workspace browser, snapshot refs, DOM actions, waits, screenshots, cookies, storage, tabs, downloads, console, errors, and browser session state.

    Also in 4 projects that use this

  • basicmachines-coSkill

    cmux-markdown

    Open markdown files in a formatted viewer panel with live reload. Use when you need to display plans, documentation, or notes alongside the terminal with rich rendering (headings, code blocks, tables, lists).

    Also in 3 projects that use this

  • basicmachines-coSkill

    cmux-settings

    View and edit cmux settings in ~/.config/cmux/cmux.json. Use when the user wants to change cmux preferences (appearance, sidebar, notifications, automation, browser, shortcuts), set a value by JSON path, validate the file, open it in an editor, or look up which keys cmux recognizes. Triggers on '/cmux-settings', 'change cmux setting', 'set <something> in cmux', 'cmux config', 'cmux.json', or 'rebind a cmux shortcut'.

    Also in 3 projects that use this

  • matyasstochSkill

    distribute-skill-to-all-agents

    Distribute a newly-created agent skill across all 4 canonical skill folders on a local machine so Claude Code, Codex/OpenAI Agents, Pi Agent, and Hermes all see it. Use whenever the user says "give this skill to all agents", "distribute this skill", "sync skills across agents", or after creating a new skill that should be globally available. Covers the .claude/skills symlink and the ~/.pi/agent/skills (NOT ~/.pi/skills) trap.

    Also in 3 projects that use this

  • manaflow-aiSkill

    cmux-workspace

    Work inside the current cmux workspace and terminal. Use for cmux workspace, current workspace, caller surface, panes, surfaces, tagged reloads, socket targeting, and non-interfering cmux automation.

    Also in 3 projects that use this

  • matyasstochSkill

    effective-agent-skills

    How to write effective agent skills — what to do, what not to do, anatomy, progressive disclosure, design patterns, anti-patterns, testing, security. Read this whenever a skill (Claude Skill, Agent Skill, SKILL.md) is being created, edited, reviewed, or debugged. Use when the user says "create a skill", "new skill", "update this skill", "improve a skill", "why isn't my skill triggering", or anything else involving authoring or editing SKILL.md files.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default: panes, not workspaces: Use cmux new-split to create splits within the current workspace.

    line 38
  2. Distinctive:

    After splitting, verify topology:

    line 90
  3. Very specific:

    Use send-key for control sequences:

    line 129
  4. Distinctive:

    Read terminal content from any surface without switching to it:

    line 152
  5. Distinctive:

    Check surface health to verify agent state before closing:

    line 224

“Common” is measured: kept by at least 6 in 10 of the 24 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Using cmux

cmux is a macOS terminal built for AI coding agents. The session runs inside cmux when CMUX_SOCKET_PATH is set.

Quick Orientation

cmux identify --json    # Current workspace, pane, surface
cmux tree --json        # Full hierarchy of windows/workspaces/panes/surfaces

Hierarchy: Window -> Workspace (sidebar tab) -> Pane (split region) -> Surface (terminal or browser tab)

Refs format: workspace:2, pane:1, surface:7 — always prefer short refs over UUIDs.

Environment Variables (Auto-Set)

VariablePurpose
CMUX_SOCKET_PATHControl socket (CLI uses automatically)
CMUX_WORKSPACE_IDCurrent workspace UUID
CMUX_SURFACE_IDCurrent surface UUID

Commands default to the current workspace/surface when flags are omitted.

Agent Orchestration

The core pattern for running multiple agents in parallel, each in its own pane.

Default: panes, not workspaces. Use cmux new-split to create splits within the current workspace. Only use cmux new-workspace when agents need completely separate project directories (e.g., monorepo subprojects with different --cwd).

Creating Balanced Pane Layouts

Each new-split returns the created surface ref — always capture it to target subsequent splits and commands:

S1=$(cmux new-split right | awk '{print $2}')   # Capture "surface:N" from "OK surface:N workspace:N"

Critical rule: always use --surface to target which pane to split. Without it, cmux splits whichever pane has focus — leading to recursive halving of one pane while others stay untouched.

Layout recipes by agent count

1 agent — single split:

S1=$(cmux new-split right | awk '{print $2}')
# Layout: [orchestrator 50% | agent-1 50%]

2 agents — split right, then subdivide:

S1=$(cmux new-split right | awk '{print $2}')
S2=$(cmux new-split down --surface $S1 | awk '{print $2}')
# Layout: [orchestrator 50% | agent-1 25%]
#                            | agent-2 25%]

3 agents — 2×2 grid (all panes equal):

ORIG=$(cmux identify --json | awk -F'"' '/"surface_ref"/{print $4}')
S1=$(cmux new-split right | awk '{print $2}')
S2=$(cmux new-split down --surface $S1 | awk '{print $2}')
S3=$(cmux new-split down --surface $ORIG | awk '{print $2}')
# Layout: [orchestrator 25% | agent-1 25%]
#         [agent-3 25%      | agent-2 25%]

4+ agents — extend the 2×2 grid by splitting the largest agent pane:

# ... after creating the 2x2 grid above (S1, S2, S3) ...
S4=$(cmux new-split right --surface $S2 | awk '{print $2}')
# Layout: [orchestrator 25%   | agent-1 25%         ]
#         [agent-3 25%        | agent-2 12% | agent-4 12%]

For 5+ agents, continue splitting the largest remaining pane. Alternate between right and down to keep proportions reasonable.

After splitting, verify topology:

cmux list-panes                         # List all panes with surface refs
cmux tree --json                        # Full topology with all refs

Launching Agents

Always launch agents in interactive mode (claude 'prompt', NOT claude -p). Interactive mode shows real-time streaming output — you can watch agents think, call tools, and produce results. Print mode (-p) buffers all output and shows nothing until the agent finishes.

Agents launched interactively don't auto-exit — they stay at the prompt after completing the task. The orchestrator detects completion via read-screen and closes the pane with close-surface.

Always instruct agents to save output to scratchpad/ so results survive pane closure and the main agent can review them later. Each agent should write a summary of its work to a unique file.

Simple prompts (one-liner, no special characters)

Pass the prompt inline with single quotes:

cmux send --surface $S1 "claude 'implement auth module. When done, save a summary of changes to scratchpad/agent-auth.md'\n"
cmux send --surface $S2 "claude 'write unit tests. When done, save a summary of results to scratchpad/agent-tests.md'\n"

Complex or multi-line prompts (preferred for detailed instructions)

Write the prompt to a file first, then pass it via $(cat). This avoids quoting/escaping corruption — cmux send interprets \n as Enter, which splits multi-line prompts across shell lines, causing quote> continuation and stuck input.

# 1. Write each agent's prompt to a file (use the Write tool)
#    e.g., scratchpad/agent-1-prompt.md, scratchpad/agent-2-prompt.md

# 2. Send the command to each agent's pane:
cmux send --surface $S1 "claude \"\$(cat scratchpad/agent-1-prompt.md)\"\n"
cmux send --surface $S2 "claude \"\$(cat scratchpad/agent-2-prompt.md)\"\n"

Never save prompts to /tmp/ or write shell scripts. Use scratchpad/ for prompt files. Avoid $, backticks, and unescaped " in prompt files — they get expanded by the shell during $(cat) substitution.

Use send-key for control sequences:

cmux send-key --surface surface:5 ctrl+c    # Interrupt a process
cmux send-key --surface surface:5 enter      # Send Enter

Handling Permission Prompts

Spawned Claude Code sessions have their own permission state. They will hit permission prompts for tools like WebSearch, Fetch, Write, etc.

Monitor and approve interactively:

cmux read-screen --surface surface:5 --lines 10   # Check for permission prompts
cmux send-key --surface surface:5 enter            # Approve (option 1: Yes)
cmux send --surface surface:5 "2\n"                # Option 2: Yes, don't ask again

Better: pre-configure permissions in .claude/settings.json before launching agents so they don't need interactive approval. This avoids the orchestrator needing to babysit permission prompts.

Monitoring Agent Output

Read terminal content from any surface without switching to it:

# Read current screen content
cmux read-screen --surface surface:5

# Read with scrollback history
cmux read-screen --surface surface:5 --scrollback

# Read last N lines only
cmux read-screen --surface surface:5 --lines 50

# Pipe output to a shell command for processing
cmux pipe-pane --surface surface:5 --command "grep -c 'DONE'"

read-screen (alias: capture-pane) is the primary tool for checking whether an agent has finished, encountered errors, or produced results.

Sidebar Status & Progress

Provide orchestration visibility in the sidebar:

# Set a status pill (key is unique per tool)
cmux set-status "agent-1" "researching" --icon "magnifyingglass" --color "#3498db"
cmux set-status "agent-2" "testing" --icon "test" --color "#ffaa00"

# Show progress bar (0.0 to 1.0)
cmux set-progress 0.5 --label "2 of 4 agents complete"

# Append log entries with severity levels
cmux log "Agent 1 finished auth module" --level success
cmux log "Agent 2 hit test failure" --level warning
cmux log --level error "Build failed in surface:6"

# Read back all sidebar state
cmux sidebar-state

Clean up after orchestration:

cmux clear-status "agent-1"
cmux clear-status "agent-2"
cmux clear-progress
cmux clear-log

Synchronization

Named synchronization tokens for coordinating between agents:

# In surface:5 — agent signals completion
cmux wait-for --signal auth-complete

# In main pane — wait for that signal (blocks until signaled or timeout)
cmux wait-for auth-complete --timeout 300

Cleanup

Close each agent's pane as soon as it finishes — don't wait to batch-close at the end. Since agents save output to scratchpad/, results persist after pane closure.

# After detecting agent-1 has finished:
test -f scratchpad/agent-auth.md && cmux close-surface --surface $S1

# After detecting agent-2 has finished:
test -f scratchpad/agent-tests.md && cmux close-surface --surface $S2

Check surface health to verify agent state before closing:

cmux surface-health                     # Health details for all surfaces in workspace

Inter-Pane Data Sharing

Share data between panes using named buffers:

# Store result from one agent
cmux set-buffer --name "auth-result" "JWT module implemented at src/auth.ts"

# Retrieve in another context
cmux paste-buffer --name "auth-result" --surface surface:6

For detailed orchestration patterns, advanced multi-agent workflows, and error recovery, consult references/orchestration.md.

Browser Automation

Core workflow: Open -> Snapshot (get refs) -> Act with refs -> Wait for changes.

# Open browser (returns surface ref)
cmux browser open https://example.com --json

# Take interactive snapshot — ALWAYS use --interactive
cmux browser surface:7 snapshot --interactive

# Interact using element refs (e1, e2, etc.) — never CSS selectors
cmux browser surface:7 click e2
cmux browser surface:7 fill e3 "search query"

# Wait for navigation, then re-snapshot (DOM changes invalidate refs)
cmux browser surface:7 wait --load-state complete --timeout-ms 15000
cmux browser surface:7 snapshot --interactive

For the complete browser API (forms, keyboard, scrolling, finding elements, JS eval, session/state, cookies, diagnostics), consult references/browser-automation.md.

Notifications

Two notification systems for different contexts:

# In-app: blue ring, sidebar badge, notification panel
cmux notify --title "Claude Code" --body "Waiting for approval"

# System-level: macOS Notification Center, sounds, visible outside cmux
osascript -e 'display notification "Build complete" with title "Claude Code" sound name "Submarine"'
NeedUse
User is in cmuxcmux notify
User may be in another apposascript with sound
Context-aware (pane/workspace)cmux notify
Must persist after cmux closesosascript

For the full notification comparison, hook integration, and decision matrix, consult references/notifications.md.

Reading Terminal Output

read-screen is the critical tool for observing what any terminal surface is displaying:

# Current visible content (what appears on screen right now)
cmux read-screen --surface surface:5

# Include scrollback buffer for full history
cmux read-screen --surface surface:5 --scrollback

# Last N lines — efficient for checking recent output
cmux read-screen --surface surface:5 --lines 20

# Process output through a shell command
cmux pipe-pane --surface surface:5 --command "tail -5"

To detect whether a Claude Code agent has completed, read the last few lines and look for the shell prompt ($ or >), or specific completion indicators in the output.

Workspace Management

cmux new-workspace --cwd /path/to/project    # New workspace with working directory
cmux new-workspace --cwd /proj --command "claude 'do task'\n"  # With startup command
cmux select-workspace --workspace workspace:2 # Switch workspaces
cmux close-workspace --workspace workspace:3  # Close workspace
cmux list-workspaces                          # List all workspaces
cmux rename-workspace "auth-feature"          # Rename current workspace
cmux find-window --content "error" --select   # Find workspace by terminal content

Claude Code Hook Integration

cmux provides a built-in hook for Claude Code session lifecycle:

cmux claude-hook session-start   # Mark session as active (alias: active)
cmux claude-hook stop            # Mark session as idle (alias: idle)
cmux claude-hook notification    # Forward notification (alias: notify)
cmux claude-hook prompt-submit   # Handle prompt submission

These hooks update sidebar metadata automatically — showing active/idle status, suppressing redundant notifications, and tracking agent PIDs.

Command Quick Reference

TaskCommand
Where am I?cmux identify --json
Full topologycmux tree --json
Split panecmux new-split right|down
Send to surfacecmux send --surface surface:N "cmd\n"
Send key eventcmux send-key --surface surface:N ctrl+c
Read screencmux read-screen --surface surface:N --lines 50
Set status pillcmux set-status "key" "value"
Set progresscmux set-progress 0.5 --label "text"
Log messagecmux log "message" --level info
Wait for signalcmux wait-for <name> --timeout 30
Signal donecmux wait-for --signal <name>
Close surfacecmux close-surface --surface surface:N
Surface healthcmux surface-health
Open browsercmux browser open <url> --json
Get element refscmux browser surface:N snapshot --interactive
Click elementcmux browser surface:N click e3
In-app notifycmux notify --title T --body B
Store buffercmux set-buffer --name "key" "value"
Flash panecmux trigger-flash

Common Mistakes

MistakeFix
Using UUIDs everywhereUse short refs: workspace:2, surface:7
No way to check agent progressUse cmux read-screen --surface surface:N --lines 50
CSS selectors in browserUse element refs from snapshot --interactive: e3, e5
Forgetting --interactive on snapshotAlways use --interactive to get element refs
Not waiting after navigationUse wait --load-state complete after page loads
Not re-snapshotting after navigationDOM changes invalidate refs — re-snapshot
Using cmux notify for system alertsUse osascript when user may be outside cmux
cmux pane create or fabricated subcommandsNo such command. Use cmux new-split right|down then cmux send --surface surface:N "cmd\n"
Creating new workspaces for parallel agentsUse cmux new-split right|down instead — workspaces are for separate project roots, not parallel tasks
Splitting the focused pane recursivelyAlways use --surface to target which pane to split — see layout recipes above
Using claude -p for spawned agentsUse claude (interactive) — -p buffers all output and shows nothing until done. Interactive mode gives real-time streaming
Sending multi-line prompts inline via cmux sendWrite prompt to scratchpad/agent-N-prompt.md, then claude "\$(cat scratchpad/agent-N-prompt.md)"
Saving prompts to /tmp/ or writing shell scriptsUse scratchpad/ for prompt files, never /tmp/
Not persisting agent outputInclude save summary to scratchpad/agent-<name>.md in every agent prompt
Leaving finished agent panes openClose each agent's pane as soon as it finishes and output is confirmed saved
No visibility into orchestrationUse set-status, set-progress, log for sidebar updates
Low-level input commandsUse high-level: click, fill, type instead of input_*

Additional Resources

Reference Files

  • references/orchestration.md — Advanced multi-agent patterns, error recovery, polling loops, workspace-per-project strategies
  • references/browser-automation.md — Complete browser API: forms, keyboard, scrolling, finding elements, JS eval, session/state, cookies, diagnostics, WKWebView limitations
  • references/notifications.md — Notification comparison, decision matrix, hook integration, Claude Code hook configuration
  • references/complete-cli.md — Full cmux CLI catalog: every command, flag, and capability organized by category

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.