How to Use Codex CLI for a Safe First Code Review

How to Use Codex CLI for a Safe First Code Review

OpenAI Codex CLI is a terminal-based coding agent that can inspect a project, explain unfamiliar code, write tests, and propose changes. This guide presents a cautious first workflow: install the tool, review a small repository in read-only mode, ask focused questions, and approve edits only after you understand what Codex plans to change.

Codex CLI's working model

Codex runs from your project directory and uses natural-language requests to work with the files around it. OpenAI describes Codex CLI as a tool for working with code from the terminal. The refreshed CLI also includes an agent view, multi-agent tools, voice, worktrees, usage statistics, and improved terminal rendering, according to OpenAI's Codex documentation and its September 29, 2026 DevDay recap.

Unlike autocomplete, a coding agent can read several files, form a plan, call development tools, and return proposed changes. That makes Codex useful for code review, but it also makes a narrow task and visible approval controls important for a first session.

Install and sign in

Before starting, confirm that your computer meets Codex CLI's documented requirements. It supports macOS 12 or later, Ubuntu 20.04 or later, Debian 10 or later, and Windows 11 through WSL2. OpenAI's installation documentation lists 4 GB of RAM as the minimum and 8 GB as the recommended amount.

Choose the command for your system from the official Codex repository:

# macOS or Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

# Or install through npm
npm install -g @openai/codex

After installation, open a terminal in the project you want to inspect and run:

codex

When Codex asks how to authenticate, select Sign in with ChatGPT. OpenAI says Codex is included across ChatGPT plans, including Free and Go, although usage limits vary by plan. An API key is also supported, but it requires separate setup.

Run a read-only review

After signing in, begin with a restrictive configuration. This lets Codex inspect files without changing them. OpenAI's help documentation identifies sandbox_mode = "read-only" with approval_policy = "on-request" as a restrictive alternative for Codex configurations.

sandbox_mode = "read-only"
approval_policy = "on-request"

Add those settings to the Codex configuration, then start Codex in the project directory. When the session opens, give it a clear review request. This example asks for findings instead of automatic edits:

Review this repository as a careful senior developer.

1. Summarize the project structure and its main entry points.
2. Identify three high-risk bugs or design problems.
3. Check whether the existing tests cover those areas.
4. For each finding, cite the file and line or function involved.
5. Do not modify files. Do not run commands that change files.
6. End with a short list of questions I should answer before approving any fix.

Specific requests produce more useful results than “fix my project.” Ask for file names, evidence, and an explanation of why each finding matters. Treat the response as a review draft, not as proof that a defect exists.

Check findings before edits

Next, review each reported issue yourself. Open the named file, compare the claim with the surrounding code, and check whether the behavior is covered by tests. If Codex cites a dependency, configuration value, or API contract, verify it against the project's own documentation or the authoritative documentation for that dependency.

For a second read-only pass, ask Codex to challenge its own conclusions:

Recheck finding 2. Try to disprove it using the current code and tests.
List any assumptions you made and explain what evidence would confirm or reject them.
Do not edit files.

This review helps separate a real defect from a missing-context problem. It also creates a useful record of the reasoning behind a proposed change.

Approve one small change

Only after reviewing the findings should you start a task for a code change. Keep the request limited to one behavior and state how success will be tested:

Address only the null-value bug in src/parser.py.
First explain the proposed change and name the files you will edit.
Wait for my approval before editing.
After approval, add a regression test and run the existing parser tests.
Do not change public interfaces or unrelated formatting.

Use version control before approving edits so the change is easy to inspect or discard. After Codex finishes, ask for a summary and test results, then review the diff yourself. Codex should support code review, not replace it. This process keeps the review focused and repeatable.

Keep approvals in control

Because Codex can work with local files and development tools, avoid giving an unfamiliar repository broad permission at the start. Keep secrets, production credentials, private customer data, and deployment access outside the project session. OpenAI also documents /init as a way to generate an AGENTS.md project-instructions scaffold for the current project.

For a first project, use a simple sequence: read first, ask for evidence, approve one change, inspect the diff, and run the project's normal tests. This gives Codex useful context without turning a small experiment into an uncontrolled rewrite.

References

OpenAI. (n.d.). Codex. GitHub. Retrieved November 16, 2026, from https://github.com/openai/codex

OpenAI. (n.d.). Installing and building Codex CLI. GitHub. Retrieved November 16, 2026, from https://github.com/openai/codex/blob/main/docs/install.md

OpenAI. (n.d.). Using Codex with your ChatGPT plan. OpenAI Help Center. Retrieved November 16, 2026, from https://help.openai.com/en/articles/11369540-using-codex-with-your-chatgpt-plan

OpenAI. (2026, September 29). DevDay 2026 recap. https://openai.com/index/devday-2026-recap/