One concept per page. Learn by turning pages like a book — no endless scrolling. Built from hands-on, verified material.
A practical, beginner-friendly guide to Codex, OpenAI's official coding agent — all 30 parts. From install and auth to config, models, MCP, Skills, automation, security, and team operations.
This guide enables you to use Codex at the following levels.
Install
→ Log in
→ Run in your project
→ Help it understand the codebase
→ Delegate work safely
→ Review changes
→ Test
→ Automate recurring tasks
→ Manage team rules and securityThis is not just a collection of commands—it explains how to weave Codex into your actual development workflow.
This guide comprehensively covers Codex's core features.
You can read it cover to cover, but it's better to adjust the order based on your goals.
Beginners should read at least in this order.
Certain concepts come up frequently when using Codex.
These terms will be explained in more detail later. For now, just remember that these names will come up repeatedly.
When you first use Codex, it might seem like there are many features. But you don't need to know everything from the start.
Just start with these 5 things.
Learning just these 5 things lets you start using Codex safely.
cd my-project
codexExplain this project's structure and how to run it in a way that beginners can understand./plan I want to refactor the login feature.
Find related files, identify risks, and propose a step-by-step plan first./diffsandbox_mode = "workspace-write"
approval_policy = "on-request"Don't start with strong permissions like danger-full-access.
Recommended defaults are:
sandbox_mode = "workspace-write"
approval_policy = "on-request"This combination lets you work within your current project while requiring user approval for risky actions.
For large tasks, first verify the plan using /plan.
/plan I want to refactor the payment module.
Analyze the current structure and propose a step-by-step change plan first.It's safer to execute after reviewing the plan.
Even code created by Codex should be reviewed by a human.
/diffEspecially review after these operations:
After changes, run relevant tests.
You can request this inside Codex.
Run tests related to the login API I just modified and summarize the results.Or run them directly.
npm testRules you need to repeat should be written in AGENTS.md.
Example:
# AGENTS.md
- Run relevant tests after all changes.
- Preserve existing API response formats.
- Follow TypeScript strict mode standards.
- Add tests for new features.This guide uses the following formats for clarity.
codex
codex "prompt"
codex --profile fast "task"model = "gpt-5.5"
sandbox_mode = "workspace-write"
approval_policy = "on-request"/plan Create a step-by-step plan for this task.Beginners should start with this configuration as a baseline.
model = "gpt-5.5"
model_reasoning_effort = "medium"
sandbox_mode = "workspace-write"
approval_policy = "on-request"Here's what each setting means:
model = "gpt-5.5"model_reasoning_effort = "medium"sandbox_mode = "workspace-write"approval_policy = "on-request"Just these settings are enough to start.
To practice Codex, it helps to have these.
It's good to prepare a test project. It's safer not to apply it directly to important production projects from the start.
It's better to start with a small example project rather than a real production project.
In the terminal:
cd sample-project
codexInside Codex:
Explain the structure, how to run it, and how to test it for someone new to the project.Beginners should avoid the following actions.
danger-full-access/diffThis section is an orientation before diving into the main Codex content.
Beginners should focus on these first:
cd project && codex/plan command/diff commandworkspace-write + on-requestAGENTS.mdSection 1. Codex Essentials
Codex is an integrated coding agent that developers can use from the terminal, desktop app, IDE, cloud, and browser environments.
Codex can do the following:
Codex is not just a chatbot that answers questions about code. It can read the codebase directly, execute commands, modify files, connect to external tools, and even delegate cloud tasks when needed.
In other words, think of it as an agent-based development tool that performs development work together with you, not just "a tool that answers questions."
Typical AI chatbots respond based on code or descriptions that users paste in. Codex, on the other hand, operates within an actual development environment.
Codex can directly perform these tasks:
# Read project structure
ls
# Run tests
npm test
# Modify specific files
apply patch
# Review changes
git diffIn other words, Codex goes beyond simply saying "fix it this way." It helps with the entire workflow of actually reading files, modifying them, and verifying the changes.
config.toml is the configuration file that determines how Codex operates.
You can configure the following:
Basic settings for beginners to remember:
model = "gpt-5.5"
sandbox_mode = "workspace-write"
approval_policy = "on-request"Since Codex can execute actual commands and modify files, safety mechanisms are necessary.
Typical sandbox modes:
read-onlyworkspace-writedanger-full-accesssandbox_mode = "workspace-write"
approval_policy = "on-request"This combination is practical for real development work while ensuring risky tasks require user approval.
For example, in workspace-write mode, Codex can modify files within the current project folder but cannot freely modify the entire system.
AGENTS.md is a file where you write the work rules that Codex must follow in your project.
Example:
# AGENTS.md
## Development Rules
- Write TypeScript code to strict mode standards.
- Always run npm test after changes.
- Do not arbitrarily change existing public APIs.
- Minimize style changes.
- Add tests for new features.Simply put, AGENTS.md is a project operations manual you give to Codex.
With a good AGENTS.md, Codex won't repeat the same mistakes.
It also makes it easier for Codex to work according to your team's methods.
MCP stands for Model Context Protocol.
With MCP, Codex can connect to external tools and services:
If basic Codex is "a tool that reads and modifies my code," then Codex with MCP becomes "an agent that connects external services to complete work."
For example, if Sentry MCP is connected, Codex can review error logs and identify bug causes through a complete workflow.
Skills are reusable work knowledge that makes Codex better at specific tasks.
For example, you can create skills like:
Skills help you avoid repeating long prompts every time.
For example, instead of saying this every time:
Review this PR. Separate out security issues, performance issues, missing tests, and API compatibility issues.You can create a PR review skill, and Codex can reuse those guidelines when needed.
Codex is not a single-purpose tool. You can use the same Codex intelligence across multiple interfaces:
For beginners, starting with CLI or IDE Extension is easiest.
Codex's basic workflow is typically as follows:
In the terminal:
cd my-project
codexInside Codex, you can make requests like this:
Explain this project's structure to me.Or:
Add input validation to the login API.After work, review changes with this command:
/diffThis is the most important step in Codex's workflow.
You don't need to memorize all commands at first. These are enough:
codex/plan/diff/status/model/compact/resume/review/permissions/quitThe most important commands for beginners are /plan and /diff.
Bad example:
Refactor this entire project for me.Good example:
/plan I want to refactor the authentication module.
First analyze the current structure and propose risks and a step-by-step plan.For complex tasks, it's safer to use /plan first.
You should always review changes made by Codex:
/diffEspecially review diffs after these operations:
Instead of repeating the same instruction, write it in AGENTS.md.
Example:
- Run npm test after all changes.
- Write migration files when changing DB schema.
- Keep existing API response formats intact.
- Write unit tests for new functions.Different tasks require different speeds and safety levels.
For example, use fast profile for quick questions, careful for security reviews, and ci for CI automation:
codex --profile fast "Explain this function"
codex --profile careful "Review this authentication logic for security"
codex --profile ci "Analyze why the test failed"Codex remembers long conversations, but performance may degrade if the context window fills up.
In such cases, use /compact:
/compactOr specify just the files you need:
@src/auth/login.ts Focus on this file to review input validation logic.codex --sandbox danger-full-accessThis mode gives Codex very broad permissions. Beginners should avoid using it by default.
Recommendation:
codex --sandbox workspace-write --ask-for-approval on-requestCode created by Codex should still be reviewed by humans.
Always follow this order:
Request → Generate Changes → /diff Review → Run Tests → CommitBad example:
Make the code better.Good example:
Read the login flow in src/auth folder,
and propose a refactoring plan to reduce duplicate validation logic.Work rules are important in team projects.
Without AGENTS.md, Codex may not know your team's style, testing approach, and deployment rules.
More MCP servers mean more tool definitions and potentially higher token costs.
It's best to connect only essential MCPs at first.
Codex in one sentence:
Beginners should learn in this order:
Install → Log in → Run CLI → Request project analysis
→ Use /plan → Request code changes → Review with /diff
→ Run tests → Write AGENTS.md → Configure profilesconfig.toml, Sandbox / Approval, AGENTS.md, MCP, and Skillsworkspace-write + on-request combination/plan first, and always review changes with /diffAGENTS.md/compact during long conversations2. Understanding How Codex Works
Codex can be understood in 4 main layers.
Codex
├─ Surface Layer
│ ├─ CLI
│ ├─ Desktop App
│ ├─ IDE Extension
│ ├─ Cloud Tasks
│ └─ Chrome Extension
│
├─ Extension Layer
│ ├─ MCP
│ ├─ Skills
│ ├─ Apps
│ └─ Web Search
│
├─ Security Layer
│ ├─ Sandbox
│ └─ Approval Policy
│
└─ Core Layer
├─ GPT-5.x-Codex Intelligence
├─ Shell Tool
├─ Patch Tool
├─ Read Tool
└─ Web Search ToolCore Layer is the innermost core intelligence of Codex. It's based on the GPT-5.x-Codex model family and understands user requests and plans actual development work.
Suppose a user requests "Add email format validation to the login API."
Codex's Core Layer doesn't just answer. It typically thinks through the following process:
1. Find where the login API is.
2. Read related route, controller, and service files.
3. Check if existing validation methods are used.
4. Create a solution matching the project style.
5. Find test files if necessary.
6. Create a change patch.
7. Show diff for user review.In other words, Core Layer is the center of reasoning, judgment, code understanding, and work planning.
Codex's brain doesn't work alone. It uses several tools to perform necessary tasks.
Because of this structure, Codex acts like an agent that takes action in actual development environments, not just explaining things.
Since Codex can execute actual commands and modify files, safety mechanisms are essential. Security Layer has two components.
Sandbox limits where Codex can technically access.
Typical sandbox modes:
read-onlyworkspace-writedanger-full-accessMost suitable default for beginners:
sandbox_mode = "workspace-write"This mode allows real development work while not giving unlimited system access.
Approval Policy determines when Codex needs user permission before taking actions.
Typical approval policies:
untrustedon-requestneverRecommended combination for beginners:
sandbox_mode = "workspace-write"
approval_policy = "on-request"This combination balances work efficiency and safety well.
Codex's sandbox is not just a promise—it uses OS-level restrictions.
Why this matters: Codex doesn't just promise "we won't do it"—it restricts access permissions at the OS level.
Extension Layer allows Codex to connect to external tools beyond basic functions.
Main components:
With MCP, Codex can connect to external services.
Connectable services:
Example: If Sentry MCP is connected, Codex can review actual error logs, find related code locations, and propose fixes.
MCP extends Codex from a simple code helper to a development agent connected to external work systems.
Skills are reusable work knowledge that makes Codex better at specific tasks.
Examples of skills you can create:
Skills are reusable manuals that teach Codex specific work methods.
Apps connect with ChatGPT connectors and let you reference business context outside the codebase.
Web Search lets Codex reference latest internet information.
Useful tasks:
However, not every task needs web search. Many internal code-only tasks work fine with just file reading and shell execution.
Surface Layer is where users actually interact with Codex. Codex doesn't provide just one interface.
You can use it across multiple surfaces:
CLI is how you use Codex from the terminal.
Basic execution:
codexPass a prompt directly:
codex "Explain this project's structure"CLI is good for:
CLI is the most basic yet powerful usage method.
Desktop App lets you use Codex visually.
Features more convenient than CLI:
Desktop App is good for:
IDE Extension is how to use Codex inside VS Code, Cursor, Windsurf, and similar editors.
IDE Extension is good for:
IDE Extension is the most natural way for beginners since you can invoke Codex from the editor you're already using.
Codex Cloud is running tasks in OpenAI-managed environment rather than locally.
Cloud tasks are good for:
Codex for Chrome is suited for browser-based work. You can use it for admin consoles, internal dashboards, CMS content, and ticket systems.
Skilled Codex users don't stick to one interface. They choose appropriate surfaces for different task types.
Codex is more of an integrated development agent with different surfaces for different situations than a single tool.
Codex's actual workflow usually goes like this:
Suppose a user requests "Add password length validation to the signup API."
Codex typically checks:
After this process, Codex creates a solution.
Codex uses AGENTS.md as important guidelines if it exists.
Example AGENTS.md content:
# AGENTS.md
- Run npm test after all changes.
- Write code to TypeScript strict mode standards.
- Don't break existing API response formats.
- Add tests for new features.Then Codex references these rules when working. You don't need to repeat instructions.
AGENTS.md is the key mechanism that makes Codex act appropriately for your project.
Codex reads configuration from multiple locations. Priority is:
Example:
codex -m gpt-5.4 "Review this code"In this case, gpt-5.4 is used for that session.
Codex uses conversation history, read files, command results, and project guidelines as context.
But context has limits. Long conversations or many files can fill the context window.
Command to use then:
/compact/compact summarizes long conversations to free up context space.
Also, specifying just needed files helps Codex work more efficiently:
@src/auth/login.ts Check login validation logic in this file.You don't need to memorize the entire structure from day one. Understand in this order:
Just these three things are enough at first:
You received a new project you've never seen. You don't know where to start.
cd my-project
codexExplain the overall structure of this project so a beginner can understand.
Summarize main folders, how to run it, how to test, and key entry points./plan Analyze how the login feature works in this project.
Find related files and create a plan that explains the data flow step-by-step.If the login API doesn't have email format validation, add it.
First check the existing validation style and apply it the same way./diffRun related tests and summarize the results.This flow is Codex's most basic usage pattern.
Codex is an integrated development agent made up of 4 layers: Core, Security, Extension, and Surface.
AGENTS.md and config.toml.Section 3. Installing Codex
Check these items before installing Codex.
Codex CLI is a coding agent that runs on your local terminal and can read, modify, and execute commands within your chosen directory.
Beginners should start based on their operating system:
Simple criteria:
macOS / Linux → standalone installer
Windows → PowerShell installer
Already have Node.js → npm
Use Homebrew frequently on macOS → HomebrewOn macOS or Linux, you can use the official installer.
curl -fsSL https://chatgpt.com/codex/install.sh | shThis method installs Codex CLI without needing npm or Homebrew.
After installation, run this command in the terminal:
codexOn first run, you'll see a login prompt.
For environments like CI, remote servers, or automation where interactive input is not possible:
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 shCODEX_NON_INTERACTIVE=1 is an environment variable to reduce interactive prompts during installation.
On Windows, you can install from PowerShell.
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"After installation, run this in PowerShell:
codexWindows has native PowerShell support for Codex, and you can also use WSL2 if a Linux native environment is needed.
If you already have Node.js and npm installed, you can install via npm.
npm install -g @openai/codexAfter installation, run:
codexnpm method is a universal way to install on macOS, Linux, and Windows.
To update, use:
npm install -g @openai/codex@latestOn macOS with Homebrew, you can install with:
brew install --cask codexAfter installation, run:
codexUpdates typically go like this:
brew update
brew upgrade --cask codexOn Windows, you can also install using winget.
winget install OpenAI.CodexHowever, the latest official Codex CLI quickstart explicitly recommends PowerShell installer for Windows. Windows beginners should use this method first:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"If using winget, verify after installation:
codex --versionIf you can't use npm, Homebrew, or installers, download platform-specific binaries directly from GitHub Releases.
codex-aarch64-apple-darwin.tar.gzcodex-x86_64-apple-darwin.tar.gzcodex-x86_64-unknown-linux-musl.tar.gzcodex-aarch64-unknown-linux-musl.tar.gzAfter download, extract, rename the executable to codex, and add it to PATH.
tar -xzf codex-x86_64-unknown-linux-musl.tar.gz
mv codex-x86_64-unknown-linux-musl codex
chmod +x codex
sudo mv codex /usr/local/bin/Verify installation:
codex --versionAfter installation, check that Codex installed correctly:
codex --versionIf successful, you'll see the version number.
codex-cli 0.136.0Then run Codex:
codexOn first run, a login screen appears.
Codex updates frequently. New versions include model support, sandbox improvements, permissions, hooks, plugins, desktop integration, and bug fixes, so upgrade regularly.
curl -fsSL https://chatgpt.com/codex/install.sh | shnpm install -g @openai/codex@latestbrew update
brew upgrade --cask codexcodex --versionShell completions let you autocomplete Codex commands in the terminal.
codex completion bash > /etc/bash_completion.d/codexIf you have permission issues, use sudo:
codex completion bash | sudo tee /etc/bash_completion.d/codexmkdir -p ~/.zsh/completions
codex completion zsh > ~/.zsh/completions/_codexIf your ~/.zshrc doesn't have the completion path, add this:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit
compinitApply:
source ~/.zshrcmkdir -p ~/.config/fish/completions
codex completion fish > ~/.config/fish/completions/codex.fishApply:
source ~/.config/fish/config.fishAfter installation, navigate to your project folder:
cd my-projectRun Codex:
codexOn first run, you'll see a login prompt. For beginners, ChatGPT account login is recommended. API key method is also available, but some features may differ, so ChatGPT login is simplest initially.
If codex command isn't recognized after installation, it's usually a PATH issue.
Error example:
codex: command not foundWindows PowerShell:
codex : The term 'codex' is not recognizedCheck with:
which codexWindows PowerShell:
where.exe codexView current PATH:
echo $PATHWindows PowerShell:
$env:PathSince Codex accesses authentication tokens and project code, installation source is critical. Only use official sources:
Official OpenAI documentation
Official openai/codex GitHub repository
Official npm package @openai/codex
Official installer URLRecently, malicious npm packages targeting Codex developers have been reported stealing auth tokens.
Avoid similarly-named unofficial packages during installation.
Bad examples:
npm install -g codex
npm install -g codex-ui
npm install -g codexui-androidRecommended:
npm install -g @openai/codexAfter installation, verify in this order:
codex --versioncodexRun from project folder:
cd my-project
codexOr run as one-liner:
codex "Explain this project's structure"Symptom:
command not found: codexSolution:
codex --version
which codex
echo $PATHIf using npm, reinstall:
npm install -g @openai/codex@latestSymptom:
EACCES: permission deniedSimplest workaround is using standalone installer:
curl -fsSL https://chatgpt.com/codex/install.sh | shmkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'Add to shell config file:
export PATH="$HOME/.npm-global/bin:$PATH"Apply:
source ~/.zshrcOr:
source ~/.bashrcCheck current policy:
Get-ExecutionPolicyInstall command temporarily uses ByPass:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"Check version first:
codex --versionRun again:
codexIf still problematic, it might be an existing config or auth file issue. See the next section on authentication.
Multiple installations might have old Codex in PATH first.
Check:
which codex
codex --versionWindows:
where.exe codex
codex --versionClean up duplicates, then reinstall or upgrade.
You're done once you've checked all these:
Codex can be used on macOS, Linux, and Windows. Recommended installation method varies by OS.
npm install -g @openai/codex)brew install --cask codexcodex --version, and avoid installing unofficial packages with similar names.Section 4. Authenticating Codex
Here are the main authentication methods available in Codex.
codex logincodex login --device-authcodex login --with-api-keycodex login --with-access-tokenFor beginners, ChatGPT OAuth login is recommended.
This is the most basic authentication method.
Run the following command in the terminal:
codex loginA browser will open—log in with your ChatGPT account. After logging in, return to the terminal and you can use Codex.
Check login status:
codex login statusIf you're properly logged in, your current authentication mode will be displayed.
For first-time users, ChatGPT account login is easier than API Key.
In environments where the browser doesn't open automatically, you can use Device Auth.
For example, it's useful in these situations:
Command:
codex login --device-authRunning this command displays an authentication URL and code in the terminal. You can then open the URL in another device or browser and enter the code to log in.
The Device Auth process works as follows.
codex login --device-auth on a remote serverYou can also authenticate Codex using an API Key. According to the official CLI reference, API Key is passed via stdin.
Example:
printenv OPENAI_API_KEY | codex login --with-api-keyOr you can enter it directly.
codex login --with-api-keyIn this case, the terminal waits for you to input the API Key.
Security note: Avoid putting API Key directly in commands.
Bad example — exposing key in command:
codex login --with-api-key sk-...Recommended method — using environment variables and stdin:
export OPENAI_API_KEY="sk-..."
printenv OPENAI_API_KEY | codex login --with-api-keyThis method is safer because the key doesn't remain in terminal history.
API Key login is appropriate for these situations.
However, beginners risk exposing API Key while managing it directly, so ChatGPT OAuth login is recommended initially.
In advanced environments, you can also pass an access token via stdin.
printenv CODEX_ACCESS_TOKEN | codex login --with-access-tokenThis method is used in automation environments that already securely issue and manage access tokens, rather than for general beginners.
Beginners typically don't need to use this method.
To check if Codex is currently logged in, use the following command:
codex login statusThis command displays your current authentication mode and returns exit code 0 if credentials exist.
Automation script example:
if codex login status >/dev/null 2>&1; then
echo "Codex is logged in"
else
echo "Codex is not logged in"
fiEven beginners should run this command first if problems occur.
To remove saved authentication credentials, use the following command:
codex logoutcodex logout removes saved API keys and ChatGPT authentication information.
Logout is recommended in these situations:
Codex must save authentication information so you don't have to log in again next time. The credential storage method can be set with cli_auth_credentials_store in config.toml.
filekeyringautoFor beginners, auto is recommended. For company equipment where security is critical, consider using keyring.
In organization or team environments, you may want to restrict login methods. This is possible with the forced_login_method setting in config.toml.
Enforce ChatGPT login only:
forced_login_method = "chatgpt"Or you can mandate API Key method only:
forced_login_method = "api"This setting is more important for teams, companies, and enterprise environments than for individual beginners.
Two kinds of authentication can appear in Codex.
To log in to Codex itself:
codex loginTo log in to an MCP server:
codex mcp login <server-name>Beginners should complete Codex login first and cover MCP later in the external service integration section.
If you use both personal and company accounts, authentication conflicts can occur.
Recommended method:
Personal projects → Personal ChatGPT account
Company projects → Company workspace account
Automation / CI → API KeyWhen switching accounts, follow this sequence:
codex logout
codex login
codex login statusWhen you log in with a ChatGPT account, available Codex features may vary depending on your account plan and organization settings.
Factors that affect availability:
Exact limits and available features can vary depending on account status and organization settings, so if there are problems, check your login status first.
API Keys and access tokens should be treated similarly to passwords.
Never do:
- Commit API Key to GitHub
- Paste API Key in README
- Share API Key directly on Slack, Discord, etc.
- Enter key in ways that remain in terminal history
- Log in to suspicious Codex-like packages from unknown sourcesWhen using API Key as an environment variable, add .env to .gitignore so it doesn't get committed to git:
.env
.env.local
*.keyFirst, check the status:
codex login statusIf it says there's no login information, log in again. If it persists, log out and log in again:
codex logout
codex loginIn environments where browser auto-launch doesn't work, use Device Auth:
codex login --device-authOn SSH servers or headless environments, use the following method:
codex login --device-authOr API Key method:
printenv OPENAI_API_KEY | codex login --with-api-keyCheck: Is the environment variable name correct? • Is the actual value not empty? • Are there no spaces before or after the key? • Is the key not revoked or rotated? • Is API usage allowed in your organization?
echo "$OPENAI_API_KEY"Check the current status:
codex login statusRemove existing authentication:
codex logoutLog in again:
codex loginIn CI, usually register the API Key as a secret, then pass it via stdin:
printenv OPENAI_API_KEY | codex login --with-api-keyFor beginners, proceed in this order:
codex --version
codex login
codex login status
codexFor remote servers, use this flow:
codex --version
codex login --device-auth
codex login status
codexFor automation environments, use this flow:
printenv OPENAI_API_KEY | codex login --with-api-key
codex login statusCodex requires authentication after installation. For beginners, codex login with ChatGPT account is the simplest method. In server environments where you can't open a browser, use codex login --device-auth, and in automation environments, pass API Key via stdin.
codex login status, log out with codex logout, and never expose API Keys and access tokens in code repositories or chat.Section 5. Quick Start: Starting Your First Session
In your first session, you only need to learn the following flow.
You don't need to attempt large refactoring or automation from the start. The goal of the first session is to get a feel for how Codex works in your project.
First, you need to have the following items ready.
Verify installation and login:
codex --version
codex login statusIf installation and login are working properly, you can start your first session.
Codex understands your project based on the folder where your terminal is located. First, navigate to your project folder.
cd ~/my-projectFor a Git project, you can verify it like this:
git statusIf it's a normal project, your current branch and change status will be displayed.
On branch main
nothing to commit, working tree cleanFor beginners, it's better to start practice on a test project or personal project, not a critical production project.
Run Codex from your project folder.
codexAn interactive Codex screen will open inside your terminal. This screen is usually called TUI, short for Terminal UI.
Once Codex is running, you can make requests in natural language.
Explain what this project structure is like.For the first request, it's better to have it read and explain the project rather than request code changes.
Enter your first request like this:
Explain this project's structure in a way that beginners can understand.
Organize the main folders, how to run it, testing methods, and core entry points.Codex usually checks the following:
At this stage, focus on understanding the project without modifying files.
Here are examples of good first questions for understanding your project.
Once you understand the project structure, request a small task. For the first time, safe documentation edits or minor code improvements are good choices.
If README doesn't have a local execution method section, add one.Or:
Check how input validation is done in the login API,
and if changes are needed, explain what should be changed first.For beginners, the first task should have a small change scope and low risk.
Requests to avoid from the start:
In the first session, small and clear tasks are best.
If a task is even slightly complex, don't execute it directly—use /plan.
/plan I want to add input validation to the login API.
Find related files, check existing validation methods and test locations,
then propose a step-by-step work plan first./plan makes Codex organize its approach before modifying files.
You can correct direction even while Codex is working.
Not that file—focus on src/auth/login.ts.If you want to change test scope:
Instead of all tests, run only login-related tests first.If you want to reduce scope:
For now, just analyze—don't modify code.Beginners should understand that Codex doesn't always perfectly match your intent on the first try, and you can keep adjusting direction during work.
If Codex modifies files, you must review the changes.
/diff/diff shows changes Codex made in the current session. Items to check:
Especially check /diff after these tasks:
The most important habit for beginners is this:
After reviewing changes, run related tests. You can have Codex find the test command.
Find the command to run related tests in this project.Or request directly:
Run tests related to the part I just modified and summarize the results.Example test commands:
npm test
pytest
pnpm test
cargo test
go test ./...When tests fail, it's better to have Codex analyze the cause first rather than immediately asking to fix it.
When work is done, request a summary from Codex.
Summarize the changes in this session.
Organize changed files, key modifications, tests run, and remaining TODOs.Good summary format:
Changed files:
- src/auth/login.ts
- src/auth/login.test.ts
Key changes:
- Added email format validation
- Return 400 response for invalid email input
- Preserved existing error response format
Tests:
- Ran npm test -- login
- All related tests passedThis summary is also useful when writing commit messages or PR descriptions.
When work is done, exit Codex.
/quitOr:
/exitReturn to the terminal and check Git status.
git status
git diffReview the changes again and commit if needed.
git add .
git commit -m "Add login email validation"Beginners should thoroughly review changes made by Codex before committing.
Here's a complete example of a first session.
cd ~/my-project
codexInside Codex, enter:
Explain this project's structure in a way that beginners can understand.
Organize main folders, how to run it, testing methods, and core entry points.Request a small task:
If README doesn't have a local execution method section, add one.
Write it to match the existing README style.Review changes:
/diffVerify and summarize, then exit:
Codex can start without opening an interactive TUI, directly passing a prompt.
codex "Explain this project's structure"Or:
codex "Analyze why the test failed"This method is useful for quick questions. However, beginners should start with interactive mode.
codexIn interactive mode, it's easier to follow what files Codex reads and what tasks it's trying to accomplish.
You can use these prompts right in your first session:
Explain the entire structure of this project.
Organize main folders and files by their roles.Find and explain step-by-step how to run this project locally.Tell me the testing execution method and main test folders.Trace how the login feature works through which files.Explain the flow from API request to response in this project.Find where the database connection configuration is.If README doesn't have an installation method section, add one.
Keep the existing tone and format./plan I want to add input validation to the signup API.
Find existing validation patterns first and propose a work plan.If there's no unit test for this function, propose a test addition plan first.Run tests related to the part I just modified.If there are test failures, analyze the cause but don't fix immediately—tell me the fix plan.Review if this change risks breaking existing behavior.Avoid requests that are too broad or vague.
Bad examples:
Improve this entire project for me.Make all code quality good.Optimize the architecture yourself.Fix all tests and deploy too.These requests have overly broad change scope and Codex may move in unintended directions.
Good examples:
/plan Analyze the login flow in src/auth and
propose a refactoring plan to reduce duplicate validation logic.
Don't modify code yet.Improve only the local execution method section in README.
Keep the format and don't change code.For the first session, this combination is recommended:
sandbox_mode = "workspace-write"
approval_policy = "on-request"If you want to start more cautiously, you can run in read-only mode:
codex --sandbox read-onlyRead-only mode is suitable for project analysis, structure explanation, and code review. If you want to actually modify files, use workspace-write.
codex --sandbox workspace-write --ask-for-approval on-requestAfter your first session ends, check the following:
git status
git diffCheck:
Revert unnecessary changes:
git checkout -- path/to/fileDelete unnecessary new files:
rm path/to/fileThe goal of the first session is to learn the Codex usage flow. You don't need to know all complex features from the start.
As you repeat this flow, remember these:
/plan/diff after file modificationsSection 6. Codex Core Interfaces
Codex is not a tool used in just one interface. You can use the same Codex agent across CLI, Desktop App, IDE Extension, Cloud, Chrome Extension and other interfaces.
Beginners don't need to use all interfaces from the start. Begin with CLI or IDE Extension, then expand to Desktop App or Cloud as work grows.
For starters, choose based on these criteria:
Want to work quickly from the terminal
→ CLI
Want to see and edit code in the editor
→ IDE Extension
Want to run multiple tasks simultaneously and see diffs visually
→ Desktop App
Want to delegate long-running tasks
→ Codex Cloud / Web
Need to work on logged-in websites or admin pages
→ Chrome ExtensionIn practice, you'll mix these based on the situation.
You might use it like this:
1. Analyze codebase structure with CLI
2. Modify current file with IDE Extension
3. Run large refactoring in parallel with Desktop App
4. Delegate long-term work to Cloud
5. Verify logged-in dashboard with Chrome ExtensionCLI is Codex's most basic usage method. Run the following command from your project folder:
codexOr pass a starting prompt directly:
codex "Explain this project structure"CLI works well in these situations:
codex execBeginners should start with this flow:
cd my-project
codexEnter inside Codex:
Explain this project's structure and how to run it.For complex tasks, plan first:
/plan I want to add input validation to the login API.
Find related files and propose a work plan.Review changes after modification:
/diffWhen you run codex, an interactive screen opens inside the terminal. This is called TUI, or Terminal UI.
In TUI, you can:
@!command format/plan, /diff, /status, etc.Real usage example:
@src/auth/login.ts Explain the login flow in this file.!npm test/statusCommands beginners should learn first:
/plan/diff/status/model/compact/review/permissions/resume/quitJust learning these three initially is enough:
/plan
/diff
/statusThe Desktop App is a visual interface for using Codex. If CLI is terminal-centered, the Desktop App is more like an operations command center for managing multiple Codex tasks.
Key advantages of Desktop App:
Suitable task examples:
Yes, you can.
If you're unfamiliar with terminals, Desktop App might be more convenient. However, considering development automation and CI/CD, learning CLI eventually is good.
Recommended order:
Comfortable with terminal
→ Start with CLI
Prefer editor and GUI
→ Start with IDE Extension or Desktop App
Want to delegate multiple tasks simultaneously
→ Use Desktop App
Want to automate
→ Learn CLI and codex execIDE Extension is the way to use Codex inside editors like VS Code, Cursor, and Windsurf.
Codex IDE Extension has these characteristics:
Example requests:
Make exception handling in this function more robust.
Find duplicate logic in current file and clean it up.
Add tests for this component.@file, search-centeredIDE Extension is good for modifying "the code you're currently viewing", while CLI is good for "analyzing the entire project or automating".
Codex Cloud or Codex Web is the way to delegate tasks to Codex in a cloud environment rather than your local computer.
Codex Cloud characteristics:
Suitable tasks:
Cloud is powerful, but beginners don't need to delegate all tasks to Cloud initially.
Cloud is suitable for tasks meeting these conditions:
Conversely, it's better to do these initially with local CLI or IDE:
Codex Chrome Extension is the interface to use when Codex needs to read or manipulate websites using Chrome.
Codex Chrome Extension characteristics:
Suitable tasks:
Codex has both the Desktop App's in-app browser and Chrome Extension.
Simply put:
Want to view my built web app screen with Codex
→ In-app Browser
Codex needs to work on actually logged-in site
→ Chrome ExtensionComputer Use is a feature for when Codex needs to view and manipulate graphical interfaces.
Computer Use characteristics:
Suitable tasks:
Beginners don't need to use Computer Use initially. First learn CLI, IDE, and Desktop App, then use Computer Use when GUI tasks are absolutely necessary.
/plan or Desktop Appcodex execcodex execBeginners should learn in this order:
/plan and /diff in CLIMost important is creating a workflow that safely completes small tasks from start to finish, not using all interfaces from the start.
Summary:
Fast direct development work
→ CLI
Manage multiple tasks and review visually
→ Desktop AppIn practice, using IDE and CLI together is good.
Example flow:
Real command example:
codex "Find how login feature works through which files"Open related files in IDE:
Strengthen input validation in this function to match existing style.Back to CLI:
npm test
git diffThis way, you divide overall analysis to CLI, fine-grained modifications to IDE, and verification back to CLI.
CLI
Desktop App
IDE Extension
Codex Cloud
Chrome Extension
/diff in CLIBeginners should apply the same principle across all interfaces: "make small requests, check diff, test".
CLI
The foundation. Quickly analyze, modify, and test from terminal.
Desktop App
Manage multiple tasks, worktrees, visual diffs, automation.
IDE Extension
Fast editing centered on current file and selection.
Codex Cloud / Web
Delegate long independent tasks to background.
Chrome Extension
Browser tasks on logged-in sites or internal tools.
Computer Use
Tasks requiring viewing and manipulating GUI apps.Section 7. CLI Basics
The most basic command is:
codexRun it from your project folder.
cd ~/my-project
codexThis opens an interactive Codex conversation screen in your terminal. You can request tasks from Codex in natural language.
Examples:
Explain the structure of this project.
Analyze which files the login feature goes through.
Find the cause of the failing test.You can also open the interactive screen and send your first request at the same time.
codex "Explain this project's structure"Or:
codex "Analyze why the tests are failing"This approach is good for quick questions or one-off tasks.
codex "Read package.json and tell me the run and test commands for this project"However, beginners are recommended to open the interactive screen with just codex and proceed from there. It's easier to follow what Codex is doing in interactive mode.
Codex understands the project based on your current terminal location.
Good example:
cd ~/projects/my-app
codexBad example:
cd ~
codexRunning from outside the project makes it hard for Codex to find relevant files. Always verify your location before running Codex.
pwdCheck if it's a Git project.
git statusIt's good to develop a habit of checking git status before running Codex.
You can specify which model to use when running Codex.
codex -m gpt-5.5Or specify it along with the prompt:
codex -m gpt-5.5 "Analyze the authentication structure of this project"-m is the short form of --model.
codex --model gpt-5.5 "Review this code"Model selection affects task difficulty and cost.
/planBeginners can just use the default model at first.
Codex lets you set how deeply the model should reason.
codex -c model_reasoning_effort="medium"For complex issues, you can increase it:
codex -c model_reasoning_effort="high" "Find the cause of this race condition"For security audits or complex architecture analysis:
codex -c model_reasoning_effort="xhigh" "Review this authentication module for security vulnerabilities"However, higher reasoning effort uses more tokens and costs. A good beginner default is:
model_reasoning_effort = "medium"Sandbox settings are important because Codex can read and modify real files.
codex --sandbox workspace-writeYou can also run in read-only mode:
codex --sandbox read-onlyThere's also full access mode:
codex --sandbox danger-full-accessHowever, beginners should avoid using danger-full-access.
read-onlyworkspace-writedanger-full-accessThe approval policy determines when Codex asks for user approval.
codex --ask-for-approval on-requestWhen used together with sandbox:
codex --sandbox workspace-write --ask-for-approval on-requestuntrustedon-requestneverThe recommended beginner combination lets you work on actual tasks while stopping for confirmation on risky operations.
If you're seeing a project for the first time, starting in read-only mode is a good idea.
codex --sandbox read-onlyIn this mode, you can make requests like:
Explain this project's structure.
Analyze which files the login feature uses.
Find how to run tests.
Review potential security issues without modifying code.Read-only mode is safe for beginners since Codex can't modify files.
In the TUI, use @ to find and attach files to the Codex conversation.
@src/auth/login.ts Explain the login flow in this file.Or:
@package.json Explain the scripts in this project.Specifying files clearly helps Codex answer more accurately.
Good example:
@src/api/users.ts Find areas in this file where input validation is insufficient.Bad example:
Find problems in the entire project.The narrower the scope, the better Codex's results.
In the TUI, add ! to execute shell commands directly.
!npm test
!git status
!pnpm lint
!pytestThis feature is useful for running commands directly during a Codex conversation and checking results.
!git diff
!npm run test:unitNote that command execution is subject to sandbox and approval settings. Risky commands may trigger approval requests.
When you need to write a long prompt in the TUI, you can open an external editor. Ctrl+G is the shortcut to open the editor set in \$VISUAL or \$EDITOR.
Usage flow:
Useful for writing lengthy task instructions.
In Codex TUI, you can recall previously entered prompts. Usually arrow keys browse draft history.
↑ Previous input
↓ Next inputCtrl+R is used to search previous prompts and slash command history.
Ctrl+RYou can then find and reuse previous /plan, /diff, task requests, etc.
You can adjust direction while Codex is working. For example, if Codex is looking at the wrong file:
Focus on src/auth/login.ts instead, not that file.If you want to narrow the scope:
This time, just analyze without modifying code.If you want to change the test scope:
Run only login-related tests first instead of all tests.The key point is that you don't have to hand off the work and abandon it—you can keep adjusting direction in the middle.
Press Escape twice to edit the previous message.
Use cases:
Example:
Original input: Fix the login feature.
After edit: /plan Analyze the login feature's input validation flow, propose what needs fixing and a test plan first. Don't modify code yet.
Beginners should correct vague requests right away.
To start a new conversation within the same Codex session, use /new.
/newUse cases:
Then your new request: Explain the deployment structure of this project.
If you want to reopen a saved conversation, use /resume.
/resumeOr you can use resume options when running CLI.
Useful situations:
However, when continuing an old session, code state may have changed, so verify first.
Check the current git state and what files changed since the last session.If you want to continue the current conversation in a different direction, use /fork.
/forkExample use case:
Keep the current refactoring direction A and also compare with a more conservative direction B
Fork copies existing conversation context and continues in a new thread. Beginners don't need to use it often at first, but it's useful for comparing alternatives.
You can change models in the middle of a session too.
/modelUse cases:
You can also specify the model when running CLI.
codex -m gpt-5.5During a session, use /model.
When conversation gets long, context can fill up. Use /compact in this case.
/compact/compact summarizes long conversation content to free up context space.
Use cases:
Beginners can use /compact in the middle of long work and then request: "Based on the summary of work so far, proceed with just the next step."
If Codex modified files, you must check with /diff.
/diffThings to check:
Beginner principle: If Codex modified something, always check /diff.
If you want to review the current working tree, use /review.
/reviewUse cases:
More specific example:
/review Focus on security issues, missing tests, and API compatibility in these changes.To check the current session state, use /status.
/statusWhat you can check varies by version and environment, but generally includes:
It's good to develop a habit of checking /status first when problems arise.
To check or adjust Codex permissions, use /permissions.
/permissionsUse cases:
Beginners should check current state first before raising permissions arbitrarily. If asked for risky permissions, verify the reason before deciding to grant them.
To check external tools connected to Codex, use:
/mcp
/apps/mcp is used to check configured MCP tools. /apps is used to explore ChatGPT connectors.
Beginners don't need to know about MCP or Apps at first. Learn them later when you need to connect external tools.
To check available skills or invoke them, use /skills.
/skillsSkills are useful for standardizing repetitive tasks. For example:
A good flow is to request directly via prompt at first, and manage as skills when patterns repeat.
To check or manage installed plugins, use /plugins.
/pluginsPlugins are a system for extending Codex functionality. Beginners should first learn the basics, then use only plugins needed for the team or project.
In the TUI, you can either run shell commands directly or request Codex to execute them.
Direct execution:
!npm testRequest from Codex:
Find and run the relevant tests, then summarize the results.!npm testBeginners find it easier to have Codex find commands at first.
Codex reads config.toml settings, but you can override values via CLI options.
For example, even if config has a default model:
model = "gpt-5.5"Specifying a different model at runtime makes the CLI option take priority for that execution.
codex -m gpt-5.4 "Review this code"Inline config override is also possible.
codex -c model_reasoning_effort="high" "Analyze this bug"Nested settings can also be specified.
codex -c 'sandbox_workspace_write.network_access=true' "Install dependencies"Remember for beginners: Options you give directly at runtime take priority over config.
You can use profiles, which are bundles of settings for different task types.
codex --profile fast "Explain this function"
codex --profile careful "Security review of this auth logic"
codex --profile ci "Analyze why this test failed"Profiles will be covered in detail in the configuration section later, but the basic concept is:
fastcarefulcipairIf you want to analyze a new project safely without modifications:
codex --sandbox read-onlyInside Codex:
Analyze the authentication flow in this project.
Don't modify code, just identify security risks.Or in one command:
codex --sandbox read-only "Analyze the authentication flow and list security risks without modifying code."For everyday development, this combination works well:
codex --sandbox workspace-write --ask-for-approval on-requestInside Codex:
/plan I want to add password length validation to the signup API.
Check existing validation patterns and test locations, then propose a plan first.After confirming plan: Proceed with the plan.
After changes: /diff
Testing: Run relevant tests and summarize results.
Simple questions can be handled in one command:
codex "Explain the scripts in package.json"
codex "Find the command to run the dev server in this project"
codex "Summarize the role of the src/auth folder"This approach is fast, but interactive TUI is better for long tasks.
Beginners should repeat this routine:
Actual command flow:
git status
codexInside Codex: /plan I want to add email validation to the login API. Check existing code style and test locations first.
After changes: /diff
After exiting: git status, git diff
Explain this project's structure so beginners can understand.
Organize the main folders, how to run it, how to test it, and key entry points.Trace which files a login request goes through until the response comes out.
Explain without modifying code./plan I want to reduce duplicate validation logic in the src/auth folder.
Organize existing structure, impact scope, and test plan first.
Don't modify files yet.If README doesn't have a local run section, add one.
Keep existing style and format.Find and run test commands related to the changes I just made,
and analyze failures if there are any.Avoid requests with broad and vague scope like these:
Fix all the code.
Make this project better.
Refactor everything.
Optimize it however you want.Better approach:
/plan Propose a way to reduce duplicate error handling logic in the src/api folder.
Explain impact and test plan first, don't modify code yet.codexcodex "prompt"codex -m model-namecodex --sandbox read-onlycodex --sandbox workspace-writecodex --ask-for-approval on-requestcodex --profile fastcodex -c key=value@!commandCtrl+GCtrl+REsc twice/plan/diff/status/quitCLI is Codex's most basic and powerful usage method. Run codex from your project folder to open an interactive TUI where you can work with terminal and project files together.
3 key things beginners must remember:
All advanced features (profile, MCP, plugin) can be learned later. Getting comfortable with the basic flow is most important.
Section 8. Complete Slash Commands Guide
Slash Commands are commands in Codex interactive CLI starting with /.
/plan
/diff
/statusIf regular prompts are "requesting Codex in natural language", Slash Commands are commands for quickly executing session control, model changes, permission checks, diff review, work planning, review, and configuration checking.
Slash Commands are typically used for:
Beginners only need to learn these 5: /plan, /diff, /status, /permissions, /quit.
Typing / in Codex TUI shows the available commands list.
/diff/plan I want to improve the error handling structure of the payment module.
Propose impact scope and step-by-step plan first.Some commands run standalone, others accept descriptions after them.
Exits the Codex CLI.
/quit
or
/exitBoth end the session.
After exiting, it's good to verify changes again in terminal:
git status
git diffStarts a new conversation within the current Codex session.
/newNote: /new doesn't undo Git changes. File modifications persist, so verify with /diff or git diff if needed.
Reopens a previously saved conversation.
/resumeAfter resuming, verify code state hasn't changed:
Check the current git state and what files changed since the last session.Branches current conversation to a new thread.
/fork/fork is used when you want to experiment in a different direction while maintaining current conversation context.
Beginners don't need to use it often at first, but it's useful for comparing alternatives.
Changes the model for the current session.
/modelBeginners can just use the default model at first.
Summarizes long conversation content to free up context space.
/compactCodex uses conversation content, read files, command output, and work plans as context. When conversation gets long, context fills up and Codex may miss previous content.
Reviews changes made in the current session.
/diffOne of the most critical commands for beginners. If Codex modifies files, you must run /diff.
After reviewing changes, you can request more from Codex:
Review if there are unnecessary changes in this diff.
Keep only the README edits from these changes and revert the code changes.Reviews the current working tree or changes.
/reviewYou can make more specific requests too:
/review Focus on security issues, missing tests, and existing API compatibility in these changes.Plans work before modifying files directly.
/plan I want to add input validation to the login API.
Find related files, check existing validation patterns and test locations,
then propose a step-by-step plan first./plan is the most critical command for beginners. For complex work, verify the plan before executing.
Use /plan first if 3+ files will likely change.
Creates or manages ongoing work goals.
/goal/goal is used to create, pause, resume, or delete maintained work goals.
Beginners should learn /plan first and use /goal when long-term work is needed.
Switches Vim edit mode in TUI composer.
/vimFor users familiar with Vim key bindings.
Explores or switches Codex lifecycle hooks. Manages automatic actions that run before or after specific events.
Attaches files to conversation.
@src/auth/login.ts Explain the login flow in this file.Creates AGENTS.md scaffold for the project.
/initAGENTS.md is a file where you write rules Codex should follow in the project.
# AGENTS.md
## Development Rules
- Run tests after code changes.
- Keep existing public API behavior.
- Follow the existing code style.
- Add tests for new behavior./init is very useful when first using Codex in a project.
Checks current session status.
/statusOne of the first things to check when problems arise.
Checks or adjusts current permissions and approval settings.
/permissionsBeginners should check status first with /permissions before raising permissions arbitrarily. Verify reason if asked for risky permissions.
Adjusts Codex communication style. Options include friendly, pragmatic, none and similar styles.
Checks configured MCP tools. Manages connections with external tools like GitHub, Figma, Sentry, databases etc.
Explores ChatGPT connectors or connectable apps. Check status of connected external business tools.
Shows background terminals. Use when Codex is running background terminal tasks.
Checks available skills or invokes them. Skills are reusable work knowledge that help Codex perform specific tasks better.
Explores and manages installed plugins. Check installed plugins, enable/disable, explore marketplace plugins.
Sets terminal window title.
/title auth-refactorUseful when multiple Codex sessions are open to distinguish windows.
Prints current applied config values and sources. Check what config is active and detect user/project config conflicts.
Sets TUI footer. Organize information like model, context, git branch nicely.
Sends logs and feedback to Codex maintainers.
/feedbackUse to report Codex bugs or unusual behavior. Verify no sensitive info is included before sending.
Logs out from Codex.
/logout
or from terminal:
codex logoutYou don't need to learn all commands from the start. Start with these 7:
Most work is safe if you follow this routine:
/plan I want to refactor the login flow in the src/auth folder.
Analyze current structure, duplicate logic, risks, and test plan first.
Don't modify code yet./plan I want to add tests for the signup API.
Check existing test structure first,
then propose what cases should be added./review/review Focus on auth bypass, missing permission checks,
and sensitive data exposure risks./review Focus on insufficient testing
and missing edge cases.After viewing /diff, you can request more:
Find unnecessary changes in this diff.
Summarize these changes as a commit message.
Write a PR description based on this diff.
Tell me which parts of this change need testing.
Review if these changes could break existing behavior./plan
/review/plan I want to organize the error handling in the payment module.
Analyze current structure, propose change scope and test plan first./review Focus on security issues, performance degradation,
and missing tests in these changes.Commands work alone, but results improve when you add criteria.
/new only starts a new conversation. File changes persist, verify with /diff or git diff.
/compact summarizes long conversation but some details may compress. Keep important requirements in AGENTS.md or separate docs.
When Codex requests more permissions, verify the reason and check if narrower permissions solve it.
/review is powerful but final review should be human. Especially for auth, payment, security, database changes.
Simple work needs only /plan. Use /goal when multi-stage long-term goals exist.
/plan Create work plan
→ Verify plan
→ Proceed with edits
→ /diff
→ /review
→ Run tests
→ Summarize
→ /quit/plan I want to add email format validation to the login API.
Check existing validation patterns and test structure first./status
→ /plan
→ Analyze possible causes
→ Run tests
→ /compact
→ Make fixes
→ /diff
→ /review/init
→ Edit AGENTS.md
→ /config
→ /permissions
→ /statusThe most critical for beginners is the /plan → /diff → /review routine. These three alone enable safe and efficient work.
Section 10. Model Selection Guide
Codex interprets settings in this order. Higher positions have higher priority.
--config — Temporary settings applied only for this run.codex/config.toml — Settings for current project or subdirectory only--profile profile file — Settings for specific work modeFor example, even if you set a default model in ~/.codex/config.toml, running with CLI options wins for that execution:
codex --model gpt-5.5Or override any key directly:
codex --config model='"gpt-5.5"'
codex --config sandbox_workspace_write.network_access=true--config values parse as TOML, not JSON. Be careful with string quoting.
User config is personal default settings.
Default location:
~/.codex/config.tomlCodex CLI and IDE extensions share the same config layer. So default model, approval policy, sandbox settings, and MCP server settings configured in CLI can apply the same way in IDE extensions.
User config typically contains:
model = "gpt-5.5"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
web_search = "cached"modelapproval_policysandbox_modeweb_search[mcp_servers.*][features]approval_policy can use untrusted, on-request, never, and sandbox_mode can use read-only, workspace-write, danger-full-access.
Project config applies only to specific repos or subdirectories.
Location:
<repo>/.codex/config.tomlCodex traverses from project root to current directory looking for .codex/config.toml. When same key appears multiple times, the config closest to current directory wins. However, project config only loads when project is trusted. In untrusted projects, project .codex/ layer, project hooks, and rules are ignored.
Example:
my-app/
.codex/config.toml
frontend/
.codex/config.tomlIf current location is my-app/frontend, frontend/.codex/config.toml is closer so applies first for same keys.
Project config should contain only project work methods:
model_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = falseSettings bound to machine or personal accounts like provider, auth, telemetry, notification may be ignored in project config.
System config applies system-wide defaults. Unix location:
/etc/codex/config.tomlPriority is lower than User config. When system admin sets defaults, users can override same keys in ~/.codex/config.toml and User config wins.
System config is "common defaults" rather than "forced policy".
Example:
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = falseFor values organizations must block, use requirements.toml instead of System config.
requirements.toml is not a regular config file but admin-enforced constraints. Even if users specify different values in config.toml, profiles, or CLI options, when conflicting with requirements, Codex restores compatible values and notifies user.
Can restrict values like:
allowed_approval_policies = ["untrusted", "on-request"]
allowed_sandbox_modes = ["read-only", "workspace-write"]
allowed_web_search_modes = ["disabled", "cached"]Example above blocks:
approval_policy = "never"
sandbox_mode = "danger-full-access"
web_search = "live"Requirements layer priority:
requirements_toml_base64requirements.tomlImportant: requirements.toml sets "allowed range" rather than "configured values".
CODEX_HOME is Codex's local state root directory. Default:
~/.codexUsually contains:
~/.codex/
config.toml
auth.json
history.jsonl
log/
sessions/
skills/You can set CODEX_HOME via environment variable, but the target directory must pre-exist.
mkdir -p ~/.codex-work
CODEX_HOME=~/.codex-work codexThen Codex uses instead of default ~/.codex/config.toml:
~/.codex-work/config.tomlUseful in practice for separating accounts, organizations, and test environments.
In TOML, writing root keys first then tables is more readable. Basic structure:
# 1. Root settings
model = "gpt-5.5"
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
web_search = "cached"
# 2. Sandbox detail settings
[sandbox_workspace_write]
network_access = false
writable_roots = []
# 3. Environment variable pass policy
[shell_environment_policy]
inherit = "core"
include_only = ["PATH", "HOME", "USER", "SHELL"]
# 4. Feature flags
[features]
hooks = true
undo = true
# 5. MCP server config example
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = trueCommon values:
approval_policy"on-request" — Ask user when neededsandbox_mode"workspace-write" — Allow writes in workspaceweb_search"cached" — Cache-based web searchmodel_reasoning_effort"medium" or "high" — Reasoning strengthsandbox_workspace_write.network_accessfalse — Block network in sandboxStart without opening too much:
model = "gpt-5.5"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
web_search = "cached"
[sandbox_workspace_write]
network_access = falseIntent is simple:
on-requestworkspace-writenetwork_access = falseweb_search = "cached"Beginners should avoid danger-full-access and approval_policy = "never" combo.
Professionals want both productivity and safety:
model = "gpt-5.5"
model_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
web_search = "cached"
hide_agent_reasoning = true
[sandbox_workspace_write]
network_access = false
writable_roots = []
[shell_environment_policy]
inherit = "core"
include_only = [
"PATH", "HOME", "USER", "SHELL",
"LANG", "LC_ALL", "TERM"
]
[features]
hooks = true
undo = true
shell_snapshot = true
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = true
startup_timeout_sec = 10
tool_timeout_sec = 60Professional guidelines:
workspace-writeon-request.codex/config.tomlWhen settings don't apply as expected, check in this order:
CLI options and --config have highest priority.
codex --model gpt-5.5
codex --config sandbox_mode='"read-only"'Test without options:
codexNearby .codex/config.toml takes priority over user config.
pwd
find .. -path "*/.codex/config.toml" -printIf project is untrusted, project config may be ignored. Check trusted status too.
--profile is usedUsing profile overlays this file on top of user config:
~/.codex/<profile-name>.config.tomlExample:
codex --profile deep-reviewAfter Codex 0.134.0, uses separate profile-name.config.toml files instead of [profiles.name] in config.toml.
CODEX_HOMEChanging CODEX_HOME changes which config file is read:
echo $CODEX_HOMEIf empty, default is:
~/.codex/config.tomlIf set, check:
$CODEX_HOME/config.tomlEven after all config changes, management policy might be blocking:
Check file:
/etc/codex/requirements.tomlOn Windows:
%ProgramData%OpenAICodex
equirements.tomlCheck especially:
allowed_approval_policies = ["on-request"]
allowed_sandbox_modes = ["workspace-write"]
allowed_web_search_modes = ["disabled", "cached"]Requirements is unyielding by users. On conflict, Codex restores compatible values.
Some keys in project .codex/config.toml are always ignored:
Keys to avoid in project:
openai_base_url = "..."
model_provider = "..."
notify = [...]
profile = "..."
[model_providers.foo]
[otel]Put these in user config:
~/.codex/config.tomlCommon mistakes:
# Wrong: string quotes missing
model = gpt-5.5
# Correct
model = "gpt-5.5"# Wrong: mixing root keys under table confuses
[sandbox_workspace_write]
network_access = false
model = "gpt-5.5"For readability, write root keys first then [table].
config.toml sets Codex default behavior. Most basic location is ~/.codex/config.toml, and per-project differences go in <repo>/.codex/config.toml.
Priority flows top to bottom and is strong. CLI options are strongest, project config beats user config. Organization security policy is managed via requirements.toml, and these values can't be bypassed by normal config.
Section 10. Model Selection Guide
In Codex, these two settings are different.
model = "gpt-5.5"
model_reasoning_effort = "xhigh"model specifies which AI model to use. model_reasoning_effort specifies how deeply that model should think.
So, "using Codex 5.5 xhigh" precisely means:
The models covered as core in the current Codex guide are:
gpt-5.5 is the primary model you should choose first in Codex. It's the latest frontier model suitable for complex coding, computer use, knowledge work, and research workflows.
Recommended situations:
Recommended setting:
model = "gpt-5.5"
model_reasoning_effort = "medium"On difficult tasks you can raise to xhigh, but it's better to use xhigh only for work where mistakes are costly, like large refactoring, long-term planning, complex debugging, and security reviews.
gpt-5.4 is a cost and performance balance model one step below gpt-5.5. As a professional workhorse frontier model, it combines stronger reasoning, tool use, and agentic workflow capability with the coding ability of gpt-5.3-codex.
Recommended situations:
Configuration example:
model = "gpt-5.4"
model_reasoning_effort = "medium"gpt-5.4-mini is suitable for lightweight and fast work. It's a fast and efficient mini model fit for responsive coding tasks and subagents, providing higher usage limits in routine local messages.
Recommended situations:
Configuration example:
model = "gpt-5.4-mini"
model_reasoning_effort = "low"Beginners can remember: "simple work with mini, complex work with 5.5".
gpt-5.3-codex is, as its name suggests, a Codex-specialized model. It's the industry-leading coding model for complex software engineering, and its coding ability is reflected in gpt-5.4. Cloud tasks and code reviews run on gpt-5.3-codex.
Recommended situations:
Configuration example:
model = "gpt-5.3-codex"
model_reasoning_effort = "high"gpt-5.3-codex-spark is not so much a "highest quality model" but a special model for fast coding iteration. It's a text-only research preview model optimized for near-instant, real-time coding iteration and is provided to ChatGPT Pro users.
Recommended situations:
Execution example:
codex -m gpt-5.3-codex-sparkSpark is a research preview, guided for Pro users only, and is a model chosen for fast iteration inside Codex rather than a generally used model in APIs.
gpt-5.2 is currently classified as an alternative model in Codex model documentation. It's a previous generation general-purpose model that can be used as an alternative choice for difficult debugging or agentic tasks requiring deep contemplation.
But there's no need to make it a central model for beginner guides.
Also, names like gpt-5.1-codex-mini shouldn't be included in the current table of contents. In the full API model list, GPT-5.1 Codex mini is marked as deprecated.
Summary:
Using gpt-5.5 and xhigh together is a very powerful combination in practice.
model = "gpt-5.5"
model_reasoning_effort = "xhigh"This combination is good for:
Conversely, xhigh may be overkill for these tasks:
Beginners should avoid changing models too much from the start. One combination is enough:
model = "gpt-5.5"
model_reasoning_effort = "medium"This combination offers the best balance of quality, speed, and cost.
If you want to be safer:
model = "gpt-5.5"
model_reasoning_effort = "high"For truly critical work:
model = "gpt-5.5"
model_reasoning_effort = "xhigh"Beginner recommendation rule is simple.
Professionals should split profiles by task type.
model = "gpt-5.5"
model_reasoning_effort = "medium"model = "gpt-5.5"
model_reasoning_effort = "xhigh"model = "gpt-5.4-mini"
model_reasoning_effort = "low"model = "gpt-5.3-codex"
model_reasoning_effort = "high"model = "gpt-5.4"
model_reasoning_effort = "medium"Set the default model in ~/.codex/config.toml.
# ~/.codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"If you want to use it strongly like your style:
# ~/.codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"However, handling all work with xhigh can increase response time and usage consumption. xhigh is described as for the most difficult asynchronous agentic tasks or evals testing model intelligence limits.
Example professional profile:
# ~/.codex/deep.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"Execution:
codex --profile deepIn the CLI, use -m or --model to start a new session with a specific model.
codex -m gpt-5.5
codex -m gpt-5.4
codex -m gpt-5.4-mini
codex -m gpt-5.3-codexIn the CLI you can use -m or --model flag, and during an active CLI session you can switch models with the /model command. In IDE extensions, use the model selector below the input box.
In an active session:
/modelOverride just once:
codex --model gpt-5.5To override reasoning effort one-time too:
codex -m gpt-5.5 -c model_reasoning_effort='"xhigh"'Model selection can be judged in this order:
If critical, use gpt-5.5.
model = "gpt-5.5"
model_reasoning_effort = "high"More critical:
model = "gpt-5.5"
model_reasoning_effort = "xhigh"If repetitive and simple, use gpt-5.4-mini.
model = "gpt-5.4-mini"
model_reasoning_effort = "low"For code review and cloud tasks, gpt-5.3-codex is important.
If you're a Pro user and need near-instant coding iteration, consider gpt-5.3-codex-spark. Spark is not Fast mode but a separate model, provided as a research preview.
Fast mode is not a separate model but a speed setting that runs supported models faster. Fast mode currently supports gpt-5.5 and gpt-5.4 and consumes more credits.
In the CLI:
/fast on
/fast off
/fast statusYou can also set it as a default in config.
service_tier = "fast"
[features]
fast_mode = trueSection 11. Reasoning Effort
Reasoning effort is a setting that determines how deeply the model should think before generating an answer.
If choosing a model in Codex is deciding "who will work," reasoning effort is deciding "how carefully they will work."
For example:
model = "gpt-5.5"
model_reasoning_effort = "xhigh"This means "use the gpt-5.5 model at the highest reasoning intensity."
Reasoning models use internal reasoning tokens to decompose problems, review multiple approaches, and plan tool use before writing the final answer. This is especially suitable for complex problem-solving, coding, scientific reasoning, and multi-step agentic workflows.
The important point is that these reasoning tokens are not shown directly to users. However, according to API documentation, reasoning tokens consume context window space and are charged as output tokens.
So, raising reasoning effort usually creates these changes:
The default reasoning intensity in Codex is set in config.toml.
model_reasoning_effort = "medium"According to Codex configuration reference, model_reasoning_effort supports these values. However, xhigh support varies by model.
minimal
low
medium
high
xhighmodel = "gpt-5.5"
model_reasoning_effort = "medium"model = "gpt-5.5"
model_reasoning_effort = "xhigh"minimal is the lowest reasoning effort in Codex config.
Recommended situations:
model = "gpt-5.4-mini"
model_reasoning_effort = "minimal"However, if code changes connect to actual file edits, it's safer to use at least low.
low is suitable for fast work, but causes a bit more thinking than minimal.
Recommended situations:
In practice, low is good for "light but annoying if wrong." The gpt-5.4-mini + low combination is especially good for fast iteration or subagent work.
medium is the most reasonable default for most users.
The GPT-5.5 documentation states that the default reasoning effort is medium, and it's the balance point between quality, reliability, latency, and cost.
Recommended situations:
model = "gpt-5.5"
model_reasoning_effort = "medium"high is a setting that makes the model solve complex problems more carefully.
Recommended situations:
model = "gpt-5.5"
model_reasoning_effort = "high"xhigh is the strongest reasoning intensity.
The GPT-5.5 documentation says to use high or xhigh when quality improvement justifies added latency and cost. In particular, xhigh is suitable for the most difficult asynchronous agentic tasks or evals testing model intelligence limits.
Recommended situations:
However, xhigh is not always the right answer. The GPT-5.5 documentation explains that higher reasoning effort is not always better, and over-exploration or quality degradation can occur if the criterion is weak or tool access is open.
In the API documentation, GPT-5.5 reasoning effort values are none, low, medium, high, xhigh.
But in Codex config.toml's model_reasoning_effort values are:
minimal
low
medium
high
xhighSo in Codex config files, use minimal.
As a Codex user, remember to use minimal as the baseline in config.toml.
Plan Mode often needs deeper reasoning than general answers. So Codex has a separate Plan Mode override: plan_mode_reasoning_effort.
model = "gpt-5.5"
model_reasoning_effort = "medium"
# Think deeper in /plan mode
plan_mode_reasoning_effort = "high"This setting is quite useful in practice. Work fast on general tasks, deliberate on planning.
Recommended combinations:
lowmediummediumhighhighxhighxhighxhighmodel_reasoning_summary is different from model_reasoning_effort.
According to Codex configuration reference, model_reasoning_summary values are:
auto
concise
detailed
nonemodel = "gpt-5.5"
model_reasoning_effort = "high"
model_reasoning_summary = "concise"Beginners usually prefer the default auto or concise concise. Showing reasoning summary in detail does not make the model think deeper. The setting that makes it think deeper is model_reasoning_effort.
model_verbosity is also different from model_reasoning_effort.
For example, this setting means "think deeply but answer briefly."
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
model_verbosity = "low"Conversely, this setting means "think moderately and explain in detail."
model = "gpt-5.5"
model_reasoning_effort = "medium"
model_verbosity = "high"Practical combinations:
Raising reasoning effort may increase internal reasoning tokens. According to API documentation, reasoning tokens are not visible to users but consume context window and are charged as output tokens.
So this formula applies:
Higher reasoning effort
= Deeper review possible
= Longer wait time possible
= Higher token usage possibleHowever, GPT-5.5 has improved to produce stronger results with fewer reasoning tokens at the same reasoning effort compared to previous models.
Practical guide:
Recommended reasoning effort varies by task type.
Beginner basic settings:
model = "gpt-5.5"
model_reasoning_effort = "medium"
model_reasoning_summary = "auto"
model_verbosity = "medium"Recommended professional profile setup:
Beginners need to remember only one standard.
Reasoning effort is a setting that determines "thinking depth" of the model. In Codex, the basic key is model_reasoning_effort, and available values are minimal, low, medium, high, xhigh.
Beginner recommendation:
model = "gpt-5.5"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "high"The one principle to remember: if the task is simple, set it low; if complex and high cost of failure, set it high.
Section 12. Understanding Codex Costs
Codex costs work as follows: Consume included usage from your ChatGPT plan first, then when you exceed the limit, additional costs are charged via credits or API token billing. Codex is included in Free, Go, Plus, Pro, Business, Edu, and Enterprise plans, but usage limits and additional billing methods vary by plan.
ChatGPT login usage = plan included usage + credits if needed
API Key usage = OpenAI API token billing
Business/Enterprise = seat + workspace credits + admin spend controlCodex is included in both Free and Go. Free is for exploring quick coding tasks, and Go is for lightweight coding tasks.
The important limitation is that Free and Go users cannot purchase additional Codex credits when limits are exceeded; instead, they're encouraged to upgrade to Plus. Free and Go users receive an upgrade prompt rather than a credit purchase option.
Plus costs about 30,000 KRW/month and includes Codex web, CLI, IDE extension, iOS, cloud-based integrations, automatic code review, Slack integration, GPT-5.5, GPT-5.4, GPT-5.3-Codex, and GPT-5.4-mini.
Plus users first consume included usage, and when limits are reached, can purchase credits to continue. Credits can be managed in Codex Settings > Usage > Credits or the Usage Dashboard.
Pro splits into two tiers.
Pro at about 150,000 KRW provides 5x higher usage than Plus, and Pro at about 300,000 KRW provides 20x higher usage than Plus. The existing about 300,000 KRW Pro is maintained, and about 150,000 KRW Pro is a lower-priced Pro option.
Pro offers all Plus Codex features plus access to GPT-5.3-Codex-Spark research preview. Spark is described as a fast day-to-day coding model for Pro users.
Business has a two-seat structure.
Standard ChatGPT seat pricing is typically about 37,500 KRW/user/month, or about 30,000 KRW/user/month with annual billing. Codex seat is Codex only with usage-based billing and no fixed monthly cost; workspace credits are needed.
Business is pay-as-you-go, allowing standard or usage-based Codex seats to be assigned, and usage can be expanded with workspace credits.
Enterprise and Edu are contract-based. With flexible pricing, there's no fixed rate limit and usage expands based on credits. However, Enterprise/Edu without flexible pricing typically have per-seat usage limits similar to Plus for most features.
When using flexible pricing in Business, Edu, or Enterprise, you can purchase additional workspace credits to continue using Codex.
When using Codex with an API Key, ChatGPT plan included usage does not apply; instead, OpenAI Platform API pricing is applied. With an API Key, you can use Codex in CLI, SDK, and IDE extension, but cloud-based features like GitHub code review and Slack are not available. Billing is based on token usage and API pricing.
API key authentication supports local Codex workflows but limits or disables features that depend on ChatGPT workspace or cloud services. Usage is billed at standard API rates on your OpenAI Platform account.
Starting April 2, 2026, Codex pricing changed from average per-message billing to token-based credit pricing aligned with API token usage. This change applies to Plus, Pro, Business, and new Enterprise, and from April 23, 2026, also applies to existing Enterprise, Edu, Health, Gov, and ChatGPT for Teachers.
Billing calculation has three units:
The official rate card shows credits per 1M input tokens, 1M cached input tokens, 1M output tokens per model. Actual credit usage varies by each task's input/cached input/output token ratio.
Calculation:
Total credits
= input_tokens / 1,000,000 × input_rate
+ cached_input_tokens / 1,000,000 × cached_input_rate
+ output_tokens / 1,000,000 × output_rateOne GPT-5.5 Codex task typically consumes about 5-45 credits, but actual usage varies by task size and token mix.
The official table's unit is 5-hour rolling window. Local messages and cloud tasks share the same 5-hour window, and additional weekly limits may apply.
Plus:
Plus limits vary within the range by model, task size, local/cloud execution, and context size.
Pro 5x (5x Plus):
Pro 20x (20x Plus):
Business: Shows the same range as Plus. However, Business can combine standard ChatGPT seats, Codex seats, workspace credits, and spend controls, so actual cost management differs from individual Plus.
Fast mode is not a separate model but a speed setting that runs supported models faster. Speed increases about 1.5x, while GPT-5.5 consumes 2.5x credits compared to Standard, and GPT-5.4 consumes 2x credits. With API key usage, Fast mode credits don't apply; standard API pricing applies instead.
GPT-5.3-Codex-Spark is a research preview model for Pro users. Spark is a text-only research preview model optimized for near-instant, real-time coding iteration.
Currently, Spark's credit rate is not final and is marked as research preview. Spark is Pro-user-exclusive research preview and is not available in the API at launch. Usage limits may adjust based on demand.
Image generation: Codex image generation is included in the same general usage limit as other Codex usage. Image generation can consume included limits 3-5x faster than similar non-image turns, and after limits are exceeded, it's deducted from credits. Image generation is not available on the Free plan.
Cost differences by task: Even the same "1 message" doesn't cost the same. Small scripts or routine functions may consume only part of the allowance, but large codebase, long-running tasks, or extended sessions maintaining lots of context consume much more per message.
Codex costs aren't determined only by directly typed sentences. In reality, these items can be included in input or output tokens:
Ways to save usage limits: reduce AGENTS.md size, limit MCP server count, remove unnecessary context, switch to smaller models.
Check current limits in the Codex usage dashboard. During a CLI session, view remaining limits with /status. In Business credits, add credits from workspace billing and set automatic reload and monthly recharge limits.
gpt-5.5 + xhigh is right for important design, security review, large refactoring, but is overkill for simple repetitive work. GPT-5.5 has about 6.67x higher credit rate on input basis and about 6.64x higher on output basis compared to GPT-5.4-mini.
AGENTS.md can be injected repeatedly into each task context, so longer files increase input tokens. In large projects, it's good to manage with nesting inside the repository so only needed context is injected.
Many MCP servers increase tool definitions and context, consuming more message limits. Always on: GitHub, filesystem (frequently used MCPs). Turn on as needed: Figma, Sentry, Jira, Linear, DB-related MCPs.
Fast mode is about 1.5x faster but GPT-5.5 uses 2.5x credits and GPT-5.4 uses 2x credits. Recommendations: on for real-time pair coding, off for simple documentation, on just before deadline edits.
Longer conversations increase context costs. Manage with: separate by task → remove unnecessary file context → /compact → new session.
Attaching many large files with @file increases input tokens significantly. Better approach: find related file candidates first → then present modification targets and reasons → approve → then open only those files.
In Business/Enterprise: seat types (standard vs Codex), monthly workspace credits pre-charge, auto reload settings (minimum/target balance), default model policy (gpt-5.4 default, gpt-5.5 for critical), Fast mode default off, standard MCPs only active, AGENTS.md per-app separation, Cloud tasks for long work only, PR review scope limited, analytics reviewed regularly.
For individuals, Plus is the baseline starting point. If using Codex daily for extended periods, Pro 5x is right. If running multiple tasks in parallel, Pro 20x fits. For teams, separate standard ChatGPT seat and usage-based Codex seat.
Codex costs are managed by plan-included usage limits and additional billing methods. They have shifted to token-based credit pricing, and the same task costs very differently depending on context size, model choice, and session length.
Section 13. Splitting Work Modes with Profiles
Codex work is never the same type.
If you type this out with long CLI options every time, it's inefficient.
codex -m gpt-5.5 -c model_reasoning_effort='"xhigh"' -c approval_policy='"on-request"' -c sandbox_mode='"read-only"'With profiles, you can shorten it to this.
codex --profile deepA Codex profile is a named settings layer.
When you pass --profile profile-name, Codex first reads the default user config ~/.codex/config.toml, then overwrites it with ~/.codex/profile-name.config.toml. A profile file is not a copy of the entire default config—it's an override file that only contains parts different from defaults.
# ~/.codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"# ~/.codex/deep.config.toml
model_reasoning_effort = "xhigh"
sandbox_mode = "read-only"codex --profile deepFinal applied settings:
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
approval_policy = "on-request"
sandbox_mode = "read-only"Profile files go under CODEX_HOME.
Default CODEX_HOME:
~/.codexProfile file format:
~/.codex/.config.toml Examples:
~/.codex/fast.config.toml
~/.codex/careful.config.toml
~/.codex/deep.config.toml
~/.codex/review.config.toml
~/.codex/ci.config.toml
~/.codex/pair.config.tomlProfile names can use letters, numbers, hyphens, and underscores.
Good names:
fast
deep-review
xhigh
ci
pair_modeNames to avoid (spaces and special characters):
deep review
review/prod
ci.prodProfiles sit in the middle of the overall settings priority.
For example, even if the profile has model = "gpt-5.4-mini", the CLI value wins if specified directly.
codex --profile fast --model gpt-5.5The final model is gpt-5.5.
Do not nest profiles inside ~/.codex/config.toml the old way.
# No longer recommended
profile = "deep"
[profiles.deep]
model = "gpt-5.5"
model_reasoning_effort = "xhigh"Since Codex 0.134.0, --profile no longer reads [profiles.profile-name] inside config.toml. Profiles must be moved to separate files: ~/.codex/profile-name.config.toml.
# ~/.codex/deep.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"codex --profile deepTo use profiles well, first establish stable defaults.
# ~/.codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "auto"
model_verbosity = "medium"
web_search = "cached"
[features]
shell_snapshot = trueThese defaults are for "everyday work". Profile files should only contain values that differ from here.
The fast profile is for quick iteration work.
# ~/.codex/fast.config.toml
model = "gpt-5.4-mini"
model_reasoning_effort = "low"
plan_mode_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "none"
model_verbosity = "low"codex --profile fast
codex -p fastREADME wording edits
Small function renaming
Import cleanup
Type error fixes
Test name changes
Simple CSS editsThe careful profile is for safe general development.
# ~/.codex/careful.config.toml
model = "gpt-5.5"
model_reasoning_effort = "high"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "auto"
model_verbosity = "medium"codex --profile carefulAdd new API endpoint
Analyze bug causes
Write tests
Modify multiple files
Small refactoringThe deep profile is the utmost caution mode. Codex 5.5 xhigh combination is clean when set to this profile.
# ~/.codex/deep.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "concise"
model_verbosity = "medium"codex --profile deepYou can also create a separate read-only deep profile.
# ~/.codex/deep-readonly.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
sandbox_mode = "read-only"codex --profile deep-readonlyLarge refactoring plans
Security reviews
Incident root cause analysis
Architecture design
Migration strategy
Important PR reviewThe review profile is dedicated to code review.
Review is usually reading and judging files without modifications, so read-only is appropriate.
# ~/.codex/review.config.toml
model = "gpt-5.3-codex"
model_reasoning_effort = "high"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "read-only"
model_reasoning_summary = "concise"
model_verbosity = "medium"codex --profile review/reviewIf you want to always lock the review model, you can put it in the base config.
# ~/.codex/config.toml
review_model = "gpt-5.3-codex"The ci profile is for non-interactive automation.
In CI, users cannot click approval buttons, so approval_policy = "never" is often used. However, this setting requires careful consideration.
# ~/.codex/ci.config.toml
model = "gpt-5.4"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "workspace-write"
model_reasoning_summary = "none"
model_verbosity = "low"codex exec --profile ci "analyze the failing tests and propose a minimal fix"# ~/.codex/ci-readonly.config.toml
model = "gpt-5.4"
model_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "read-only"Combinations to avoid in CI:
approval_policy = "never"
sandbox_mode = "danger-full-access"The pair profile is for pair coding.
The goal is to provide both explanation and code change quality without being too slow.
# ~/.codex/pair.config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "auto"
model_verbosity = "medium"codex --profile pairDesign new feature together
Explain code while reading
Review plan before changes
Trace test failures together
Request improvements while viewing diffThe auto profile is for work that allows some autonomous execution locally.
Unlike CI which is fully non-interactive, use it when you want to reduce constant prompting.
# ~/.codex/auto.config.toml
model = "gpt-5.4"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "auto"
model_verbosity = "medium"The above setting is named auto but it's not fully automatic. Truly running without prompts requires approval_policy = "never", but that's only recommended in isolated environments like CI.
# ~/.codex/auto-never.config.toml
model = "gpt-5.4"
model_reasoning_effort = "medium"
approval_policy = "never"
sandbox_mode = "workspace-write"
model_reasoning_summary = "none"
model_verbosity = "low"git status
codex --profile auto-neverBasic execution:
codex --profile fast
codex --profile careful
codex --profile deep
codex --profile reviewcodex -p fast
codex -p deepcodex exec --profile ci "run tests and summarize failures"codex --profile careful --model gpt-5.4codex --profile deep -c model_reasoning_effort='"high"'Example:
codex --profile deep -c sandbox_mode='"read-only"'In this case, the profile is deep, but only for this run, sandbox_mode changes to read-only. By priority, CLI override wins over profile.
Codex uses the word "profile" for two different things.
This section covers config profiles.
Permission profiles are a beta feature for finer control over filesystem and network access scope for local commands. Permission profiles don't compose with existing sandbox_mode.
Beginners should stick to the existing sandbox_mode and approval_policy approach through Chapter 14 (Sandbox and Approval).
Beginners don't need to create too many profiles. Three are enough.
# ~/.codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "auto"
model_verbosity = "medium"# ~/.codex/fast.config.toml
model = "gpt-5.4-mini"
model_reasoning_effort = "low"
plan_mode_reasoning_effort = "medium"
model_reasoning_summary = "none"
model_verbosity = "low"codex --profile fast# ~/.codex/careful.config.toml
model = "gpt-5.5"
model_reasoning_effort = "high"
plan_mode_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "workspace-write"codex --profile careful# ~/.codex/deep.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
model_reasoning_summary = "concise"codex --profile deepEveryday work → base config
Light work → fast
Important work → careful
High-cost failures → deepProfessionals should split into at least five.
fast = quick iteration
careful = general work
deep = utmost caution
review = code review
ci = automation~/.codex/config.toml
~/.codex/fast.config.toml
~/.codex/careful.config.toml
~/.codex/deep.config.toml
~/.codex/review.config.toml
~/.codex/ci.config.tomlIn teams, separate personal profiles from project config.
If a profile doesn't apply as expected, check in this order.
ls ~/.codexCorrect filename:
deep.config.tomlIncorrect filenames:
deep.toml
profile-deep.config.toml
deep.configIf this remains inside ~/.codex/config.toml, remove it:
profile = "deep"
[profiles.deep]
model = "gpt-5.5"When run like this, CLI model takes priority over profile:
codex --profile fast --model gpt-5.5Check if the current repo has project config:
find . -path "*/.codex/config.toml" -printProject config takes priority over profile.
If project config doesn't apply, check if it's a trusted project. Codex ignores config and project-local hooks from untrusted projects for security.
In project-local .codex/config.toml, profile, profiles, provider, notification, telemetry-related keys, etc. are ignored. Profile selection must use CLI --profile profile-name and ~/.codex/profile-name.config.toml.
# /.codex/config.toml
profile = "deep"codex --profile deepCodex profiles are not just option collections. For each recurring work pattern, you save the optimal settings ahead of time in separate files and pull them up with a single command.
Beginners can start with just fast, careful, and deep. In professional work, you can add review, ci, and pair for more nuanced responses.
Section 14. Sandbox and Approval System
Sandbox and Approval are different security mechanisms.
Sandbox is a technical boundary, Approval is a confirmation procedure.
Example:
sandbox_mode = "workspace-write"
approval_policy = "on-request"This setting means Codex can read, modify, and run regular commands within the current workspace, and requests approval for modifications outside the workspace or network access.
Codex's local execution security consists of three layers.
Codex CLI and IDE extension enforce sandbox policy via OS-level mechanisms. Defaults are: no network access, write permissions limited to the active workspace.
In config.toml, sandbox is configured with sandbox_mode.
sandbox_mode = "workspace-write"Three supported values:
read-onlyworkspace-writedanger-full-accessread-only is the most conservative mode. Codex can examine and explain files but requires approval to modify or run commands.
sandbox_mode = "read-only"
approval_policy = "on-request"Recommended situations:
Execution example:
codex --sandbox read-only --ask-for-approval on-requestProfile example:
# ~/.codex/review.config.toml
model = "gpt-5.5"
model_reasoning_effort = "high"
sandbox_mode = "read-only"
approval_policy = "on-request"workspace-write is the most frequently used default mode for local development. Codex can read, modify, and execute routine local commands within the current workspace. Modifications outside the workspace or network access require approval requests.
sandbox_mode = "workspace-write"
approval_policy = "on-request"Recommended situations:
Beginner basic recommendation:
# ~/.codex/config.toml
sandbox_mode = "workspace-write"
approval_policy = "on-request"CLI execution:
codex --sandbox workspace-write --ask-for-approval on-requestdanger-full-access removes sandbox restrictions. It eliminates filesystem and network boundaries, granting Codex full access. Use only when you want to give full access to Codex.
sandbox_mode = "danger-full-access"Most dangerous combination:
sandbox_mode = "danger-full-access"
approval_policy = "never"This combination means no sandbox, no approval request, full access allowed.
Acceptable use cases:
Should not use as default on regular local development machines.
Approval policy determines when Codex pauses and asks the user.
approval_policy = "on-request"Supported values:
untrustedon-requestnevergranularuntrusted is a conservative approval policy. Codex asks before running commands not in the trusted set. Only known-safe read operations run automatically; commands that change state or trigger external execution paths require approval.
sandbox_mode = "workspace-write"
approval_policy = "untrusted"Recommended situations:
on-request is the most practical default. Codex basically works within sandbox, asking only when it needs to go outside. Default permissions are also workspace-write + on-request + user reviewer combination.
sandbox_mode = "workspace-write"
approval_policy = "on-request"Recommended situations:
Recommended basic configuration:
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"never is a policy that doesn't show approval prompts. Important: never doesn't mean removing sandbox—it means removing prompts. Codex still does its best only within configured sandbox constraints.
Safe example:
sandbox_mode = "read-only"
approval_policy = "never"Meaning: Read-only possible, no approval request, no modifications or out-of-bounds work
CI example:
sandbox_mode = "workspace-write"
approval_policy = "never"Meaning: Modifications within workspace possible, no approval request, work outside workspace fails or is restricted
Dangerous example:
sandbox_mode = "danger-full-access"
approval_policy = "never"Should not use this combination on regular local machines.
Granular approval controls whether to surface prompts or auto-reject per approval type.
approval_policy = { granular = {
sandbox_approval = true,
rules = true,
mcp_elicitations = true,
request_permissions = false,
skill_approval = false
} }Controllable items:
sandbox_approvalrulesprompt decisionmcp_elicitationsrequest_permissionsrequest_permissions tool promptskill_approvalBeginners don't need granular from the start. Most cases are covered by approval_policy = "on-request".
You can also configure who reviews approval prompts.
approvals_reviewer = "user"Supported values:
Default:
approval_policy = "on-request"
approvals_reviewer = "user"Auto-review example:
approval_policy = "on-request"
approvals_reviewer = "auto_review"
sandbox_mode = "workspace-write"Important: Auto-review doesn't change sandbox boundaries—it only changes the reviewer for approval requests.
In workspace-write mode, network access is off by default. To allow it, add this setting:
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = trueRecommended default:
[sandbox_workspace_write]
network_access = falseSituations where network should be enabled:
npm install, pip installNote: Network access for web_search and shell commands are different.
workspace-write only allows writing within the current workspace by default. For other directories, add writable_roots.
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
writable_roots = [
"/Users/me/.pyenv/shims",
"/Users/me/dev/shared-package"
]Good use examples:
.pyenv/shimsBad use example:
[sandbox_workspace_write]
writable_roots = ["/"]This essentially undermines the sandbox purpose significantly.
In Codex CLI, you can switch permission modes during a session with /permissions.
/permissionsUsage flow:
Good pattern for beginners:
Rules determine allow, confirm, or block for specific command prefixes.
allowpromptforbiddenUsage examples:
It's more appropriate to use rules for specific command prefixes (allow, prompt, forbid) than to broaden permissions.
Codex also has beta permission profiles.
Existing approach:
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = falsePermission profile approach:
default_permissions = ":workspace"Warning: Do not use default_permissions together with sandbox_mode or [sandbox_workspace_write]. Use one or the other.
Beginner basis: Through Chapter 14, learning just sandbox_mode + approval_policy approach is enough. Permission profiles are advanced/beta permission models covered separately.
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"Effect: Can work within workspace, modifications outside/network access require approval
sandbox_mode = "read-only"
approval_policy = "on-request"Effect: Analysis possible, modifications or command execution require approval
Recommended: Code review, security analysis, first-time repo, production code checking
sandbox_mode = "read-only"
approval_policy = "never"Effect: Read-only, no approval prompt, no modifications
sandbox_mode = "workspace-write"
approval_policy = "never"Effect: Can modify within workspace, no approval prompt, workspace-outside work restricted
Recommended conditions: CI runner isolated, secret exposure limited, changes reviewed via PR diff
sandbox_mode = "workspace-write"
approval_policy = "untrusted"Effect: File modifications possible, untrusted commands require approval
sandbox_mode = "danger-full-access"
approval_policy = "never"Risk: No filesystem restriction, no network restriction, no approval
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = trueRisk: Increased possibility of prompt injection via external docs, package scripts, API responses
[sandbox_workspace_write]
writable_roots = ["/"]Risk: workspace-write protection meaning mostly disappears
Instead add only needed folders narrowly:
[sandbox_workspace_write]
writable_roots = ["/Users/me/dev/shared-package"]sandbox_mode = "danger-full-access"
approval_policy = "never"Risk: Increased exposure possibility for CI secrets, deploy keys, cloud tokens, package tokens
In CI, default to workspace-write or read-only, and restrict network and secret access at runner level.
Beginners should start with this configuration.
# ~/.codex/config.toml
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"
[sandbox_workspace_write]
network_access = falseWhat each setting means:
workspace-writeon-requestusernetwork_access = falseFor unfamiliar repos, use a read-only profile:
# ~/.codex/readonly.config.toml
sandbox_mode = "read-only"
approval_policy = "on-request"
approvals_reviewer = "user"Execution: codex --profile readonly
# ~/.codex/dev.config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"
[sandbox_workspace_write]
network_access = falseExecution: codex --profile dev
# ~/.codex/deep-readonly.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
sandbox_mode = "read-only"
approval_policy = "on-request"
approvals_reviewer = "user"Execution: codex --profile deep-readonly
# ~/.codex/deep-edit.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
plan_mode_reasoning_effort = "xhigh"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"
[sandbox_workspace_write]
network_access = falseExecution: codex --profile deep-edit
# ~/.codex/net.config.toml
model = "gpt-5.5"
model_reasoning_effort = "high"
sandbox_mode = "workspace-write"
approval_policy = "on-request"
approvals_reviewer = "user"
[sandbox_workspace_write]
network_access = trueExecution: codex --profile net
Do not use this profile as your default.
In CI/CD, humans cannot click approval buttons, so approval_policy = "never" is often used. However, maintain sandbox.
Read-only CI:
# ~/.codex/ci-readonly.config.toml
sandbox_mode = "read-only"
approval_policy = "never"Auto-modifying CI:
# ~/.codex/ci-edit.config.toml
sandbox_mode = "workspace-write"
approval_policy = "never"
[sandbox_workspace_write]
network_access = falseExecution:
codex exec --profile ci-readonly "review this diff and report risks"
codex exec --profile ci-edit "fix lint errors only"CI settings to avoid:
sandbox_mode = "danger-full-access"
approval_policy = "never"Only review this combination exceptionally if the CI runner is strongly isolated and secrets and network are restricted externally.
Check: sandbox_mode = "read-only"
Fix: sandbox_mode = "workspace-write" + approval_policy = "on-request"
Check: sandbox_mode = "workspace-write"
Fix: Add writable_roots in [sandbox_workspace_write]
Check: network_access = false
Fix: network_access = true (enable only when needed)
Check: approval_policy = "never"
Fix: approval_policy = "on-request"
Check: sandbox_mode = "read-only" + approval_policy = "untrusted"
Fix: sandbox_mode = "workspace-write" + approval_policy = "on-request"
Check: Is the project trusted state? Is .codex/config.toml in current repo? Is CLI override higher priority covering it?
Recommendation: Run git commit yourself, let Codex handle diff generation and testing only
Sandbox defines what you can do.
sandbox_mode = "read-only"sandbox_mode = "workspace-write"sandbox_mode = "danger-full-access"Approval defines when to ask.
approval_policy = "untrusted"approval_policy = "on-request"approval_policy = "never"Remember:
Section 15. How to Use AGENTS.md
AGENTS.md is a Markdown file that tells Codex your project's work rules.
If humans have README.md, AI coding agents have AGENTS.md.
According to official Codex documentation, AGENTS.md is durable project guidance that moves with the repository and applies before Codex starts work.
AGENTS.md saves rules you'd repeat constantly.
Instead of saying this every time:
This project uses pnpm.
Run tests with pnpm test.
Update docs when changing API.
Never read or modify .env files.
Check lint and typecheck before PR.You leave it once in the repository root. Official Best Practices documentation explains that good AGENTS.md should contain repo layout, execution method, build/test/lint commands, engineering convention, PR expectations, constraints, do-not rules, and verification standards.
Codex creates an instruction chain on startup. Discovery order is:
${CODEX_HOME}/AGENTS.override.md or ${CODEX_HOME}/AGENTS.mdAGENTS.override.md, AGENTS.md, fallback files from project root to current work directoryDefault CODEX_HOME is ~/.codex. Codex merges ~/.codex/AGENTS.md → repo/AGENTS.md → repo/apps/web/AGENTS.md in order.
Global AGENTS.md applies to all projects—your personal baseline instructions.
Location: ~/.codex/AGENTS.md
Example:
# ~/.codex/AGENTS.md
## Working agreements
- Respond in English.
- Present a simple plan before code changes.
- Always ask before deleting important files or major refactoring.
- Explain why before adding new production dependencies and suggest alternatives.Good for global file: Response language, explanation style, approval preferences, personal habits, preferred package manager
Not good for global file: Specific repo test commands, specific team coding conventions, specific service deployment procedures
Project AGENTS.md sits in the repo root—shared team instructions.
Location: repo-root/AGENTS.md
Example structure:
Official documentation explains that repository-level AGENTS.md tells Codex project rules while inheriting global defaults.
Large repos or monorepos shouldn't stop at root.
Example structure:
repo/
AGENTS.md
apps/
web/
AGENTS.md
admin/
AGENTS.md
services/
payments/
AGENTS.mdWhen Codex starts in services/payments, it reads in this order: ~/.codex/AGENTS.md → repo/AGENTS.md → repo/services/payments/AGENTS.md. Files closer to current directory merge later and override earlier ones.
AGENTS.override.md takes priority over regular AGENTS.md in the same directory.
When both exist in same dir: Codex uses AGENTS.override.md, ignoring AGENTS.md.
AGENTS.override.md~/.codex/AGENTS.override.mdWarning: AGENTS.override.md is powerful. If you created it temporarily, remove it after work.
If your team already uses other instruction files, you can make Codex read those too.
Configuration example:
# ~/.codex/config.toml
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]
project_doc_max_bytes = 65536With this, Codex searches each directory in this order: AGENTS.override.md → AGENTS.md → TEAM_GUIDE.md → .agents.md
Codex stops adding files when instruction chain total reaches project_doc_max_bytes. Default is 32 KiB.
Configuration example:
# ~/.codex/config.toml
project_doc_max_bytes = 65536But blindly increasing size isn't the answer.
Official Best Practices also recommend keeping main file concise, and splitting planning, code review, architecture into task-specific markdown.
In Codex CLI, you can create a starter AGENTS.md with /init.
/initOfficial Best Practices explain that /init slash command scaffolds a starter AGENTS.md, and you should edit the result to match your team's actual build, test, review, and ship practices.
Recommended flow:
Most straightforward template structure:
Keep coding style short and concrete.
Good example:
## Coding conventions
- Avoid any in TypeScript; include reason as comment if needed.
- React components use named export.
- Don't put business logic directly in API route handlers; separate into src/domain.
- Prioritize Tailwind utility for CSS; extract repeated patterns to components.
- Follow style of existing files first.Bad example: "Write good code", "Make it clean", "Keep it maintainable" is too abstract. Codex needs rules it can actually judge.
Codex needs exact commands for verification after work.
Good example:
## Commands
- Install dependencies: pnpm install
- Run unit tests: pnpm test
- Run a single test file: pnpm test -- path/to/file.test.ts
- Run lint: pnpm lint
- Run type checks: pnpm typecheck
- Build production bundle: pnpm buildMonorepo example:
- Web app dev: pnpm --filter web dev
- Web app tests: pnpm --filter web test
- API tests: pnpm --filter api test
- All checks: pnpm turbo run lint test typecheckExplicitly write what Codex should not do.
Basic do-not list:
## Do not
- Do not run deployment commands.
- Do not rotate, print, or modify secrets.
- Do not edit .env* files.
- Do not rewrite migration history.
- Do not delete user data or test fixtures unless explicitly requested.
- Do not introduce new production dependencies without explaining why.
- Do not make broad formatting-only changes in unrelated files.Or more strongly:
## High-risk actions
Ask for explicit confirmation before:
- Running database migrations
- Deleting files
- Changing authentication or authorization logic
- Modifying payment, billing, or money movement code
- Adding dependencies
- Changing CI/CD configurationAGENTS.md is behavior guidance, not a technical enforcement mechanism.
Always be specific about security rules.
Example:
## Security and secrets
- Do not read, print, copy, or modify .env, .env.*, private keys, certificates, or credential files.
- If a task requires secrets, stop and ask the user.
- Never paste tokens, API keys, cookies, or credentials into logs or responses.
- Treat production data as sensitive.
- Do not make network calls to production services unless explicitly requested.Data project example:
- Do not modify files in data/raw/.
- Write processed data to data/processed/.
- Write reports to reports/.
- Do not include personally identifiable information in generated examples.If your team uses Codex as a reviewer, write review criteria separately.
Simple approach:
## Review expectations
When reviewing code:
- Focus on correctness, security, test coverage, and maintainability.
- Prefer actionable findings over style opinions.
- Include file paths and concrete examples.
- Mention missing tests when behavior changes.
- Do not approve changes that fail typecheck or tests.Separate-file approach: Add "Follow docs/code_review.md when reviewing pull requests" to AGENTS.md, and Codex can follow those guidelines during review.
In monorepos, keep root small and put details in subfolders.
Recommended structure:
repo/
AGENTS.md
apps/
web/
AGENTS.md
mobile/
AGENTS.md
services/
api/
AGENTS.md
payments/
AGENTS.md
packages/
ui/
AGENTS.mdRoot covers repository-wide rules and layout; each subfolder handles its module's specific rules. Closest file wins, so subprojects get tailored guidance.
AGENTS.md is not Codex-only—it's an open format for multiple AI coding tools.
If you have existing files:
Migration: rename existing file to AGENTS.md and create symbolic link for backward compatibility.
Four confusing concepts must be distinguished.
Distinction guide: What should I follow? → AGENTS.md | Which model/permissions? → config.toml | Which commands block? → Rules | How to package workflows? → Skills
Good AGENTS.md structure:
## Project overview
TypeScript monorepo using pnpm workspaces...
## Commands
- Install: pnpm install
- Tests: pnpm test (or pnpm --filter web test)
## Coding conventions
- Use TypeScript strict types
- Keep business logic out of route handlers
## Safety rules
- Do not read or modify .env* files
## PR expectations
- Summarize changed files, mention tests run, list risksWhy this example is good: Commands are actually executable | Forbidden actions are clear | Test criteria exist | File structure disclosed | Action rules outnumber abstract statements
Bad example:
## Rules
- Be smart.
- Write clean code.
- Make it scalable.
- Use best practices.
- Always improve everything.
- Never make mistakes.Worse pattern: "Always refactor", "Fix everything you see", "Run any needed commands"—this causes unnecessary large changes and dependency updates.
AGENTS.md is not write-once. Update when:
Real maintenance routine: Codex makes same mistake twice → Fix root cause with short rule → Add to AGENTS.md → See effect on next task → Separate to sub-docs when too long
1. Codex doesn't seem to read AGENTS.md
codex --ask-for-approval never "Summarize the current instructions."2. Wrong guidance applies
Check: ~/.codex/AGENTS.override.md, repo/AGENTS.override.md, override in subdirs. Rename or remove as needed.
3. Subfolder guidance not applying
codex --cd services/payments "Show which instruction files are active."4. Fallback file ignored
Check: project_doc_fallback_filenames configured, start new session.
5. Guidance gets cut off
Fix: Increase project_doc_max_bytes or shorten root, split by subfolder.
AGENTS.md tells Codex your project's work rules.
Basic location: ~/.codex/AGENTS.md (personal) → repo/AGENTS.md (team) → repo/subdir/AGENTS.md (subdirectory)
Core template sections: Project overview, Commands, Repository layout, Coding conventions, Testing rules, Safety rules, PR expectations
Include in AGENTS.md: Project structure, execution commands, test/lint/build commands, coding conventions, forbidden actions, security rules, PR review criteria
Don't include: Overly abstract language, outdated commands, personal preferences not fitting all repos, secrets or credentials, security policies that should be technically enforced
Section 16. Hooks
Hooks are an extension system that automatically runs user scripts at specific points during Codex execution.
Simply put:
Official documentation describes hooks as an extension framework for injecting deterministic scripts into the Codex lifecycle. For example, you can check if an API key is attached to a prompt, log conversation contents, run validation scripts at the end of a turn, or inject additional context from specific directories.
At the moment Codex tries to do something
→ hook executes
→ can allow, block, warn, or inject additional contextIf AGENTS.md is "guidelines to follow", hooks are "automatic checks that run at predetermined times".
Hooks are suitable for these situations.
Writing "don't do this" in AGENTS.md is guidance, but blocking it with hooks is execution control. For important policies, it's safer to use hooks, sandbox, approval, and rules together rather than relying on AGENTS.md alone.
Hooks are enabled by default. To disable, set [features].hooks = false in config.toml.
[features]
hooks = trueOrganization administrators can also force hooks off in requirements.toml.
[features]
hooks = falseCodex looks for hooks next to the active config layer. The four most commonly used locations in practice are:
~/.codex/hooks.json
~/.codex/config.toml
<repo>/.codex/hooks.json
<repo>/.codex/config.tomlProject-local hooks are loaded only when the project .codex/ layer is in a trusted state.
Hooks can be configured in two ways.
{
"hooks": {
"PreToolUse": [
{
"matcher": "^Bash$",
"hooks": [
{
"type": "command",
"command": "python3 .codex/hooks/pre_tool_use_policy.py",
"timeout": 30,
"statusMessage": "Checking Bash command"
}
]
}
]
}
}Second is the inline approach in config.toml.
[[hooks.PreToolUse]]
matcher = "^Bash$"
[[hooks.PreToolUse.hooks]]
type = "command"
command = '/usr/bin/python3 "$(git rev-parse --show-toplevel)/.codex/hooks/pre_tool_use_policy.py"'
timeout = 30
statusMessage = "Checking Bash command"Recommendation:
Hook configuration has three levels.
Event
→ Matcher group
→ Hook handlerExamples:
matcher is a regex string that determines when a hook runs. "*", "", or omitting the matcher matches all occurrences of that event.
Commonly used matchers:
Bash
^Bash$
^apply_patch$
Edit|Write
mcp__filesystem__read_file
mcp__filesystem__.*
startup|resume|clear|compact
manual|autoMatcher targets by event:
Non-managed command hooks must be reviewed and trusted by the user before execution. Codex records trust based on the current hash of the hook definition, so if hook content changes, it becomes a review target again.
Managing hooks from CLI:
/hooksYou can do the following in /hooks:
Check hook source
Review new or modified hooks
Trust hooks
Disable individual non-managed hooksManaged hooks come from management sources like system, MDM, cloud, or requirements.toml. These hooks are policy-marked as trusted and cannot be disabled by users from the hook browser.
Currently, the config reference examples these lifecycle hook events:
SessionStart runs when a session starts.
Matcher targets:
startup
resume
clear
compactInput includes source. If you print plain text to stdout, it becomes additional developer context. JSON output can provide additionalContext.
Use cases: Inject team rules at session start, provide additional context per work directory, insert recent work notes summary
UserPromptSubmit runs right before the user prompt is passed to the model.
Input includes the prompt submitted by the user. This event currently doesn't use matchers and configured matchers are ignored. Plain text stdout becomes additional developer context, and you can also block the prompt itself with decision: "block".
Use cases: Check if API keys are in the prompt, block high-risk requests like production DB deletion, inject additional guidance context based on prompt content
Block output example:
{
"decision": "block",
"reason": "Prompt appears to contain a secret. Remove it before continuing."
}You can also pass block reason via exit code 2 and stderr.
PreToolUse runs right before supported tools like Bash, apply_patch, MCP tools are executed.
Input includes tool_name, tool_use_id, tool_input. For Bash and apply_patch, use tool_input.command.
Use cases: Block dangerous Bash commands, block specific file modifications, restrict MCP tool calls, inject additional context before command execution, rewrite supported tool inputs
Block output example:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "deny",
"permissionDecisionReason": "Destructive command blocked by hook."
}
}Supported tool calls can be rewritten with permissionDecision: "allow" and updatedInput.
PermissionRequest runs right before Codex requests approval from the user.
For example, it runs when shell escalation or managed-network approval is needed. It doesn't run for commands that don't need approval. This hook can allow, deny, or pass the request to normal approval flow without deciding.
Approval output:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "allow"
}
}
}Denial output:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "deny",
"message": "Blocked by repository policy."
}
}
}When multiple hooks return a decision, deny wins. If there's no deny and at least one allow, the approval prompt doesn't show and proceeds.
PostToolUse runs after tool execution.
It runs after Bash, apply_patch, MCP tool calls, and even when a Bash command ends with non-zero status. However, you cannot undo the side effects of an already-executed tool.
Use cases: Inspect command output, turn test failure results into model-visible feedback, detect changes to generated files, warn after forbidden file changes
Important limitation: PostToolUse cannot undo already-executed work. Use PreToolUse if blocking is your goal.
PreCompact runs right before conversation compact. PostCompact runs right after compact. Matcher targets are manual or auto.
Use cases: Save important TODOs before compact, check summary quality after compact, update memo files in long sessions
If PreCompact hook returns continue: false, it can stop before compact. If PostCompact hook returns continue: false, it can stop after compact.
SubagentStart runs when a subagent starts. SubagentStop runs when a subagent stops.
In SubagentStart, plain text stdout can become additional developer context for the subagent. SubagentStop expects JSON stdout on exit 0, and plain text output is invalid.
Use cases: Inject additional instructions per subagent, provide separate security standards to review subagent, trigger additional execution if subagent results are insufficient
Stop runs when a turn ends.
Matcher is currently not used. Exit 0 expects JSON stdout and plain text output is invalid. decision: "block" doesn't reject the turn but auto-generates a continuation prompt for Codex to keep going.
Use cases: Force additional check if tests didn't run, enforce checklist before work ends, inspect last assistant message, force continued writing if required report format is missing
Stop hooks can create infinite continuation loops. You must check input fields like stop_hook_active to limit repetition.
Official hook input includes stop_hook_active, letting you check if that turn was already continued by a Stop hook.
All command hooks receive a single JSON object via stdin. Common fields are:
Reading input in a Python hook:
#!/usr/bin/env python3
import json
import sys
payload = json.load(sys.stdin)
event = payload.get("hook_event_name")
cwd = payload.get("cwd")
model = payload.get("model")Several events support common output fields.
{
"continue": true,
"stopReason": "optional",
"systemMessage": "optional",
"suppressOutput": false
}General success: exit 0 + no stdout
Block or continuation: exit 2 + print reason to stderr, or output event-specific JSON to stdout
Actual support range differs per event.
Goal: Auto-block commands like rm -rf, git push, deploy, kubectl delete, terraform apply.
.codex/hooks.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "^Bash$",
"hooks": [
{
"type": "command",
"command": "/usr/bin/python3 \"$(git rev-parse --show-toplevel)/.codex/hooks/block_dangerous_bash.py\"",
"timeout": 10,
"statusMessage": "Checking Bash safety policy"
}
]
}
]
}
}.codex/hooks/block_dangerous_bash.py:
#!/usr/bin/env python3
import json
import re
import sys
payload = json.load(sys.stdin)
tool_input = payload.get("tool_input") or {}
command = tool_input.get("command", "")
dangerous_patterns = [
r"\brm\s+-rf\b",
r"\bgit\s+push\b",
r"\bkubectl\s+delete\b",
r"\bterraform\s+apply\b",
].codex/hooks.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "/usr/bin/python3 \"$(git rev-parse --show-toplevel)/.codex/hooks/check_prompt_secret.py\"",
"timeout": 10,
"statusMessage": "Checking prompt for secrets"
}
]
}
]
}
}Input includes the prompt submitted by the user. UserPromptSubmit runs right before the prompt is sent to the model.
The Stop hook runs when a turn ends. You can make Codex verify again if tests are needed.
.codex/hooks.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "/usr/bin/python3 \"$(git rev-parse --show-toplevel)/.codex/hooks/stop_require_tests.py\"",
"timeout": 10,
"statusMessage": "Checking completion criteria"
}
]
}
]
}
}Plugins can also include lifecycle hooks.
Default plugin hook location:
hooks/hooks.jsonOr you can specify hook path in .codex-plugin/plugin.json.
These environment variables are provided to plugin hook commands:
Organization administrators can enforce managed hooks in requirements.toml.
Note: Codex does not deploy scripts in managed_dir. The organization's MDM or device-management system must install and update scripts.
Managed hooks come from sources like system, MDM, cloud, or requirements.toml, are policy-trusted, and cannot be disabled by users from the hook browser.
1. Hooks execute local commands
Hook commands are executed in the session's cwd.
Pattern to avoid:
{
"type": "command",
"command": "curl https://example.com/install.sh | sh"
}2. Project-local hooks don't run until trust review
Malicious repos can plant .codex/hooks.json, so Codex doesn't execute non-managed hooks right away and requires review/trust procedures.
Recommendation: Review full hook command in /hooks, check absolute paths and script content, look for suspicious network calls, trust after review
3. Multiple matching hooks all execute
If matching hooks exist in multiple files, all run. Don't assume multiple security hooks guarantee a specific order.
4. PostToolUse is not undo
PostToolUse can inspect tool execution after the fact, but cannot revert the side effects of already-executed commands. Use PreToolUse for blocking.
5. Don't rely on transcript format
Hook input's transcript_path is for convenience. Transcript format is not a stable interface for hooks and may change.
6. Don't put secrets in hook scripts
Don't hardcode API_KEY; read from environment variables with os.environ.get().
7. Use short timeouts
Default timeout is 600 seconds if omitted. Long-running hooks slow down Codex workflows. "timeout": 10 is recommended.
1. Hook doesn't run
Check: Is [features] hooks = false in config.toml? Or check if /hooks shows trust is needed.
2. Project hook is ignored
Cause: Project is untrusted. Project-local hooks load only when project .codex/ layer is trusted. Check project trust status in /hooks and restart the session.
3. Hook seems to run twice
Cause: hooks.json and config.toml inline hooks exist simultaneously, user hook and project hook match simultaneously, or plugin hook also matches. Solution: Use either hooks.json or inline [hooks] per layer.
4. Other hook runs even though PreToolUse blocked
Normal behavior. Multiple matching command hooks on the same event start concurrently, so important blocking logic should be in one hook.
5. Command already ran even though PostToolUse blocked
Normal behavior. PostToolUse is after-tool hook, so move command pre-execution blocking to PreToolUse.
6. Stop hook loops infinitely
Cause: Stop hook keeps returning decision: block. Solution: Use if payload.get("stop_hook_active"): sys.exit(0) to prevent infinite loops.
Use commandWindows or TOML alias command_windows.
[[hooks.PreToolUse.hooks]]
type = "command"
command = "python3 .codex/hooks/check.py"
command_windows = 'py -3 .codex\hooks\check.py'
timeout = 10Hooks are a system that runs command scripts at specific points in the Codex lifecycle.
The most important principles are block with PreToolUse, post-execution check with PostToolUse, work-end validation with Stop.
Beginners need only learn three: UserPromptSubmit (prompt inspection), PreToolUse (pre-execution blocking), PostToolUse (post-execution inspection).
Section 17. MCP: Model Context Protocol
MCP is a standard protocol for AI applications to connect to external tools, data sources, and workflows.
Simply put:
Through MCP, Codex can:
In Codex, MCP is an extension layer that adds external context and tools beyond basic built-in tools.
Codex built-in abilities:
Read files
Modify files
Run shell commands
Review diffs
Run testsAbilities extended by MCP:
Manipulate GitHub PRs/issues
Read Figma designs
Check Sentry errors
Open browsers and take screenshots
Search external documentation
Query internal systemsThe MCP standard consists of three main components.
From Codex perspective:
Codex = Host
Codex internal MCP connection = Client
GitHub/Figma/Sentry/Context7 MCP = ServerThere are two main types of MCP servers Codex supports.
Distinction:
STDIO MCP = run server process on my computer
Streamable HTTP = connect to external or local MCP server via URLMCP configuration goes in config.toml.
Default location:
~/.codex/config.tomlPer-project location:
/.codex/config.toml Note: Project MCP settings in .codex/config.toml apply only in trusted projects.
Untrusted projects skip the project-scoped .codex/ layer.
You can add MCP servers via CLI.
Basic form:
codex mcp add -- With environment variables:
codex mcp add --env VAR1=VALUE1 --env VAR2=VALUE2 -- Example:
codex mcp add context7 -- npx -y @upstash/context7-mcpCheck and help:
/mcp
codex mcp --helpFine-tuned configuration goes in config.toml.
Basic structure:
[mcp_servers.]
... Example:
# ~/.codex/config.toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = true
startup_timeout_sec = 20
tool_timeout_sec = 60STDIO servers are MCP servers run as local commands.
Basic example:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]Commonly used fields in STDIO:
commandargsenvenv_varscwdstartup_timeout_sectool_timeout_secenabledExample of setting environment variables.
[mcp_servers.mytool]
command = "node"
args = ["server.js"]
cwd = "/Users/me/dev/my-mcp-server"
env_vars = ["MY_LOCAL_TOKEN"]
[mcp_servers.mytool.env]
NODE_ENV = "production"env_vars accepts plain variable name or { name = "...", source = "local" | "remote" } object.
String entry uses local source by default; source = "remote" is used only in executor-backed remote stdio.
Streamable HTTP servers are MCP servers accessed via URL.
Basic example:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"HTTP header example:
[mcp_servers.company_docs]
url = "https://mcp.company.internal/mcp"
bearer_token_env_var = "COMPANY_MCP_TOKEN"
[mcp_servers.company_docs.http_headers]
X-Workspace = "engineering"
[mcp_servers.company_docs.env_http_headers]
X-User-Token = "COMPANY_USER_TOKEN"Fields for Streamable HTTP servers:
urlbearer_token_env_varhttp_headersenv_http_headersIt's safer not to write secrets directly in http_headers, but use bearer_token_env_var or env_http_headers instead.
Bearer token approach: put token in environment variable and config only references the variable name.
Set environment variable:
export FIGMA_OAUTH_TOKEN="..."Config setting:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"Bad example (writing token directly):
[mcp_servers.figma.http_headers]
Authorization = "Bearer actual_token_value"Why: Even if config.toml is accidentally committed, the token value itself is safe.
MCP servers supporting OAuth log in via CLI.
codex mcp login OAuth callback configuration:
mcp_oauth_callback_port = 5555
mcp_oauth_callback_url = "https://devbox.example.internal/callback"If not set, Codex uses an ephemeral port.
OAuth credential storage method:
mcp_oauth_credentials_store = "auto"Possible values: auto, file, keyring
You can restrict permissions by specifying OAuth scopes.
Example:
[mcp_servers.github]
url = "https://example.com/mcp"
scopes = ["repo:read", "issues:read"]mcp_servers.<id>.scopes defines OAuth scopes to request during that MCP server authentication.
It's safe to add write scope only when necessary.
When an MCP server provides many tools, it's good to enable only needed ones.
Allowlist:
[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
enabled_tools = ["open", "screenshot"]Denylist:
[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
enabled_tools = ["open", "screenshot", "evaluate"]
disabled_tools = ["evaluate"]disabled_tools applies after enabled_tools.
Tool control fields:
enabled_toolsdisabled_toolsenabled = falseYou can set approval policy per MCP tool.
Server default:
[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
default_tools_approval_mode = "prompt"Override specific tool:
[mcp_servers.chrome_devtools.tools.open]
approval_mode = "approve"Value meanings:
autopromptapproveTo auto-approve read-only tools only:
[mcp_servers.docs]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
default_tools_approval_mode = "prompt"
[mcp_servers.docs.tools.search]
approval_mode = "approve"
[mcp_servers.docs.tools.read]
approval_mode = "approve"Basic principle: Keep write/delete risky tools as prompt.
Codex MCP configuration doesn't have a single universal read_only = true option applying to all servers.
To operate close to read-only, combine these four things:
enabled_toolsdisabled_toolsdefault_tools_approval_mode = "prompt"GitHub read-only example:
[mcp_servers.github]
url = "https://example-github-mcp.company/mcp"
scopes = ["repo:read", "issues:read"]
enabled_tools = ["repos/list", "pull_requests/read", "issues/read"]
disabled_tools = ["repos/delete", "pull_requests/merge", "issues/write"]
default_tools_approval_mode = "prompt"Key: Read-only MCP is created with server auth permission + tool allowlist + approval mode.
MCP servers can return instructions field during initialization.
Codex reads this instructions as server-wide guidance and uses it with that server's tools.
Example:
This server provides read-only access to internal API documentation.
Use search_docs before read_doc.
Do not call write or admin tools.
Rate limit: at most 5 requests per minute.Good content for server instructions:
First 512 characters are important for Codex to decide server use, so write self-contained.
Plugins can include MCP servers too.
Example:
[plugins."sample@test".mcp_servers.sample]
enabled = true
default_tools_approval_mode = "prompt"
enabled_tools = ["read", "search"]
[plugins."sample@test".mcp_servers.sample.tools.search]
approval_mode = "approve"Distinction:
[mcp_servers.<id>][plugins.<plugin>.mcp_servers.<server>]Codex can also run itself as an MCP server for other agents or tools to use.
codex mcp-serverUse cases:
Beginners don't need this feature right away. Usually "connecting MCP servers to Codex" comes first, and "exposing Codex itself as MCP server" is advanced automation.
MCP servers are convenient but can increase cost and context usage.
Cost-increasing factors:
To reduce costs, configure like this:
Disable unnecessary servers:
[mcp_servers.big_server]
enabled = falseAllow only needed tools:
[mcp_servers.github]
enabled_tools = ["pull_requests/read", "issues/read"]
disabled_tools = ["pull_requests/merge", "issues/write"]Recommendation:
enabled = falseenabled_toolspromptRecommended order for beginners:
Beginner basics:
GitHub MCP is useful for giving Codex GitHub API context like repositories, PRs, issues.
Recommended uses:
Risks:
GitHub MCP safe configuration example:
[mcp_servers.github]
url = "https://example-github-mcp.company/mcp"
scopes = ["repo:read", "issues:read"]
enabled_tools = ["repos/list", "pull_requests/read", "issues/read"]
default_tools_approval_mode = "prompt"Figma MCP is useful for reading design files and reflecting them in implementation.
Recommended uses:
Basic example:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"Recommended policy:
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
default_tools_approval_mode = "prompt"Figma is safe to operate read-focused.
Sentry MCP is useful for providing production error, stack trace, issue context to Codex.
Recommended uses:
Note: Sentry may contain sensitive data like user info, URLs, request body, token fragments.
Recommended configuration:
[mcp_servers.sentry]
url = "https://example-sentry-mcp.company/mcp"
bearer_token_env_var = "SENTRY_MCP_TOKEN"
enabled_tools = ["issues/search", "issues/read", "events/read"]
default_tools_approval_mode = "prompt"Browser MCPs are useful for opening and inspecting web apps in real browsers.
Recommended uses:
Chrome DevTools example:
[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
enabled_tools = ["open", "screenshot"]
default_tools_approval_mode = "prompt"
startup_timeout_sec = 20
tool_timeout_sec = 45
[mcp_servers.chrome_devtools.tools.open]
approval_mode = "approve"Note: Browser MCPs can access login sessions, cookies, admin pages, internal dashboards, so prompt default is safer.
Doc search MCPs are the safest starting point for beginners.
Context7 example:
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = true
default_tools_approval_mode = "approve"CLI add:
codex mcp add context7 -- npx -y @upstash/context7-mcpWhy recommended:
1. Don't write token directly in config
Bad example:
[mcp_servers.company.http_headers]
Authorization = "Bearer actual_token"Good example:
[mcp_servers.company]
bearer_token_env_var = "COMPANY_MCP_TOKEN"2. Keep write tools as prompt by default
[mcp_servers.github]
default_tools_approval_mode = "prompt"Auto-approve read tools only:
[mcp_servers.github.tools.pull_requests_read]
approval_mode = "approve"3. Turn off unnecessary tools
[mcp_servers.github]
enabled_tools = ["pull_requests/read", "issues/read"]
disabled_tools = ["pull_requests/merge", "issues/write"]4. Don't keep many MCP servers on all the time
[mcp_servers.figma]
enabled = false5. Trust project MCPs only in trusted projects
If project .codex/config.toml contains MCP servers, verify server command or URL is safe first.
6. Minimize OAuth scope
[mcp_servers.github]
scopes = ["repo:read", "issues:read"]Add write scope only when necessary.
7. Specify startup timeout and tool timeout
startup_timeout_sec = 20
tool_timeout_sec = 45Defaults: startup timeout 10 sec, tool timeout 60 sec
1. Server not showing in /mcp
Check:
/mcpLook for:
[mcp_servers.<id>] table name correct?enabled = false?2. STDIO server fails to start
Check:
startup_timeout_sec too short?3. HTTP MCP authentication fails
Check:
echo $FIGMA_OAUTH_TOKENLook for:
bearer_token_env_var instead of var name?4. OAuth callback fails
For fixed port:
mcp_oauth_callback_port = 5555For specific redirect URI:
mcp_oauth_callback_url = "https://devbox.example.internal/callback"5. Too many tools shown and Codex gets confused
Solution:
[mcp_servers.big_server]
enabled_tools = ["search", "read"]
disabled_tools = ["write", "delete", "admin"]Or disable server itself:
[mcp_servers.big_server]
enabled = false6. Tool execution often hangs
Auto-approve read tools:
[mcp_servers.docs.tools.search]
approval_mode = "approve"
[mcp_servers.docs.tools.read]
approval_mode = "approve"Keep risky tools as prompt:
[mcp_servers.github.tools.merge]
approval_mode = "prompt"7. Cost increased because of MCP
Cause:
Solution:
[mcp_servers.figma]
enabled = false
[mcp_servers.github]
enabled_tools = ["pull_requests/read", "issues/read"]Simplest and safest configuration:
# ~/.codex/config.toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = true
default_tools_approval_mode = "approve"
startup_timeout_sec = 20
tool_timeout_sec = 60Use case:
Configuration managing multiple MCPs selectively:
# ~/.codex/config.toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled = true
default_tools_approval_mode = "approve"
startup_timeout_sec = 20
tool_timeout_sec = 60
[mcp_servers.figma]
url = "https://mcp.figma.com/mcp"
bearer_token_env_var = "FIGMA_OAUTH_TOKEN"
enabled = false
default_tools_approval_mode = "prompt"
startup_timeout_sec = 20
tool_timeout_sec = 45
[mcp_servers.chrome_devtools]
url = "http://localhost:3000/mcp"
enabled = false
enabled_tools = ["open", "screenshot"]
default_tools_approval_mode = "prompt"
startup_timeout_sec = 20
tool_timeout_sec = 45
[mcp_servers.chrome_devtools.tools.open]
approval_mode = "approve"Operation method:
enabled = false, enable when neededConfiguration centered on GitHub:
[mcp_servers.github]
url = "https://example-github-mcp.company/mcp"
bearer_token_env_var = "GITHUB_MCP_TOKEN"
scopes = ["repo:read", "issues:read"]
enabled_tools = [
"repos/list",
"pull_requests/read",
"issues/read"
]
disabled_tools = [
"pull_requests/merge",
"issues/write",
"repos/delete"
]
default_tools_approval_mode = "prompt"
[mcp_servers.github.tools."pull_requests/read"]
approval_mode = "approve"
[mcp_servers.github.tools."issues/read"]
approval_mode = "approve"Goal:
MCP is a standard extension system connecting Codex to external tools. You can add external context like GitHub, Figma, Sentry, and doc search when basic built-in tools aren't enough.
Supported transport:
Default config location is ~/.codex/config.toml (global) or <repo>/.codex/config.toml (project, trusted only).
Beginners should start with doc search MCP (Context7), then gradually add GitHub, Figma, Sentry, Browser as read-only, which is safe.
Most important principle:
Section 18. Skills System
A Skill is a task-specific knowledge package that tells Codex "handle this kind of work this way".
Skill examples suitable for repeated work:
Core is "knowledge" not "repeatable work procedure". The purpose of Skill is to capture procedures Codex should follow during actual work, not just a simple instruction manual.
If you keep copy-pasting the same prompt, convert it to a Skill.
Four reasons Skills are needed:
Skill is especially effective in these situations.
"Test writing Skill" example includes: test framework, file naming rules, unit/integration test distinction, mock allowance scope, test execution command, failure cause check order, result report format.
Basic structure is:
my-skill/
SKILL.md
scripts/
references/
assets/
agents/
openai.yamlSKILL.md is required; scripts/, references/, assets/, agents/openai.yaml are optional. SKILL.md must contain at minimum name and description metadata.
Simplest Skill can be made with just metadata (name, description) and procedure.
description is very important. Codex uses this to auto-select Skills.
Good description example:
Review pull requests, diffs, branches, or code changes for correctness, security, test coverage, maintainability, and risky behavior. Use when the user asks for PR review, code review, diff review, or merge readiness.Bad description example:
Helps with code.Bad description is too broad for Codex to decide when to use this Skill.
Codex uses Skills in two ways.
User directly calls a specific Skill.
$pr-review Review this diff for me.User doesn't mention Skill name; Codex picks appropriate Skill based on task content.
Review risky parts of this PR.For implicit invocation to work, description needs trigger words like "PR", "review", "diff", "code change".
Skill defines work procedure; MCP connects to external tools and systems. Together they're powerful.
Example: "Sentry incident analysis Skill" defines procedure, MCP server fetches Sentry data.
You can declare MCP tool dependencies in Skill's agents/openai.yaml.
dependencies:
tools:
- type: "mcp"
value: "openaiDeveloperDocs"
description: "OpenAI Docs MCP server"Skills accessing external systems must verify permission, authentication, data exposure scope.
PR review Skill is a representative one most teams see immediate benefit from.
Folder structure:
.agents/
skills/
pr-review/
SKILL.md
references/
review-checklist.mdPR review Skill review priority:
Summary, Critical findings, Major findings, Minor findings, Test gaps, Merge recommendation (Block / Approve after fixes / Approve).
$pr-review Review diff between current branch and main.Test writing Skill is useful for fixing team test style.
Test writing process:
Pure functions: prefer unit tests / API behavior: prefer integration tests if existing pattern exists / Bug fixes: add regression tests / UI behavior: follow existing component test pattern
Good Skill is not long but increases task success rate.
Good Skill characteristics:
Bad Skill patterns: scope too broad like "develop well" / include whole project rules in Skill / include AGENTS.md content in Skill / external tool access too broad / long background description only without execution / output format missing so results differ each time
Approach Skill writing in this order:
Skills become important to manage as they grow. If too many Skills are installed, the initial Skill list is limited, so description must be short and clear.
Skill location by use:
Management principles:
Cleanup criteria when Skills grow:
To disable specific Skill, set enabled = false in ~/.codex/config.toml.
Skills transform Codex from "tool you direct every time" to "work agent remembering and reusing team's repeated work methods".
First three Skills worth making:
Beginners don't need to make complex Skills from the start. Just move one frequently-used prompt to SKILL.md, apply it to real work, then gradually polish description, procedure, and output format.
Section 19. Plugins
A Codex Plugin is a bundle of features that Codex can use. One Plugin can contain the following elements:
- Skills
- Apps / connectors
- MCP servers
- Hooks
- Assets
- Plugin manifestIn simple terms:
Skill = Work method
MCP = Connect external tools
Hook = Automatic rules at specific points
Plugin = Skill + MCP + Hook + app integration
bundled as an installable packageBeginners can think of a Plugin as "an additional work pack you install in Codex."
Skills and Plugins look similar but have different roles.
In other words, Skill defines "how Codex should work," and Plugin "makes that work method easy for others to install and use."
Plugin discovery is the process where Codex finds a list of available Plugins to install.
In the Codex app, you can explore curated plugins, plugins shared in your workspace, and plugins you created in the Plugins screen. In the CLI, you can open the plugin browser with the /plugins command after running Codex.
codex
/pluginsThe basic flow for finding plugins is:
There are two ways to use a Plugin.
First, just tell Codex what you want.
Summarize unread Gmail threads from today for me.Second, specify a particular Plugin or bundled Skill.
@Gmail Summarize only the important unread emails from today.Codex can choose the appropriate tool from installed ones even without you specifying the Plugin directly. If you want to use a specific Plugin or Skill, you can specify it with @.
A Plugin marketplace is a JSON catalog containing a list of installable Plugins. Codex can read not only the official curated marketplace but also repo marketplaces, legacy-compatible marketplaces, and personal marketplaces.
Representative locations are as follows:
Official Plugin Directory
$REPO_ROOT/.agents/plugins/marketplace.json
$REPO_ROOT/.claude-plugin/marketplace.json
~/.agents/plugins/marketplace.jsonExamples of personal or team marketplaces are as follows:
{
"name": "team-codex-plugins",
"interface": {
"displayName": "Team Codex Plugins"
},
"plugins": [
{
"name": "team-pr-review",
"source": {
"source": "local",
"path": "./plugins/team-pr-review"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_INSTALL"
},
"category": "Productivity"
}
]
}You can also add a marketplace directly from the CLI.
codex plugin marketplace add owner/repo
codex plugin marketplace add owner/repo --ref main
codex plugin marketplace add https://github.com/example/plugins.git --sparse .agents/plugins
codex plugin marketplace add ./local-marketplace-rootcodex plugin marketplace supports add, list, remove, and upgrade, and can take GitHub shorthand, Git URL, SSH URL, or local marketplace root as the source.
Workspace plugin sharing is the ability to share a Plugin you created with members of the same ChatGPT workspace.
The sharing flow is as follows:
The person who receives the share can find the Plugin in the Shared with you area of the Plugin Directory.
It's good to set operating standards like this:
Personal experimental Plugin → Not shared
Team internal repeated Plugin → Workspace sharing
Standard Plugin by repo → repo marketplace
Organization-wide standard Plugin → managed marketplace or organization policy
Publicly shareable Plugin → Review public / curated distributionA Plugin can include hooks. You can place a hooks/ directory in the Plugin root and include lifecycle hooks configuration in it.
The expected structure is as follows:
my-plugin/
.codex-plugin/
plugin.json
skills/
my-skill/
SKILL.md
hooks/
hooks.json
.mcp.json
.app.json
assets/Plugin hooks are useful in the following situations:
Plugin installation and activation are separate states.
To completely remove an installed Plugin, select uninstall from the Plugin browser.
To keep an installed Plugin but turn it off, you can configure it in ~/.codex/config.toml like this:
[plugins."gmail@openai-curated"]
enabled = falseAfter configuration, restart Codex.
From a management perspective, these criteria work well:
Frequently used Plugin → enabled = true
Occasionally used Plugin → Enable only when needed
Security-sensitive Plugin → Disabled by default
Team standard Plugin → Enable based on repo or workspace standard
Experimental Plugin → Enable only in personal configAt the team level, you shouldn't just keep adding Plugins. Plugins are convenient because they can bundle Skills, MCP, apps, and hooks together, but this also increases security and maintenance responsibilities.
Team operation principles are as follows:
The Plugin manifest is placed in .codex-plugin/plugin.json. This manifest serves three purposes: Plugin identification, connecting bundled components, and providing metadata displayed on the installation screen.
{
"name": "team-pr-review",
"version": "0.1.0",
"description": "Bundle team PR review skills and review automation.",
"author": {
"name": "Engineering Team",
"email": "[email protected]"
},
"repository": "https://github.com/example/team-codex-plugins",
"license": "MIT",
"keywords": ["review", "quality", "pull-request"],
"skills": "./skills/",
"mcpServers": "./.mcp.json"
}New teams don't need to build an elaborate Plugin system from the start. The best sequence is:
When a Plugin isn't working, check systematically. The first thing to verify is the Plugin's installation status.
From the CLI, open /plugins to check installation status.
codex
/pluginsIf not installed, reinstall from the Plugin Directory or marketplace.
If ~/.codex/config.toml shows the following, the Plugin is off:
[plugins."plugin-name@marketplace-name"]
enabled = falseTo use it, change it to true or remove the entry and restart Codex.
Also verify that the marketplace is properly recognized:
codex plugin marketplace listIf using a Git-based marketplace, update to the latest:
codex plugin marketplace upgradeFor a repo marketplace, the location is typically:
$REPO_ROOT/.agents/plugins/marketplace.jsonsource.path must be a relative path from the marketplace root, typically starting with ./.
The correct location for the Plugin manifest is as follows:
my-plugin/
.codex-plugin/
plugin.jsonNote that .codex-plugin/ should contain only plugin.json, while skills/, hooks/, assets/, .mcp.json, and .app.json should be at the Plugin root.
If a Plugin includes external apps like Gmail, Slack, or Google Drive, authentication may be required. Some Plugins require authentication during installation, while others require it on first use.
If the Plugin includes .mcp.json, you should also verify that the MCP server runs normally.
Check items are:
It's safer to use the Plugin in a new thread after installation.
Create work methods with Skills, bundle them as Plugins, and distribute via Marketplace. Share with your team through workspace sharing and manage enable / disable with config.toml.
Recommended first Plugins for beginners:
It's safest to start with a simple Plugin containing just one Skill, then add MCP, hooks, and app integration once you confirm it's actually used repeatedly.
Section 20. Plan Mode and Collaboration
Plan Mode is a mode that makes Codex do the following work before implementation:
1. Understand the requirements
2. Examine related files and structure
3. Ask clarifying questions about ambiguities
4. Propose the scope of changes
5. Plan the execution order
6. Organize risks and verification methods
7. Move to implementation once the user approvesYou can enable Plan Mode with /plan or Shift + Tab.
Basic usage:
codex
/planYou can simply enter /plan or provide the request along with it from the start.
Slash command input:
/plan Create a migration plan to change login logic to OAuth-based.When you enter /plan and press Enter, the current conversation switches to Plan Mode. You can also provide an inline prompt at the same time. However, you cannot use /plan while work is already running.
Direct execution reads and modifies files right away.
Fix the bug where the error message doesn't show on login failure.Plan Mode, on the other hand, designs before implementing.
/plan Review the login failure handling flow and propose a plan to improve the error message display structure.In practice, you can divide as "small fixes by direct execution, structural changes by Plan Mode."
In the following situations, it's better to use /plan first rather than execute directly.
For example, the following requests are better suited for Plan Mode than direct execution:
/plan Create a plan to gradually migrate from REST API to GraphQL./plan Find points where duplicate payments could occur in the current payment flow and create an improvement plan./plan Create a plan to extract a shared UI component package from this monorepo.Conversely, if the scope is small and clear, you can execute directly:
The Button component is missing the disabled style. Add it.Bad request: Too broad, Codex doesn't know what criteria to use to change the structure.
Cleanly refactor this project structure.Good request: Clearly conveys goals and constraints.
/plan It looks like the roles of src/api and src/services are mixed.
Analyze the current structure and create a step-by-step refactoring plan to clean up the service layer
while maintaining the public API.
Include validation commands for each step so tests don't break.In refactoring, "what not to change" is as important as "what to change."
Example constraints:
Don't change public API, DB schema, or route paths,
only clean up the internal structure.The biggest advantage of Plan Mode is turning vague requirements into executable tasks.
Vague state:
The dashboard is too slow, improve it.Create a diagnosis plan with Plan Mode:
/plan Create a dashboard performance improvement plan.
First, don't guess bottlenecks. Organize which files and metrics to look at first.
Ask me clarifying questions if needed.The essence of Plan Mode is "create a plan, then the user reviews and decides whether to execute." After receiving a plan, review it by these criteria:
After review, it's better to divide execution into small units rather than run everything at once:
Good. Execute only Step 1 first. Don't proceed with Step 2 and beyond yet.The plan looks good. But exclude the DB migration and proceed only through service layer cleanup.Execute Steps 1 and 2, report the test results, then stop.This plan is too large. Split it into 3 PRs and reorganize.Following this flow allows you to quickly redirect Codex if it goes off course.
When Codex is running, you can control the workflow with Enter and Tab.
For example, if Codex is creating a plan but missed an important constraint, add it immediately with Enter:
Wait, don't change the public API at all and create the plan again.If you want Codex to review immediately after completing the current task, you can schedule the next command with Tab:
/reviewOr you can queue test execution:
!pnpm testIntervention criteria during work:
To use Plan Mode well, you should let Codex narrow down the problem together with you, rather than demanding immediate answers.
Bad prompt:
Improve the entire structure.Good prompt:
/plan Analyze the current src/modules structure and create a refactoring plan to reduce import cycles.
Keep the public API and route paths unchanged.
First classify candidate files for change and stage them in order of decreasing risk.
Include test commands to run at each step.The basic structure of a collaborative prompt is:
A good prompt clarifies goals and constraints and specifically instructs what to check first and what questions to ask.
A template you can use in real situations:
/plan Create a plan to achieve [goal].
Current problem:
- [Problem 1]
- [Problem 2]
Constraints:
- [What cannot be changed]
- [Behavior to maintain]
Requests:
- First identify related files.
- Ask clarifying questions about unclear points.
- Present a step-by-step plan before implementing.Shows how to write prompts in real situations:
/plan I want to clean up the authentication logic.
Goal:
- Separate login, token refresh, and logout flows
- Maintain existing API response format
- Gradually change so tests don't break
Constraints:
- No DB schema changes
- No public route changes
- Preserve existing refresh token behavior
Requests:
- Classify authentication-related files first.
- Separate risky changes from safe changes.
- Plan to split into 2-3 PRs.Plan Mode is particularly useful when bottlenecks are unclear, like performance improvements:
/plan I want to improve dashboard initial load speed.
Goal:
- Reduce first-screen render time
- Remove unnecessary API calls
- Minimize UX changes
Constraints:
- Don't change the design
- Maintain API contract
Requests:
- First create an investigation plan to find bottleneck candidates.
- Propose measurable metrics.
- Don't implement right away. First tell me what data to check.Technical migration has large scope and risk, so Plan Mode is essential:
/plan Create a plan to migrate the test environment from Jest to Vitest.
Constraints:
- Don't change all tests at once
- Have a parallel period so CI doesn't break
- Identify jest-specific mock usage points first
Output:
- Impact scope
- Step-by-step migration plan
- Risk factors
- PR separation plan
- Verification commandsUse based on task complexity:
Splitting into multiple steps allows you to quickly redirect even if direction goes wrong.
When summarized to one sentence, the concept of Plan Mode is:
Just following this principle lets you use Codex much more safely and predictably.
Plan Mode is a collaboration mode for safely handling complex tasks. It's not just making Codex think longer, but allowing the user to review work direction, reduce risks, and control execution units.
By following the flow of planning → scope adjustment → step-by-step approval → verification → proceed to next step, you can quickly redirect Codex if it goes off course.
Section 21. Goal Mode
Goal Mode is a feature that makes Codex continue multiple stages of work based on a single persistent goal. If Section 20's Plan Mode is a "mode for creating a plan first," Goal Mode is more like a "mode for pushing that plan through to completion."
The basic form is:
/goal Finish the migration and keep tests greenKorean example:
/goal Complete the authentication refactoring and proceed until all related tests pass.Goal Mode is particularly suitable for the following types of work:
The key is "one work session" but rather "a long-term goal with completion conditions."
A good goal must have completion conditions.
/goal Improve the code.This goal is too broad—it's hard to know what to improve or when it's done.
/goal Resolve all type errors in the payment module and reach a state where
pnpm test:payment and pnpm lint pass.This goal clearly includes objective, scope, and completion conditions.
A template for writing goals clearly:
/goal Complete [work goal].
Scope:
- [Target files/modules/features]
Completion conditions:
- [Test command] passes
- [Build command] passes
- [Documentation update]
- [Report diff summary]
Constraints:
- [What cannot be touched]
- [API to maintain]
- [Disallowed changes]/goal Improve accessibility issues on the user settings page.
Scope:
- src/pages/settings
- src/components/settings
Completion conditions:
- Keyboard navigation possible
- Resolve missing aria-label issues
- pnpm test settings passes
- Summarize changed files and reasons at the end
Constraints:
- Don't change design tokens
- Keep route paths the sameCreate a goal using the format /goal <objective> from CLI or app composer.
/goal Finish the Vitest migration and keep CI green.Korean example:
/goal Complete the first-phase Jest to Vitest migration,
proceeding until existing tests pass.To check the current goal, enter /goal without arguments:
/goalGoal objective allows up to 4,000 characters. For longer instructions, it's recommended to write them in a separate file and reference it in the goal:
/goal Proceed with Vitest migration based on the completion conditions in docs/goals/vitest-migration.md.To temporarily stop Goal Mode while it's running, use /goal pause:
/goal pauseSituations where pause is needed:
/goal pause
Summarize the files changed so far and remaining work.Resume goal — To restart a stopped goal, use /goal resume:
/goal resumeWhen resuming, provide any conditions you've adjusted:
/goal resume
However, exclude Step 3 and proceed only through stabilizing current changes' tests.Clear goal — To remove the current goal, use /goal clear:
/goal clearClear a goal when: objectives change, want to use the thread for different work, goal is set too broadly, already completed, or want to restart with a new Plan Mode flow.
To change goals, clearing the old one then setting a new one is clearest.
Recommended flow for long-term work:
/plan./goal./goal pause if needed./goal resume./goal clear after completion./plan Create a Jest to Vitest migration plan.
But start with packages/auth using a step-by-step plan, not changing everything at once.
After reviewing the plan:
/goal Migrate Jest tests in packages/auth to Vitest and
proceed until pnpm test --filter auth passes.
Constraint: Don't change shared test utilities yet, only allow changes within the auth package./goal Complete v2.3.0 release preparation.
Completion conditions:
- Write initial changelog
- Identify version bump candidates
- Check for breaking changes
- pnpm test passes
- Write initial PR description
Constraints:
- Don't actually create tags or publish/goal Repeatedly improve prompts and test cases until eval score is 0.85 or above.
Completion conditions:
- npm run eval passes
- score >= 0.85
- Summarize modified prompts and failure casesFor difficult work, it's effective to provide an evaluation system or script and have Codex iteratively improve until the score is good enough.
Control with slash commands:
/goal <objective>
/goal
/goal pause
/goal resume
/goal clearIf you don't see /goal, enable the feature flag in config.toml:
[features]
goals = trueOr:
codex features enable goalsEnter /goal in the composer. When Goal is active, a progress row appears above the composer, and you can control pause, resume, goal editing, and clear with buttons.
Goal Mode is also available in IDE extensions. It's good to give goals based on open files, selections, diagnostics, and test failures.
/goal Resolve type errors in the currently open checkout flow and
proceed until this module's tests pass.Narrowing the scope is important in the IDE.
/goal Fix all type errors in the entire project./goal Resolve type errors in src/features/checkout and
proceed until pnpm typecheck --filter checkout passes.Goal Mode is a feature that gives Codex a persistent goal to achieve and makes it continue multiple stages of work based on completion conditions.
Best usage pattern:
Basic sentence beginners can use right away:
/goal Complete [task] and proceed until [verification command] passes.
Constraint: Maintain [what cannot change].Section 22. Memory System
Codex memory is a local recall system that lets Codex remember useful information from past threads and apply it to future work. For example, if you remember the tech stack you frequently use, your preferred workflow, project conventions, common mistakes, and frequently used commands, you don't need to repeat the same explanations in every new session.
When memory is enabled, Codex remembers these recurring patterns and can reference them in similar future tasks.
For example, you don't need to say this every time:
This project uses pnpm.
Run tests with pnpm test, not npm test.
Don't edit DB migration files directly; add a new migration instead.
API response types must be updated in zod schema first.However, memory is more like "a helpful recall layer" rather than "a rules file". Rules that must be followed, build commands, forbidden actions, and security guidelines should go in AGENTS.md or repository documentation, not memory.
Official documentation also recommends storing essential team guidelines in AGENTS.md or checked-in documents, and treating memory as a local recall layer only.
The part that confuses beginners most is the role difference between memory and AGENTS.md.
AGENTS.md is explicit guidance you give to Codex. You manually write work rules, coding styles, test commands, forbidden actions, and review criteria that are in your project.
On the other hand, memory is a system where Codex stores information it repeatedly judged as useful from previous sessions. It's not a document where you directly declare "follow this rule without fail," but rather a way for Codex to reference what it learned from past context in future sessions.
As a beginner, you can remember it this way:
If it must be followed → AGENTS.md
If you reference it repeatedly → memory
If the whole team needs to know → AGENTS.md
If it's your personal habit → memoryMemory is most useful when it reduces repetitive context you get tired of explaining.
I always want a plan first before making changes.
Break large changes into small diffs.
Answer in Korean but keep code comments in English.This repository uses pnpm workspace structure.
Frontend is in apps/web, backend is in services/api.
Tests are run per package, not from root.Don't edit generated files directly in this project.
Always re-run codegen after schema changes.
Add timestamp prefix to migration file names.Memory helps when you're refactoring over multiple days or continuing a specific module's design direction. After memory is enabled, Codex can create useful context from eligible prior threads into local memory files, skip short-lived or active sessions, and memory updates may be processed in the background rather than immediately.
There's also an advanced feature called Chronicle. Chronicle is an opt-in research preview feature that combines Codex's memory functionality with screen context to help it better remember recent work flows.
However, it requires Screen Recording and Accessibility permissions on macOS, can quickly consume rate limits, and increases risks of prompt injection and sensitive information exposure.
Memory is convenient, but storing everything isn't always good. If wrong memories accumulate, Codex can repeatedly make incorrect assumptions.
For example, if you used npm before but switched to pnpm now, outdated information in memory could interfere with your work. In this case, you should review or delete the memory.
Skip tests only for this task.
Use mocks quickly for today.
Ignore type errors on this branch for now.It's risky to keep this in memory. A "for this time only" decision can act like a long-term rule.
Codex memory settings have an option to exclude threads that use external context like MCP tool calls, web search, and tool search from memory generation. The official config key is memories.disable_on_external_context, which helps prevent temporary information from external tools from becoming permanent memory.
We recommend the following settings for beginners:
[features]
memories = true
[memories]
use_memories = true
generate_memories = true
disable_on_external_context = true
min_rate_limit_remaining_percent = 20This configuration uses memory but excludes threads with mixed external context from memory generation, and reduces memory generation when rate limit is too low.
In team projects, don't use memory as a "team rules repository." Content that the whole team must follow should go in these locations:
AGENTS.mdREADME.mdCONTRIBUTING.mddocs/Memory defaults to local state, so it can differ per team member. Relying only on memory for team rules reduces reproducibility.
Here are the standards for safe memory use in teams:
The following content is good to put in AGENTS.md:
# AGENTS.md
## Test commands
- Frontend: pnpm --filter web test
- API: pnpm --filter api test
- Typecheck: pnpm typecheck
## Rules
- Do not edit generated files directly.
- Do not commit .env files.
- Ask before adding new production dependencies.On the other hand, these are personal preferences okay to keep in memory:
I want a change scope summary before refactoring.
Explain in Korean but keep code identifiers as-is.
After work, summarize focusing on diff so I can review.In teams, use AGENTS.md as the reference document, not memory, and treat memory only as a personal productivity aid.
Memory should never contain sensitive information. Although Codex can redact secrets during memory generation, official documentation warns to always review memory files or generated memory artifacts before sharing.
Memory files are stored by default under Codex home, with the default path being ~/.codex/memories/.
Information that should absolutely never be kept in memory includes:
API keys
access tokens
passwords
DB connection strings
Customer personal information
Sensitive content from internal incident reports
Non-public contract information
Security vulnerability exploit detailsMemory-related files should be treated as generated state. You can open them to debug issues or before sharing a Codex home directory, but you shouldn't depend on direct editing as your normal control method.
If you want to adjust memory usage in the current thread, you can use /memories in Codex app or TUI. This command controls whether the current thread uses existing memory and whether the current thread can be used for future memory generation. However, thread-level choices don't change global memory settings.
To use safely in practice, follow these 6 principles:
Memory is a feature that helps Codex reduce repetition for you. But rules that must be followed should go in AGENTS.md, not memory. Never keep sensitive information in memory.
Section 23. Session Management
In Codex, session is not just a chat history but rather a workspace for continuing a specific task.
Beginners can understand session like this:
session = One unit of work being conducted with CodexFor example, these should be separated into different sessions:
Session A: Fix login bug
Session B: Refactor payment API
Session C: Clean up README docs
Session D: Analyze test failure causeWithin one session, files Codex has seen, your instructions, commands Codex executed, code Codex modified, and decisions made accumulate.
Thread is the actual conversation flow between Codex and you. A thread is a conversation between you and the Codex agent, containing multiple turns. Each turn is one user request and the agent's corresponding work.
Structurally, it looks like this:
Thread
├─ Turn 1: "Explain this project structure"
│ ├─ User message
│ ├─ Agent message
│ └─ File reads
│
├─ Turn 2: "Fix the login bug"
│ ├─ User message
│ ├─ Shell command
│ ├─ File edit
│ └─ Agent summary
│
└─ Turn 3: "Run tests too"
├─ User message
├─ Test command
└─ Result summaryAs a beginner, you don't need to strictly distinguish between session and thread. But in practice, this way of thinking helps:
resume is a feature that recalls a previously saved conversation and continues it.
In CLI, use it like this:
/resumeEntering /resume opens a saved session picker, and you can recall the transcript of your chosen conversation and continue while maintaining the original history.
Usage example:
Recall the login bug fix session from yesterday with /resume.
Codex maintains what files it saw and what decisions it made previously.
Then request "Add tests based on the part you fixed earlier."When to use resume is clear:
Conversely, if you're starting something completely different, /new is better than resume.
fork is a feature that duplicates the current conversation and branches into a new thread. /fork duplicates the current conversation into a thread with a new ID, letting you experiment with different approaches in parallel while keeping the original transcript intact.
In CLI, use it like this:
/forkFork is most useful in these situations:
For example, if fixing a login bug, the original thread can do minimal fixes for just the bug, while the fork thread can try refactoring the entire auth logic.
Recommended patterns when forking:
Example of starting a forked thread:
In this fork, don't keep the previous fix direction.
Based on the auth middleware, propose a more structural solution.
But don't edit files yet—just write a plan.compact is a feature that summarizes earlier parts of a long conversation to make context lighter.
In CLI, use it like this:
/compact/compact replaces earlier turns with a concise summary after a long conversation, preserving important content while gaining context.
Core concept for beginners to understand:
Good times to use compact:
It's safer to request this before compact:
Summarize key decisions, modified files, remaining work, and cautions so far.
Then I'll run /compact.After compact, it's good to re-anchor work criteria with the next message:
Continue based on the summary just compressed.
Current goal is to return 401 instead of 500 on login failure.
Limit modification scope to auth middleware and related tests.Codex can hold much information within a thread, but it doesn't remember infinitely. As conversations grow longer, important information gets buried, or old exploration can interfere with current work decisions.
Context window management means three things:
Good and bad examples:
Bad way:
"Look at the whole project and find and fix the problem."Good way:
"Focus on src/auth and tests/auth to find why login fails with a 500.
First list no more than 3 candidate causes, and show me a plan before making changes."This routine is effective for long work:
When conversation gets long, it's good to have Codex create a work status report first:
Recommended prompt:
Summarize the work so far in this format:
1. Original goal
2. Files reviewed
3. Cause identified
4. Changes made so far
5. Remaining work
6. Test execution and results
7. Cautions for continuing this work next timeAfter writing a work status report, choose based on situation:
Patterns to avoid:
Useful prompts for wrapping up a thread:
Write a final summary so I can wrap up this thread.
Include:
- Changed files
- Key changes
- Tests run
- Remaining risks
- Draft commit messageSplitting sessions by work unit is safest. Recommended criteria:
Real-world example of running multiple sessions in parallel:
Session 1: auth-login-bugfix
- Fix login failure 500 error
- Add related tests
- Minimum change principle
Session 2: auth-refactor-experiment
- Improve auth middleware structure
- Separate from original bug fix
- Use fork or separate worktree
Session 3: auth-docs-update
- Update README and API docs
- Separate from code changesCodex app is a desktop environment focused on handling multiple threads in parallel, and for long work it's good to be clear about the boundary between local threads and cloud tasks.
Core slash commands for session management:
Session management is key to using Codex efficiently. It's important to distinguish between session and thread, and choose the right tool for each work type.
The most important principle is one:
Use /resume when work continues, /fork when direction branches, /compact when conversation grows long, and /new when work completely changes.
Section 24. Non-Interactive Mode: codex exec
codex exec is a command to run Codex in non-interactive mode. While normal codex opens an interactive TUI inside the terminal, codex exec passes a prompt once, Codex does the work, and outputs results.
Basic form:
codex exec "Summarize this repository structure and tell me 5 risky areas"Short form:
codex e "Review recent changes for me"Beginners can understand it like this:
codex exec is especially useful in these situations:
The biggest difference between interactive TUI and codex exec is whether a human intervenes mid-way.
Core standard:
The most basic usage is passing a task instruction as a string:
codex exec "Read the README and summarize this project's purpose in 5 sentences"Code review:
codex exec "Review current git diff and point out only high-likelihood bugs"Analyze test failure log:
npm test 2>&1 | codex exec "Summarize the test failure cause and suggest the smallest fix direction"If stdin is piped and a prompt argument exists at the same time, the prompt is used as an instruction and piped content as additional context.
Good prompt examples:
codex exec "Review current changes.
Output format:
1. Potential fatal bugs
2. Missing tests
3. Security risks
4. Fix priority
Don't modify code, just review."To actually modify files, specify sandbox permissions:
codex exec --sandbox workspace-write \
"Reproduce the failing test and fix it with the smallest code change to pass"codex exec result goes to stdout, so it works well with redirection or tee. Progress is streamed to stderr during execution, and only the final agent message is output to stdout.
Save release notes to file:
codex exec "Write release notes based on the last 10 commits" \
> release-notes.mdSave to both screen and file:
codex exec "Review current changes" \
| tee codex-review.mdWrite final message to file with -o option:
codex exec "Summarize project metadata" \
-o project-summary.mdAutomation pattern:
mkdir -p reports
codex exec "Review current git diff and summarize risk level" \
-o reports/codex-review.mdAutomation often needs output that machines can process more easily than human-readable text. Use --json for this:
codex exec --json "Summarize repository structure" | jqWith --json, stdout becomes JSON Lines (JSONL) stream, where you get events like thread.started, turn.started, turn.completed, turn.failed, item.*, error.
--jsonExample:
codex exec --json "Review current changes" \
> codex-events.jsonlJSONL format (one JSON object per line):
{"type":"thread.started","thread_id":"..."}
{"type":"turn.started"}
{"type":"item.completed","item":{"type":"agent_message","text":"..."}}
{"type":"turn.completed","usage":{"input_tokens":1000,"output_tokens":200}}Extract specific events only in CI:
codex exec --json "Analyze test failure cause" \
| jq -r 'select(.type=="item.completed")'Important: --json gets the entire execution process as event stream; it's not for enforcing final result structure. To fix final result fields, use --output-schema in the next section.
--output-schema makes Codex's final response conform to a specified JSON Schema. Use when downstream automation needs stable fields.
For example, if you want review results in this structure:
{
"risk_level": "low | medium | high",
"summary": "string",
"issues": ["string"],
"recommended_action": "string"
}Create a schema file (schemas/review.schema.json):
{
"type": "object",
"properties": {
"risk_level": {
"type": "string",
"enum": ["low", "medium", "high"]
},
"summary": { "type": "string" },
"issues": {
"type": "array",
"items": { "type": "string" }
},
"recommended_action": { "type": "string" }
},
"required": ["risk_level", "summary", "issues", "recommended_action"],
"additionalProperties": false
}Then run:
codex exec "Review current git diff and assess risk level" \
--output-schema schemas/review.schema.json \
-o reports/review.jsonGood for: PR auto-review, release notes metadata, test failure classification, security risk classification, issue triage results.
Difference between --json and --output-schema:
--json--output-schema-oUse all three options together:
codex exec --json \
"Review current changes and write results conforming to schema" \
--output-schema schemas/review.schema.json \
-o reports/review.json \
> logs/codex-events.jsonlMain purposes for using codex exec in CI/CD:
GitHub Actions example:
name: Codex Review
on:
pull_request:
jobs:
codex-review:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test 2>&1 | tee test.log
- name: Analyze test result with Codex
env:
CODEX_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
cat test.log | codex exec \
"Analyze the test log for failure cause and suggest minimal fix direction" \
-o codex-test-analysis.md
- name: Upload Codex report
uses: actions/upload-artifact@v4
with:
name: codex-test-analysis
path: codex-test-analysis.mdSecurity note: Don't put OPENAI_API_KEY or CODEX_API_KEY in job-wide environment variables. Build scripts, tests, dependency lifecycle hooks, and compromised actions can read the same job environment variables.
Safer structure:
Script to run repeatedly locally (scripts/codex-review.sh):
#!/usr/bin/env bash
set -euo pipefail
mkdir -p reports
echo "[1/3] Collecting git diff..."
git diff --stat > reports/diff-stat.txt
git diff > reports/diff.patch
echo "[2/3] Running Codex review..."
codex exec \
--sandbox read-only \
"Based on reports/diff.patch, review the changes.
Don't modify code, just write the following:
1. Summary of key changes
2. Potential bugs
3. Missing tests
4. Security risks
5. Checklist before merge" \
-o reports/codex-review.md
echo "[3/3] Done."
echo "Report: reports/codex-review.md"Grant execute permission and run:
chmod +x scripts/codex-review.sh
./scripts/codex-review.shScript for analyzing test failures:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p reports
npm test 2>&1 | tee reports/test.log || true
cat reports/test.log | codex exec \
--sandbox read-only \
"Analyze this test log.
Output:
- Failed tests
- Direct cause
- Most likely code location
- Minimal fix direction
- Commands to check further" \
-o reports/test-analysis.mdAuto-fix script allowing file modification (needs more care):
codex exec \
--sandbox workspace-write \
"Run npm test, reproduce the failure, and fix it with minimal changes to pass.
Don't do unrelated refactoring.
Run npm test again after fixing."Production requirements: verify working directory is clean, clearly limit modification scope, specify test command, human reviews diff results, CI saves only patches as artifacts.
codex exec is used in automation, so permission settings are critical. Default sandbox is read-only, use --sandbox workspace-write to allow file changes, or --sandbox danger-full-access for broader access.
Recommended combinations:
read-only + neverread-only + neverread-only + neverread-only + neverworkspace-write + neverworkspace-write + neverdanger-full-access + neverConfig example:
sandbox_mode = "read-only"
approval_policy = "never"Separate profile for file modification:
# ~/.codex/ci-fix.config.toml
sandbox_mode = "workspace-write"
approval_policy = "never"
model_reasoning_effort = "medium"Run:
codex exec --profile ci-fix \
"Reproduce failing test and fix with minimal changes to pass"Combinations to avoid:
danger-full-access on local production projectsworkspace-write with vague promptsFrequently used commands:
codex exec "Summarize current repository structure"
codex e "Review current changes"
codex exec "Write release notes" -o release-notes.md
codex exec --json "Analyze repository" > codex-events.jsonl
codex exec --sandbox workspace-write \
"Fix failing test with minimal changes"Most important principles:
read-only for read tasksworkspace-write for modification tasksdanger-full-access only in isolated environmentsSection 25. Codex Cloud and Background Tasks
Codex Cloud is a way to have Codex read, modify, and run commands in an isolated cloud environment provided by OpenAI, rather than on your local computer.
Beginners can understand it this way:
Local Codex = Codex working on my computer
Codex Cloud = Codex working in a cloud containerWhen Codex Cloud is useful:
A Codex thread can run locally or in the cloud.
A cloud task is a unit of work you delegate to Codex to perform in the cloud.
Most basic flow:
In CLI, use codex cloud command.
Basic usage:
codex cloud exec --env ENV_ID "task description"Example:
codex cloud exec --env ENV_ID \
"Fix login to return 401 instead of 500 on failure and add related tests"To get multiple solutions, use --attempts. (Range: 1~4)
codex cloud exec --env ENV_ID --attempts 3 \
"Suggest and implement safer improvements to payment failure retry logic"A good task prompt is specific and states conditions clearly.
Goal:
Fix the issue where the server returns 500 on login failure.
Conditions:
- Focus on auth middleware and related tests
- No unrelated refactor
- Run tests after fixing
- Include changed files, test results, and remaining risks in result summaryYou can check recent cloud tasks from the terminal.
Basic command:
codex cloudThis opens an interactive picker to browse active and finished tasks.
View recent task list:
codex cloud listCheck specific environment or JSON format:
codex cloud list --limit 10
codex cloud list --env ENV_ID
codex cloud list --env ENV_ID --jsonWhen a cloud task is done, review the diff before merging right away.
Apply the diff locally using the codex apply command.
Basic form:
codex apply TASK_ID
codex a TASK_ID # short aliasRecommended flow:
git status
git stash push -m "before applying codex cloud task"
codex apply TASK_ID
git diff
npm testA major advantage of Codex Cloud is that results can be turned into PRs.
Recommended PR flow:
Before creating a PR, always check:
GitHub integration also allows calling via PR comment:
@codex fix the CI failures
@codex fix the P1 issueCodex Cloud is better suited for "work where I delegate a clear goal" than "work where I need to keep watching".
Good examples:
Codex Cloud can work in the background and run multiple tasks in parallel.
Good parallel task example:
Avoid parallel work: Modifying the same file simultaneously can cause diff conflicts or directional conflicts.
Codex Cloud is powerful, but because it "runs in the cloud," there are different precautions than local Codex.
Key precautions:
Some Codex Cloud CLI features may be marked experimental.
To use cloud tasks reliably, follow these principles:
Most frequently used Codex Cloud commands:
# Explore cloud tasks
codex cloud
# Create cloud task
codex cloud exec --env ENV_ID "task description"
# Request multiple solutions
codex cloud exec --env ENV_ID --attempts 3 "task description"
# Recent task list
codex cloud list
# Check task list as JSON
codex cloud list --json
# Apply completed cloud task diff locally
codex apply TASK_ID
codex a TASK_ID # short aliasCodex Cloud is a powerful tool for speeding up development. But understanding cloud environment characteristics, writing specific task prompts, and maintaining a habit of always reviewing results are important.
Section 26. Codex Desktop App
Codex Desktop App is a desktop work hub for managing Codex work in one place. It's a focused desktop experience for handling multiple Codex threads in parallel, providing built-in worktree support, automations, and Git functionality.
Beginners can understand it this way:
Desktop App is especially useful when:
The core advantage of Desktop App is managing multiple tasks simultaneously. You can run tasks from multiple projects in one Codex app window and switch between codebases by adding each as a project.
For example, you can divide it like this:
Project A: trading-dashboard
- Thread 1: Fix chart rendering bug
- Thread 2: Analyze test failures
- Thread 3: Update README
Project B: api-server
- Thread 1: Fix auth middleware
- Thread 2: Review rate limit logicGood usage patterns:
Worktree is a feature that lets Codex work independently in a separate checkout without touching your current work. It allows you to run multiple independent tasks in the same project in parallel without interfering with each other.
Beginners can understand it this way:
Example: You're fixing the payment screen locally, and want Codex to strengthen login tests—worktree is great for that.
Recommended criteria:
Desktop App's review pane is where you visually verify Codex's changes and accept only what you need. It's where you understand what Codex changed, give targeted feedback, and decide what to keep.
Things you can do in review pane:
Especially important is inline comments. Specific feedback on diff lines helps Codex understand your intent more precisely than general instructions.
Good review prompt example:
Reflect only my inline comments.
Don't do unrelated refactoring,
and run tests after fixing.Practical workflow:
Each thread in Desktop App has a built-in terminal scoped to the current project or worktree. It verifies changes, runs scripts, performs git work, and Codex can read current terminal output and reference failed builds or running dev servers.
Typical commands you run:
git status
npm test
npm run lint
npm run dev
git diffThe advantage of this approach is creating a "modify → run → check failure → remodify" loop on the same screen without opening CLI separately.
You can also use conversation forking in Desktop App. Fork when you need to:
Example: Original thread solves login bug with minimal edits, fork thread refactors auth middleware structure.
First request after fork should be clear:
In this fork, discard the minimal edit approach,
and explore simplifying auth middleware structure itself.
Write only the plan first, don't modify files.Floating pop-out window brings the current thread to a separate small window you can stick near your work. Useful when doing quick iteration near browser, editor, or design preview.
Frontend work layout example:
Left: Code editor
Right: Browser preview
Top small window: Codex pop-out threadRecommended prompt style:
I'm looking at this component's mobile layout.
I'll give you feedback while checking in the browser,
so limit changes to ButtonGroup.tsx and related CSS.Desktop App's automations schedule recurring tasks to run in background. You can automate recurring work in background, add findings to inbox, or auto-archive if nothing to report.
Usage examples:
Running automation in worktree is safer because it won't conflict with your unfinished local work.
Good automation prompt example:
Every Monday morning, summarize this project's recent changes.
Output:
1. Major changed files
2. Parts with test failure risk
3. Parts needing documentation updates
4. Work needing follow-up
Don't modify code, just write the report.Appshots is a feature on macOS that sends the currently foremost app window to Codex thread. Note that Appshots contain screen info, so it's safer not to capture windows showing account info, tokens, customer data, or personal info.
Desktop App has an in-app browser where you can preview web apps and visually comment. Use it to review local dev servers, file-backed previews, or public pages without logging in, while viewing together in thread. Enable browser use lets Codex directly click, input, inspect, and screenshot within the in-app browser.
Computer Use lets Codex see, click, and type in macOS or Windows apps. Useful for desktop app testing, browser or simulator flow verification, and GUI-only bug reproduction.
CLI is fast and light. But Desktop App excels at managing multiple tasks visually, reviewing diffs, and bundling browser, terminal, Git, and automation on one screen.
Typical Desktop App flow: Add project → Create thread per task → Start risky work with worktree → Write plan → Implement → Test in terminal → Review diff in review pane → Fix with inline comments → Stage only needed changes → Commit/push or create PR
Codex Desktop App = local work hub managing Codex work in parallel
Most important principles:
Section 27. IDE Extension
Codex is not just a CLI tool. You can extend the same Codex work to these environments:
IDE Extension → Connected to code you see
Chrome → Connected to logged-in websites
GitHub Action → Connected to CI/CD
SDK → Connected to your custom automation systemSo section 27 is understood this way:
IDE Extension is how you connect Codex inside your code editor.
In CLI, Codex works based on project folder. But in IDE, these naturally become context:
Currently open files
Selected code
Active editor
Project folder
Current working branch
Diagnostics info in IDESupported flow breakdown:
Installation flow is similar across all three IDEs.
1. Install Codex Extension in IDE
2. Open Codex sidebar
3. Log in with ChatGPT account or API Key
4. Open project folder
5. Request work based on current file or whole repoOn first use, it's better to make Codex understand project before delegating file modifications.
Explain this project's structure.
Don't modify files first,
just summarize main folders and execution flow.When requesting based on current file, write it this way:
Based on the currently open file,
review the error handling flow.
Show root causes and fix plan before modifying.Even if Cursor or Windsurf have built-in AI, it's better to use Codex for heavier agent work.
agent mode is when Codex doesn't just answer but directly reads, modifies files, and runs commands.
Good use cases:
Find bug root causes
Edit multiple files together
Add tests
Perform refactoring
Analyze build failuresGood request example:
Find the issue where login returns 500 on failure.
Limit changes to auth files and tests.
Show plan first, fix after approval.Bad request example:
Review whole project and fix it.In agent mode, always specify these three things:
Clear request example:
Goal:
Fix signup failure showing empty error message
Scope:
src/auth, src/components/signup, tests/auth
Verification:
npm test -- authinline edits is requesting Codex to modify a specific code block or your current selection.
Inline edit is better than agent mode for small changes:
Function name change
Simplify conditionals
Fix type errors
Clean up comments
Add small validationExample:
Keep function behavior, just
reduce duplicate conditionals.
Don't change function signature.Key principle in inline edit: specify "don't expand work beyond selection".
Edit only within selection.
Don't touch other files.Better to view Codex CLI, Desktop App, IDE Extension, and Cloud not as completely separate, but as multiple surfaces of same workflow.
codex exec or GitHub ActionFor example, you can move like this:
Find bug in IDE
→ Request root cause analysis
→ Delegate to Cloud if work grows
→ Apply result diff in IDE
→ Run tests in local terminal
→ Automate recurring work in CIThe biggest advantage of IDE Extension is you can delegate work to Codex based on "the file I'm viewing now".
Good pattern:
1. Open file with issue.
2. Select related code.
3. Request explanation from Codex based on current file.
4. Get plan before fixing.
5. Get small diff to fix.
6. Run tests.Example for currently open file:
Find why useEffect runs multiple times unnecessarily in this open file.
Don't edit yet,
just tell me root cause candidates and fix direction.Fix request:
Fix only the 2nd cause you explained.
Don't change component structure,
just minimal dependency array and state update flow changes.Best way to use Codex in IDE is the modify → compile → test → pass failure log → remodify loop.
1. Request modification from Codex
2. Run test in IDE terminal
3. Check failure log
4. Pass failure log to Codex
5. Request minimal fix
6. Test againPrompt example:
Fix based on the TypeScript error in terminal.
Don't bypass type with any,
match existing type structure.Test failure analysis example:
Review this test failure log,
organize 3 or fewer root causes.
Then fix most likely cause with minimal changes.This way is especially good for beginners because instead of having Codex make big code changes once, you create small validation loops.
Codex for Chrome lets Codex use websites in Chrome browser.
Beginners can understand it this way:
Good tasks to use:
Check settings in admin console
Read data on dashboard
Edit content in CMS
Perform recurring work in internal tools
Check logged-in web app stateChrome Extension is for website work, IDE Extension is for code work.
Example flow:
1. Reproduce dashboard bug in Chrome
2. Describe screen state to Codex or request action
3. Check root cause candidates
4. Modify related code in IDE
5. Check screen in Chrome againBe aware that browsers contain sensitive info:
Customer data
Admin permissions
Payment info
Internal metrics
Personal info
Session cookiesSo it's better to give Chrome Extension minimal permissions per site and disallow unnecessary sites.
GitHub Action is how you connect Codex to CI/CD pipeline. openai/codex-action@v1 runs Codex in GitHub Actions workflow and can apply patches or post reviews.
Typical use cases:
PR auto-review
Analyze test failures
Issue triage
Generate release notes draft
Summarize security risks
Check doc update gapsSimple flow:
1. Create PR
2. Run GitHub Action
3. Use codex exec to analyze diff or test log
4. Save result as comment or artifact
5. Final human checkMost important principle in CI is security:
Don't indiscriminately expose API key to whole job.
Don't inject secret before repository-controlled script runs.
Give write permission only to needed jobs.
Don't auto-merge Codex fix results.In CI, non-interactive codex exec fits better than interactive codex.
Example:
codex exec "Review current git diff and summarize only potential bugs"Test log analysis:
npm test 2>&1 | tee test.log
cat test.log | codex exec \
"Analyze this test failure log,
summarize root causes and minimal fix direction" \
-o codex-test-analysis.mdFor PR review:
git diff origin/main...HEAD | codex exec \
"Review this PR diff.
Output:
1. Fatal bug possibilities
2. Missing tests
3. Security risks
4. Items to check before merge" \
-o codex-review.mdRecommended default combination in CI:
Review/analysis work → read-only
Patch generation → workspace-write
Auto-merge → not recommended
approval_policy → neverCodex SDK is how you call Codex inside your own Python or TypeScript program, rather than via CLI or IDE.
Beginners can understand it this way:
When SDK is needed:
Build in-house code review bot
Create automatic test failure analysis system
Automate issue triage
Build refactoring pipeline
Interpret security scan results with Codex
Connect custom dashboard to CodexExample structure:
1. Python script reads GitHub issue.
2. Create thread with Codex SDK.
3. Pass issue content and related files as context.
4. Codex returns analysis.
5. Script saves as comment or report.CLI is enough for:
Personal automation
Simple review
Test log summary
Release note generationSDK is needed for:
Need to traverse multiple repos
Need to save results to DB
Need to connect to internal systems
Need to manage per-user permissions, state, history
Need to operate defined workflow like a productDon't use all four at once. Better to expand in this order:
Best first routine for beginners:
1. Open project in VS Code.
2. Open Codex Extension.
3. Request explanation based on current file.
4. Delegate only small edits.
5. Test in IDE terminal.
6. Pass failure log to Codex again.
7. Review diff directly.
8. Expand to Cloud, Chrome, CI when comfortable.Most important criterion is:
Section 28. Operational Optimization: Performance, Debugging, Security, Enterprise
Operating Codex well doesn't just mean "making it answer faster." The real goal is to satisfy four things simultaneously.
Codex settings are decided at multiple layers: user config, project config, profile, system config, and managed requirements. The priority order is CLI flag and override (highest), then project config, profile, user config, system config, and built-in default (lowest).
Codex slowing down isn't always because the model itself is slow. Most of the time it's because input context is too large, the task scope is unclear, tool output is too long, or MCPs, files, and logs are attached excessively.
When noisy output accumulates in long conversations, context pollution and context rot occur, lowering session reliability. It's better to keep core requirements and decisions in the main thread, and separate noisy work like exploration, testing, and log analysis into subagents or separate threads.
The context window is the working memory space where Codex refers to when judging current work. More isn't always better—putting in just the right information is what matters.
Look at this entire repo and find and fix performance issues.Focus on src/api/orders and tests/orders,
and find the cause of slow order creation API.
First, organize just 3 or fewer bottleneck candidates without modifying files./compact summarizes long conversations to clean up context. It doesn't delete the conversation—it replaces older turns with summaries, keeping only important information.
@file is a powerful way to explicitly put specific files into context. But attaching too many files makes Codex take longer to find important information and increases costs.
@src Look at the whole thing and find the issue.@src/auth/middleware.ts
@src/auth/session.ts
@tests/auth/session.test.ts
Focus on these three files and look at the login expiration handling issue.
First organize just the root cause candidates without fixing.MCP is the standard way to connect Codex with external context outside the repo. Use MCP when the needed context is outside the repo, changes frequently, or repeated integration is required. Don't attach all tools from the start—begin with 1-2 tools that actually remove workflow friction.
[mcp_servers.github]
enabled = true
[mcp_servers.figma]
enabled = false
[mcp_servers.sentry]
enabled = falseIn practice, it's good to divide profiles by work nature.
Create each profile as a separate TOML file and apply with --profile profile-name. This way you activate tools only when needed while maintaining baseline performance.
Test logs, build logs, grep, find, npm test, pytest output easily become thousands of lines. If you give all raw output as-is, things slow down and important failure causes get buried.
# Pass only the last 120 lines instead of the entire log
npm test 2>&1 | tail -n 120
# Pass only around the failure line
pytest 2>&1 | grep -A 20 -B 10 "FAILED"
# Save only TypeScript errors
npm run typecheck 2>&1 | grep "error TS" > ts-errors.logYou can tell Codex: "Don't try to read all the logs. Find the root cause based on the failed test names, first stack trace, and related file paths."
For quick iteration work, you don't always need the highest reasoning effort. Codex's fast mode increases speed in exchange for higher credit rate usage.
model = "gpt-5.4-mini"
model_reasoning_effort = "low"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[features]
fast_mode = true
service_tier = "fast"codex --profile fastSubagents divide large tasks among multiple agents. Each subagent performs its own model and tool work, using more tokens, but for independent read-heavy work like exploration, testing, triage, and summarization, there's a parallelization advantage.
Review this branch with parallel subagents.
- agent 1: Security risks
- agent 2: Missing tests
- agent 3: Maintainability issues
After all three agents finish,
remove duplicates and summarize by priority.In large repos, "show me everything" is the slowest request. First narrow the structure, then narrow the files, finally limit the change scope.
Don't read this entire repo.
Just find entrypoint candidates related to the payment API.
Don't modify files.
Organize related directories and key file candidates into 10 or fewer.Cost and speed are heavily influenced by three things: model choice, reasoning effort, and context and tool output size.
model = "gpt-5.5"
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"When Codex behaves strangely, check operating state before rewriting prompts.
pwd
git status
codex doctor --summary
codex doctor --json > codex-doctor.jsoncodex doctor is a stable command that checks local installation, config, auth, runtime, Git, terminal, app-server, and thread inventory state.
Summary only:
codex doctor --summary
JSON for support requests:
codex doctor --json > codex-doctor.jsonNote that the doctor report shows "current Codex state itself" but doesn't judge whether your prompt is good or bad.
During a session, use /status to verify the current work state.
Especially for sandbox issues, you must first verify the workspace root is correct. For example, if you ran from apps/frontend but the actual modification target is packages/shared, Codex might try to modify files outside its permissions or keep requesting approval.
codex --cd apps/frontend --add-dir ../sharedConfig issues mostly happen when "the config I think I have" differs from "the config actually applied."
Codex reads user-level config from ~/.codex/config.toml and in trusted projects also reads .codex/config.toml. Project config cannot override certain machine-local keys like some provider, auth, and telemetry routing. Profile files go next to config.toml in the form ~/.codex/profile-name.config.toml.
codex --config model='"gpt-5.4"'
codex --config sandbox_workspace_write.network_access=true
codex --config 'shell_environment_policy.include_only=["PATH","HOME"]'Let's learn the symptoms and how to check authentication problems.
codex login
codex logout
codex doctor --summaryLet's learn typical sandbox problem symptoms and solutions.
sandbox_mode accepts read-only, workspace-write, and danger-full-access values, determining file system and network access policies during command execution.
sandbox_mode = "workspace-write"
approval_policy = "on-request"
[sandbox_workspace_write]
network_access = falseApproval issues occur when Codex keeps asking "can I do this?" or conversely, when it runs way too much without asking.
untrustedon-requestneverIt's recommended to use on-request for interactive runs and never for non-interactive runs.
With auto-review attached, you can send approval-requiring requests to a reviewer agent first.
approval_policy = "on-request"
approvals_reviewer = "auto_review"approvals_reviewer = "auto_review" sends approval-requiring requests to a reviewer agent first. The reviewer checks sandbox escalation, blocked network requests, permission requests, side-effecting app/MCP tool calls, and evaluates risks like data exfiltration, credential probing, and destructive actions.
Automatic review uses additional model calls, so usage may increase.
Let's learn MCP problem symptoms and how to check them.
codex mcp list
codex doctor --summaryIf MCP is suspected, first disable all and reproduce. For plugin issues, disable recently installed plugins, verify if they include hooks, check MCPs added by plugins, and run with minimal configuration.
Shell environment issues are the most common problem beginners encounter.
source .venv/bin/activate
export NODE_ENV=test
npm install
codexBefore running Codex, source language environments like Python virtual environment and prepare necessary daemons and environment variables. This prevents Codex from wasting tokens exploring the environment.
With shell_environment_policy, you can control which environment variables are passed to subprocesses.
[shell_environment_policy]
inherit = "core"
include_only = ["PATH", "HOME", "USER", "SHELL", "NODE_ENV"]
exclude = ["*SECRET*", "*TOKEN*", "*KEY*"]include_only keeps only allowed variable patterns, exclude removes specific patterns, and inherit accepts all, core, or none values.
Always check Git state before and after Codex work.
git status
git diff
git branch --show-currentgit status
git stash push -m "before codex work"
codex
git diff
npm testWhen reproducing issues, pass them to Codex in the following format.
Codex security fundamentals are not trusting a smart agent, but limiting what the agent can do.
workspace-write sandbox has network access off by default. To turn on network access, set [sandbox_workspace_write] network_access = true.
Sandbox limits the file system and network access scope of commands Codex executes.
Be careful with danger-full-access or --dangerously-bypass-approvals-and-sandbox, and use only in isolated environments like Docker when necessary.
The following files require special care.
[permissions.filesystem]
deny_read = [
"/**/*.env",
"~/.ssh",
"~/.aws",
]It's good to reduce secrets in shell environment in personal settings and enforce deny-read with managed requirements in team settings.
Environment variables are convenient, but if an agent can run shell commands, secrets can be unintentionally exposed.
export OPENAI_API_KEY=...
export PROD_DB_PASSWORD=...
codex --sandbox danger-full-access[shell_environment_policy]
inherit = "core"
exclude = ["*SECRET*", "*TOKEN*", "*KEY*", "*PASSWORD*"]shell_environment_policy determines which environment variables to pass to subprocesses when Codex runs them.
ignore_default_excludes keeps variables with KEY, SECRET, TOKEN before other filters apply, so it requires extreme security care.
When Codex has network access, it's easy to check external docs, install packages, and call APIs. But from a security perspective, data exfiltration and prompt injection risks increase.
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = false[sandbox_workspace_write]
network_access = trueIn team environments, it's better to control with domain allowlist in requirements. You can define central network requirements in [experimental_network] and set allowed/denied domains and managed allowlist-only mode.
danger-full-access is convenient but shouldn't become the default work mode.
Auto-review has a reviewer agent evaluate risk before a person sees approval requests.
approval_policy = "on-request"
approvals_reviewer = "auto_review"The reviewer evaluates already-approval-requiring actions like sandbox escalation, blocked network requests, permission requests, and side-effecting app/MCP tool calls, checking risks like data exfiltration, credential probing, and destructive actions.
Hooks automatically run scripts matching Codex lifecycle events. They're powerful from a security perspective but can create a new attack surface if misused.
In teams, it's good to control with managed hooks. Admins can define lifecycle hooks in requirements.toml and use allow_managed_hooks_only = true to load only managed hooks, skipping user, project, session, and plugin hooks.
model = "gpt-5.5"
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = false
[shell_environment_policy]
inherit = "core"
exclude = ["*KEY*", "*SECRET*", "*TOKEN*", "*PASSWORD*"]When operating Codex in an organization, the following matters more than individual productivity.
Enterprise admins can control Codex behavior in two ways: requirements that users cannot override, and managed defaults that provide starting values but users can change during sessions.
System config provides machine-level default values.
/etc/codex/config.toml can be used as the system config layer.
System config ranks lower than user config and higher than built-in defaults.
# /etc/codex/config.toml
model = "gpt-5.5"
model_reasoning_effort = "medium"
approval_policy = "on-request"
sandbox_mode = "workspace-write"Use system config as "recommended defaults" and enforce control with requirements.toml.
requirements.toml is where organization admins enforce security-sensitive configuration.
allowed_approval_policies = ["untrusted", "on-request"]
allowed_sandbox_modes = ["read-only", "workspace-write"]
allowed_web_search_modes = ["cached"]
[permissions.filesystem]
deny_read = [
"/**/*.env",
"~/.ssh",
]Organizations should set usage standards for model and reasoning effort to balance cost, security, and quality.
# ~/.codex/review.config.toml
model = "gpt-5.5"
model_reasoning_effort = "high"
approval_policy = "on-request"
sandbox_mode = "read-only"Profile files overlay on top of base user config in the form ~/.codex/profile-name.config.toml.
Permission profiles standardize "what permissions for what work" across the team.
model = "gpt-5.5"
model_reasoning_effort = "high"
sandbox_mode = "read-only"
approval_policy = "on-request"
[sandbox_workspace_write]
network_access = falseLarge organizations need to track Codex usage, failures, approval flows, and configuration drift.
[otel]
environment = "prod"
exporter = "otlp-http"
log_user_prompt = falseOrganizations are better served with workspace accounts and central management rather than individual API key operations.
In large organizations, "how to use" is more important than "allowing Codex."
Section 29. Real-World Workflows and Migration
Good Codex users aren't "people who assign big work at once"—they're people who break tasks into small pieces and build verification loops.
Bad flow:
Look at the entire project and improve it on your own.Good flow:
1. Narrow the problem scope.
2. Get a plan first.
3. Make small changes only.
4. Verify diff.
5. Run tests.
6. If it fails, provide the log again.
7. Get a final summary and commit message.OpenAI's Codex best practices also recommend getting a plan first for difficult work, and making repeating instructions reusable through AGENTS.md.
Good prompts include these 5 things.
Goal:
Fix login failure to return 401 instead of 500.
Fix scope:
Check only in src/auth, tests/auth.
Forbidden:
Don't refactor the entire auth structure.
Don't make unrelated formatting changes.
Verification:
npm test -- auth
Output:
- Root cause
- Modified files
- Test results
- Remaining risksAfter receiving a prompt, Codex repeatedly does model calls, file reading, file editing, tool calls, and other work to complete the task. The more concrete the initial prompt, the less unnecessary exploration Codex does and the more accurately it acts.
Bad prompts usually have scope that's too broad.
Improve this project.
Find all bugs.
Make performance good.
Strengthen security.
Refactor the entire codebase.
Add tests on your own.These requests are bad because Codex finds it hard to understand what counts as success.
Bad request:
Improve performance.Good request:
Find the cause of slow orders API response.
Check only src/api/orders and src/db/orders related files,
and organize 3 or fewer bottleneck candidates before modifying.Codex work succeeds more when the task is smaller.
Big task:
Refactor the payment system.Broken down into small tasks:
1. Find the entrypoint of payment creation flow.
2. Explain the failure handling logic only.
3. Find the retry condition duplication.
4. Create a fix plan.
5. Fix one file first.
6. Add related tests.
7. Review the entire diff.Complex work requires getting a plan first.
Create only the plan.
Don't modify files.
Show the target files, change reasons, and test strategy.Good plan request:
Review whether duplicate payment can occur on payment failure.
Don't modify code first.
1. Related files
2. Current flow
3. Risk points
4. Fix plan
5. Needed tests
Organize in this order.Then approve the execution.
OK. Execute plan 2.
But don't change public API signature.
After fixing, run npm test -- payments.Official best practices also recommend the flow of requesting a plan first for difficult work, confirming the direction with the user, then implementing.
After Codex modifies code, always verify the diff.
git diffItems to verify:
Review the diff you just changed yourself.
Check only these items.
1. Unrelated changes
2. Missing tests
3. Edge cases
4. Security risks
5. Parts that could be fixed more minimallyCodex app handles multiple threads in parallel and provides Git features and worktree support. If you need to review diffs visually and stage/revert them, Desktop App is more convenient than CLI.
Just telling Codex "also test" isn't enough. Test commands differ by project.
Good example (Node.js):
After fixing, run these commands.
npm test -- auth
npm run typecheck
npm run lintPython project:
After fixing, run these commands.
pytest tests/auth -q
ruff check .
mypy .Rust project:
After fixing, run these commands.
cargo test auth
cargo clippyWhen tests fail, don't attach the entire log—pass only the core.
Fix based on this failure log.
Don't do complete refactoring.
Command:
npm test -- auth
Failure:
...Instructions you repeat shouldn't be put in the prompt each time—put them in AGENTS.md.
Good content for AGENTS.md:
# AGENTS.md
## Work Principles
- No unrelated refactoring
- Write plan before changing public API
- Don't report completion without tests
## Tests
- unit test: npm test
- typecheck: npm run typecheck
- lint: npm run lint
## Code Style
- Keep existing patterns
- Confirm before changing public API
## Security
- Don't read .env, secret, token files
- Explain edge cases when changing auth/payment/permission logicCodex reads the AGENTS.md file before work and applies global guidance and project-specific overrides hierarchically. Good AGENTS.md must be short and clear.
MCPs are powerful but connecting all tools always makes Codex slow and context complex.
Good guideline:
OpenAI best practices explain to use MCP when the needed context is outside the repo, changes frequently, or repeated integration is needed. It's better to start with 1-2 tools that actually reduce workflow friction rather than attaching many tools from the start.
High reasoning effort like xhigh is useful for complex judgment but not every task needs it.
Continually using xhigh on small tasks increases cost and time. It's good to keep medium as the default and raise it only when failing or high-risk.
There's work you shouldn't assign to Codex.
Risky work should be reframed like this.
Bad request:
Find and fix problems in production DB.Good request:
Analyze root causes based on this anonymized error log.
Don't access or modify the actual DB.For a new repo, don't modify right away.
Recommended prompt:
Assume you're seeing this codebase for the first time and explain.
Don't modify files.
Output:
1. Project purpose
2. Main directories
3. Execution entrypoint
4. Test structure
5. Config files
6. Things to be careful about when Codex worksAfter the first explanation, narrow down further.
Explain only the authentication flow in more detail.
Organize related file candidates into 10 or fewer,
and don't modify yet.CLI is an environment where you can read repositories, modify files, and execute commands while iterating interactively with the user. For unknown codebases, it's good to start with interactive CLI or IDE to understand structure first.
Fixing test failures is one of Codex's strong tasks. Narrow the failure scope instead of throwing the entire log.
Flow:
Analyze this test failure.
First organize 3 or fewer root cause candidates,
and fix minimally starting from the most likely cause.
Command:
npm test -- auth
Log:
...After fixing:
Explain the modified part
and let me know why this test should pass.
Also check if there are unrelated changes.API additions easily get out of scope. First find the structure.
I want to add a new API endpoint.
First, investigate the existing API pattern.
Goal:
Add POST /api/orders/:id/cancel
Don't fix yet, organize only:
1. Where existing routes are defined
2. Controller/service structure
3. Validation method
4. Test location
5. Implementation planAfter plan confirmation:
OK. Implement maintaining existing patterns.
Fix scope:
- route
- controller
- service
- tests/orders
Forbidden:
Don't refactor common error handlerWrap-up:
Organize changed files, test results, and API usage example.Refactoring is risky if executed directly. You must get a plan first.
I want to refactor this module.
Don't modify files yet.
Goal:
Reduce duplicate validation logic and improve testability
Output:
1. Current structure problems
2. Refactoring candidates
3. Risk level
4. Step-by-step plan
5. Tests to run at each stepGood refactoring doesn't finish at once.
Step 1: Extract duplicate function without moving code
Step 2: Add tests
Step 3: Replace call sites
Step 4: Remove deprecated code
Step 5: Full testUsing worktrees lets you run independent work in parallel in the same repository without interfering with each other. It's safer to conduct experimental refactoring in a worktree or separate branch instead of mixing with existing work.
It's good to start security review read-only.
Review the current branch diff from a security perspective.
Don't modify files.
Focus items:
1. Authentication bypass potential
2. Missing permission checks
3. Insufficient input validation
4. Secret exposure
5. SSRF / SQL injection / XSS potential
6. Sensitive info left in logsResult format:
Write each issue in this format.
- Risk: high / medium / low
- Location:
- Problem:
- Attack Scenario:
- Fix Direction:
- Test Suggestion:Pass fixing as a separate step.
Fix only item 1 with high risk from the review.
Add related tests after fixing,
and don't touch other items.PR review should filter easy-to-miss items first rather than replacing human review.
Locally:
git diff origin/main...HEAD | codex exec \
"Review this PR diff.
Output:
1. Critical bug potential
2. Missing tests
3. Security risks
4. Unnecessary changes
5. Things to check before merging" \
-o codex-pr-review.mdIn CI:
Codex GitHub Action lets you run repeatable Codex work in GitHub Actions workflows, automating PR review, release prep, migration, and other work.
Documentation often lags behind code changes. Having Codex find doc gaps is useful.
Based on the current git diff, find places where documentation needs updating.
Don't modify docs yet,
organize update candidates and reasons.Fix request:
Update only the API usage example in README.
Don't modify code files.
Keep existing tone and format.Migration carries large failure risk so it must be broken into steps.
Example: Move library v1 to v2
I want to migrate from library v1 to v2.
First investigate the impact scope without modifying files.
Output:
1. v1 API usage locations
2. Patterns needing changes
3. Risky call sites
4. Step-by-step migration plan
5. Test strategyThen execute in small units.
Proceed with step 1 only.
Replace deprecated import with new import,
but don't change behavior logic.
After fixing, run typecheck only.Good migration principles:
Release notes work well with codex exec.
git log --oneline v1.2.0..HEAD | codex exec \
"Organize this commit list into user-facing release notes.
Focus on user impact over internal implementation details." \
-o release-notes.mdBetter input:
git log --oneline v1.2.0..HEAD > commits.txt
git diff --stat v1.2.0..HEAD > diff-stat.txtcodex exec \
"Create release notes based on commits.txt and diff-stat.txt.
Sections:
- Added
- Changed
- Fixed
- Migration Notes
- Known Issues" \
-o release-notes.mdcodex exec runs Codex in non-interactive mode without opening an interactive TUI, suitable for scripts and CI. It fits well with repeatable output generation work like release notes.
Issue triage focuses on "classification" over "fixing."
Triage this GitHub issue.
Don't modify code.
Output:
1. Type: bug / feature / question / docs
2. Priority: P0 / P1 / P2 / P3
3. Reproducibility
4. Needed additional info
5. Related code candidates
6. Summary for next ownerWhen automating multiple issues, setting a schema helps.
{
"type": "bug",
"priority": "P2",
"needs_reproduction": true,
"missing_info": ["version", "logs"],
"suggested_owner": "frontend"
}Codex is useful for reading existing repos and drafting onboarding docs.
Create an onboarding doc draft for new developers.
Don't create the file yet, propose a table of contents first.
Include:
1. Project purpose
2. How to run locally
3. How to test
4. Main directories
5. Deployment flow
6. Common errors
7. Recommended first issuesThen create the document:
OK. Write to docs/onboarding.md.
But mark uncertain content as "needs confirmation."Important principles:
Browser work should be thought of separately from code work.
Fitting work:
Check user permission settings in this admin page.
Don't make changes,
just summarize current settings and risky-looking items.When modifications are needed:
Change only these items.
Don't touch other settings.
Changes:
- Role: Viewer
- Export permission: OffBrowser automation requires care with permissions and data exposure. It's safer to narrow work scope and grant permissions only to needed sites when dealing with screens showing customer data, admin rights, payment info, or internal metrics.
When moving from another AI coding tool to Codex, "changing commands as-is" is less important than changing work habits to Codex style.
Core Shifts:
If you're familiar with terminal-based agents like Claude Code, Codex CLI is the most natural starting point.
Transition Points:
Recommended first config:
model = "gpt-5.5"
model_reasoning_effort = "medium"
sandbox_mode = "workspace-write"
approval_policy = "on-request"If you're a Cursor user, it's natural to start with Codex Extension in IDE first.
Transition Points:
For Cursor, good to separate roles between existing IDE AI features and Codex.
IDE base AI:
Codex:
Users familiar with Copilot need to separate "auto-completion" and "agent work."
Transition Points:
Rather than completely abandoning Copilot, attaching Codex to larger work units works well.
If you're familiar with Git-based code editing flow like Aider, Git discipline matters in Codex too.
Transition Points:
Recommended flow:
git status
codex
git diff
npm test
git add .
git commit -m "fix: handle expired auth sessions"You can have Codex create commit messages.
Propose a commit message in Conventional Commit format based on current diff.
Include why changes were made and test results in the body.The first practical task for migration is adding AGENTS.md.
Initial prompt:
Create an appropriate AGENTS.md draft for this repo.
Don't create the file yet,
explain what should be included and why.Then create:
OK. Create AGENTS.md at the root.
Keep content short and practical-guideline focused.# AGENTS.md
## Project Overview
- Briefly explain this project's purpose.
## Work Principles
- No unrelated refactoring
- Write plan before public API changes
- Don't report completion without tests
## Commands
- install:
- test:
- typecheck:
- lint:
## Code Style
- Maintain existing patterns
- Confirm before public API changes
## Security
- Don't read .env, secret, token files
- Explain edge cases when changing auth/payment/permission logicWhen attaching Codex to existing shell scripts or CI, codex exec is simplest.
Existing test script:
npm testAdd Codex analysis:
npm test 2>&1 | tee test.log || true
cat test.log | codex exec \
"Analyze this test failure log.
Output:
1. Failed tests
2. Direct cause
3. Related file candidates
4. Minimal fix direction" \
-o reports/test-analysis.mdExisting PR workflow:
git diff origin/main...HEADAdd Codex review:
git diff origin/main...HEAD | codex exec \
"Review this PR diff.
Point out only critical bugs, missing tests, security risks." \
-o reports/codex-review.mdThese combinations are safely used in CI by default:
When adopting Codex organization-wide, this order is good.
Items to include in team standard docs:
Migration success criteria:
Good usage:
Bad usage:
Breaking work small, verifying plans, checking diffs, and closing with tests is the most stable flow.
Good work habits are the most important Codex performance improvement.
Codex learns how you work. When the habit develops of breaking work small, getting plans first, verifying diffs, and specifying tests, Codex becomes a more accurate and trustworthy tool.
Repeating this flow lifts both team development speed and stability.
Section 30. Quick Reference, Updates, Reference Materials