Automated code review workflow using OpenAI Codex CLI. Implements iterative fix-and-review cycles until code passes validation or reaches iteration limit.
Automated code review workflow using OpenAI Codex CLI. Implements iterative fix-and-review cycles to ensure code quality through automated validation.
Use when: Building features that require automated code review, iterative refinement cycles, or validation against specific quality standards using Codex CLI.
✅ Use this skill when:
❌ Skip this skill when:
--skip-git-repo-check flag)codex --versionThis skill follows a structured 6-step process:
Implement the user's requested feature using standard best practices. Ensure code is well-structured before submitting for review.
Track progress with TodoWrite:
Git requirement: Codex CLI requires a git repository. If not in a git repo, run git init first, or use --skip-git-repo-check flag (not recommended for production).
Execute Codex CLI review using codex exec (NOT 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"
Key points:
Codex CLI returns structured markdown output with variable formats. Look for:
Critical issue indicators (MUST FIX):
Quality improvements (LOWER PRIORITY):
Confirmation indicators (success):
Decision criteria:
For each issue identified:
Best practices:
After applying fixes, run targeted review:
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."
This helps Codex:
Analyze results:
Maximum iterations: 2 review cycles (initial + 1 re-review)
Why limit:
When max reached:
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
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
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
# 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
# Check if in git repo
git status
# Initialize if needed
git init
# Alternative: skip check
codex exec "..." --skip-git-repo-check
Codex CLI not found:
which codex or codex --versionGit repository error:
git init--skip-git-repo-checkCodex CLI errors:
unexpected argument - Check syntax, use codex exec not codex reviewcodex loginAmbiguous results:
Long-running reviews:
Required:
Recommended:
Skill Type: Automation Difficulty: Intermediate Estimated Time: Varies by task (review: 1-2min, fixes: 5-30min per iteration) Integration: Codex CLI, Git