Codex
Codex is OpenAI's command-line coding tool (Codex CLI). This page covers its global instructions, MCP servers, shell functions and common commands.
Configuration#
Codex keeps its config files in the ~/.codex directory.
Global instructions#
Put the following in ~/.codex/AGENTS.md:
MCP servers#
Add the following to ~/.codex/config.toml:
Shell function#
Wrap codex in a shell function of the same name so every launch gets the base arguments. Add the function to ~/.zshrc or your PowerShell $PROFILE. Pick one of the two variants below.
Always start a new session#
Start a fresh session every time, with only the base arguments.
Zsh:
PowerShell:
Resume the current directory's session automatically#
Try to continue the latest session for the current directory first. If that fails, start a new one.
Zsh:
PowerShell:
Usage#
Common commands:
codex resume --last filters sessions by the current working directory by default. Run it inside a project to continue that project's latest session. Codex does not resume automatically when you cd into a directory. To resume first and fall back to a new session, use a shell function.