Install
openclaw skills install claude-code-dispatchInvoke Claude Code CLI as a subprocess for coding tasks that require file access, editing, and shell execution
openclaw skills install claude-code-dispatchDelegate coding tasks to Claude Code CLI. Use this when a task requires capabilities beyond what the current agent can do: file editing, shell commands, multi-file debugging, code review with file access, or any work that needs direct filesystem interaction.
Claude Code must be installed and authenticated on the host machine. The host's ~/.claude/settings.json must pre-authorize the tools this skill will use. Example minimal config:
{
"permissions": {
"allow": [
"Read",
"Edit",
"Glob",
"Grep",
"Bash(git:*)",
"Bash(npm:*)"
]
}
}
Without pre-authorized permissions, Claude Code will fail in non-interactive mode because it cannot prompt for approval.
Route tasks to Claude Code when they require:
Do NOT use when:
bash {baseDir}/scripts/invoke-claude.sh \
--prompt "Fix the broken import in src/App.tsx" \
--workdir "/path/to/project" \
--model sonnet \
--tools "Read,Edit,Glob,Grep,Bash"
| Parameter | Required | Default | Description |
|---|---|---|---|
--prompt | Yes | — | Task description for Claude Code |
--workdir | Yes | — | Working directory (must exist) |
--model | No | sonnet | Model: sonnet, opus, or haiku |
--tools | No | Read,Edit,Glob,Grep | Comma-separated allowed tools |
--budget | No | 2.00 | Max budget in USD (for cost reporting) |
--timeout | No | 300 | Timeout in seconds |
--system | No | — | Additional system prompt text |
Common tool combinations for different task types:
Read,Glob,GrepRead,Edit,Glob,GrepRead,Edit,Glob,Grep,BashThe script returns a structured summary:
STATUS: success|failure
MODEL: sonnet|opus|haiku
COST: $0.04
DURATION: 12s
RESULT: <Claude Code's response>
Exit codes: 0 = success, 1 = Claude Code error, 2 = preflight failure, 3 = timeout.
Fix a build error:
bash {baseDir}/scripts/invoke-claude.sh \
--prompt "The build is failing with 'Cannot find module ./utils'. Diagnose and fix." \
--workdir "/Users/dave/WebProjects/summer-camps" \
--tools "Read,Edit,Glob,Grep,Bash"
Code review:
bash {baseDir}/scripts/invoke-claude.sh \
--prompt "Review the changes in the last commit. Focus on correctness and security." \
--workdir "/Users/dave/WebProjects/summer-camps" \
--model opus \
--tools "Read,Glob,Grep,Bash"
Run tests and fix failures:
bash {baseDir}/scripts/invoke-claude.sh \
--prompt "Run the test suite, then fix any failing tests." \
--workdir "/Users/dave/WebProjects/summer-camps" \
--tools "Read,Edit,Glob,Grep,Bash" \
--timeout 600
load-openclaw-env or similar scripts.brew install jq