codex-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex Agent Collaboration Skill
Codex Agent协作技能
This skill enables Claude Code to collaborate with OpenAI's Codex CLI agent.
本技能支持Claude Code与OpenAI的Codex CLI agent协作。
MANDATORY: Code Review Workflow
强制要求:代码审查工作流
IMPORTANT: When performing code review, you MUST follow this workflow:
重要提示:执行代码审查时,必须遵循以下工作流:
Step 1: Call Codex for Review
步骤1:调用Codex进行审查
bash
codex exec -C <project_path> -s read-only -o /tmp/codex-review.md \
"Review the code in <file_or_directory>. Check for:
- Security vulnerabilities
- Performance issues
- Code quality and best practices
- Potential bugs and edge cases
- Naming and readability
Provide specific, actionable feedback with file paths and line numbers."bash
codex exec -C <project_path> -s read-only -o /tmp/codex-review.md \
"Review the code in <file_or_directory>. Check for:
- Security vulnerabilities
- Performance issues
- Code quality and best practices
- Potential bugs and edge cases
- Naming and readability
Provide specific, actionable feedback with file paths and line numbers."Step 2: Read Codex Feedback
步骤2:查看Codex反馈
bash
cat /tmp/codex-review.mdbash
cat /tmp/codex-review.mdStep 3: Apply Fixes Based on Codex Feedback
步骤3:根据Codex反馈修复问题
For each issue identified by Codex:
- Read the relevant file
- Apply the fix using Edit tool
- Verify the fix addresses Codex's concern
针对Codex识别出的每个问题:
- 阅读相关文件
- 使用编辑工具应用修复
- 验证修复是否解决了Codex指出的问题
Step 4: Re-verify with Codex (Optional)
步骤4:使用Codex重新验证(可选)
bash
codex exec -C <project_path> -s read-only \
"Verify the fixes applied to <files>. Confirm issues are resolved."bash
codex exec -C <project_path> -s read-only \
"Verify the fixes applied to <files>. Confirm issues are resolved."Workflow Examples
工作流示例
Example 1: Review and Fix a Single File
示例1:审查并修复单个文件
bash
undefinedbash
undefinedStep 1: Get Codex review
Step 1: Get Codex review
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Review src/auth/login.ts for security vulnerabilities and code quality issues. Provide specific line numbers and fixes."
"Review src/auth/login.ts for security vulnerabilities and code quality issues. Provide specific line numbers and fixes."
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Review src/auth/login.ts for security vulnerabilities and code quality issues. Provide specific line numbers and fixes."
"Review src/auth/login.ts for security vulnerabilities and code quality issues. Provide specific line numbers and fixes."
Step 2: Read the feedback
Step 2: Read the feedback
cat /tmp/codex-review.md
Then Claude reads the feedback, applies fixes with Edit tool, and optionally re-verifies.cat /tmp/codex-review.md
随后Claude会读取反馈,使用编辑工具应用修复,并可选择重新验证。Example 2: Review Recent Changes
示例2:审查最近的变更
bash
undefinedbash
undefinedGet diff of recent changes
Get diff of recent changes
git diff HEAD~1 > /tmp/recent-changes.diff
git diff HEAD~1 > /tmp/recent-changes.diff
Step 1: Have Codex review the diff
Step 1: Have Codex review the diff
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Review the changes in the last commit. Check for bugs, security issues, and improvements needed."
"Review the changes in the last commit. Check for bugs, security issues, and improvements needed."
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Review the changes in the last commit. Check for bugs, security issues, and improvements needed."
"Review the changes in the last commit. Check for bugs, security issues, and improvements needed."
Step 2: Read and apply fixes
Step 2: Read and apply fixes
cat /tmp/codex-review.md
undefinedcat /tmp/codex-review.md
undefinedExample 3: Full Project Review
示例3:全项目审查
bash
undefinedbash
undefinedStep 1: Comprehensive review
Step 1: Comprehensive review
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Perform a comprehensive code review of src/. Focus on:
"Perform a comprehensive code review of src/. Focus on:
- Security vulnerabilities (OWASP Top 10)
- Error handling patterns
- Performance bottlenecks
- Code duplication Prioritize issues by severity (critical/high/medium/low)."
codex exec -C /project -s read-only -o /tmp/codex-review.md
"Perform a comprehensive code review of src/. Focus on:
"Perform a comprehensive code review of src/. Focus on:
- Security vulnerabilities (OWASP Top 10)
- Error handling patterns
- Performance bottlenecks
- Code duplication Prioritize issues by severity (critical/high/medium/low)."
Step 2: Read prioritized feedback
Step 2: Read prioritized feedback
cat /tmp/codex-review.md
undefinedcat /tmp/codex-review.md
undefinedReview Request Format
审查请求格式
When asking Codex for review, include:
Review <target_files_or_directory>.
Context:
- Project type: <TypeScript/Python/etc>
- Framework: <Express/React/etc>
- Focus areas: <security/performance/quality>
Check for:
1. Security vulnerabilities
2. Performance issues
3. Error handling
4. Code quality
5. Edge cases
Output format:
For each issue:
- File: <path>
- Line: <number>
- Severity: critical/high/medium/low
- Issue: <description>
- Fix: <specific code change>向Codex发起审查请求时,请包含以下内容:
Review <target_files_or_directory>.
Context:
- Project type: <TypeScript/Python/etc>
- Framework: <Express/React/etc>
- Focus areas: <security/performance/quality>
Check for:
1. Security vulnerabilities
2. Performance issues
3. Error handling
4. Code quality
5. Edge cases
Output format:
For each issue:
- File: <path>
- Line: <number>
- Severity: critical/high/medium/low
- Issue: <description>
- Fix: <specific code change>Applying Fixes
应用修复
After receiving Codex feedback, apply fixes systematically:
- Parse the review - Extract each issue with file, line, severity
- Prioritize - Fix critical/high issues first
- Read file - Use Read tool to see current code
- Apply fix - Use Edit tool with precise old_string/new_string
- Track progress - Mark each issue as fixed
收到Codex的反馈后,按以下系统步骤应用修复:
- 解析审查结果 - 提取每个问题的文件、行号和严重程度
- 确定优先级 - 优先修复严重/高优先级问题
- 读取文件 - 使用读取工具查看当前代码
- 应用修复 - 使用编辑工具,精确指定old_string/new_string进行修改
- 跟踪进度 - 标记每个问题为已修复
Prerequisites
前提条件
Codex CLI must be installed and authenticated:
bash
undefined必须安装并认证Codex CLI:
bash
undefinedInstall via npm
Install via npm
npm install -g @openai/codex
npm install -g @openai/codex
Or via Homebrew (macOS)
Or via Homebrew (macOS)
brew install --cask codex
brew install --cask codex
Authenticate
Authenticate
codex login
undefinedcodex login
undefinedCommand Reference
命令参考
Basic Command Pattern
基本命令格式
bash
codex exec [options] "<task_description>"bash
codex exec [options] "<task_description>"Core Options
核心选项
| Option | Description |
|---|---|
| Task description (positional, must be quoted) |
| Working directory (use absolute path) |
| Read-only sandbox (use for reviews) |
| Save output to file |
| Output as JSON Lines |
| Option | Description |
|---|---|
| Task description (positional, must be quoted) |
| Working directory (use absolute path) |
| Read-only sandbox (use for reviews) |
| Save output to file |
| Output as JSON Lines |
AI-to-AI Communication
AI与AI通信
When communicating with Codex, PRIORITIZE ACCURACY AND PRECISION:
- Use structured data and exact technical terms
- Provide full file paths and precise details
- Include relevant context from the current codebase
- NO conversational formatting needed
与Codex通信时,优先保证准确性和精确性:
- 使用结构化数据和准确的技术术语
- 提供完整的文件路径和精确细节
- 包含当前代码库的相关上下文
- 无需使用对话式格式
Other Use Cases
其他使用场景
Cross-Verification (after Claude implements)
交叉验证(Claude实现后)
bash
codex exec -C /project -s read-only \
"Verify the implementation in src/feature/. Check correctness and edge cases."bash
codex exec -C /project -s read-only \
"Verify the implementation in src/feature/. Check correctness and edge cases."Get Alternative Implementation
获取替代实现方案
bash
codex exec -C /project -s read-only -o /tmp/alternative.md \
"Propose an alternative implementation for the caching in src/cache/manager.ts"bash
codex exec -C /project -s read-only -o /tmp/alternative.md \
"Propose an alternative implementation for the caching in src/cache/manager.ts"Debugging Assistance
调试辅助
bash
codex exec -C /project -s read-only \
"Debug: tests in tests/auth.test.ts failing with timeout. Analyze root cause."bash
codex exec -C /project -s read-only \
"Debug: tests in tests/auth.test.ts failing with timeout. Analyze root cause."Session Management
会话管理
For multi-turn reviews:
bash
undefined对于多轮次审查:
bash
undefinedInitial review
Initial review
codex exec -C /project -s read-only "Review src/api/ for security issues"
codex exec -C /project -s read-only "Review src/api/ for security issues"
Note session ID from output
Note session ID from output
Follow-up after fixes
Follow-up after fixes
codex exec resume <session_id> "I've applied the fixes. Please re-verify."
undefinedcodex exec resume <session_id> "I've applied the fixes. Please re-verify."
undefinedTroubleshooting
故障排除
Authentication Issues
认证问题
bash
codex logout
codex loginbash
codex logout
codex loginCheck Installation
检查安装
bash
codex --version
which codexbash
codex --version
which codexSee Also
另请参阅
- sandbox-modes.md - Sandbox security levels
- examples.md - More usage examples
- advanced.md - Advanced configuration
- sandbox-modes.md - Sandbox安全级别
- examples.md - 更多使用示例
- advanced.md - 高级配置