Delegate to Claude Code (CLI)
Run claude for a second opinion, review, or a delegated edit worker. Default
path: claude-rc-spawn — interactive Claude in detached tmux with Remote
Control, so the user can watch and steer from claude.ai/code. Use plain
claude -p when machine-readable capture matters more than visibility.
Model default: --model opus --effort high (sonnet --effort low for trivia).
Happy path
Write the brief to
.agent-runs/$slug/prompt.md(slug="claude-$(date +%Y%m%d-%H%M%S)"; mkdir -p ".agent-runs/$slug"): context, exact task, constraints, acceptance criteria, verification commands, output shape. Demand evidence (commands run, exit status, changed files, risks) and state explicitly: verify synchronously — never end the turn waiting on a background monitor or watcher. Workers otherwise park themselves "waiting for the monitor" and yield-loop.Launch. Reviewer (read-only) via Remote Control tmux:
claude-rc-spawn \ --cwd "$PWD" \ --prompt-file ".agent-runs/$slug/prompt.md" \ --name "$slug-review" --tmux-session "$slug-review" \ --permission-mode plan \ --model opus --effort highEdit worker: same command, replacing
--permission-mode planwith--permission-mode acceptEdits, renaming--name/--tmux-sessionto"$slug-edit", and adding--worktree "$slug"(Claude creates the worktree and branch).Noninteractive fallback (JSON capture, no Remote Control):
cat ".agent-runs/$slug/prompt.md" | claude -p \ --model opus --effort high \ --permission-mode plan \ --output-format json \ --name "$slug-review" --add-dir .For an edit worker replace
--permission-mode planwith--permission-mode acceptEdits, replace--output-format jsonwith--output-format stream-json --verbose, and add--worktree "$slug" --max-budget-usd 10. For a fire-and-return background worker useclaude --bg --worktree "$slug" --model opus --effort high --permission-mode acceptEdits --name "$slug-edit" "$(cat ".agent-runs/$slug/prompt.md")"and manage it withclaude agents --json.Harvest.
--output-format json: final text in.result, session id in.session_id;stream-json --verbosefor live logs.claude-rc-spawnsaves the prompt andtmux.logunder.agent-runs/<tmux-session>/. Watch withtmux attach -t "$slug-review"or from claude.ai/code by name. Resume withclaude --continue/--resume <session-id>; add--fork-sessionto branch. For large work, split maker and checker: run a fresh reviewer over the diff before accepting.
Gotchas
- Remote Control needs a full claude.ai login.
CLAUDE_CODE_OAUTH_TOKEN,ANTHROPIC_API_KEY, or a non-defaultANTHROPIC_BASE_URLin the environment can break it before the session starts;claude-rc-spawnstrips them by default. Remote Control dies with the local process — keep the tmux session alive until the run completes. --worktreestarts fromorigin/HEAD, not your branch. Setworktree.baseReftoheadwhen the worker must see local in-progress state. Worktrees land under.claude/worktrees/<name>(gitignore that dir);-p --worktreeruns get no exit prompt, so clean up finished worktrees yourself.- A worker that ends its turn "waiting for a monitor" is stuck. Nudge it once (resume the session or paste into its tmux session); if it parks again, take over — its edits are already on disk in the worktree.
--agentselects a persona only; hard permissions come from--permission-mode(plan,acceptEdits,auto) — pair them every time. UseacceptEditsfor a bounded unattended edit worker,autowhen you want background safety checks around broader tool calls.--max-budget-usdcaps print-mode (claude -p) runs only.- Add
--tmuxwith--worktreewhen you want Claude Code's built-in tmux handling instead ofclaude-rc-spawn. claude -pskips the workspace-trust dialog — run it only in directories you trust.--add-dirgrants file access; it does not make that directory the working checkout or copy its config.- Name every run (
--name) so concurrent agents are distinguishable inclaude agentsand claude.ai/code.
Not possible
- Remote Control with API-key /
claude setup-token/CLAUDE_CODE_OAUTH_TOKENauth — full claude.ai login only. - Budget caps on
--bgbackground agents (--max-budget-usdis print-mode only). --dangerously-skip-permissionsoutside a bounded, preferably network-isolated container/VM — it can write protected config areas; never the default edit-worker mode.- Persistent servers for future mobile/web dispatch — that is
claude remote-controlserver mode; use theclaude-remote-control-serverskill.