✻

智能编码代理委派与并行开发

claude-code-cli · v0.1.0
开发 安全 B 级 作者 atelypham 公开目录收录
1.1k 下载 0 安装 2.9k 收藏 10 浏览

简介

将复杂编码任务委托给Claude Code CLI,支持交互式PTY模式和自动化管道模式,适合大型重构、PR审查和并行开发工作流。

原始描述

Delegate coding tasks to Claude Code CLI via background process. Use when: building features, reviewing PRs, refactoring codebases, or iterative coding that...

通过你的 Agent 添加

安装目录:claude-code-cli/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/claude-code-cli/
Codex CLI~/.codex/skills/claude-code-cli/
DeepSeek Harness~/.agents/skills/claude-code-cli/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Claude Code CLI技能是一个强大的编码代理委派工具,通过背景进程运行Anthropic的Claude Code CLI。它提供两种运行模式:交互式PTY模式(pty:true)用于需要确认、权限提示或用户输入的复杂任务;无头管道模式(-p标志)用于自动化脚本和CI场景。

关键执行模式包括:前台同步执行(等待完成)、后台异步执行(返回sessionId可监控)、以及结合Process工具的动作系统(list/poll/log/write/submit/send-keys/kill)进行会话管理。

显著优点

  1. 双模式架构灵活:PTY模式解决交互式CLI的伪终端依赖问题,管道模式支持结构化JSON输出和流式响应,覆盖从探索性开发到生产自动化的全场景
  2. 会话连续性完善:支持--resume、--continue、--fork-session及PR关联恢复,配合HANDOFF.md模式处理超长任务上下文断裂
  3. 安全机制分层:--permission-mode提供default/acceptEdits/plan/dontAsk/bypassPermissions五级权限控制,避免--dangerously-skip-permissions的完全失控风险
  4. 并行工作流原生支持:Git worktree集成实现多分支并行修复、Fan-Out批量操作模式、Writer/Reviewer双会话协作审查
  5. 资源与预算管控:--max-budget-usd消费上限、--allowedTools工具粒度限制、推荐最多3-4并发会话的资源管理

潜在局限

  • 外部依赖重:必须预装Node.js和@anthropic-ai/claude-codenpm包,对网络环境和Anthropic服务可用性敏感
  • PTY模式必需性认知门槛:新手易忽略pty:true导致代理挂起,文档虽强调但属于常见误用点
  • 超时策略复杂:真实任务需1800s+超时,与常规exec工具的短默认值冲突,需显式配置
  • 沙箱逃逸风险:elevated:true允许在主机运行,配合--dangerously-skip-permissions存在权限提升攻击面

适合人群

  • 管理大型代码库的资深开发者、需要批量处理技术债务的架构师
  • 执行PR审查、安全审计的DevOps工程师(配合隔离的/tmp目录工作流)
  • 构建自动化代码分析、迁移脚本的AI工程团队

常规风险

  1. 工作区污染:严禁在~/.openclaw/或活动项目目录直接执行分支切换,必须使用独立克隆/worktree
  2. 会话泄漏:后台任务未设置完成通知(openclaw system event)时,用户无法感知失败状态
  3. 预算失控:未设置--max-budget-usd的管道模式可能在API异常时产生意外费用
  4. 权限提示阻塞:后台任务未使用acceptEdits模式会因等待确认而僵死
  5. 并发资源争用:超过4个活跃会话可能导致Claude Code CLI响应降级或系统资源耗尽

技能正文


name: claude-code-cli description: Use when working with the Claude Code CLI (claude) — headless and interactive modes, flags, agents, plugins, MCP servers, hooks, settings, sessions, and the local custom ecosystem (forge, bob, alf, pa, wiki, agent-teams). Covers Claude Code 2.1.x. Refresh of the upstream superpowers:working-with-claude-code reference plus local-environment additions. disambiguation: The claude binary — its flags, hooks, settings, MCP and plugin surfaces. The copilot binary's equivalents are gh-copilot-cli.

Claude Code CLI

Task-indexed reference for Claude Code 2.1.170 (and the 2.1.x line in general). Forked from the superpowers working-with-claude-code skill at v0.3.1, refreshed against local ground truth, and extended with custom files that document this machine's forge/bob/alf/pa/wiki ecosystem.

This SKILL.md is the navigation index. Detailed documentation lives in references/. Read only what the current task needs.

When to use

  • Building anything that calls claude from the shell or a script (headless -p mode)
  • Authoring or debugging Claude Code agents, skills, plugins, hooks, MCP servers
  • Editing ~/.claude/settings.json, ~/.claude/CLAUDE.md, ~/.claude/AGENTS.md
  • Cross-referencing Claude Code features against Antigravity CLI (agy), Codex CLI, or GitHub Copilot CLI (see antigravity-cli, gh-copilot-cli, cross-tool-portability sub-skill)
  • Operating inside the local custom ecosystem (forge, bob, alf, pa, wiki, agent-teams)

Versions covered

Component Version (verified locally 2026-06-10)
Claude Code CLI 2.1.170
Plugin: superpowers (source for forked references) 0.3.1
Codex plugin 1.0.2

When the local claude version drifts from this skill, run scripts/verify-claude-install.sh to flag stale sections.

Quick task index

Headless / scripted invocation

Task Read
Run a one-shot prompt and exit references/headless.md, references/cli-reference.md
Pipe data in / out as JSON references/headless.md (--input-format, --output-format, --json-schema)
CI-safe minimal mode (no hooks, no auto-memory, strict API key) references/headless.md (--bare section)
Cap session $ spend references/headless.md (--max-budget-usd)
Pin a pre-defined agent for a single invocation references/sub-agents.md (--agent, --agents)
Pick the model / fallback model references/model-config.md

Interactive use

Task Read
Slash commands, key bindings, modes references/interactive-mode.md, references/slash-commands.md
Output styles, statusline references/output-styles.md, references/statusline.md
Resume / fork / continue sessions references/cli-reference.md (--resume, --continue, --fork-session, --session-id)
Built-in git worktree references/cli-reference.md (-w/--worktree, --tmux)

Agents and skills

Task Read
Author an agent (~/.claude/agents/<name>.md) references/sub-agents.md
Author a skill (~/.claude/skills/<name>/SKILL.md) references/skills.md + the cross-tool-portability sub-skill of research-for-skills
Cross-tool skill that must work in Antigravity (agy)/Codex/Copilot research-for-skills/cross-tool-portability/cross-tool-portability.md
Skill discovery / progressive disclosure references/skills.md

Orchestration, teams, tasks, scheduling

Task Read
Workflow tool — script-driven multi-agent orchestration (agent(), pipeline(), parallel(), budget, journal resume) references/orchestration.md
Saved/named workflows (.claude/workflows/, ~/.claude/workflows/) references/orchestration.md
Effort levels (low→max) and ultracode (v2.1.160+) references/orchestration.md
Session cron (CronCreate/CronList/CronDelete), /loop pacing (ScheduleWakeup), RemoteTrigger, /schedule cloud routines, /goal references/orchestration.md
Why a subagent cannot fan out (Agent/Workflow = main loop ONLY) and the invert-control pattern references/orchestration.md (KEY ASYMMETRY section)
Native agent teams (TeamCreate/SendMessage — experimental, env-gated) references/native-teams-tasks.md
Native task lifecycle (TaskCreate/TaskList/TaskGet/TaskUpdate/TaskStop/TaskOutput, Monitor) references/native-teams-tasks.md
Teammate hooks (TeammateIdle/TaskCreated/TaskCompleted) references/native-teams-tasks.md
Background agents (run_in_background, claude agents Agent View, claude --bg --exec, worktrees + EnterWorktree) references/native-teams-tasks.md
Native teams vs the portable file-based agent-teams skill references/native-teams-tasks.md

Plugins and marketplaces

Task Read
Install/uninstall/enable/disable a plugin references/plugins.md, references/cli-reference.md (plugin subcommands)
Add a marketplace references/plugin-marketplaces.md
Plugin component reference (commands, agents, skills, hooks, MCP, statuslines) references/plugins-reference.md
Validate a plugin in development claude plugin validate <path> (see references/plugins.md)

MCP servers

Task Read
Add a stdio/http/sse MCP server references/mcp.md (claude mcp add, add-json)
Use a project-local MCP config references/mcp.md (--mcp-config, --strict-mcp-config)
Reset per-project MCP choices claude mcp reset-project-choices
Build your own MCP server use the mcp-server-creator skill

Hooks and settings

Task Read
Settings.json schema references/settings.md
Hooks lifecycle, events, matchers references/hooks.md, references/hooks-guide.md
Override settings at the CLI --settings, --setting-sources (see references/cli-reference.md)
Stream hook events to JSON --include-hook-events --output-format=stream-json

Memory, context, files

Task Read
CLAUDE.md hierarchy and imports references/memory.md
Add context dirs / extra files --add-dir, --file (see references/cli-reference.md)
Custom system prompt --system-prompt, --append-system-prompt
Checkpoints (auto-save / restore) references/checkpointing.md

Authentication and providers

Task Read
API key / OAuth / token references/iam.md, claude auth subcommands
Long-lived setup token claude setup-token
Amazon Bedrock references/amazon-bedrock.md
Google Vertex AI references/google-vertex-ai.md (CLAUDE_CODE_USE_VERTEX=1)
Custom LLM gateway references/llm-gateway.md

Cost, analytics, monitoring

Task Read
What sessions cost and how it's measured references/costs.md
Where data goes references/data-usage.md
Analytics export references/analytics.md
Monitoring usage in CI references/monitoring-usage.md

Editor / IDE integrations

Task Read
VS Code integration references/vs-code.md
JetBrains plugin references/jetbrains.md
Dev containers references/devcontainer.md
GitHub Actions references/github-actions.md
GitLab CI/CD references/gitlab-ci-cd.md
Third-party integrations references/third-party-integrations.md

Compliance, security, networking

Task Read
Permission modes (acceptEdits, auto, bypassPermissions, default, dontAsk, plan) references/security.md, references/cli-reference.md
IAM / token scopes / roles references/iam.md
Egress allow-list / firewall references/network-config.md
Terminal config references/terminal-config.md
Legal / compliance references/legal-and-compliance.md
Migration from older versions references/migration-guide.md
Troubleshooting references/troubleshooting.md

Custom local ecosystem (this machine only)

These are not documented in upstream superpowers — they are specific to this user's setup.

Task Read
Forge → bob → agent-teams → team-manager → specialists workflow references/custom-ecosystem.md
Hard-rules checklist before spawning agents references/custom-ecosystem.md (Hard Rules section)
MEMORY index, project context (PROJECT.md, history.md, tasks.md) references/custom-ecosystem.md (Memory + Project Docs sections)
119-skill library, _meta inventory references/custom-ecosystem.md (Skills section)
Cross-CLI orchestration: Claude + Codex + Antigravity (agy) in parallel references/cross-tool-integration.md
What changed since the Jan 2026 superpowers snapshot references/upgrades-since-jan-2026.md

Permission modes (verified from claude --help)

Six modes, exactly:

Mode Behaviour
default Ask before each tool call
acceptEdits Auto-allow file edits, ask for everything else
auto Run the auto-mode classifier (see claude auto-mode)
dontAsk Allow tool calls without prompting (use with --allowedTools)
bypassPermissions Skip permission checks entirely (sandbox/trusted dirs only)
plan Read-only planning mode

--allow-dangerously-skip-permissions is a separate opt-in flag and should only be used in sandboxes with no internet access.

Top-level subcommands (verified)

agents       Manage background agents (Agent View dashboard; --json for scripting)
auth         Manage authentication (login/logout/status)
auto-mode    Inspect auto mode classifier configuration
doctor       Check Claude Code auto-updater health
install      Install Claude Code native build
mcp          Configure and manage MCP servers
              add | add-json | get | list | remove | serve | reset-project-choices
plugin       Manage Claude Code plugins
              install | uninstall | enable | disable | list | update | validate
              marketplace { add | list | remove | update }
project      Manage Claude Code project state (purge: delete transcripts/tasks/file history/config)
setup-token  Set up a long-lived authentication token
ultrareview  Run a cloud-hosted multi-agent code review of the current branch / a PR (--json, --timeout)
update       Check for updates and install if available

Verified against claude --help on 2.1.170 (2026-06-10). agents is the background-agent Agent View (see references/native-teams-tasks.md), not a list of configured subagents. Use claude agents --help for the current sub-options on this machine.

Headless (-p) cheat sheet

# One-shot prompt, plain text
claude -p "summarize this file" < notes.md

# JSON output for scripts
claude -p --output-format json "list TODOs in this repo"

# Strict structured output
claude -p --output-format json \
  --json-schema '{"type":"object","properties":{"todos":{"type":"array","items":{"type":"string"}}},"required":["todos"]}' \
  "list TODOs"

# Stream-json for incremental processing
claude -p --output-format stream-json --include-partial-messages "long task here"

# CI-safe minimal mode
ANTHROPIC_API_KEY=$KEY claude --bare -p "lint this file" \
  --add-dir . --settings ./ci-settings.json

# Pin a pre-defined agent for the call
claude -p --agent reviewer "review the diff in this branch"

# Inline custom agent
claude -p --agents '{"redactor":{"description":"Redacts secrets","prompt":"You are a secret redactor."}}' \
  --agent redactor "redact secrets from this file"

# Cap spend
claude -p --max-budget-usd 0.50 "research X and report"

See references/headless.md for the full surface.

Anti-patterns

Don't Why
Put complete docs inline in this SKILL.md Use references/*.md — progressive disclosure keeps loading cheap
Write --max-budget-usd outside --print Flag only works in headless mode
Use --output-format=stream-json without --include-partial-messages for streaming UX Only stream-json + partial messages emit incremental chunks
Edit references in ~/.claude/plugins/cache/... That's the read-only plugin cache. Edit only the forked copies in this skill.
Assume ~/.claude/AGENTS.md is auto-loaded by Claude Code Symlink AGENTS.md -> CLAUDE.md works for the user. Native AGENTS.md support is UNVERIFIED as of 2026-04-08 — flagged for first-boot test G2
Skip --bare in CI when you need reproducibility Hooks and auto-memory inject non-deterministic context in non-bare mode
Run claude against /etc, /var, or other system dirs without --add-dir review Permission scoping silently fails if you don't list the dirs
Chain hooks across CLIs without an AI_CLI_CALL_DEPTH guard Claude → Codex → Claude can recurse. Convention only — see cross-tool-portability/challenger-concerns.md
Forget to run verify-claude-install.sh after a claude update Flag surface drifts; this fork goes stale silently

Verification

Run scripts/verify-claude-install.sh after any claude update. The script:

  1. Captures claude --version, claude --help, claude mcp --help, claude plugin --help, claude agents --help
  2. Diffs cli-reference.md against the new --help (loose diff — flag-name only)
  3. Sanity-checks ~/.claude/settings.json exists and parses as JSON
  4. Reports drift loud and exits non-zero if anything looks stale

See also

  • references/custom-ecosystem.md — forge/bob/alf/pa/wiki/agent-teams stack
  • references/cross-tool-integration.md — Claude + Codex + Antigravity (agy) orchestration
  • references/upgrades-since-jan-2026.md — delta vs the superpowers snapshot
  • antigravity-cli — Antigravity CLI (agy) counterpart
  • gh-copilot-cli — GitHub Copilot CLI counterpart
  • vscode-agents — the VS Code (GUI) counterpart: agent mode, custom .agent.md agents, multi-model driver+consultant flows, MCP, Copilot coding agent
  • gcp-workstations — running this whole stack on a GCP Workstation
  • research-for-skills/cross-tool-portability/ — rules for skills that span multiple CLIs
  • codex-orchestration — calling Codex CLI from Claude Code

正文来自原始仓库, 版权归作者所有,许可:MIT。 权利人认为有不妥,可申请下架。

原始仓库

作者的项目地址:https://github.com/joogy06/agent-foundry

标签

ai-coding-agentcli-automationcode-refactoringpr-reviewparallel-processingptybackground-tasks

同类 Skill