Codex CLI Best Practices — Design, Change, and Verify in Small, Fast Iterations¶
Principles (4 Points)¶
- Plan First: Start with
update_planto break down into 5–7 steps. Update iteratively. - Minimal Diff:
apply_patchshould be equivalent to 1 commit. Avoid unrelated changes. - Proximate Verification: Test the "immediate vicinity" of changes → expand (build/link/simple E2E).
- Transparency: Privilege escalation/destructive operations/external I/O require 1 action = 1 message for prior agreement.
Template (Example)¶
1) Plan: Implement ○○ (specify boundaries/exceptions)
2) Read: Related files within 200 lines, verify in stages
3) Patch: Apply only changes (minimal comments)
4) Verify: Test/build/static analysis in proximate → broad order
5) Document: Lightweight update of README/AGENTS.md/comments
Example (Small Fix)¶
Plan: Change home link from .md → / (2 places)
Read: Relevant section of docs/index.md
Patch: Fix href in a tags
Verify: mkdocs build, local navigation check
Document: Specify reason for change in commit message
Common Pitfalls and Avoidance¶
- Bloated patches: Don't mix feature addition, cleanup, and style fixes. Split into separate plans.
- Hiding failures: Show failure logs and immediately propose alternatives/rollback.
- "While we're at it" fixes: Turn off-topic fixes into TODOs and defer to separate PR/task.
Efficiency Mode (Dangerous Mode)¶
For maximum development efficiency, you can completely skip approval prompts with the following command:
# Most important: Start interactive session (equivalent to Claude Code's --dangerously-skip-permissions)
codex --dangerously-bypass-approvals-and-sandbox
# → After session starts, all operations are auto-approved
# → Can execute multiple tasks interactively in succession
# Safer alternative (recommended)
codex --full-auto # Balanced auto-execution session
codex -a never -s workspace-write # Auto-execute only within workspace
Warning: --dangerously-bypass-approvals-and-sandbox disables all safety mechanisms. Do not use in production; use only in development environments.
Verification Checklist (This Repository Example)¶
- MkDocs:
mkdocs build --strict(local) / CI is non-blocking → will be stricter in future - Links:
pytest --check-links docs/ -q(external links summarized in nightly job) - Translation pairs: run the JP/EN article pair validation script (AI-Daily-News excluded)
Costs and Limits¶
- No additional API charges when using ChatGPT integration. Model/usage limits follow plan and usage conditions.
- Benchmarks measured locally (wall-clock time, token count, success rate). Record results in Issues for continuous evaluation.
- Parent page: OpenAI Codex CLI Complete Guide
- Related: Overview and Quick Start / Claude Code Comparison
- Troubleshooting: How to Disable Network Restrictions