Skip to content

Building with Codex works when three things are set before the agent writes code: AGENTS.md and skills carry the project’s rules, each task runs in its own Git worktree, and a command you chose in advance decides when the task is done. Codex’s own summary is a claim to check, not the evidence.

This hub serves developers who use Codex daily and tech leads who set team defaults; the pages below keep work isolated and make every result prove itself. Checked against Codex CLI 0.157.1.

Which Codex build page answers your question?

Section titled “Which Codex build page answers your question?”
Your questionPage
How do I make AGENTS.md and skills load, and prove they did?Optimize AGENTS.md and skills for Codex
How do I phrase a task so Codex gets it right first time?Effective prompting and AGENTS.md strategies
How do I stop long sessions drifting and hand work between threads?Context management across Codex surfaces
Which commands and shortcuts are worth learning?Codex CLI commands, slash commands and shortcuts
How do I run parallel threads in the desktop app?Codex desktop app: parallel threads, worktrees and review
How do I make every session start faster?Codex efficiency hacks
How do I build an endpoint I trust without reading the handler?Build APIs with Codex
How do I prove a schema change or migration is safe?Database work with Codex
How do I refactor hundreds of files safely?Large-scale refactoring with worktrees
How do I apply one change across many packages or repositories?Codex batch operations
How do I migrate a legacy codebase in waves?Legacy code modernization with Codex
How do I keep docs and changelogs in step with the code?Generate and maintain documentation with Codex

Before this stage: the Codex quick start and plan with Codex. Related: multi-agent workflows and build workflows for every tool.

In what order should a Codex build task run?

Section titled “In what order should a Codex build task run?”

Each step closes one way for a finished-looking task to be wrong. The commands below are the CLI’s.

  1. Check what Codex actually loads. From the repository root, render the model-visible input:

    Terminal window
    codex debug prompt-input > /tmp/codex-input.json

    Since 0.150.0 an untrusted project does not supply its project-level AGENTS.md (the global ~/.codex/AGENTS.md still loads). Trust the repository by accepting the prompt Codex shows when a session first opens in it, then check the dump. The dump is JSON, so quotes, backslashes and line breaks from AGENTS.md appear escaped: grep for a short phrase from a single line with none of those characters, or add a unique sentinel word to AGENTS.md and grep for that. A non-zero count means your rules loaded:

    Terminal window
    grep -c "<short phrase or sentinel from AGENTS.md>" /tmp/codex-input.json
  2. Plan read-only. Start the session with codex -s read-only, or use /plan, and ask for the plan and the acceptance checks before any edit.

  3. Build in a worktree. Start with codex --worktree, or /worktree in a session, so parallel tasks never share a working directory.

  4. Gate on your commands, not Codex’s report. The tests, type check and lint named in AGENTS.md decide when the task is done; check their exit codes.

  5. Review before commit. Run codex review --uncommitted in the worktree and fix every finding you would block a pull request on (correctness, security, data loss) before the branch reaches one.

Stay on the default model, GPT-6.1 Sol, and raise reasoning effort before you switch models. Codex runs GPT-6.1 Sol at low effort by default; raise it per session with /model. For signed-in accounts the server can set a different default model, so check /model for what you are actually running. The models hub has the current lineup.

How do you know a Codex build is right without reading every line?

Section titled “How do you know a Codex build is right without reading every line?”

Codex controls none of this evidence. Read it first, then open the diff only where it points.

EvidenceWhat it provesWho owns it
codex debug prompt-input contains your rulesCodex worked with your conventionsMaintainer of AGENTS.md
A new test failed before the change and passes afterThe change does what the plan promisedDeveloper
Full suite, type check and lint exit 0Existing behaviour still holdsCI
codex review --uncommitted has no finding you would block a pull request onNo known defect by your own review rulesDeveloper
No unexplained change to tests, CI or shared codeCodex did not move the goalpostsTech lead via CODEOWNERS

What goes wrong when Codex builds features?

Section titled “What goes wrong when Codex builds features?”
SymptomCauseRecovery
Codex ignores a rule you wrote in AGENTS.mdUntrusted project, or the file is outside the loaded chainStep 1, then move long procedures into a skill
One thread overwrites another’s editBoth ran in the main checkoutStep 3
Codex reports “all tests pass” and CI failsCodex ran a subset, or a different commandName exact commands in AGENTS.md; require exit codes in the report
The fix works because a test was loosenedThe agent can edit its own checksFlag test changes in the finish prompt; put test paths under CODEOWNERS
A long session starts contradicting earlier decisionsContext was compacted and details were lostWrite a handoff file and continue in a fresh thread

For the same stage in other agents, see build with Claude Code and build with Cursor.