How OpenAI Uses Codex to Accelerate Engineering
OpenAI uses Codex daily across its Security, Product Engineering, Frontend, API, Infrastructure, and Performance Engineering teams to accelerate engineering tasks ranging from system understanding and codebase refactoring to feature deployment and incident resolution.
Accelerating Code Understanding and Onboarding
Codex enables engineers to quickly navigate unfamiliar parts of the codebase during onboarding, debugging, or incident response. It is used to locate core feature logic, map relationships between services and modules, and trace data flow through systems. During active incidents, Codex helps engineers identify interactions between components and trace how failure states propagate.
‘When I fix a bug, I use Ask mode to see where else in the codebase the same issue might appear’
— Performance Engineer, Retrieval Systems
Streamlining Refactoring and Migrations
Codex is used to apply consistent changes across multiple files or packages, particularly when updates exceed the capabilities of regex or find-and-replace. This includes updating APIs, migrating dependencies, and cleaning up code by breaking up oversized modules or replacing legacy patterns with modern ones.
‘Codex swapped every legacy getUserById( ) for our new service pattern and opened the PR. It did in minutes what would’ve taken hours.’
— Backend Engineer, ChatGPT Web
Performance Optimization and Technical Debt Reduction
Codex identifies performance bottlenecks by analyzing slow or memory-intensive code paths, such as inefficient loops and costly queries. It also supports general code health by flagging risky or deprecated patterns to reduce long-term technical debt and prevent regressions.
‘I use Codex to scan for repeated expensive DB calls. It’s great at flagging hot paths and drafting batched queries I can later tune.’
— Infrastructure Engineer, API Reliability
Improving Test Coverage and Reliability
Codex accelerates the creation of tests, particularly for modules with thin or missing coverage. It generates unit and integration tests based on function signatures and surrounding logic, with a specific focus on identifying boundary conditions such as empty inputs, maximum lengths, and unusual valid states.
‘I point Codex at low’coverage modules overnight and wake up to runnable unit’test PRs.’
— Frontend Engineer, ChatGPT Desktop
Increasing Development Velocity and Flow
Codex reduces friction at both the start and end of the development cycle. It is used to scaffold boilerplate (folders, modules, API stubs), triage bugs, generate rollout scripts, and create telemetry hooks. Additionally, engineers use Codex to turn product feedback or specifications directly into starter code.
To maintain productivity during fragmented schedules, engineers use Codex to capture unfinished work or spin off exploratory tasks, allowing them to resume work without losing context.
‘I was in meetings all day and still merged 4 PRs because Codex was working in the background.’
— Product Engineer, ChatGPT Enterprise
Exploration and Ideation
Codex is employed for open-ended design work, such as validating design decisions, exploring alternative implementation patterns (e.g., switching from request/response to event-driven), and identifying related bugs by searching for similar patterns across the codebase.
Engineering Best Practices for Codex
OpenAI teams use several specific habits to maximize the value of Codex:
- Two-Step Workflow: Start with "Ask Mode" to generate an implementation plan, then switch to "Code Mode" for execution. This keeps the model grounded and reduces errors.
- Environment Optimization: Iteratively improving startup scripts, environment variables, and internet access to reduce error rates.
- Issue-Based Prompting: Structuring prompts like GitHub Issues, including file paths, component names, diffs, and documentation snippets.
- Task Queue as Backlog: Using the Codex task queue to capture tangential ideas or incidental fixes without requiring an immediate full PR.
- Persistent Context via AGENTS.md: Maintaining an
AGENTS.mdfile to provide Codex with naming conventions, business logic, and dependencies that cannot be inferred from code. - Best of N: Generating multiple responses for a single task to explore various solutions or combine parts of different iterations for a stronger result.