关于 codex-review-workflow
codex-review-workflow 是一套使用 OpenAI Codex CLI 进行代码审查的工作流技能,适用于需要自动检查代码的开发者。它规定了初审、修复和复审步骤,并将审查迭代限制为两轮。
主要功能
- 01通过 Codex CLI 执行代码审查
- 02按步骤分析审查结果
- 03集中修复发现的问题
- 04针对修复内容复审
- 05最多进行两轮审查
适用场景
- 01检查新功能的缺陷与安全问题
- 02按质量标准验证代码
- 03修复问题后确认结果
- 04将 Codex CLI 纳入开发审查流程
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ daffy0208/ ai-dev-standards --skill codex-review-workflow安装后在 Claude Code 中输入/codex-review-workflow确认已加载。
附带文件manifest.yaml
详细介绍
Codex Review 工作流
概述
使用 OpenAI Codex CLI 的自动化代码审查工作流。通过自动验证实现迭代式修复与审查循环,确保代码质量。
适用场景: 使用 Codex CLI 构建需要自动化代码审查、迭代完善循环或依据特定质量标准进行验证的功能。
何时使用此技能
✅ 以下情况使用此技能:
- 用户明确要求使用 Codex CLI 审查(例如,“用 Codex 审查一下”)
- 实现需要自动化代码验证的功能
- 编写必须达到特定质量标准的代码
- 需要进行迭代式审查与完善
- 自动验证安全性、漏洞和最佳实践
❌ 以下情况跳过此技能:
- 用户只需要人工代码审查
- 环境中无法使用 Codex CLI
- 任务纯粹是探索或研究性质
- 代码很简单,不需要正式审查
前置条件
- 已安装 Codex CLI,且可通过 PATH 使用
- Git 仓库(或使用
--skip-git-repo-check标志) - 验证安装:
codex --version
核心工作流
此技能遵循结构化的 6 步流程:
1. 完成编码任务
使用标准最佳实践实现用户要求的功能。提交审查前,确保代码结构良好。
使用 TodoWrite 跟踪进度:
- 实现请求的功能/修复
- 运行 Codex CLI 初次审查
- 修复审查中发现的问题(如有)
- 运行 Codex CLI 最终审查
- 报告最终状态
2. 运行 Codex CLI 初次审查
Git 要求: Codex CLI 需要 Git 仓库。如果当前目录不在 Git 仓库中,请先运行 git init,或使用 --skip-git-repo-check 标志(不建议用于生产环境)。
使用 codex exec 执行 Codex CLI 审查(不要使用 codex review):
# For a specific file
codex exec "Review the code in <file_name> for bugs, security issues, best practices, and potential improvements. Provide specific, actionable feedback with line numbers and examples."
# For multiple files
codex exec "Review the files auth.py, user.py, and session.py for bugs, security issues, best practices, and potential improvements. Provide specific feedback for each file."
# With working directory context
codex exec "Review the code in email_validator.py for bugs, security issues, best practices, and potential improvements. Provide specific feedback." -C /path/to/project
# With specific model
codex exec "Review <file_name>..." -m gpt-5-codex
# With custom configuration
codex exec "Review <file_name>..." -c model="o3"
要点:
- 在提示词中明确说明要审查的内容
- 要求提供行号和具体示例
- 设置合适的超时时间(建议使用 120000ms,即 2 分钟)
3. 分析审查结果
Codex CLI 会返回结构化的 Markdown 输出,格式可能有所不同。请留意以下内容:
严重问题指标(必须修复):
- 章节:Bug、Security、Key Issues、Key Findings
- 严重程度标记:“High:”、“Medium:”、“critical”、“vulnerability”
质量改进项(优先级较低):
- 章节:Maintainability、Usability、Best Practices、Suggestions
- 严重程度标记:“Low:”
确认指标(成功):
- 章节:Resolved Checks、Review、Review Findings
- 短语:“No remaining findings”、“All issues resolved”、“All [N] issues look resolved”
- 勾选标记(✅)或表示确认的措辞
决策标准:
- 完成: 没有 Bug/Security/Key Issues 章节,且只剩建议
- 完成: Resolved Checks 确认之前的所有问题均已修复
- 完成: 出现“No remaining findings”或“All issues resolved”等短语
- 继续: 存在 Bug/Security/Key Issues 章节 → 继续执行第 4 步
4. 修复已发现的问题
对于发现的每个问题:
- 找到有问题的代码
- 理解问题所在
- 使用 Edit 工具应用修复
- 记录更改内容及原因
最佳实践:
- 在重新审查前,一次性修复所有问题
- 优先处理严重错误,再处理警告
- 向用户清楚说明每项修复
- 在解决问题的同时保留原有功能
5. 运行后续 Codex CLI 审查
应用修复后,运行有针对性的审查:
codex exec "Review the updated <file_name> code. Check if the previous issues have been fixed: 1) issue description, 2) issue description, etc. Report any remaining issues or confirm the code is now correct."
这有助于 Codex:
- 确认特定问题是否已解决
- 发现可能引入的新问题
- 给出明确的通过/未通过确认
分析结果:
- 所有问题均已修复: 标记工作流完成,并报告成功
- 仍有问题: 判断是否继续迭代(检查限制)
6. 处理迭代次数限制
最大迭代次数: 2 轮审查(初审 + 1 轮复审)
限制原因:
- 避免无限循环
- 有些问题需要人工判断
- 复杂问题需要架构调整
达到最大次数时:
- 在 TodoWrite 中标记当前任务状态
- 总结已修复的问题和剩余问题
- 向用户显示最终的 Codex CLI 输出
- 询问用户是否要:
- 继续手动修复
- 调整方法
- 接受当前状态
示例
示例 1:简单修复工作流
User: "Add a function to calculate fibonacci numbers and review it with Codex"
Claude:
1. Creates fibonacci function
2. Checks for git repo, runs git init if needed
3. Runs: codex exec "Review fibonacci.py for bugs, edge cases, and best practices."
4. Codex output:
- **Bug** `fibonacci.py:5`: Missing input validation for negative numbers
- **Maintainability** `fibonacci.py:10`: Consider adding type hints
5. Adds input validation and type hints
6. Runs: codex exec "Review updated fibonacci.py. Check if input validation added."
7. Codex output:
**Resolved Checks**
- `fibonacci.py:5` Input validation is now present
- `fibonacci.py:10` Type hints added
8. Reports completion
示例 2:多轮迭代(安全性)
User: "Implement user authentication and run through Codex review"
Claude:
1. Implements auth system across multiple files
2. Runs: codex exec "Review auth.py, user.py, session.py for security vulnerabilities."
3. Codex output:
- **Security** `auth.py:23`: Password stored without hashing
- **Security** `session.py:45`: Session tokens don't expire
- **Bug** `user.py:67`: SQL injection vulnerability
- **Security** `auth.py:89`: Missing CSRF protection
- **Bug** `user.py:12`: No input validation
4. Fixes all 5 issues
5. Runs targeted review: "Check if these issues are fixed: password hashing, session expiration, SQL injection, CSRF, input validation."
6. Codex output:
**Resolved Checks**
- All 5 issues confirmed fixed
**Findings**
- Minor style suggestions
7. Reached iteration limit (2 reviews)
8. Reports: "All critical security issues fixed. Minor style suggestions remain."
9. Asks user about style fixes
示例 3:首轮审查通过
User: "Write a date formatter helper, review with Codex"
Claude:
1. Creates date formatting function with error handling
2. Runs: codex exec "Review utils/date_formatter.py for bugs, edge cases."
3. Codex output:
No bugs or critical issues. Code properly handles:
- None values with error messages
- Invalid format strings
- Timezone conversions
**Suggestions**
- Could add more detailed error messages
4. Reviews suggestion, decides optional for current use case
5. Marks task complete
集成说明
Codex CLI 命令
# Basic review
codex exec "Review <file_name> for bugs, security issues, best practices. Provide specific feedback with line numbers."
# With working directory
codex exec "Review <file_name>..." -C /path/to/project
# With specific model
codex exec "Review <file_name>..." -m gpt-5-codex
# Skip git check (not recommended)
codex exec "Review <file_name>..." --skip-git-repo-check
Git 仓库要求
# Check if in git repo
git status
# Initialize if needed
git init
# Alternative: skip check
codex exec "..." --skip-git-repo-check
错误处理
未找到 Codex CLI:
- 检查:
which codex或codex --version - 告知用户 Codex CLI 不可用
- 提议在不进行自动审查的情况下完成任务
Git 仓库错误:
- 错误:“Not inside trusted directory and --skip-git-repo-check not specified”
- 解决方案:运行
git init - 替代方案:添加
--skip-git-repo-check
Codex CLI 错误:
- 常见错误:
unexpected argument- 检查语法,使用codex exec而非codex review- 身份验证错误 - 用户可能需要运行
codex login
- 使用修正后的参数再尝试一次
- 如果问题仍然存在,请向用户寻求指导
结果含糊不清:
- 如果无法确定通过与否,应谨慎处理
- 查看“Key Issues”和“Suggestions”部分
- 向用户展示输出并请求澄清
耗时较长的审查:
- 对于复杂审查,Codex 可能需要 30-120 秒
- 使用适当的超时时间(建议 120000ms)
最佳实践
- 始终使用 TodoWrite 跟踪工作流步骤
- 在每个审查阶段展示 Codex 输出
- 清楚地说明修复内容,不要悄无声息地修复
- 遵守迭代次数限制,避免无限循环
- 保留功能,在解决问题时不要破坏现有功能
- 遇到不确定情况时询问,反馈含糊时请咨询用户
自定义选项
- 调整迭代次数限制(默认:2 轮审查)
- 指定自定义 Codex CLI 命令
- 为 Codex 规则提供配置文件
- 定义要纳入或排除审查的文件
- 设置严重性阈值(仅错误或包含警告)
相关技能
- testing-strategist:创建测试套件以配合代码审查
- security-engineer:进行手动安全审查和威胁建模
- quality-auditor:进行全面的质量评估
- technical-writer:记录审查结果和改进内容
工具与依赖项
必需:
- Codex CLI(OpenAI)
- Git(用于获取仓库上下文)
推荐:
- TodoWrite 工具(跟踪进度)
- Edit 工具(应用修复)
成功提示
- 编写优质的初始代码:起点越好,所需迭代越少
- 在审查提示词中明确说明要求:“检查登录函数中的 SQL 注入问题”比“审查这段代码”更具体
- 将相关文件放在一起:整体审查身份验证系统,而不是逐个审查文件
- 一次性修复所有问题:比逐个修复更高效
- 使用有针对性的后续提示词:询问具体修复内容,而不是要求通用审查
- 知道何时停止:有些问题需要人工判断或架构调整
技能类型: 自动化 难度: 中级 预计耗时: 因任务而异(审查:1-2 分钟;每轮迭代的修复:5-30 分钟) 集成: Codex CLI、Git