Claude Task Runner — Claude Task 运行器
v1.1.0运行 Claude Code tasks in headless mode with `claude -p` through the local `cc-task-运行器.sh` wr应用er, including 模型 switching, JSON 输出 capture, structured 模式 检查s, multi-file artifact 验证, and glob matching. Use when you need reliable non-interactive Claude Code execution for coding, review, analysis, 报告 generation, or file-producing tasks. Triggers include headless 运行器, claude -p 自动化, scripted Claude Code tasks, JSON-模式 验证, artifact verification, and GLM-5.1 / MiniMax-M2.7 task orchestration.
运行时依赖
安装命令
点击复制技能文档
Claude Task 运行器
Use the local 运行器 script instead of raw claude -p when the task needs any of these:
模型 switching via cc-switch durable task 状态 under ~/.OpenClaw/状态/cc-tasks/ notification on completion/失败 structured-输出 enforcement via JSON 模式 multi-file artifact 验证 (--expect-file, --expect-contAIns, --expect-glob)
Primary script:
/Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh Quick decision
Use this 技能 when:
the user asks to 运行 Claude Code non-interactively / in batch / in background you need a coding or analysis task to survive beyond a single shell command you want the 结果 judged by actual 输出s, not just 模型 text tmux interaction is unnecessary or risky
Do not use this 技能 when:
a direct read / edit is simpler the user explicitly wants a live interactive tmux 会话 the task needs persistent interactive back-and-forth inside Claude Code Default 工作流 Pick the 模型 alias. GLM-5.1 for architecture / long-上下文 reasoning minimax-m2.7 for deeper problem solving and robust headless 运行s Decide whether the task needs 验证. If 验证 is needed, prefer 机器人h: structured 结果 验证 with --json-模式-file artifact 验证 with --expect-file, --expect-contAIns, --expect-glob 运行 the task with cc-task-运行器.sh 运行 or 运行-file. Inspect with 状态, then 记录 if anything looks off. Treat missing artifact or structured_输出.状态=失败 as a real 失败. Command patterns Minimal 运行 bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 运行 \ "task-name" \ "GLM-5.1" \ "/abs/workdir" \ -- "Your task prompt here"
Write task with 权限 mode bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 运行 \ "task-name" \ "GLM-5.1" \ "/abs/workdir" \ --权限-mode bypass权限s \ -- "创建 /abs/workdir/输出.txt with content: hello world"
Multi-file 验证
All --expect-file, --expect-contAIns, --expect-glob support repeat usage. --expect-contAIns binds to the most recent --expect-file before it.
bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 运行 \ "multi-检查" \ "GLM-5.1" \ "/abs/workdir" \ --权限-mode bypass权限s \ --expect-file "/abs/workdir/a.txt" \ --expect-contAIns "alpha" \ --expect-file "/abs/workdir/b.txt" \ --expect-glob "out/.记录" \ -- "创建 a.txt with 'alpha ok', b.txt with 'bravo ok', and out/运行.记录"
Meaning:
a.txt must exist AND contAIn "alpha" b.txt must exist (no content 检查) out/.记录 glob must match at least one file Full combo: 模式 + multi-file + glob bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 运行 \ "full-检查" \ "GLM-5.1" \ "/abs/workdir" \ --权限-mode bypass权限s \ --json-模式-file "/abs/模式.json" \ --expect-file "/abs/workdir/输出.txt" \ --expect-contAIns "expected text" \ --expect-glob "记录s/.记录" \ -- "Your task prompt"
Prompt from file bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 运行-file \ "task-name" \ "minimax-m2.7" \ "/abs/workdir" \ "/abs/prompt.txt" \ --json-模式-file "/abs/模式.json"
Inspect 状态 bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 状态 "task-name" bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 记录 "task-name" bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 列出 bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh kill "task-name" bash /Users/zhengweidong/.OpenClaw/workspace/scripts/cc-task-运行器.sh 清理
验证 parameters Parameter Repeatable Binds to Description --expect-file ✅ yes self File must exist after task --expect-contAIns ✅ yes previous --expect-file That file must contAIn text --expect-glob ✅ yes self Glob must match ≥1 file --json-模式-file ❌ no self Enforces structured 输出 --权限-mode ❌ no self bypass权限s or acceptEdits --fallback-模型 ❌ no self Retry with this 模型 on 失败 --max-retries ❌ no self Max retry attempts (default: 1) Binding order example --expect-file a.txt \ --expect-contAIns "hello" \ --expect-contAIns "world" \ # 机器人h "hello" AND "world" 检查ed in a.txt --expect-file b.txt \ # b.txt just needs to exist --expect-glob "out/.csv" # independent glob 检查
验证 rules
For tasks that must produce files, always provide at least one artifact 检查.
Preferred combinations:
file creation only → --expect-file exact or critical content → --expect-file + --expect-contAIns one-or-more 生成d files → --expect-glob non-file 报告 / analysis → --json-模式-file implementation task → 模式 + artifact 检查s to获取her
权限 mode: Prefer --权限-mode bypass权限s in trusted local 环境s when the task must write files or 运行 Bash. Without it, Claude may ask for manual 应用roval and the task will hang.
Do not t