Claude Code Dispatch
Delegate 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.
Prerequisites
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:
CODEBLOCK0
Without pre-authorized permissions, Claude Code will fail in non-interactive mode because it cannot prompt for approval.
When to Use
Route tasks to Claude Code when they require:
- - File reading, editing, or creation on the host filesystem
- Shell command execution (builds, tests, git operations)
- Multi-file debugging or refactoring
- Code review with actual file access
- Any task where the agent needs to interact with the local filesystem
Do NOT use when:
- - The task is purely conversational (answering questions, planning)
- You can handle it with your own capabilities or other skills
- The task involves external APIs you already have access to
Usage
CODEBLOCK1
Parameters
| Parameter | Required | Default | Description |
|---|
| INLINECODE1 | Yes | — | Task description for Claude Code |
| INLINECODE2 |
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 |
Model Selection Guide
- - sonnet (default): Fast. Good for single-file fixes, simple refactors, code review, running tests.
- opus: Slower but more capable. Use for complex multi-file debugging, architectural changes, tasks requiring deep reasoning across many files.
- haiku: Fastest and cheapest. Use for trivial tasks like renaming, formatting, or simple lookups.
Tool Presets
Common tool combinations for different task types:
- - Read-only (code review, analysis): INLINECODE15
- Standard editing (default): INLINECODE16
- Full access (builds, tests, git): INLINECODE17
Output Format
The script returns a structured summary:
CODEBLOCK2
Exit codes: 0 = success, 1 = Claude Code error, 2 = preflight failure, 3 = timeout.
Examples
Fix a build error:
CODEBLOCK3
Code review:
CODEBLOCK4
Run tests and fix failures:
CODEBLOCK5
Limitations
- - No concurrent invocations to the same working directory. Queue tasks sequentially.
- No multi-turn conversations. Each invocation is independent. For follow-up work, dispatch a new invocation with more context in the prompt.
- Result truncation. Responses longer than 2000 characters are truncated at the nearest line boundary.
Notes
- - Cost is reported for observability. Subscription users are not charged per-token but the field shows what the task would cost on the API.
- Claude Code inherits environment variables from the host, including any API keys loaded by
load-openclaw-env or similar scripts. - The prompt is passed via stdin pipe, not shell interpolation, so special characters in prompts are safe.
Claude Code 调度
将编码任务委派给 Claude Code CLI。当任务需要超出当前代理能力范围的操作时使用:文件编辑、Shell命令、多文件调试、带文件访问的代码审查,或任何需要直接文件系统交互的工作。
前置条件
Claude Code 必须在主机上安装并完成身份验证。主机的 ~/.claude/settings.json 必须预先授权此技能将使用的工具。最小配置示例:
json
{
permissions: {
allow: [
Read,
Edit,
Glob,
Grep,
Bash(git:*),
Bash(npm:*)
]
}
}
如果没有预先授权的权限,Claude Code 将在非交互模式下失败,因为它无法提示用户批准。
使用时机
当任务需要以下能力时,将任务路由到 Claude Code:
- - 在主机文件系统上读取、编辑或创建文件
- 执行Shell命令(构建、测试、Git操作)
- 多文件调试或重构
- 带实际文件访问的代码审查
- 代理需要与本地文件系统交互的任何任务
在以下情况下不要使用:
- - 任务纯粹是对话式的(回答问题、规划)
- 你可以用自己的能力或其他技能处理
- 任务涉及你已经可以访问的外部API
使用方法
bash
bash {baseDir}/scripts/invoke-claude.sh \
--prompt 修复 src/App.tsx 中的损坏导入 \
--workdir /path/to/project \
--model sonnet \
--tools Read,Edit,Glob,Grep,Bash
参数
| 参数 | 必填 | 默认值 | 描述 |
|---|
| --prompt | 是 | — | Claude Code 的任务描述 |
| --workdir |
是 | — | 工作目录(必须存在) |
| --model | 否 | sonnet | 模型:sonnet、opus 或 haiku |
| --tools | 否 | Read,Edit,Glob,Grep | 逗号分隔的允许工具列表 |
| --budget | 否 | 2.00 | 最大预算(美元,用于成本报告) |
| --timeout | 否 | 300 | 超时时间(秒) |
| --system | 否 | — | 额外的系统提示文本 |
模型选择指南
- - sonnet(默认):快速。适用于单文件修复、简单重构、代码审查、运行测试。
- opus:较慢但能力更强。用于复杂的多文件调试、架构变更、需要跨多个文件进行深度推理的任务。
- haiku:最快且最便宜。用于重命名、格式化或简单查找等琐碎任务。
工具预设
不同任务类型的常用工具组合:
- - 只读(代码审查、分析):Read,Glob,Grep
- 标准编辑(默认):Read,Edit,Glob,Grep
- 完全访问(构建、测试、Git):Read,Edit,Glob,Grep,Bash
输出格式
脚本返回结构化摘要:
STATUS: success|failure
MODEL: sonnet|opus|haiku
COST: $0.04
DURATION: 12s
RESULT:
退出码:0 = 成功,1 = Claude Code 错误,2 = 前置检查失败,3 = 超时。
示例
修复构建错误:
bash
bash {baseDir}/scripts/invoke-claude.sh \
--prompt 构建失败,错误信息为 Cannot find module ./utils。诊断并修复。 \
--workdir /Users/dave/WebProjects/summer-camps \
--tools Read,Edit,Glob,Grep,Bash
代码审查:
bash
bash {baseDir}/scripts/invoke-claude.sh \
--prompt 审查上次提交的更改。重点关注正确性和安全性。 \
--workdir /Users/dave/WebProjects/summer-camps \
--model opus \
--tools Read,Glob,Grep,Bash
运行测试并修复失败:
bash
bash {baseDir}/scripts/invoke-claude.sh \
--prompt 运行测试套件,然后修复所有失败的测试。 \
--workdir /Users/dave/WebProjects/summer-camps \
--tools Read,Edit,Glob,Grep,Bash \
--timeout 600
限制
- - 不支持对同一工作目录的并发调用。任务需顺序排队。
- 不支持多轮对话。每次调用都是独立的。如需后续工作,请在提示中包含更多上下文后发起新的调用。
- 结果截断。超过2000个字符的响应将在最近的换行边界处截断。
注意事项
- - 成本报告用于可观测性。订阅用户不按token收费,但该字段显示该任务在API上所需的成本。
- Claude Code 继承主机的环境变量,包括由 load-openclaw-env 或类似脚本加载的任何API密钥。
- 提示通过stdin管道传递,而非Shell插值,因此提示中的特殊字符是安全的。