一键导入
headless-worker
Patterns for headless Claude execution via claude -p --output-format json. Tool allowlist tiers, env inheritance, model override for Sonnet routing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Patterns for headless Claude execution via claude -p --output-format json. Tool allowlist tiers, env inheritance, model override for Sonnet routing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | headless-worker |
| description | Patterns for headless Claude execution via claude -p --output-format json. Tool allowlist tiers, env inheritance, model override for Sonnet routing. |
The conceptual claude -p patterns documented here are the foundation. The concrete multi-backend implementation — DeepSeek / GLM / Codex routing tables, the distilled-result contract, --repo topology resolution — lives in ${CLAUDE_PLUGIN_ROOT}/scripts/claude-headless-exec (and codex-headless-exec), fronted by /deep-execute, /glm-execute, /codex-execute, and orchestrated by /auto-execute. This file covers the general headless-model principles only; do not duplicate the backend-specific tables.
Execute structured tasks via claude -p in headless mode. Useful for batch processing, CI/CD, and cron-driven automation.
# Single prompt, JSON output
claude -p "analyze this diff: $(git diff)" --output-format json
# With tool access (read-only by default)
claude -p "check test results in /tmp/test-output.log" \
--allowedTools Bash --output-format json
# Model override for Sonnet
claude -p "complex architectural review" --model claude-sonnet-5
See references/tool-allowlists.md for tier definitions.
| Tier | Bash | Read, Write, Edit | Git |
|---|---|---|---|
| 1 — read-only | yes (safe commands) | Read only | no |
| 2 — read+write | yes | Read + Write + Edit | no |
| 3 — full | yes | all | yes |
Default: Tier 1.
See references/backend-env.md for routing matrix.
claude -p inherits ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN from parentenv -i — it strips inherited varsStand up and drive a campaign runbook — a single orchestration manuscript that sequences multiple related plans by dependency and walks them through the 6-stage waterfall in serial/parallel waves, with a live computed dashboard. Use when coordinating a multi-plan feature arc (not a single plan — that's /meta-dev). Invoked by the /runbook command.
The shared execute→review→fix loop for headless plan execution. A fresh worker per task (DeepSeek default via claude-headless-exec, GLM/Sonnet-200K on flag, Codex review-only) executes and self-runs its task Verify hook; review gates at the PHASE boundary (not per task) via the meta-dev:review-agent Opus subagent, which computes its own git diff and returns a verdict; a fixer worker repairs on non-pass (tier-specific fix ladder). Only N worker lines + one phase verdict return to the conductor — diffs never enter the main thread. Used by /meta-execute --deep|--glm|--sonnet|--codex and /auto-execute. Protocol: references/loop-protocol.md.
Stand up and maintain a visible stage-level task list for the /meta-dev 6-stage waterfall. Use in autopilot/walk runs so the user can walk away and watch Brainstorm→Design→Plan→Harden→Execute→Review progress live. Stage granularity only — never mirrors /meta-execute's per-task list.
Forward-moving compaction handoff. Use when a long session is getting context-heavy mid-project and you want to compact WITHOUT losing momentum — writes a durable, forward-looking handoff so the post-compaction session resumes the exact next step instead of being left hanging. Also used to proactively flag clean compaction boundaries during work. Triggered on-demand via /meta-compact or proactively when a clean boundary meets a heavy context.
Grug-brain sniff test for plans AND code — detect over-engineering, complexity demons, vague tasks, and bad practices in plans/specs (primary) or code (secondary). Report-only, never edits. Invoked as /sniff-test. By default sniffs the subject under discussion in the current conversation; takes a path, or --diff/--staged/--all. Use before executing a plan, before merging code, or when something "smells off".
Batch engineering changelog. Append entries during work, cut on demand or auto-threshold, draft release post, pair with version bump.