OpenAI Codex Complete Guide

AI Navigate Original / 5/16/2026

共有:

Key Points

  • Codex is an OpenAI coding agent; async "done while you sleep"
  • CLI and Cloud forms; Cloud links GitHub Issue→PR
  • Strengths: async, parallel, GitHub-integrated; weak: cost, supervision
  • AGENTS.md persists rules; Issue-driven, human-review PRs, tests in CI

What Is OpenAI Codex

OpenAI Codex is an AI coding agent OpenAI introduced in 2025. Its biggest trait is "throw a task and it's done while you sleep" async execution. There are CLI and Cloud forms.

2 Forms

1. Codex CLI

A CLI running in the local terminal. Operation feel similar to Claude Code.

2. Codex Cloud (Agent Mode)

Runs in OpenAI's cloud. Links with a GitHub repo and, triggered by Issues or PRs, automatically writes code and submits a PR.

Pricing

  • Included from ChatGPT Plus (USD 20/mo) up
  • Pro (USD 200/mo): greatly increased usage
  • Via API: usage billing, separate

Codex CLI Install

npm install -g @openai/codex
codex login
# Log into OpenAI in the browser

cd your-project
codex

Usage (CLI)

Interactive Mode

$ codex
> What's this project's structure?
> Rewrite the auth module to JWT auth
> Add tests too

One-Line Task

$ codex "make all TypeScript files strict-mode compliant"

Codex Cloud Setup

1. GitHub Linkage

  • chat.openai.com → Settings → Codex → GitHub linkage
  • Select target repos
  • Access: Read / Write, Issue / PR operations

2. Submit a Task

  • Select "Codex" mode in ChatGPT
  • Instruct "fix bug X in this repo and create a PR"
  • Codex branches in the cloud, writes code, makes a PR
  • Track progress in the ChatGPT screen

Strengths

  • Async: a PR is complete while you sleep
  • Parallel: submit multiple tasks at once
  • GitHub integration: Issue → PR end to end
  • Reliable exec environment: runs tests in an isolated cloud environment

Weaknesses

  • Pricing: long tasks require the Pro plan
  • Supervision: runs in the cloud, real-time intervention is hard
  • Security: confidential repos with care
  • Less adopted vs Claude Code: ecosystem still smaller

Customize with AGENTS.md

Place AGENTS.md in the project root and Codex always follows it:

# AGENTS.md
## Project rules
- TypeScript strict
- All changes must include tests
- Run npm run lint before finalizing
- Commit messages: Conventional Commits format

Typical Use Cases

  • "Fix this bug group" in the morning → PR complete by noon
  • "Test coverage to 80%" → achieved in a few hours
  • "Update dependencies to latest" → auto up to test confirmation
  • "Address all security warnings" → Issue to PR

Selective Use vs Claude Code

Codex CloudClaude Code
Where it runsCloudLocal CLI
Async
SupervisionHardEasy
SecurityCloud-sentLocal-centric
PricingPlus ~ ProPro ~ Max

Mastery Tips

  • Issue-driven: write details in a GitHub Issue and pass to Codex
  • Approval flow: auto PRs always human-reviewed
  • Mandatory tests: guarantee AI-code quality in CI
  • From routine tasks: dependency updates, test additions, lint fixes

Next Step

The complete guides for the 4 main tools (Claude Code / Cursor / Copilot / Codex) are now in place. Next, to Skills and AI pair-programming know-how.