Claude Task Runner
简介
Claude Task Runner
原始描述
Run Claude Code tasks in headless mode with `claude -p` through the local `cc-task-runner.sh` wrapper, including model switching, JSON output capture, struct...
通过你的 Agent 添加
安装目录:claude-task-runner/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: claude-task-runner
description: Run Claude Code tasks in headless mode with claude -p through the local cc-task-runner.sh wrapper, including model switching, JSON output capture, structured schema checks, multi-file artifact validation, and glob matching. Use when you need reliable non-interactive Claude Code execution for coding, review, analysis, report generation, or file-producing tasks. Triggers include headless runner, claude -p automation, scripted Claude Code tasks, JSON-schema validation, artifact verification, and GLM-5.1 / MiniMax-M2.7 task orchestration.
Claude Task Runner
Use the local runner script instead of raw claude -p when the task needs any of these:
- model switching via
cc-switch - durable task state under
~/.openclaw/state/cc-tasks/ - notification on completion/failure
- structured-output enforcement via JSON Schema
- multi-file artifact validation (
--expect-file,--expect-contains,--expect-glob)
Primary script:
/Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh
Quick decision
Use this skill when:
- the user asks to run 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 result judged by actual outputs, not just model text
- tmux interaction is unnecessary or risky
Do not use this skill when:
- a direct
read/editis simpler - the user explicitly wants a live interactive tmux session
- the task needs persistent interactive back-and-forth inside Claude Code
Default workflow
- Pick the model alias.
GLM-5.1 for architecture / long-context reasoning
minimax-m2.7 for deeper problem solving and robust headless runs
- Decide whether the task needs validation.
- If validation is needed, prefer both:
- structured result validation with
--json-schema-file
- artifact validation with
--expect-file, --expect-contains, --expect-glob
- Run the task with
cc-task-runner.sh run or run-file.
- Inspect with
status, then log if anything looks off.
- Treat missing artifact or
structured_output.status=failure as a real failure.
Command patterns
Minimal run
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run \
"task-name" \
"GLM-5.1" \
"/abs/workdir" \
-- "Your task prompt here"
Write task with permission mode
GLM-5.1for architecture / long-context reasoningminimax-m2.7for deeper problem solving and robust headless runs
- structured result validation with
--json-schema-file - artifact validation with
--expect-file,--expect-contains,--expect-glob
cc-task-runner.sh run or run-file.status, then log if anything looks off.structured_output.status=failure as a real failure.Minimal run
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run \
"task-name" \
"GLM-5.1" \
"/abs/workdir" \
-- "Your task prompt here"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run \
"task-name" \
"GLM-5.1" \
"/abs/workdir" \
--permission-mode bypassPermissions \
-- "Create /abs/workdir/output.txt with content: hello world"
Multi-file validation
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-runner.sh run \
"multi-check" \
"GLM-5.1" \
"/abs/workdir" \
--permission-mode bypassPermissions \
--expect-file "/abs/workdir/a.txt" \
--expect-contains "alpha" \
--expect-file "/abs/workdir/b.txt" \
--expect-glob "out/*.log" \
-- "Create a.txt with 'alpha ok', b.txt with 'bravo ok', and out/run.log"
Meaning:
a.txtmust exist AND contain "alpha"b.txtmust exist (no content check)out/*.logglob must match at least one file
Full combo: schema + multi-file + glob
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run \
"full-check" \
"GLM-5.1" \
"/abs/workdir" \
--permission-mode bypassPermissions \
--json-schema-file "/abs/schema.json" \
--expect-file "/abs/workdir/output.txt" \
--expect-contains "expected text" \
--expect-glob "logs/*.log" \
-- "Your task prompt"
Prompt from file
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run-file \
"task-name" \
"minimax-m2.7" \
"/abs/workdir" \
"/abs/prompt.txt" \
--json-schema-file "/abs/schema.json"
Inspect state
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh status "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh log "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh list
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh kill "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh clean
Validation parameters
Parameter
Repeatable
Binds to
Description
--expect-file <path>
✅ yes
self
File must exist after task
--expect-contains <text>
✅ yes
previous --expect-file
That file must contain text
--expect-glob <pattern>
✅ yes
self
Glob must match ≥1 file
--json-schema-file <file>
❌ no
self
Enforces structured output
--permission-mode <mode>
❌ no
self
bypassPermissions or acceptEdits
--fallback-model <alias>
❌ no
self
Retry with this model on failure
--max-retries <n>
❌ no
self
Max retry attempts (default: 1)
Binding order example
--expect-file a.txt \
--expect-contains "hello" \
--expect-contains "world" \ # both "hello" AND "world" checked in a.txt
--expect-file b.txt \ # b.txt just needs to exist
--expect-glob "out/*.csv" # independent glob check
Validation rules
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run \
"full-check" \
"GLM-5.1" \
"/abs/workdir" \
--permission-mode bypassPermissions \
--json-schema-file "/abs/schema.json" \
--expect-file "/abs/workdir/output.txt" \
--expect-contains "expected text" \
--expect-glob "logs/*.log" \
-- "Your task prompt"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh run-file \
"task-name" \
"minimax-m2.7" \
"/abs/workdir" \
"/abs/prompt.txt" \
--json-schema-file "/abs/schema.json"
Inspect state
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh status "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh log "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh list
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh kill "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh clean
Validation parameters
Parameter
Repeatable
Binds to
Description
--expect-file <path>
✅ yes
self
File must exist after task
--expect-contains <text>
✅ yes
previous --expect-file
That file must contain text
--expect-glob <pattern>
✅ yes
self
Glob must match ≥1 file
--json-schema-file <file>
❌ no
self
Enforces structured output
--permission-mode <mode>
❌ no
self
bypassPermissions or acceptEdits
--fallback-model <alias>
❌ no
self
Retry with this model on failure
--max-retries <n>
❌ no
self
Max retry attempts (default: 1)
Binding order example
--expect-file a.txt \
--expect-contains "hello" \
--expect-contains "world" \ # both "hello" AND "world" checked in a.txt
--expect-file b.txt \ # b.txt just needs to exist
--expect-glob "out/*.csv" # independent glob check
Validation rules
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh status "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh log "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh list
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh kill "task-name"
bash /Users/zhengweidong/.openclaw/workspace/scripts/cc-task-runner.sh clean
| Parameter | Repeatable | Binds to | Description |
|---|---|---|---|
--expect-file <path> |
✅ yes | self | File must exist after task |
--expect-contains <text> |
✅ yes | previous --expect-file |
That file must contain text |
--expect-glob <pattern> |
✅ yes | self | Glob must match ≥1 file |
--json-schema-file <file> |
❌ no | self | Enforces structured output |
--permission-mode <mode> |
❌ no | self | bypassPermissions or acceptEdits |
--fallback-model <alias> |
❌ no | self | Retry with this model on failure |
--max-retries <n> |
❌ no | self | Max retry attempts (default: 1) |
Binding order example
--expect-file a.txt \
--expect-contains "hello" \
--expect-contains "world" \ # both "hello" AND "world" checked in a.txt
--expect-file b.txt \ # b.txt just needs to exist
--expect-glob "out/*.csv" # independent glob check
For tasks that must produce files, always provide at least one artifact check.
Preferred combinations:
- file creation only →
--expect-file - exact or critical content →
--expect-file+--expect-contains - one-or-more generated files →
--expect-glob - non-file report / analysis →
--json-schema-file - implementation task → schema + artifact checks together
Permission mode: Prefer --permission-mode bypassPermissions in trusted local environments when the task must write files or run Bash. Without it, Claude may ask for manual approval and the task will hang.
Do not trust plain language like "已完成" or "done" without validation.
Exit codes
Code
Meaning
0
Task completed, all validations passed
1
Model/runtime error
2
Artifact validation failed
3
Structured output reported failure
JSON schema guidance
| Code | Meaning |
|---|---|
| 0 | Task completed, all validations passed |
| 1 | Model/runtime error |
| 2 | Artifact validation failed |
| 3 | Structured output reported failure |
Keep schemas small. Use them to force a machine-checkable result contract.
Good default schema for most tasks:
status:success|failuresummary: short textfiles_changed: optional arrayerror_category: optionalsuggestion: optional
Model notes
Current local environment supports GLM-5.1 headless via:
- base URL:
https://open.bigmodel.cn/api/anthropic - model id:
glm-5.1
The local cc-switch wrapper already special-cases this. Use the alias GLM-5.1, not a raw model id, when calling the runner.
Failure handling
If a task fails:
- run
status - run
log - identify which layer failed:
- model/runtime error (exit 1)
- artifact validation failure (exit 2)
- structured schema failure (exit 3)
- either rerun with a stricter prompt or fix the prompt/schema/expectations
If the model says success but artifact validation fails, trust the validator, not the prose.
Files to read when needed
Read these only when you need deeper details:
references/runner-usage.mdfor usage notes and patternsreferences/task-schema-example.jsonfor a reusable schema templatescripts/run-task-example.shfor a concrete invocation pattern
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。