Codex Core Concepts
This chapter explains the mental model behind Codex across the Desktop App, CLI, IDE extension, and Cloud.
1. Agent Loop (Reason + Act)
Codex works as an agent: it reads the current context, reasons about the next step, uses tools such as the shell, file editor, browser, or MCP servers, observes the result, and repeats until the task is complete.
The practical implication is simple: give Codex a goal, enough context, and clear constraints. It can then inspect the repository, make edits, run checks, and report the result.
2. Instruction Chain
Codex follows a layered instruction chain. Higher-priority system and developer instructions come first, then project instructions such as AGENTS.md, then your current request.
When instructions conflict, the higher-priority instruction wins. When they do not conflict, Codex combines them.
3. Progressive Disclosure
Codex does not need every possible document loaded at once. Skills, AGENTS files, and MCP resources can point to deeper context only when it becomes relevant.
This keeps work focused and reduces the chance that unrelated instructions pollute the task.
4. Three Permission Gates: Sandbox / Approval / Rules
Codex is controlled by three separate gates:
- Sandbox: what files, commands, and network access are available.
- Approval policy: whether Codex must ask before sensitive operations.
- Rules: organization or project policies that allow, block, or require review for command patterns.
Treat these as defense in depth rather than one single switch.
5. Five-Layer Customization Stack
Typical customization layers are:
- Account or organization policy
- Global Codex config
- Project-level
AGENTS.md - Skills and plugins
- The current prompt
Put durable rules in durable layers. Put task-specific details in the current prompt.
6. Local And Cloud Execution
Local execution runs in your local project environment and is best when the task needs local files, local tools, or quick interactive iteration.
Cloud execution runs remotely and is useful for background work, GitHub issues, PR tasks, and team workflows.
7. Models And Reasoning Effort
Codex can use different models and reasoning effort levels. Bigger models and higher reasoning effort are better for difficult design, debugging, and multi-step work. Smaller models are useful for quick edits and routine checks.
8. Mental Model Summary
Think of Codex as a careful pair programmer with tools:
- Give it a concrete outcome.
- Let it inspect before editing.
- Keep repository conventions in
AGENTS.md. - Use permissions and rules to match the risk level.
- Ask for verification when correctness matters.
Next Steps
Continue with Installation & Usage, then Desktop App.