codeagent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodeagent Wrapper Integration
Codeagent Wrapper 集成
Overview
概述
Execute codeagent-wrapper commands with pluggable AI backends (Codex, Claude, Gemini). Supports file references via syntax, parallel task execution with backend selection, and configurable security controls.
@通过可插拔的AI后端(Codex、Claude、Gemini)执行codeagent-wrapper命令。支持通过语法进行文件引用、可选择后端的并行任务执行,以及可配置的安全控制。
@When to Use
适用场景
- Complex code analysis requiring deep understanding
- Large-scale refactoring across multiple files
- Automated code generation with backend selection
- 需要深度理解的复杂代码分析
- 跨多个文件的大规模重构
- 可选择后端的自动化代码生成
Usage
使用方法
HEREDOC syntax (recommended):
bash
codeagent-wrapper --backend codex - [working_dir] <<'EOF'
<task content here>
EOFWith backend selection:
bash
codeagent-wrapper --backend claude - . <<'EOF'
<task content here>
EOFSimple tasks:
bash
codeagent-wrapper --backend codex "simple task" [working_dir]
codeagent-wrapper --backend gemini "simple task" [working_dir]HEREDOC语法(推荐):
bash
codeagent-wrapper --backend codex - [working_dir] <<'EOF'
<任务内容>
EOF指定后端:
bash
codeagent-wrapper --backend claude - . <<'EOF'
<任务内容>
EOF简单任务:
bash
codeagent-wrapper --backend codex "简单任务" [working_dir]
codeagent-wrapper --backend gemini "简单任务" [working_dir]Backends
后端
| Backend | Command | Description | Best For |
|---|---|---|---|
| codex | | OpenAI Codex (default) | Code analysis, complex development |
| claude | | Anthropic Claude | Simple tasks, documentation, prompts |
| gemini | | Google Gemini | UI/UX prototyping |
| 后端 | 命令 | 描述 | 最佳适用场景 |
|---|---|---|---|
| codex | | OpenAI Codex(默认) | 代码分析、复杂开发 |
| claude | | Anthropic Claude | 简单任务、文档编写、提示词工程 |
| gemini | | Google Gemini | UI/UX原型设计 |
Backend Selection Guide
后端选择指南
Codex (default):
- Deep code understanding and complex logic implementation
- Large-scale refactoring with precise dependency tracking
- Algorithm optimization and performance tuning
- Example: "Analyze the call graph of @src/core and refactor the module dependency structure"
Claude:
- Quick feature implementation with clear requirements
- Technical documentation, API specs, README generation
- Professional prompt engineering (e.g., product requirements, design specs)
- Example: "Generate a comprehensive README for @package.json with installation, usage, and API docs"
Gemini:
- UI component scaffolding and layout prototyping
- Design system implementation with style consistency
- Interactive element generation with accessibility support
- Example: "Create a responsive dashboard layout with sidebar navigation and data visualization cards"
Backend Switching:
- Start with Codex for analysis, switch to Claude for documentation, then Gemini for UI implementation
- Use per-task backend selection in parallel mode to optimize for each task's strengths
Codex(默认):
- 深度代码理解与复杂逻辑实现
- 具备精确依赖追踪的大规模重构
- 算法优化与性能调优
- 示例:"分析@src/core的调用图并重构模块依赖结构"
Claude:
- 需求明确的快速功能实现
- 技术文档、API规范、README生成
- 专业提示词工程(如产品需求、设计规范)
- 示例:"为@package.json生成包含安装、使用和API文档的完整README"
Gemini:
- UI组件脚手架与布局原型设计
- 具备风格一致性的设计系统实现
- 支持无障碍的交互元素生成
- 示例:"创建包含侧边栏导航和数据可视化卡片的响应式仪表板布局"
后端切换:
- 先使用Codex进行分析,再切换到Claude编写文档,最后用Gemini实现UI
- 在并行模式中为每个任务选择合适的后端,以优化任务执行效果
Parameters
参数
- (required): Task description, supports
taskreferences@file - (optional): Working directory (default: current)
working_dir - (required): Select AI backend (codex/claude/gemini)
--backend- Note: Claude backend only adds when explicitly enabled
--dangerously-skip-permissions
- Note: Claude backend only adds
- (必填):任务描述,支持
task引用@file - (可选):工作目录(默认:当前目录)
working_dir - (必填):选择AI后端(codex/claude/gemini)
--backend- 注意:仅当显式启用时,Claude后端才会添加
--dangerously-skip-permissions
- 注意:仅当显式启用时,Claude后端才会添加
Return Format
返回格式
Agent response text here...
---
SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14Agent响应文本...
---
SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14Resume Session
恢复会话
bash
undefinedbash
undefinedResume with codex backend
使用codex后端恢复会话
codeagent-wrapper --backend codex resume <session_id> - <<'EOF'
<follow-up task>
EOF
codeagent-wrapper --backend codex resume <session_id> - <<'EOF'
<后续任务>
EOF
Resume with specific backend
使用指定后端恢复会话
codeagent-wrapper --backend claude resume <session_id> - <<'EOF'
<follow-up task>
EOF
undefinedcodeagent-wrapper --backend claude resume <session_id> - <<'EOF'
<后续任务>
EOF
undefinedParallel Execution
并行执行
Default (summary mode - context-efficient):
bash
codeagent-wrapper --parallel <<'EOF'
---TASK---
id: task1
backend: codex
workdir: /path/to/dir
---CONTENT---
task content
---TASK---
id: task2
dependencies: task1
---CONTENT---
dependent task
EOFFull output mode (for debugging):
bash
codeagent-wrapper --parallel --full-output <<'EOF'
...
EOFOutput Modes:
- Summary (default): Structured report with changes, output, verification, and review summary.
- Full (): Complete task messages. Use only when debugging specific failures.
--full-output
With per-task backend:
bash
codeagent-wrapper --parallel <<'EOF'
---TASK---
id: task1
backend: codex
workdir: /path/to/dir
---CONTENT---
analyze code structure
---TASK---
id: task2
backend: claude
dependencies: task1
---CONTENT---
design architecture based on analysis
---TASK---
id: task3
backend: gemini
dependencies: task2
---CONTENT---
generate implementation code
EOFConcurrency Control:
Set to limit concurrent tasks (default: unlimited).
CODEAGENT_MAX_PARALLEL_WORKERS默认(摘要模式 - 高效上下文):
bash
codeagent-wrapper --parallel <<'EOF'
---TASK---
id: task1
backend: codex
workdir: /path/to/dir
---CONTENT---
任务内容
---TASK---
id: task2
dependencies: task1
---CONTENT---
依赖任务
EOF完整输出模式(用于调试):
bash
codeagent-wrapper --parallel --full-output <<'EOF'
...
EOF输出模式:
- 摘要(默认):包含变更、输出、验证和审核摘要的结构化报告。
- 完整():完整的任务消息。仅在调试特定失败场景时使用。
--full-output
指定任务后端:
bash
codeagent-wrapper --parallel <<'EOF'
---TASK---
id: task1
backend: codex
workdir: /path/to/dir
---CONTENT---
分析代码结构
---TASK---
id: task2
backend: claude
dependencies: task1
---CONTENT---
基于分析结果设计架构
---TASK---
id: task3
backend: gemini
dependencies: task2
---CONTENT---
生成实现代码
EOF并发控制:
设置以限制并发任务数(默认:无限制)。
CODEAGENT_MAX_PARALLEL_WORKERSEnvironment Variables
环境变量
- : Override timeout in milliseconds (default: 7200000 = 2 hours)
CODEX_TIMEOUT - : Control Claude CLI permission checks
CODEAGENT_SKIP_PERMISSIONS- For Claude backend: Set to /
trueto add1(default: disabled)--dangerously-skip-permissions - For Codex/Gemini backends: Currently has no effect
- For Claude backend: Set to
- : Limit concurrent tasks in parallel mode (default: unlimited, recommended: 8)
CODEAGENT_MAX_PARALLEL_WORKERS
- :覆盖超时时间(毫秒,默认:7200000 = 2小时)
CODEX_TIMEOUT - :控制Claude CLI权限检查
CODEAGENT_SKIP_PERMISSIONS- 对于Claude后端:设置为/
true以添加1(默认:禁用)--dangerously-skip-permissions - 对于Codex/Gemini后端:当前无效果
- 对于Claude后端:设置为
- :限制并行模式下的并发任务数(默认:无限制,推荐:8)
CODEAGENT_MAX_PARALLEL_WORKERS
Invocation Pattern
调用模式
Single Task:
Bash tool parameters:
- command: codeagent-wrapper --backend <backend> - [working_dir] <<'EOF'
<task content>
EOF
- timeout: 7200000
- description: <brief description>
Note: --backend is required (codex/claude/gemini)Parallel Tasks:
Bash tool parameters:
- command: codeagent-wrapper --parallel --backend <backend> <<'EOF'
---TASK---
id: task_id
backend: <backend> # Optional, overrides global
workdir: /path
dependencies: dep1, dep2
---CONTENT---
task content
EOF
- timeout: 7200000
- description: <brief description>
Note: Global --backend is required; per-task backend is optional单任务:
Bash工具参数:
- command: codeagent-wrapper --backend <backend> - [working_dir] <<'EOF'
<任务内容>
EOF
- timeout: 7200000
- description: <简要描述>
注意:--backend为必填项(codex/claude/gemini)并行任务:
Bash工具参数:
- command: codeagent-wrapper --parallel --backend <backend> <<'EOF'
---TASK---
id: task_id
backend: <backend> # 可选,覆盖全局设置
workdir: /path
dependencies: dep1, dep2
---CONTENT---
任务内容
EOF
- timeout: 7200000
- description: <简要描述>
注意:全局--backend为必填项;任务级后端为可选Critical Rules
重要规则
NEVER kill codeagent processes. Long-running tasks are normal. Instead:
-
Check task status via log file:bash
# View real-time output tail -f /tmp/claude/<workdir>/tasks/<task_id>.output # Check if task is still running cat /tmp/claude/<workdir>/tasks/<task_id>.output | tail -50 -
Wait with timeout:bash
# Use TaskOutput tool with block=true and timeout TaskOutput(task_id="<id>", block=true, timeout=300000) -
Check process without killing:bash
ps aux | grep codeagent-wrapper | grep -v grep
Why: codeagent tasks often take 2-10 minutes. Killing them wastes API costs and loses progress.
切勿终止codeagent进程。长时间运行的任务属于正常情况。正确的做法是:
-
通过日志文件检查任务状态:bash
# 查看实时输出 tail -f /tmp/claude/<workdir>/tasks/<task_id>.output # 检查任务是否仍在运行 cat /tmp/claude/<workdir>/tasks/<task_id>.output | tail -50 -
带超时等待:bash
# 使用TaskOutput工具并设置block=true和超时时间 TaskOutput(task_id="<id>", block=true, timeout=300000) -
检查进程而不终止:bash
ps aux | grep codeagent-wrapper | grep -v grep
原因:codeagent任务通常需要2-10分钟。终止进程会浪费API成本并丢失进度。
Security Best Practices
安全最佳实践
- Claude Backend: Permission checks enabled by default
- To skip checks: set or pass
CODEAGENT_SKIP_PERMISSIONS=true--skip-permissions
- To skip checks: set
- Concurrency Limits: Set in production to prevent resource exhaustion
CODEAGENT_MAX_PARALLEL_WORKERS - Automation Context: This wrapper is designed for AI-driven automation where permission prompts would block execution
- Claude后端:默认启用权限检查
- 跳过检查:设置或传递
CODEAGENT_SKIP_PERMISSIONS=true--skip-permissions
- 跳过检查:设置
- 并发限制:在生产环境中设置以防止资源耗尽
CODEAGENT_MAX_PARALLEL_WORKERS - 自动化上下文:此Wrapper专为AI驱动的自动化场景设计,在这些场景中权限提示会阻塞执行
Recent Updates
最近更新
- Multi-backend support for all modes (workdir, resume, parallel)
- Security controls with configurable permission checks
- Concurrency limits with worker pool and fail-fast cancellation
- 所有模式(工作目录、恢复会话、并行)均支持多后端
- 具备可配置权限检查的安全控制
- 带有工作池和快速失败取消的并发限制