cc-launch-cmux-workspace
Overview
Open a target repository/path as a new cmux workspace, start Claude Code there, and verify the session. This skill is Claude Code only; do not generalize it to Codex or opencode unless the user explicitly asks for a different skill.
Workflow
Resolve the target from the user's request.
- If the user gives an absolute path, use that path.
- If the user gives a repo name, search
~/workspace/github.com/*/<repo>.
- If there are zero or multiple matches, stop and ask the user to choose.
Confirm the tools exist:
command -v cmux
command -v claude
Run the helper script from this skill directory:
scripts/launch_cc_workspace.sh <repo-or-path>
scripts/launch_cc_workspace.sh <repo-or-path> --name "<workspace name>"
Report the result concisely: target path, cmux workspace id, TTY, and Claude session id if available.
Helper Behavior
The helper script performs the fragile sequence:
- Create a workspace with
cmux new-workspace --cwd <path> --focus true, then confirm it in the cmux session JSON. If cmux RPC returns an error, still inspect the session JSON because workspace creation can succeed before the socket write fails.
- Fall back to
cmux <path> only if new-workspace did not create a new workspace.
- Identify the matching workspace and terminal TTY from the cmux session JSON.
- Launch Claude by sending
claude\n into the workspace's terminal: cmux send --workspace <id> "claude\n". This runs the claude CLI in the interactive login shell, yielding an operable terminal Claude that inherits the shell environment (direnv/devshell, PATH). It goes through the cmux socket, so unlike AppleScript it does NOT depend on OS window focus.
- Do NOT use
cmux new-surface --type agent-session --provider claude. That creates a cmux-managed React agent surface (shows as "Claude Code · React"), which is not a normal operable terminal and does not give you the shell's environment.
- Only if
cmux send does not yield a running Claude, fall back to AppleScript (activate cmux → keystroke claude → key code 36). AppleScript is focus-dependent and can silently miss the embedded terminal, so it is a last resort.
- Verify startup through the cmux session JSON (
terminal.agent.kind == "claude", label shows "Claude Code" not "Claude Code · React") and ps -t <tty>.
Manual Fallback
If the helper script fails after creating the workspace, use this sequence:
# 1) Create the workspace
cmux new-workspace --cwd <absolute-target-path> --focus true
# 2) Find the new workspace id + terminal tty
jq -r '.windows[0].tabManager.workspaces[] | [.workspaceId,.currentDirectory,.panels[0].ttyName] | @tsv' \
"$HOME/Library/Application Support/cmux/session-com.cmuxterm.app.json"
# 3) Launch Claude deterministically by sending it into the workspace terminal
cmux send --workspace <workspace-id> "claude\n"
# 4) Verify
ps -t <tty> -o pid,ppid,stat,command
# Last resort only (focus-dependent, may silently miss the terminal):
# osascript -e 'tell application "cmux" to activate' \
# -e 'delay 0.5' \
# -e 'tell application "System Events" to keystroke "claude"' \
# -e 'tell application "System Events" to key code 36'
Treat the launch as successful when ps shows /opt/homebrew/bin/claude or cmux session JSON shows terminal.agent.kind == "claude" for the workspace (label "Claude Code", not "Claude Code · React").
Notes
- The
--name option is best effort; if cmux RPC is unavailable, the workspace is left with cmux's default title.
- Prefer
cmux send --workspace <id> "claude\n" (terminal launch) over --type agent-session. The agent-session surface is a cmux-managed React panel, not an operable interactive terminal; the terminal-launched Claude is operable AND inherits the workspace shell's environment — verified that the repo's nix devshell node/npx (via direnv) are available to the launched Claude, which matters for MCP servers it spawns.
cmux send escape sequences: \n / \r send Enter, \t sends Tab. cmux send-key <key> sends a discrete key (e.g. enter, ctrl+c).
- Do not use
tmux fallback for this skill. The point is to launch inside cmux terminal workspace.
- The helper script has side effects: it opens a cmux workspace and may start a Claude session.
1---2name: cc-launch-cmux-workspace3description: Launch Claude Code in a new cmux terminal workspace for a specified repository or path. Use when the user asks to open a repo in cmux and start a Claude session, such as "cmux で repo の Claude session を起動して", "新しい workspace で Claude Code を開いて", or "s-code の Claude session を cmux terminal で起動して". ※cmux 専用(herdr ではない)。herdr で複数ロールのエージェントチームを配備するのは herdr-agent-team が担当。4---56# cc-launch-cmux-workspace78## Overview910Open a target repository/path as a new cmux workspace, start Claude Code there, and verify the session. This skill is Claude Code only; do not generalize it to Codex or opencode unless the user explicitly asks for a different skill.1112## Workflow13141. Resolve the target from the user's request.15 - If the user gives an absolute path, use that path.16 - If the user gives a repo name, search `~/workspace/github.com/*/<repo>`.17 - If there are zero or multiple matches, stop and ask the user to choose.18192. Confirm the tools exist:2021 ```bash22 command -v cmux23 command -v claude24 ```25263. Run the helper script from this skill directory:2728 ```bash29 scripts/launch_cc_workspace.sh <repo-or-path>30 scripts/launch_cc_workspace.sh <repo-or-path> --name "<workspace name>"31 ```32334. Report the result concisely: target path, cmux workspace id, TTY, and Claude session id if available.3435## Helper Behavior3637The helper script performs the fragile sequence:3839- Create a workspace with `cmux new-workspace --cwd <path> --focus true`, then confirm it in the cmux session JSON. If cmux RPC returns an error, still inspect the session JSON because workspace creation can succeed before the socket write fails.40- Fall back to `cmux <path>` only if `new-workspace` did not create a new workspace.41- Identify the matching workspace and terminal TTY from the cmux session JSON.42- Launch Claude by sending `claude\n` into the workspace's terminal: `cmux send --workspace <id> "claude\n"`. This runs the claude CLI in the interactive login shell, yielding an **operable terminal Claude** that inherits the shell environment (direnv/devshell, PATH). It goes through the cmux socket, so unlike AppleScript it does NOT depend on OS window focus.43- Do NOT use `cmux new-surface --type agent-session --provider claude`. That creates a cmux-managed React **agent surface** (shows as "Claude Code · React"), which is not a normal operable terminal and does not give you the shell's environment.44- Only if `cmux send` does not yield a running Claude, fall back to AppleScript (activate cmux → keystroke `claude` → key code 36). AppleScript is focus-dependent and can silently miss the embedded terminal, so it is a last resort.45- Verify startup through the cmux session JSON (`terminal.agent.kind == "claude"`, label shows "Claude Code" not "Claude Code · React") and `ps -t <tty>`.4647## Manual Fallback4849If the helper script fails after creating the workspace, use this sequence:5051```bash52# 1) Create the workspace53cmux new-workspace --cwd <absolute-target-path> --focus true54# 2) Find the new workspace id + terminal tty55jq -r '.windows[0].tabManager.workspaces[] | [.workspaceId,.currentDirectory,.panels[0].ttyName] | @tsv' \56 "$HOME/Library/Application Support/cmux/session-com.cmuxterm.app.json"57# 3) Launch Claude deterministically by sending it into the workspace terminal58cmux send --workspace <workspace-id> "claude\n"59# 4) Verify60ps -t <tty> -o pid,ppid,stat,command6162# Last resort only (focus-dependent, may silently miss the terminal):63# osascript -e 'tell application "cmux" to activate' \64# -e 'delay 0.5' \65# -e 'tell application "System Events" to keystroke "claude"' \66# -e 'tell application "System Events" to key code 36'67```6869Treat the launch as successful when `ps` shows `/opt/homebrew/bin/claude` or cmux session JSON shows `terminal.agent.kind == "claude"` for the workspace (label "Claude Code", not "Claude Code · React").7071## Notes7273- The `--name` option is best effort; if cmux RPC is unavailable, the workspace is left with cmux's default title.74- Prefer `cmux send --workspace <id> "claude\n"` (terminal launch) over `--type agent-session`. The agent-session surface is a cmux-managed React panel, not an operable interactive terminal; the terminal-launched Claude is operable AND inherits the workspace shell's environment — verified that the repo's nix devshell `node`/`npx` (via direnv) are available to the launched Claude, which matters for MCP servers it spawns.75- `cmux send` escape sequences: `\n` / `\r` send Enter, `\t` sends Tab. `cmux send-key <key>` sends a discrete key (e.g. `enter`, `ctrl+c`).76- Do not use `tmux` fallback for this skill. The point is to launch inside cmux terminal workspace.77- The helper script has side effects: it opens a cmux workspace and may start a Claude session.