Principles
- Those who write don't review: Claude focuses on writing code, does not self-review boundary conditions
- Those who review don't write: Codex focuses on finding issues, does not modify code
- Loop until clean: fix when there are issues, review again after fixing, until Codex has no new issues
When to Trigger
After completing feature development, Bug fixes or refactoring, before git commit run this workflow.
Process
Step 1: Confirm the scope of work
检查未提交的改动:git diff --stat
列出变更文件清单,确认审查范围
Step 2: Invoke Codex review
Preferred method - MCP tool invocation(if the Codex MCP server is loaded):
- Use the
codexMCP tool, pass in the list of changed files, request a code review - Focus on: boundary conditions, logic flaws, type safety, null handling, concurrency issues
Fallback method - CLI invocation(if MCP is unavailable):
git diff HEAD | codex "你是严格的代码审查员,分析以下代码变更。用中文输出问题列表,每个问题说明:文件路径:行号、问题类型(逻辑/类型/并发/资源)、具体描述、风险、修复建议。没有问题则输出 NO_ISSUES。"
Step 3: Parse the issue list
Structure the Codex output into an issue list:
问题 #1:[类型] [文件:行号]
描述:...
修复方案:...
问题 #2:...
If no issues → skip to step 6
Step 4: Claude fixes item by item
Fix one by one according to the issue list:
- Priority: logic flaws > type safety > boundary conditions > code quality
- Update progress after each fix:
✅ 已修复 #Nor⏭️ 跳过 #N(说明原因) - Don't over-fix: only change the issues Codex pointed out, don't refactor unrelated code along the way
Step 5: Invoke Codex review again
Repeat steps 2-3, check:
- Whether the fix correctly resolved the original issue
- Whether the fix introduced new issues
If there are new issues → return to step 4
If no new issues → continue to step 6
Step 6: Verify
# 根据项目类型选择合适的验证命令
# lint / typecheck
# build / compile
# test
After all pass, proceed to step 7. If verification fails → fix and return to step 2.
Step 7: Commit
git add <相关文件>
git commit -m "$(cat <<'EOF'
<commit message>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EOF
)"
Review focus checklist
During Codex review, pay special attention to the following dimensions:
| Dimension | Check items |
|---|---|
| Boundary conditions | Empty arrays/empty strings, zero values, extremely large/small values, index out of bounds |
| Logic flaws | Missing conditional checks, logic short-circuit errors, missing states in state machines |
| Type safety | nil/null dereference, type assertion failure, interface mismatch |
| Concurrency safety | Data races, deadlocks, unlocked shared state |
| Error handling | Ignoring error return values, loss of error information, unrecovered panic |
| Resource management | Files/connections not closed, memory leaks, incorrect use of defer |
Output format
At the end of the workflow, report:
## Cross-Review 完成报告
**审查轮次**:N 轮
**发现问题**:N 个
**已修复**:N 个
**跳过**:N 个(含原因)
**验证结果**:✅ 全部通过 / ❌ 部分失败
已提交:<commit hash> <commit message>