做什么
使用Codex CLI(OpenAI)和Claude Code CLI(Anthropic)的综合指南 - AI动力编码代理
技能库 智客分类:Agent 工作流 ai-coding-agents
使用 Codex CLI(OpenAI)和Claude Code CLI(Anthropic)的综合指南 - AI动力编码代理. 用于协调 CLI 命令,自动化任务,配置代理,或解决问题时使用.
官方网址:skills.sh
先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。
使用Codex CLI(OpenAI)和Claude Code CLI(Anthropic)的综合指南 - AI动力编码代理
- 通过CLI操作复杂的编码任务
按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:AI Coding Agents Skill、When to Use、Quick Reference、Starting Sessions、Safety Modes、Model Selection。
文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。 正文约 565 行,超过规范建议的 500 行,激活时仍会整份载入。
Comprehensive guide for using Codex CLI (OpenAI) and Claude Code CLI (Anthropic) - AI-powered coding agents. Use when orchestrating CLI commands, automating tasks, configuring agents, or troubleshooting issues.
AI Coding Agents SkillWhen to UseQuick ReferenceStarting SessionsSafety ModesModel SelectionCodex CLI (OpenAI)InstallationorAuthenticationCore CommandsmacOS
来源分类:skills.sh agent-skill
nameai-coding-agentsdescription具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗
先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。
复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。
把 Agent Skill「ai-coding-agents」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-eb6882a47e3c8120-Ai-%E7%BC%96%E7%A0%81%E4%BB%A3%E7%90%86.html 请存为 .cursor/skills/ai-coding-agents/SKILL.md 或 .claude/skills/ai-coding-agents/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。
npx skills add 'https://github.com/xiaolai/vmark' --list
npx skills add 'https://github.com/xiaolai/vmark' --skill 'ai-coding-agents'
CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。
untrusted|on-failure|on-request|never -c, --config Override config -C, --cd Working directory -i, --image Attach image(s) -p, --profile Config profile --full-auto Low-friction mode --yolo Bypass all safety (DANGEROUS) --search Enable web search --add-dir Grant additional write access --enable Enable feature flag --disable Disable feature flag --oss Use local OSS model ``` --- ## Claude Code CLI (Anthropic) ### Installation ```bash npm install -g @anthropic-ai/claude-code ``` ### Authentication ```bash claude # First run prompts login claude setup-token # Set up long-lived token # Requires Claude Pro/Max subscription OR API key ``` ### Core Commands #### `claude` - Interactive Mode ```bash claude # Start REPL claude "explain this project" # With prompt claude -c # Continue last conversation claude -r "session-name" # Resume by name/ID claude --model opus # Select model claude --chrome # Enable Chrome integration claude --ide # Auto-connect to IDE ``` #### `claude -p` - Print Mode (Non-Interactive) ```bash claude -p "explain this function" # Query and exit cat file | claude -p "explain" # Process piped input claude -p --output-format json "q" # JSON output claude -p --output-format stream-json "q" # Streaming JSON claude -p --max-turns 3 "task" # Limit agent turns claude -p --max-budget-usd 5 "task" # Spending limit claude -p --json-schema '{...}' "q" # Validate output schema ``` #### `claude mcp` - MCP Server Management ```bash claude mcp list # List servers claude mcp get # Server details claude mcp add # Add stdio server claude mcp add -t http # Add HTTP server claude mcp add -e KEY=val -- cmd # With env vars claude mcp add -H "Auth: Bearer x" # With headers claude mcp add -s project # Project scope claude mcp remove # Remove server claude mcp serve # Run as MCP server claude mcp add-from-claude-desktop # Import from desktop app claude mcp reset-project-choices # Reset approvals ``` #### `claude plugin` - Plugin Management ```bash claude plugin list # List plugins claude plugin install # Install plugin claude plugin install @marketplace # From specific marketplace claude plugin uninstall # Remove plugin claude plugin enable # Enable disabled plugin claude plugin disable # Disable plugin claude plugin update # Update plugin claude plugin validate # Validate manifest claude plugin marketplace # Manage marketplaces ``` #### `claude update` - Self-Update ```bash claude update # Check and install updates ``` #### `claude doctor` - Diagnostics ```bash claude doctor # Check health/issues ``` #### `claude install` - Native Build ```bash claude install # Install native build claude install stable # Specific version claude install latest # Latest version ``` ### Slash Commands (Interactive) | Command | Purpose | |---------|---------| | `/init` | Generate CLAUDE.md | | `/clear` | Reset context | | `/compact` | Summarize conversation | | `/bug` | Report issues | | `/doctor` | Run diagnostics | | `/model` | Switch model | | `/config` | View/edit settings | | `/permissions` | Manage permissions | | `/memory` | View/edit memory | | `/project:` | Project-specific commands | | `/user:` | User-specific commands | ### Custom Commands Create `.claude/commands/fix-issue.md`: ```markdown Fix GitHub issue #$ARGUMENTS 1. Read the issue details 2. Identify the problem 3. Implement the fix 4. Write tests 5. Create a commit ``` Usage: `/project:fix-issue 1234` ### Configuration **User settings** (`~/.claude/settings.json`): ```json { "model": "claude-sonnet-4-5-20250929", "verbose": false, "theme": "dark" } ``` **Project settings** (`.claude/settings.json`): ```json { "allowedTools": ["Bash(git:*)", "Read", "Edit"], "disallowedTools": ["Bash(rm:*)"] } ``` ### CLI Flags #### Core ``` -p, --print Non-interactive mode -c, --continue Continue last conversation -r, --resume Resume specific session -v, --version Show version ``` #### Model & Config ``` --model sonnet|opus|haiku or full name --fallback-model Fallback when overloaded --settings Load settings JSON --setting-sources user,project,local --session-id Use specific session ID ``` #### System Prompt ``` --system-prompt Replace default prompt --append-system-prompt Append to default --system-prompt-file Replace with file (print only) --append-system-prompt-file Replace with file (print only) ``` #### Agent & Tools ``` --agent Specify agent --agents Define custom subagents --tools Restrict built-in tools --allowedTools Auto-approve tools --disallowedTools Remove tools from context ``` #### Permissions ``` --permission-mode acceptEdits|bypassPermissions|default|delegate|dontAsk|plan --dangerously-skip-permissions Skip all prompts (DANGEROUS) --allow-dangerously-skip-permissions Enable bypass option ``` #### Output ``` --output-format text|json|stream-json --input-format text|stream-json --include-partial-messages Include streaming chunks --verbose Verbose logging --debug [FILTER] Debug mode with filtering ``` #### Advanced ``` --max-turns Limit agent turns (print only) --max-budget-usd Spending limit (print only) --json-schema Validate JSON output --chrome / --no-chrome Chrome integration --ide IDE auto-connect --fork-session Create new session on resume --no-session-persistence Don't save session --add-dir Additional directories --plugin-dir Load plugins --disable-slash-commands Disable all skills --mcp-config MCP server configs --strict-mcp-config Only use specified MCP --betas Beta API headers ``` ### Custom Subagents ```bash claude --agents '{ "reviewer": { "description": "Code reviewer. Use after changes.", "prompt": "You are a senior code reviewer...", "tools": ["Read", "Grep", "Glob"], "model": "sonnet" } }' ``` --- ## Common Patterns & Edge Cases ### CI/CD Integration **Codex in GitHub Actions:** ```yaml - name: Run Codex run: | echo "${{ secrets.OPENAI_API_KEY }}" | codex login --with-api-key codex exec --json -o result.txt "fix linting errors" ``` **Claude in CI:** ```yaml - name: Run Claude env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | claude -p --output-format json "review this PR" > review.json ``` ### Handling Rate Limits **Codex:** Automatic backoff built-in. **Claude:** Use `--fallback-model`: ```bash claude -p --fallback-model haiku "quick task" ``` ### Working with Large Codebases ```bash # Codex: Use /compact to free context # In session: /compact # Claude: Use /compact or start fresh claude --no-session-persistence -p "analyze src/" ``` ### Multi-Directory Access ```bash # Codex codex --add-dir ../shared-lib --add-dir ../config # Claude claude --add-dir ../shared-lib ../config ``` ### Structured Output **Codex:** ```bash codex exec --output-schema schema.json "generate API spec" ``` **Claude:** ```bash claude -p --json-schema '{"type":"object","properties":{"name":{"type":"string"}}}' "extract data" ``` ### Image Input **Codex:** ```bash codex -i screenshot.png "explain this UI" codex -i img1.png -i img2.png "compare these" ``` **Claude:** ```bash # Via file reference in prompt claude "analyze the image at ./screenshot.png" ``` ### Session Forking ```bash # Codex: /fork in session # Claude claude -r "session-id" --fork-session "try alternative approach" ``` ### MCP Server Debugging **Codex:** ```bash codex mcp list --json | jq . ``` **Claude:** ```bash claude --debug "mcp" --mcp-config ./mcp.json ``` --- ## Troubleshooting ### Authentication Issues | Problem | Codex | Claude | |---------|-------|--------| | Not logged in | `codex login status` | `claude doctor` | | Token expired | `codex logout && codex login` | `claude setup-token` | | API key issues | Check `OPENAI_API_KEY` | Check `ANTHROPIC_API_KEY` | ### Sandbox Issues | Problem | Solution | |---------|----------| | Permission denied | Use `--add-dir` for specific directories | | Can't run commands | Check sandbox mode, use `workspace-write` | | Network blocked | Sandbox may block network; use `danger-full-access` carefully | ### MCP Server Issues | Problem | Solution | |---------|----------| | Server not found | Check `mcp list`, verify installation | | Connection failed | Check server logs, verify URL/command | | Auth required | Use `mcp login` (Codex) or add headers (Claude) | ### Performance Issues | Problem | Solution | |---------|----------| | Slow responses | Use lighter model (gpt-4.1-mini / haiku) | | Context overflow | Use `/compact` to summarize | | High costs | Set `--max-budget-usd` (Claude) | --- ## Best Practices 1. **Start with read-only** for exploration, escalate as needed 2. **Use sessions** - resume work instead of starting fresh 3. **Create AGENTS.md/CLAUDE.md** for project-specific instructions 4. **Leverage MCP servers** for external integrations 5. **Use structured output** in CI/CD for parsing 6. **Set spending limits** with `--max-budget-usd` 7. **Review diffs** before applying (`/diff`, `codex cloud diff`) 8. **Commit checkpoints** before major changes
Agent 工作流
创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.
Agent 工作流
使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.
Agent 工作流
管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.
Agent 工作流
Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…