mirror of
https://github.com/openai/codex.git
synced 2026-02-01 22:47:52 +00:00
Replaced user documentation with links to developers docs site (#8662)
This eliminates redundant user documentation and allows us to focus our documentation investments. I left tombstone files for most of the existing ".md" docs files to avoid broken links. These now contain brief links to the developers docs site.
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
## Advanced
|
||||
|
||||
If you already lean on Codex every day and just need a little more control, this page collects the knobs you are most likely to reach for: tweak defaults in [Config](./config.md), add extra tools through [Model Context Protocol support](#model-context-protocol), and script full runs with [`codex exec`](./exec.md). Jump to the section you need and keep building.
|
||||
|
||||
## Config quickstart
|
||||
|
||||
Most day-to-day tuning lives in `config.toml`: set approval + sandbox presets, pin model defaults, and add MCP server launchers. The [Config guide](./config.md) walks through every option and provides copy-paste examples for common setups.
|
||||
|
||||
## Tracing / verbose logging
|
||||
|
||||
Because Codex is written in Rust, it honors the `RUST_LOG` environment variable to configure its logging behavior.
|
||||
|
||||
The TUI defaults to `RUST_LOG=codex_core=info,codex_tui=info,codex_rmcp_client=info` and log messages are written to `~/.codex/log/codex-tui.log`, so you can leave the following running in a separate terminal to monitor log messages as they are written:
|
||||
|
||||
```bash
|
||||
tail -F ~/.codex/log/codex-tui.log
|
||||
```
|
||||
|
||||
By comparison, the non-interactive mode (`codex exec`) defaults to `RUST_LOG=error`, but messages are printed inline, so there is no need to monitor a separate file.
|
||||
|
||||
See the Rust documentation on [`RUST_LOG`](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) for more information on the configuration options.
|
||||
|
||||
## Model Context Protocol (MCP)
|
||||
|
||||
The Codex CLI and IDE extension is a MCP client which means that it can be configured to connect to MCP servers. For more information, refer to the [`config docs`](./config.md#mcp-integration).
|
||||
|
||||
## Using Codex as an MCP Server
|
||||
|
||||
The Codex CLI can also be run as an MCP _server_ via `codex mcp-server`. For example, you can use `codex mcp-server` to make Codex available as a tool inside of a multi-agent framework like the OpenAI [Agents SDK](https://platform.openai.com/docs/guides/agents). Use `codex mcp` separately to add/list/get/remove MCP server launchers in your configuration.
|
||||
|
||||
### Codex MCP Server Quickstart
|
||||
|
||||
You can launch a Codex MCP server with the [Model Context Protocol Inspector](https://modelcontextprotocol.io/legacy/tools/inspector):
|
||||
|
||||
```bash
|
||||
npx @modelcontextprotocol/inspector codex mcp-server
|
||||
```
|
||||
|
||||
Send a `tools/list` request and you will see that there are two tools available:
|
||||
|
||||
**`codex`** - Run a Codex session. Accepts configuration parameters matching the Codex Config struct. The `codex` tool takes the following properties:
|
||||
|
||||
| Property | Type | Description |
|
||||
| ----------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| **`prompt`** (required) | string | The initial user prompt to start the Codex conversation. |
|
||||
| `approval-policy` | string | Approval policy for shell commands generated by the model: `untrusted`, `on-failure`, `on-request`, `never`. |
|
||||
| `base-instructions` | string | The set of instructions to use instead of the default ones. |
|
||||
| `config` | object | Individual [config settings](https://github.com/openai/codex/blob/main/docs/config.md#config) that will override what is in `$CODEX_HOME/config.toml`. |
|
||||
| `cwd` | string | Working directory for the session. If relative, resolved against the server process's current directory. |
|
||||
| `model` | string | Optional override for the model name (e.g. `o3`, `o4-mini`). |
|
||||
| `profile` | string | Configuration profile from `config.toml` to specify default options. |
|
||||
| `sandbox` | string | Sandbox mode: `read-only`, `workspace-write`, or `danger-full-access`. |
|
||||
|
||||
**`codex-reply`** - Continue a Codex session by providing the conversation id and prompt. The `codex-reply` tool takes the following properties:
|
||||
|
||||
| Property | Type | Description |
|
||||
| ------------------------------- | ------ | -------------------------------------------------------- |
|
||||
| **`prompt`** (required) | string | The next user prompt to continue the Codex conversation. |
|
||||
| **`conversationId`** (required) | string | The id of the conversation to continue. |
|
||||
|
||||
### Trying it Out
|
||||
|
||||
> [!TIP]
|
||||
> Codex often takes a few minutes to run. To accommodate this, adjust the MCP inspector's Request and Total timeouts to 600000ms (10 minutes) under ⛭ Configuration.
|
||||
|
||||
Use the MCP inspector and `codex mcp-server` to build a simple tic-tac-toe game with the following settings:
|
||||
|
||||
**approval-policy:** never
|
||||
|
||||
**prompt:** Implement a simple tic-tac-toe game with HTML, JavaScript, and CSS. Write the game in a single file called index.html.
|
||||
|
||||
**sandbox:** workspace-write
|
||||
|
||||
Click "Run Tool" and you should see a list of events emitted from the Codex MCP server as it builds the game.
|
||||
@@ -1,50 +1,3 @@
|
||||
# AGENTS.md Discovery
|
||||
# AGENTS.md
|
||||
|
||||
Codex uses [`AGENTS.md`](https://agents.md/) files to gather helpful guidance before it starts assisting you. This page explains how those files are discovered and combined, so you can decide where to place your instructions.
|
||||
|
||||
## Global Instructions (`~/.codex`)
|
||||
|
||||
- Codex looks for global guidance in your Codex home directory (usually `~/.codex`; set `CODEX_HOME` to change it). For a quick overview, see the [Memory with AGENTS.md section](../docs/getting-started.md#memory-with-agentsmd) in the getting started guide.
|
||||
- If an `AGENTS.override.md` file exists there, it takes priority. If not, Codex falls back to `AGENTS.md`.
|
||||
- Only the first non-empty file is used. Other filenames, such as `instructions.md`, have no effect unless Codex is specifically instructed to use them.
|
||||
- Whatever Codex finds here stays active for the whole session, and Codex combines it with any project-specific instructions it discovers.
|
||||
|
||||
## Project Instructions (per-repository)
|
||||
|
||||
When you work inside a project, Codex builds on those global instructions by collecting project docs:
|
||||
|
||||
- The search starts at the repository root and continues down to your current directory. If a Git root is not found, only the current directory is checked.
|
||||
- In each directory along that path, Codex looks for `AGENTS.override.md` first, then `AGENTS.md`, and then any fallback names listed in your Codex configuration (see [`project_doc_fallback_filenames`](../docs/config.md#project_doc_fallback_filenames)). At most one file per directory is included.
|
||||
- Files are read in order from root to leaf and joined together with blank lines. Empty files are skipped, and very large files are truncated once the combined size reaches 32 KiB (the default [`project_doc_max_bytes`](../docs/config.md#project_doc_max_bytes) limit). If you need more space, split guidance across nested directories or raise the limit in your configuration.
|
||||
|
||||
## How They Come Together
|
||||
|
||||
Before Codex gets to work, the instructions are ingested in precedence order: global guidance from `~/.codex` comes first, then each project doc from the repository root down to your current directory. Guidance in deeper directories overrides earlier layers, so the most specific file controls the final behavior.
|
||||
|
||||
### Priority Summary
|
||||
|
||||
1. Global `AGENTS.override.md` (if present), otherwise global `AGENTS.md`.
|
||||
2. For each directory from the repository root to your working directory: `AGENTS.override.md`, then `AGENTS.md`, then configured fallback names.
|
||||
|
||||
Only these filenames are considered. To use a different name, add it to the fallback list in your Codex configuration or rename the file accordingly.
|
||||
|
||||
## Fallback Filenames
|
||||
|
||||
Codex can look for additional instruction filenames beyond the two defaults if you add them to `project_doc_fallback_filenames` in your Codex configuration. Each fallback is checked after `AGENTS.override.md` and `AGENTS.md` in every directory along the search path.
|
||||
|
||||
Example: suppose your configuration lists `["TEAM_GUIDE.md", ".agents.md"]`. Inside each directory Codex will look in this order:
|
||||
|
||||
1. `AGENTS.override.md`
|
||||
2. `AGENTS.md`
|
||||
3. `TEAM_GUIDE.md`
|
||||
4. `.agents.md`
|
||||
|
||||
If the repository root contains `TEAM_GUIDE.md` and the `backend/` directory contains `AGENTS.override.md`, the overall instructions will combine the root `TEAM_GUIDE.md` (because no override or default file was present there) with the `backend/AGENTS.override.md` file (which takes precedence over the fallback names).
|
||||
|
||||
You can configure those fallbacks in `~/.codex/config.toml` (or another profile) like this:
|
||||
|
||||
```toml
|
||||
project_doc_fallback_filenames = ["TEAM_GUIDE.md", ".agents.md"]
|
||||
```
|
||||
|
||||
For additional configuration details, see [Config](../docs/config.md) and revisit the [Memory with AGENTS.md guide](../docs/getting-started.md#memory-with-agentsmd) for practical usage tips.
|
||||
For information about AGENTS.md, see [this documentation](https://developers.openai.com/codex/guides/agents-md).
|
||||
|
||||
@@ -1,68 +1,3 @@
|
||||
# Authentication
|
||||
|
||||
## Usage-based billing alternative: Use an OpenAI API key
|
||||
|
||||
If you prefer to pay-as-you-go, you can still authenticate with your OpenAI API key:
|
||||
|
||||
```shell
|
||||
printenv OPENAI_API_KEY | codex login --with-api-key
|
||||
```
|
||||
|
||||
Alternatively, read from a file:
|
||||
|
||||
```shell
|
||||
codex login --with-api-key < my_key.txt
|
||||
```
|
||||
|
||||
The legacy `--api-key` flag now exits with an error instructing you to use `--with-api-key` so that the key never appears in shell history or process listings.
|
||||
|
||||
This key must, at minimum, have write access to the Responses API.
|
||||
|
||||
## Migrating to ChatGPT login from API key
|
||||
|
||||
If you've used the Codex CLI before with usage-based billing via an API key and want to switch to using your ChatGPT plan, follow these steps:
|
||||
|
||||
1. Update the CLI and ensure `codex --version` is `0.20.0` or later
|
||||
2. Delete `~/.codex/auth.json` (on Windows: `C:\\Users\\USERNAME\\.codex\\auth.json`)
|
||||
3. Run `codex login` again
|
||||
|
||||
## Connecting on a "Headless" Machine
|
||||
|
||||
Today, the login process entails running a server on `localhost:1455`. If you are on a "headless" server, such as a Docker container or are `ssh`'d into a remote machine, loading `localhost:1455` in the browser on your local machine will not automatically connect to the webserver running on the _headless_ machine, so you must use one of the following workarounds:
|
||||
|
||||
### Authenticate locally and copy your credentials to the "headless" machine
|
||||
|
||||
The easiest solution is likely to run through the `codex login` process on your local machine such that `localhost:1455` _is_ accessible in your web browser. When you complete the authentication process, an `auth.json` file should be available at `$CODEX_HOME/auth.json` (on Mac/Linux, `$CODEX_HOME` defaults to `~/.codex` whereas on Windows, it defaults to `%USERPROFILE%\\.codex`).
|
||||
|
||||
Because the `auth.json` file is not tied to a specific host, once you complete the authentication flow locally, you can copy the `$CODEX_HOME/auth.json` file to the headless machine and then `codex` should "just work" on that machine. Note to copy a file to a Docker container, you can do:
|
||||
|
||||
```shell
|
||||
# substitute MY_CONTAINER with the name or id of your Docker container:
|
||||
CONTAINER_HOME=$(docker exec MY_CONTAINER printenv HOME)
|
||||
docker exec MY_CONTAINER mkdir -p "$CONTAINER_HOME/.codex"
|
||||
docker cp auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"
|
||||
```
|
||||
|
||||
whereas if you are `ssh`'d into a remote machine, you likely want to use [`scp`](https://en.wikipedia.org/wiki/Secure_copy_protocol):
|
||||
|
||||
```shell
|
||||
ssh user@remote 'mkdir -p ~/.codex'
|
||||
scp ~/.codex/auth.json user@remote:~/.codex/auth.json
|
||||
```
|
||||
|
||||
or try this one-liner:
|
||||
|
||||
```shell
|
||||
ssh user@remote 'mkdir -p ~/.codex && cat > ~/.codex/auth.json' < ~/.codex/auth.json
|
||||
```
|
||||
|
||||
### Connecting through VPS or remote
|
||||
|
||||
If you run Codex on a remote machine (VPS/server) without a local browser, the login helper starts a server on `localhost:1455` on the remote host. To complete login in your local browser, forward that port to your machine before starting the login flow:
|
||||
|
||||
```bash
|
||||
# From your local machine
|
||||
ssh -L 1455:localhost:1455 <user>@<remote-host>
|
||||
```
|
||||
|
||||
Then, in that SSH session, run `codex` and select "Sign in with ChatGPT". When prompted, open the printed URL (it will be `http://localhost:1455/...`) in your local browser. The traffic will be tunneled to the remote server.
|
||||
For information about Codex CLI authentication, see [this documentation](https://developers.openai.com/codex/auth).
|
||||
|
||||
1072
docs/config.md
1072
docs/config.md
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,11 @@
|
||||
|
||||
This project is under active development and the code will likely change pretty significantly.
|
||||
|
||||
**At the moment, we only plan to prioritize reviewing external contributions for bugs or security fixes.**
|
||||
**At the moment, we are generally accepting external contributions only for bugs fixes.**
|
||||
|
||||
If you want to add a new feature or change the behavior of an existing one, please open an issue proposing the feature and get approval from an OpenAI team member before spending time building it.
|
||||
If you want to add a new feature or change the behavior of an existing one, please open an issue proposing the feature or upvote an existing enhancement request. We will generally prioritize new features based on community feedback. New features must compose well with existing and upcoming features and fit into our roadmap. They must also be implemented consistently across all Codex surfaces (CLI, IDE extension, web, etc.).
|
||||
|
||||
If you want to contribute a bug fix, please open a bug report first - or verify that there is an existing bug report that discusses the issue. All bug fix PRs should include a link to a bug report.
|
||||
|
||||
**New contributions that don't go through this process may be closed** if they aren't aligned with our current roadmap or conflict with other priorities/upcoming features.
|
||||
|
||||
@@ -17,8 +19,8 @@ If you want to add a new feature or change the behavior of an existing one, plea
|
||||
### Writing high-impact code changes
|
||||
|
||||
1. **Start with an issue.** Open a new one or comment on an existing discussion so we can agree on the solution before code is written.
|
||||
2. **Add or update tests.** Every new feature or bug-fix should come with test coverage that fails before your change and passes afterwards. 100% coverage is not required, but aim for meaningful assertions.
|
||||
3. **Document behaviour.** If your change affects user-facing behaviour, update the README, inline help (`codex --help`), or relevant example projects.
|
||||
2. **Add or update tests.** A bug fix should generally come with test coverage that fails before your change and passes afterwards. 100% coverage is not required, but aim for meaningful assertions.
|
||||
3. **Document behavior.** If your change affects user-facing behavior, update the README, inline help (`codex --help`), or relevant example projects.
|
||||
4. **Keep commits atomic.** Each commit should compile and the tests should pass. This makes reviews and potential rollbacks easier.
|
||||
|
||||
### Opening a pull request
|
||||
@@ -32,8 +34,8 @@ If you want to add a new feature or change the behavior of an existing one, plea
|
||||
### Review process
|
||||
|
||||
1. One maintainer will be assigned as a primary reviewer.
|
||||
2. If your PR adds a new feature that was not previously discussed and approved, we may choose to close your PR (see [Contributing](#contributing)).
|
||||
3. We may ask for changes - please do not take this personally. We value the work, but we also value consistency and long-term maintainability.
|
||||
2. If your PR adds a new feature that was not previously discussed and approved, we may close your PR (see [Contributing](#contributing)).
|
||||
3. We may ask for changes. Please do not take this personally. We value the work, but we also value consistency and long-term maintainability.
|
||||
4. When there is consensus that the PR meets the bar, a maintainer will squash-and-merge.
|
||||
|
||||
### Community values
|
||||
@@ -44,7 +46,7 @@ If you want to add a new feature or change the behavior of an existing one, plea
|
||||
|
||||
### Getting help
|
||||
|
||||
If you run into problems setting up the project, would like feedback on an idea, or just want to say _hi_ - please open a Discussion or jump into the relevant issue. We are happy to help.
|
||||
If you run into problems setting up the project, would like feedback on an idea, or just want to say _hi_ - please open a Discussion topic or jump into the relevant issue. We are happy to help.
|
||||
|
||||
Together we can make Codex CLI an incredible tool. **Happy hacking!** :rocket:
|
||||
|
||||
@@ -63,14 +65,6 @@ All contributors **must** accept the CLA. The process is lightweight:
|
||||
|
||||
No special Git commands, email attachments, or commit footers required.
|
||||
|
||||
#### Quick fixes
|
||||
|
||||
| Scenario | Command |
|
||||
| ----------------- | ------------------------------------------------ |
|
||||
| Amend last commit | `git commit --amend -s --no-edit && git push -f` |
|
||||
|
||||
The **DCO check** blocks merges until every commit in the PR carries the footer (with squash this is just the one).
|
||||
|
||||
### Security & responsible AI
|
||||
|
||||
Have you discovered a vulnerability or have concerns about model output? Please e-mail **security@openai.com** and we will respond promptly.
|
||||
|
||||
@@ -1,362 +1,3 @@
|
||||
# Example config.toml
|
||||
# Sample configuration
|
||||
|
||||
Use this example configuration as a starting point. For an explanation of each field and additional context, see [Configuration](./config.md). Copy the snippet below to `~/.codex/config.toml` and adjust values as needed.
|
||||
|
||||
```toml
|
||||
# Codex example configuration (config.toml)
|
||||
#
|
||||
# This file lists all keys Codex reads from config.toml, their default values,
|
||||
# and concise explanations. Values here mirror the effective defaults compiled
|
||||
# into the CLI. Adjust as needed.
|
||||
#
|
||||
# Notes
|
||||
# - Root keys must appear before tables in TOML.
|
||||
# - Optional keys that default to "unset" are shown commented out with notes.
|
||||
# - MCP servers, profiles, and model providers are examples; remove or edit.
|
||||
|
||||
################################################################################
|
||||
# Core Model Selection
|
||||
################################################################################
|
||||
|
||||
# Primary model used by Codex. Default: "gpt-5.1-codex-max" on all platforms.
|
||||
model = "gpt-5.1-codex-max"
|
||||
|
||||
# Model used by the /review feature (code reviews). Default: "gpt-5.1-codex-max".
|
||||
review_model = "gpt-5.1-codex-max"
|
||||
|
||||
# Provider id selected from [model_providers]. Default: "openai".
|
||||
model_provider = "openai"
|
||||
|
||||
# Optional manual model metadata. When unset, Codex auto-detects from model.
|
||||
# Uncomment to force values.
|
||||
# model_context_window = 128000 # tokens; default: auto for model
|
||||
# model_auto_compact_token_limit = 0 # disable/override auto; default: model family specific
|
||||
# tool_output_token_limit = 10000 # tokens stored per tool output; default: 10000 for gpt-5.1-codex-max
|
||||
|
||||
################################################################################
|
||||
# Reasoning & Verbosity (Responses API capable models)
|
||||
################################################################################
|
||||
|
||||
# Reasoning effort: minimal | low | medium | high | xhigh (default: medium; xhigh on gpt-5.1-codex-max and gpt-5.2)
|
||||
model_reasoning_effort = "medium"
|
||||
|
||||
# Reasoning summary: auto | concise | detailed | none (default: auto)
|
||||
model_reasoning_summary = "auto"
|
||||
|
||||
# Text verbosity for GPT-5 family (Responses API): low | medium | high (default: medium)
|
||||
model_verbosity = "medium"
|
||||
|
||||
# Force-enable reasoning summaries for current model (default: false)
|
||||
model_supports_reasoning_summaries = false
|
||||
|
||||
################################################################################
|
||||
# Instruction Overrides
|
||||
################################################################################
|
||||
|
||||
# Additional user instructions inject before AGENTS.md. Default: unset.
|
||||
# developer_instructions = ""
|
||||
|
||||
# (Ignored) Optional legacy base instructions override (prefer AGENTS.md). Default: unset.
|
||||
# instructions = ""
|
||||
|
||||
# Inline override for the history compaction prompt. Default: unset.
|
||||
# compact_prompt = ""
|
||||
|
||||
# Override built-in base instructions with a file path. Default: unset.
|
||||
# experimental_instructions_file = "/absolute/or/relative/path/to/instructions.txt"
|
||||
|
||||
# Load the compact prompt override from a file. Default: unset.
|
||||
# experimental_compact_prompt_file = "/absolute/or/relative/path/to/compact_prompt.txt"
|
||||
|
||||
################################################################################
|
||||
# Approval & Sandbox
|
||||
################################################################################
|
||||
|
||||
# When to ask for command approval:
|
||||
# - untrusted: only known-safe read-only commands auto-run; others prompt
|
||||
# - on-failure: auto-run in sandbox; prompt only on failure for escalation
|
||||
# - on-request: model decides when to ask (default)
|
||||
# - never: never prompt (risky)
|
||||
approval_policy = "on-request"
|
||||
|
||||
# Filesystem/network sandbox policy for tool calls:
|
||||
# - read-only (default)
|
||||
# - workspace-write
|
||||
# - danger-full-access (no sandbox; extremely risky)
|
||||
sandbox_mode = "read-only"
|
||||
|
||||
# Extra settings used only when sandbox_mode = "workspace-write".
|
||||
[sandbox_workspace_write]
|
||||
# Additional writable roots beyond the workspace (cwd). Default: []
|
||||
writable_roots = []
|
||||
# Allow outbound network access inside the sandbox. Default: false
|
||||
network_access = false
|
||||
# Exclude $TMPDIR from writable roots. Default: false
|
||||
exclude_tmpdir_env_var = false
|
||||
# Exclude /tmp from writable roots. Default: false
|
||||
exclude_slash_tmp = false
|
||||
|
||||
################################################################################
|
||||
# Shell Environment Policy for spawned processes
|
||||
################################################################################
|
||||
|
||||
[shell_environment_policy]
|
||||
# inherit: all (default) | core | none
|
||||
inherit = "all"
|
||||
# Skip default excludes for names containing KEY/SECRET/TOKEN (case-insensitive). Default: true
|
||||
ignore_default_excludes = true
|
||||
# Case-insensitive glob patterns to remove (e.g., "AWS_*", "AZURE_*"). Default: []
|
||||
exclude = []
|
||||
# Explicit key/value overrides (always win). Default: {}
|
||||
set = {}
|
||||
# Whitelist; if non-empty, keep only matching vars. Default: []
|
||||
include_only = []
|
||||
# Experimental: run via user shell profile. Default: false
|
||||
experimental_use_profile = false
|
||||
|
||||
################################################################################
|
||||
# History & File Opener
|
||||
################################################################################
|
||||
|
||||
[history]
|
||||
# save-all (default) | none
|
||||
persistence = "save-all"
|
||||
# Maximum bytes for history file; oldest entries are trimmed when exceeded. Example: 5242880
|
||||
# max_bytes = 0
|
||||
|
||||
# URI scheme for clickable citations: vscode (default) | vscode-insiders | windsurf | cursor | none
|
||||
file_opener = "vscode"
|
||||
|
||||
################################################################################
|
||||
# UI, Notifications, and Misc
|
||||
################################################################################
|
||||
|
||||
[tui]
|
||||
# Desktop notifications from the TUI: boolean or filtered list. Default: true
|
||||
# Examples: false | ["agent-turn-complete", "approval-requested"]
|
||||
notifications = false
|
||||
|
||||
# Enables welcome/status/spinner animations. Default: true
|
||||
animations = true
|
||||
|
||||
# Suppress internal reasoning events from output. Default: false
|
||||
hide_agent_reasoning = false
|
||||
|
||||
# Show raw reasoning content when available. Default: false
|
||||
show_raw_agent_reasoning = false
|
||||
|
||||
# Disable burst-paste detection in the TUI. Default: false
|
||||
disable_paste_burst = false
|
||||
|
||||
# Track Windows onboarding acknowledgement (Windows only). Default: false
|
||||
windows_wsl_setup_acknowledged = false
|
||||
|
||||
# External notifier program (argv array). When unset: disabled.
|
||||
# Example: notify = ["notify-send", "Codex"]
|
||||
# notify = [ ]
|
||||
|
||||
# In-product notices (mostly set automatically by Codex).
|
||||
[notice]
|
||||
# hide_full_access_warning = true
|
||||
# hide_rate_limit_model_nudge = true
|
||||
|
||||
################################################################################
|
||||
# Authentication & Login
|
||||
################################################################################
|
||||
|
||||
# Where to persist CLI login credentials: file (default) | keyring | auto
|
||||
cli_auth_credentials_store = "file"
|
||||
|
||||
# Base URL for ChatGPT auth flow (not OpenAI API). Default:
|
||||
chatgpt_base_url = "https://chatgpt.com/backend-api/"
|
||||
|
||||
# Restrict ChatGPT login to a specific workspace id. Default: unset.
|
||||
# forced_chatgpt_workspace_id = ""
|
||||
|
||||
# Force login mechanism when Codex would normally auto-select. Default: unset.
|
||||
# Allowed values: chatgpt | api
|
||||
# forced_login_method = "chatgpt"
|
||||
|
||||
# Preferred store for MCP OAuth credentials: auto (default) | file | keyring
|
||||
mcp_oauth_credentials_store = "auto"
|
||||
|
||||
################################################################################
|
||||
# Project Documentation Controls
|
||||
################################################################################
|
||||
|
||||
# Max bytes from AGENTS.md to embed into first-turn instructions. Default: 32768
|
||||
project_doc_max_bytes = 32768
|
||||
|
||||
# Ordered fallbacks when AGENTS.md is missing at a directory level. Default: []
|
||||
project_doc_fallback_filenames = []
|
||||
|
||||
################################################################################
|
||||
# Tools (legacy toggles kept for compatibility)
|
||||
################################################################################
|
||||
|
||||
[tools]
|
||||
# Enable web search tool (alias: web_search_request). Default: false
|
||||
web_search = false
|
||||
|
||||
# Enable the view_image tool so the agent can attach local images. Default: true
|
||||
view_image = true
|
||||
|
||||
# (Alias accepted) You can also write:
|
||||
# web_search_request = false
|
||||
|
||||
################################################################################
|
||||
# Centralized Feature Flags (preferred)
|
||||
################################################################################
|
||||
|
||||
[features]
|
||||
# Leave this table empty to accept defaults. Set explicit booleans to opt in/out.
|
||||
unified_exec = false
|
||||
apply_patch_freeform = false
|
||||
view_image_tool = true
|
||||
web_search_request = false
|
||||
enable_experimental_windows_sandbox = false
|
||||
skills = false
|
||||
|
||||
################################################################################
|
||||
# Experimental toggles (legacy; prefer [features])
|
||||
################################################################################
|
||||
|
||||
# Include apply_patch via freeform editing path (affects default tool set). Default: false
|
||||
experimental_use_freeform_apply_patch = false
|
||||
|
||||
# Define MCP servers under this table. Leave empty to disable.
|
||||
[mcp_servers]
|
||||
|
||||
# --- Example: STDIO transport ---
|
||||
# [mcp_servers.docs]
|
||||
# command = "docs-server" # required
|
||||
# args = ["--port", "4000"] # optional
|
||||
# env = { "API_KEY" = "value" } # optional key/value pairs copied as-is
|
||||
# env_vars = ["ANOTHER_SECRET"] # optional: forward these from the parent env
|
||||
# cwd = "/path/to/server" # optional working directory override
|
||||
# startup_timeout_sec = 10.0 # optional; default 10.0 seconds
|
||||
# # startup_timeout_ms = 10000 # optional alias for startup timeout (milliseconds)
|
||||
# tool_timeout_sec = 60.0 # optional; default 60.0 seconds
|
||||
# enabled_tools = ["search", "summarize"] # optional allow-list
|
||||
# disabled_tools = ["slow-tool"] # optional deny-list (applied after allow-list)
|
||||
|
||||
# --- Example: Streamable HTTP transport ---
|
||||
# [mcp_servers.github]
|
||||
# url = "https://github-mcp.example.com/mcp" # required
|
||||
# bearer_token_env_var = "GITHUB_TOKEN" # optional; Authorization: Bearer <token>
|
||||
# http_headers = { "X-Example" = "value" } # optional static headers
|
||||
# env_http_headers = { "X-Auth" = "AUTH_ENV" } # optional headers populated from env vars
|
||||
# startup_timeout_sec = 10.0 # optional
|
||||
# tool_timeout_sec = 60.0 # optional
|
||||
# enabled_tools = ["list_issues"] # optional allow-list
|
||||
|
||||
################################################################################
|
||||
# Model Providers (extend/override built-ins)
|
||||
################################################################################
|
||||
|
||||
# Built-ins include:
|
||||
# - openai (Responses API; requires login or OPENAI_API_KEY via auth flow)
|
||||
# - oss (Chat Completions API; defaults to http://localhost:11434/v1)
|
||||
|
||||
[model_providers]
|
||||
|
||||
# --- Example: override OpenAI with explicit base URL or headers ---
|
||||
# [model_providers.openai]
|
||||
# name = "OpenAI"
|
||||
# base_url = "https://api.openai.com/v1" # default if unset
|
||||
# wire_api = "responses" # "responses" | "chat" (default varies)
|
||||
# # requires_openai_auth = true # built-in OpenAI defaults to true
|
||||
# # request_max_retries = 4 # default 4; max 100
|
||||
# # stream_max_retries = 5 # default 5; max 100
|
||||
# # stream_idle_timeout_ms = 300000 # default 300_000 (5m)
|
||||
# # experimental_bearer_token = "sk-example" # optional dev-only direct bearer token
|
||||
# # http_headers = { "X-Example" = "value" }
|
||||
# # env_http_headers = { "OpenAI-Organization" = "OPENAI_ORGANIZATION", "OpenAI-Project" = "OPENAI_PROJECT" }
|
||||
|
||||
# --- Example: Azure (Chat/Responses depending on endpoint) ---
|
||||
# [model_providers.azure]
|
||||
# name = "Azure"
|
||||
# base_url = "https://YOUR_PROJECT_NAME.openai.azure.com/openai"
|
||||
# wire_api = "responses" # or "chat" per endpoint
|
||||
# query_params = { api-version = "2025-04-01-preview" }
|
||||
# env_key = "AZURE_OPENAI_API_KEY"
|
||||
# # env_key_instructions = "Set AZURE_OPENAI_API_KEY in your environment"
|
||||
|
||||
# --- Example: Local OSS (e.g., Ollama-compatible) ---
|
||||
# [model_providers.ollama]
|
||||
# name = "Ollama"
|
||||
# base_url = "http://localhost:11434/v1"
|
||||
# wire_api = "chat"
|
||||
|
||||
################################################################################
|
||||
# Profiles (named presets)
|
||||
################################################################################
|
||||
|
||||
# Active profile name. When unset, no profile is applied.
|
||||
# profile = "default"
|
||||
|
||||
[profiles]
|
||||
|
||||
# [profiles.default]
|
||||
# model = "gpt-5.1-codex-max"
|
||||
# model_provider = "openai"
|
||||
# approval_policy = "on-request"
|
||||
# sandbox_mode = "read-only"
|
||||
# model_reasoning_effort = "medium"
|
||||
# model_reasoning_summary = "auto"
|
||||
# model_verbosity = "medium"
|
||||
# chatgpt_base_url = "https://chatgpt.com/backend-api/"
|
||||
# experimental_compact_prompt_file = "./compact_prompt.txt"
|
||||
# include_apply_patch_tool = false
|
||||
# experimental_use_freeform_apply_patch = false
|
||||
# tools_web_search = false
|
||||
# tools_view_image = true
|
||||
# features = { unified_exec = false }
|
||||
|
||||
################################################################################
|
||||
# Projects (trust levels)
|
||||
################################################################################
|
||||
|
||||
# Mark specific worktrees as trusted. Only "trusted" is recognized.
|
||||
[projects]
|
||||
# [projects."/absolute/path/to/project"]
|
||||
# trust_level = "trusted"
|
||||
|
||||
################################################################################
|
||||
# OpenTelemetry (OTEL) – disabled by default
|
||||
################################################################################
|
||||
|
||||
[otel]
|
||||
# Include user prompt text in logs. Default: false
|
||||
log_user_prompt = false
|
||||
# Environment label applied to telemetry. Default: "dev"
|
||||
environment = "dev"
|
||||
# Exporter: none (default) | otlp-http | otlp-grpc
|
||||
exporter = "none"
|
||||
|
||||
# Example OTLP/HTTP exporter configuration
|
||||
# [otel.exporter."otlp-http"]
|
||||
# endpoint = "https://otel.example.com/v1/logs"
|
||||
# protocol = "binary" # "binary" | "json"
|
||||
|
||||
# [otel.exporter."otlp-http".headers]
|
||||
# "x-otlp-api-key" = "${OTLP_TOKEN}"
|
||||
|
||||
# Example OTLP/gRPC exporter configuration
|
||||
# [otel.exporter."otlp-grpc"]
|
||||
# endpoint = "https://otel.example.com:4317",
|
||||
# headers = { "x-otlp-meta" = "abc123" }
|
||||
|
||||
# Example OTLP exporter with mutual TLS
|
||||
# [otel.exporter."otlp-http"]
|
||||
# endpoint = "https://otel.example.com/v1/logs"
|
||||
# protocol = "binary"
|
||||
|
||||
# [otel.exporter."otlp-http".headers]
|
||||
# "x-otlp-api-key" = "${OTLP_TOKEN}"
|
||||
|
||||
# [otel.exporter."otlp-http".tls]
|
||||
# ca-certificate = "certs/otel-ca.pem"
|
||||
# client-certificate = "/etc/codex/certs/client.pem"
|
||||
# client-private-key = "/etc/codex/certs/client-key.pem"
|
||||
```
|
||||
For a sample configuration file, see [this documentation](https://developers.openai.com/codex/config-sample).
|
||||
|
||||
115
docs/exec.md
115
docs/exec.md
@@ -1,114 +1,3 @@
|
||||
## Non-interactive mode
|
||||
# Non-interactive mode
|
||||
|
||||
Use Codex in non-interactive mode to automate common workflows.
|
||||
|
||||
```shell
|
||||
codex exec "count the total number of lines of code in this project"
|
||||
```
|
||||
|
||||
In non-interactive mode, Codex does not ask for command or edit approvals. By default it runs in `read-only` mode, so it cannot edit files or run commands that require network access.
|
||||
|
||||
Use `codex exec --full-auto` to allow file edits. Use `codex exec --sandbox danger-full-access` to allow edits and networked commands.
|
||||
|
||||
### Default output mode
|
||||
|
||||
By default, Codex streams its activity to stderr and only writes the final message from the agent to stdout. This makes it easier to pipe `codex exec` into another tool without extra filtering.
|
||||
|
||||
To write the output of `codex exec` to a file, in addition to using a shell redirect like `>`, there is also a dedicated flag to specify an output file: `-o`/`--output-last-message`.
|
||||
|
||||
### JSON output mode
|
||||
|
||||
`codex exec` supports a `--json` mode that streams events to stdout as JSON Lines (JSONL) while the agent runs.
|
||||
|
||||
Supported event types:
|
||||
|
||||
- `thread.started` - when a thread is started or resumed.
|
||||
- `turn.started` - when a turn starts. A turn encompasses all events between the user message and the assistant response.
|
||||
- `turn.completed` - when a turn completes; includes token usage.
|
||||
- `turn.failed` - when a turn fails; includes error details.
|
||||
- `item.started`/`item.updated`/`item.completed` - when a thread item is added/updated/completed.
|
||||
- `error` - when the stream reports an unrecoverable error; includes the error message.
|
||||
|
||||
Supported item types:
|
||||
|
||||
- `agent_message` - assistant message.
|
||||
- `reasoning` - a summary of the assistant's thinking.
|
||||
- `command_execution` - assistant executing a command.
|
||||
- `file_change` - assistant making file changes.
|
||||
- `mcp_tool_call` - assistant calling an MCP tool.
|
||||
- `web_search` - assistant performing a web search.
|
||||
- `todo_list` - the agent's running plan when the plan tool is active, updating as steps change.
|
||||
|
||||
Typically, an `agent_message` is added at the end of the turn.
|
||||
|
||||
Sample output:
|
||||
|
||||
```jsonl
|
||||
{"type":"thread.started","thread_id":"0199a213-81c0-7800-8aa1-bbab2a035a53"}
|
||||
{"type":"turn.started"}
|
||||
{"type":"item.completed","item":{"id":"item_0","type":"reasoning","text":"**Searching for README files**"}}
|
||||
{"type":"item.started","item":{"id":"item_1","type":"command_execution","command":"bash -lc ls","aggregated_output":"","status":"in_progress"}}
|
||||
{"type":"item.completed","item":{"id":"item_1","type":"command_execution","command":"bash -lc ls","aggregated_output":"2025-09-11\nAGENTS.md\nCHANGELOG.md\ncliff.toml\ncodex-cli\ncodex-rs\ndocs\nexamples\nflake.lock\nflake.nix\nLICENSE\nnode_modules\nNOTICE\npackage.json\npnpm-lock.yaml\npnpm-workspace.yaml\nPNPM.md\nREADME.md\nscripts\nsdk\ntmp\n","exit_code":0,"status":"completed"}}
|
||||
{"type":"item.completed","item":{"id":"item_2","type":"reasoning","text":"**Checking repository root for README**"}}
|
||||
{"type":"item.completed","item":{"id":"item_3","type":"agent_message","text":"Yep — there’s a `README.md` in the repository root."}}
|
||||
{"type":"turn.completed","usage":{"input_tokens":24763,"cached_input_tokens":24448,"output_tokens":122}}
|
||||
```
|
||||
|
||||
### Structured output
|
||||
|
||||
By default, the agent responds with natural language. Use `--output-schema` to provide a JSON Schema that defines the expected JSON output.
|
||||
|
||||
The JSON Schema must follow the [strict schema rules](https://platform.openai.com/docs/guides/structured-outputs).
|
||||
|
||||
Sample schema:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"project_name": { "type": "string" },
|
||||
"programming_languages": { "type": "array", "items": { "type": "string" } }
|
||||
},
|
||||
"required": ["project_name", "programming_languages"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
```
|
||||
|
||||
```shell
|
||||
codex exec "Extract details of the project" --output-schema ~/schema.json
|
||||
...
|
||||
|
||||
{"project_name":"Codex CLI","programming_languages":["Rust","TypeScript","Shell"]}
|
||||
```
|
||||
|
||||
Combine `--output-schema` with `-o` to only print the final JSON output. You can also pass a file path to `-o` to save the JSON output to a file.
|
||||
|
||||
### Git repository requirement
|
||||
|
||||
Codex requires a Git repository to avoid destructive changes. To disable this check, use `codex exec --skip-git-repo-check`.
|
||||
|
||||
### Resuming non-interactive sessions
|
||||
|
||||
Resume a previous non-interactive session with `codex exec resume <SESSION_ID>` or `codex exec resume --last`. This preserves conversation context so you can ask follow-up questions or give new tasks to the agent.
|
||||
|
||||
```shell
|
||||
codex exec "Review the change, look for use-after-free issues"
|
||||
codex exec resume --last "Fix use-after-free issues"
|
||||
```
|
||||
|
||||
Only the conversation context is preserved; you must still provide flags to customize Codex behavior.
|
||||
|
||||
```shell
|
||||
codex exec --model gpt-5.1-codex-max --json "Review the change, look for use-after-free issues"
|
||||
codex exec --model gpt-5.1 --json resume --last "Fix use-after-free issues"
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
By default, `codex exec` will use the same authentication method as Codex CLI and VSCode extension. You can override the api key by setting the `CODEX_API_KEY` environment variable.
|
||||
|
||||
```shell
|
||||
CODEX_API_KEY=your-api-key-here codex exec "Fix merge conflict"
|
||||
```
|
||||
|
||||
NOTE: `CODEX_API_KEY` is only supported in `codex exec`.
|
||||
For information about non-interactive mode, see [this documentation](https://developers.openai.com/codex/noninteractive).
|
||||
|
||||
@@ -1,74 +1,3 @@
|
||||
# Execpolicy quickstart
|
||||
# Execution policy
|
||||
|
||||
Codex can enforce your own rules-based execution policy before it runs shell commands. Policies live in `.rules` files under `~/.codex/rules`.
|
||||
|
||||
## How to create and edit rules
|
||||
|
||||
### TUI interactions
|
||||
|
||||
Codex CLI will present the option to whitelist commands when a command causes a prompt.
|
||||
|
||||
<img width="513" height="168" alt="Screenshot 2025-12-04 at 9 23 54 AM" src="https://github.com/user-attachments/assets/4c8ee8ea-3101-4a81-bb13-3f4a9aa02502" />
|
||||
|
||||
Whitelisted commands will no longer require your permission to run in current and subsequent sessions.
|
||||
|
||||
Under the hood, when you approve and whitelist a command, codex will edit `~/.codex/rules/default.rules`.
|
||||
|
||||
### Editing `.rules` files
|
||||
|
||||
1. Create a policy directory: `mkdir -p ~/.codex/rules`.
|
||||
2. Add one or more `.rules` files in that folder. Codex automatically loads every `.rules` file in there on startup.
|
||||
3. Write `prefix_rule` entries to describe the commands you want to allow, prompt, or block:
|
||||
|
||||
```starlark
|
||||
prefix_rule(
|
||||
pattern = ["git", ["push", "fetch"]],
|
||||
decision = "prompt", # allow | prompt | forbidden
|
||||
match = [["git", "push", "origin", "main"]], # examples that must match
|
||||
not_match = [["git", "status"]], # examples that must not match
|
||||
)
|
||||
```
|
||||
|
||||
- `pattern` is a list of shell tokens, evaluated from left to right; wrap tokens in a nested list to express alternatives (for example, match both `push` and `fetch`).
|
||||
- `decision` sets the severity; Codex picks the strictest decision when multiple rules match (forbidden > prompt > allow).
|
||||
- `match` and `not_match` act as optional unit tests. Codex validates them when it loads your policy, so you get feedback if an example has unexpected behavior.
|
||||
|
||||
In this example rule, if Codex wants to run commands with the prefix `git push` or `git fetch`, it will first ask for user approval.
|
||||
|
||||
## Preview decisions
|
||||
|
||||
Use the `codex execpolicy check` subcommand to preview decisions before you save a rule (see the [`codex-execpolicy` README](../codex-rs/execpolicy/README.md) for syntax details):
|
||||
|
||||
```shell
|
||||
codex execpolicy check --rules ~/.codex/rules/default.rules git push origin main
|
||||
```
|
||||
|
||||
Pass multiple `--rules` flags to test how several files combine, and use `--pretty` for formatted JSON output. See the [`codex-rs/execpolicy` README](../codex-rs/execpolicy/README.md) for a more detailed walkthrough of the available syntax.
|
||||
|
||||
Example output when a rule matches:
|
||||
|
||||
```json
|
||||
{
|
||||
"matchedRules": [
|
||||
{
|
||||
"prefixRuleMatch": {
|
||||
"matchedPrefix": ["git", "push"],
|
||||
"decision": "prompt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"decision": "prompt"
|
||||
}
|
||||
```
|
||||
|
||||
When no rules match, `matchedRules` is an empty array and `decision` is omitted.
|
||||
|
||||
```json
|
||||
{
|
||||
"matchedRules": []
|
||||
}
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
`execpolicy` commands are still in preview. The API may have breaking changes in the future.
|
||||
For an overview of execution policy rules, see [this documentation](https://developers.openai.com/codex/exec-policy).
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
## Experimental technology disclaimer
|
||||
|
||||
Codex CLI is an experimental project under active development. It is not yet stable, may contain bugs, incomplete features, or undergo breaking changes. We're building it in the open with the community and welcome:
|
||||
|
||||
- Bug reports
|
||||
- Feature requests
|
||||
- Pull requests
|
||||
- Good vibes
|
||||
|
||||
Help us improve by filing issues or submitting PRs (see [contributing.md](./contributing.md) for guidance)!
|
||||
55
docs/faq.md
55
docs/faq.md
@@ -1,55 +0,0 @@
|
||||
## FAQ
|
||||
|
||||
This FAQ highlights the most common questions and points you to the right deep-dive guides in `docs/`.
|
||||
|
||||
### OpenAI released a model called Codex in 2021 - is this related?
|
||||
|
||||
In 2021, OpenAI released Codex, an AI system designed to generate code from natural language prompts. That original Codex model was deprecated as of March 2023 and is separate from the CLI tool.
|
||||
|
||||
### Which models are supported?
|
||||
|
||||
We recommend using Codex with GPT-5.1 Codex Max, our best coding model. The default reasoning level is medium, and you can upgrade to high or xhigh (where supported, e.g. `gpt-5.1-codex-max` and `gpt-5.2`) for complex tasks with the `/model` command.
|
||||
|
||||
You can also use older models by using API-based auth and launching codex with the `--model` flag.
|
||||
|
||||
### How do approvals and sandbox modes work together?
|
||||
|
||||
Approvals are the mechanism Codex uses to ask before running a tool call with elevated permissions - typically to leave the sandbox or re-run a failed command without isolation. Sandbox mode provides the baseline isolation (`Read Only`, `Workspace Write`, or `Danger Full Access`; see [Sandbox & approvals](./sandbox.md)).
|
||||
|
||||
### Can I automate tasks without the TUI?
|
||||
|
||||
Yes. [`codex exec`](./exec.md) runs Codex in non-interactive mode with streaming logs, JSONL output, and structured schema support. The command respects the same sandbox and approval settings you configure in the [Config guide](./config.md).
|
||||
|
||||
### How do I stop Codex from editing my files?
|
||||
|
||||
By default, Codex can modify files in your current working directory (Auto mode). To prevent edits, run `codex` in read-only mode with the CLI flag `--sandbox read-only`. Alternatively, you can change the approval level mid-conversation with `/approvals`.
|
||||
|
||||
### How do I connect Codex to MCP servers?
|
||||
|
||||
Configure MCP servers through your `config.toml` using the examples in [Config -> Connecting to MCP servers](./config.md#connecting-to-mcp-servers).
|
||||
|
||||
### I'm having trouble logging in. What should I check?
|
||||
|
||||
Confirm your setup in three steps:
|
||||
|
||||
1. Walk through the auth flows in [Authentication](./authentication.md) to ensure the correct credentials are present in `~/.codex/auth.json`.
|
||||
2. If you're on a headless or remote machine, make sure port-forwarding is configured as described in [Authentication -> Connecting on a "Headless" Machine](./authentication.md#connecting-on-a-headless-machine).
|
||||
|
||||
### Does it work on Windows?
|
||||
|
||||
Running Codex directly on Windows may work, but is not officially supported. We recommend using [Windows Subsystem for Linux (WSL2)](https://learn.microsoft.com/en-us/windows/wsl/install).
|
||||
|
||||
### Where should I start after installation?
|
||||
|
||||
Follow the quick setup in [Install & build](./install.md) and then jump into [Getting started](./getting-started.md) for interactive usage tips, prompt examples, and AGENTS.md guidance.
|
||||
|
||||
### `brew upgrade codex` isn't upgrading me
|
||||
|
||||
If you're running Codex v0.46.0 or older, `brew upgrade codex` will not move you to the latest version because we migrated from a Homebrew formula to a cask. To upgrade, uninstall the existing oudated formula and then install the new cask:
|
||||
|
||||
```bash
|
||||
brew uninstall --formula codex
|
||||
brew install --cask codex
|
||||
```
|
||||
|
||||
After reinstalling, `brew upgrade --cask codex` will keep future releases up to date.
|
||||
@@ -1,120 +1,3 @@
|
||||
## Getting started
|
||||
# Getting started with Codex CLI
|
||||
|
||||
Looking for something specific? Jump ahead:
|
||||
|
||||
- [Tips & shortcuts](#tips--shortcuts) – hotkeys, resume flow, prompts
|
||||
- [Non-interactive runs](./exec.md) – automate with `codex exec`
|
||||
- Ready for deeper customization? Head to [`advanced.md`](./advanced.md)
|
||||
|
||||
### CLI usage
|
||||
|
||||
| Command | Purpose | Example |
|
||||
| ------------------ | ---------------------------------- | ------------------------------- |
|
||||
| `codex` | Interactive TUI | `codex` |
|
||||
| `codex "..."` | Initial prompt for interactive TUI | `codex "fix lint errors"` |
|
||||
| `codex exec "..."` | Non-interactive "automation mode" | `codex exec "explain utils.ts"` |
|
||||
|
||||
Key flags: `--model/-m`, `--ask-for-approval/-a`.
|
||||
|
||||
### Resuming interactive sessions
|
||||
|
||||
- Run `codex resume` to display the session picker UI
|
||||
- Resume most recent: `codex resume --last`
|
||||
- Resume by id: `codex resume <SESSION_ID>` (You can get session ids from /status or `~/.codex/sessions/`)
|
||||
- The picker shows the session's recorded Git branch when available.
|
||||
- To show the session's original working directory (CWD), run `codex resume --all` (this also disables cwd filtering and adds a `CWD` column).
|
||||
|
||||
Examples:
|
||||
|
||||
```shell
|
||||
# Open a picker of recent sessions
|
||||
codex resume
|
||||
|
||||
# Resume the most recent session
|
||||
codex resume --last
|
||||
|
||||
# Resume a specific session by id
|
||||
codex resume 7f9f9a2e-1b3c-4c7a-9b0e-123456789abc
|
||||
```
|
||||
|
||||
### Running with a prompt as input
|
||||
|
||||
You can also run Codex CLI with a prompt as input:
|
||||
|
||||
```shell
|
||||
codex "explain this codebase to me"
|
||||
```
|
||||
|
||||
### Example prompts
|
||||
|
||||
Below are a few bite-size examples you can copy-paste. Replace the text in quotes with your own task.
|
||||
|
||||
| ✨ | What you type | What happens |
|
||||
| --- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
||||
| 1 | `codex "Refactor the Dashboard component to React Hooks"` | Codex rewrites the class component, runs `npm test`, and shows the diff. |
|
||||
| 2 | `codex "Generate SQL migrations for adding a users table"` | Infers your ORM, creates migration files, and runs them in a sandboxed DB. |
|
||||
| 3 | `codex "Write unit tests for utils/date.ts"` | Generates tests, executes them, and iterates until they pass. |
|
||||
| 4 | `codex "Bulk-rename *.jpeg -> *.jpg with git mv"` | Safely renames files and updates imports/usages. |
|
||||
| 5 | `codex "Explain what this regex does: ^(?=.*[A-Z]).{8,}$"` | Outputs a step-by-step human explanation. |
|
||||
| 6 | `codex "Carefully review this repo, and propose 3 high impact well-scoped PRs"` | Suggests impactful PRs in the current codebase. |
|
||||
| 7 | `codex "Look for vulnerabilities and create a security review report"` | Finds and explains security bugs. |
|
||||
|
||||
Looking to reuse your own instructions? Create slash commands with [custom prompts](./prompts.md).
|
||||
|
||||
### Memory with AGENTS.md
|
||||
|
||||
You can give Codex extra instructions and guidance using `AGENTS.md` files. Codex looks for them in the following places, and merges them top-down:
|
||||
|
||||
1. `~/.codex/AGENTS.md` - personal global guidance
|
||||
2. Every directory from the repository root down to your current working directory (inclusive). In each directory, Codex first looks for `AGENTS.override.md` and uses it if present; otherwise it falls back to `AGENTS.md`. Use the override form when you want to replace inherited instructions for that directory.
|
||||
|
||||
For more information on how to use AGENTS.md, see the [official AGENTS.md documentation](https://agents.md/).
|
||||
|
||||
### Tips & shortcuts
|
||||
|
||||
#### Use `@` for file search
|
||||
|
||||
Typing `@` triggers a fuzzy-filename search over the workspace root. Use up/down to select among the results and Tab or Enter to replace the `@` with the selected path. You can use Esc to cancel the search.
|
||||
|
||||
#### Esc–Esc to edit a previous message
|
||||
|
||||
When the chat composer is empty, press Esc to prime “backtrack” mode. Press Esc again to open a transcript preview highlighting the last user message; press Esc repeatedly to step to older user messages. Press Enter to confirm and Codex will fork the conversation from that point, trim the visible transcript accordingly, and pre‑fill the composer with the selected user message so you can edit and resubmit it.
|
||||
|
||||
In the transcript preview, the footer shows an `Esc edit prev` hint while editing is active.
|
||||
|
||||
#### `--cd`/`-C` flag
|
||||
|
||||
Sometimes it is not convenient to `cd` to the directory you want Codex to use as the "working root" before running Codex. Fortunately, `codex` supports a `--cd` option so you can specify whatever folder you want. You can confirm that Codex is honoring `--cd` by double-checking the **workdir** it reports in the TUI at the start of a new session.
|
||||
|
||||
#### `--add-dir` flag
|
||||
|
||||
Need to work across multiple projects in one run? Pass `--add-dir` one or more times to expose extra directories as writable roots for the current session while keeping the main working directory unchanged. For example:
|
||||
|
||||
```shell
|
||||
codex --cd apps/frontend --add-dir ../backend --add-dir ../shared
|
||||
```
|
||||
|
||||
Codex can then inspect and edit files in each listed directory without leaving the primary workspace.
|
||||
|
||||
#### Shell completions
|
||||
|
||||
Generate shell completion scripts via:
|
||||
|
||||
```shell
|
||||
codex completion bash
|
||||
codex completion zsh
|
||||
codex completion fish
|
||||
```
|
||||
|
||||
#### Image input
|
||||
|
||||
Paste images directly into the composer (Ctrl+V / Cmd+V) to attach them to your prompt. You can also attach files via the CLI using `-i/--image` (comma‑separated):
|
||||
|
||||
```bash
|
||||
codex -i screenshot.png "Explain this error"
|
||||
codex --image img1.png,img2.jpg "Summarize these diagrams"
|
||||
```
|
||||
|
||||
#### Environment variables and executables
|
||||
|
||||
Make sure your environment is already set up before launching Codex so it does not spend tokens probing what to activate. For example, source your Python virtualenv (or other language runtimes), start any required daemons, and export the env vars you expect to use ahead of time.
|
||||
For an overview of Codex CLI features, see [this documentation](https://developers.openai.com/codex/cli/features#running-in-interactive-mode).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Install & build
|
||||
## Installing & building
|
||||
|
||||
### System requirements
|
||||
|
||||
@@ -46,3 +46,17 @@ just test
|
||||
# Otherwise, fall back to:
|
||||
cargo test --all-features
|
||||
```
|
||||
|
||||
## Tracing / verbose logging
|
||||
|
||||
Codex is written in Rust, so it honors the `RUST_LOG` environment variable to configure its logging behavior.
|
||||
|
||||
The TUI defaults to `RUST_LOG=codex_core=info,codex_tui=info,codex_rmcp_client=info` and log messages are written to `~/.codex/log/codex-tui.log`, so you can leave the following running in a separate terminal to monitor log messages as they are written:
|
||||
|
||||
```bash
|
||||
tail -F ~/.codex/log/codex-tui.log
|
||||
```
|
||||
|
||||
By comparison, the non-interactive mode (`codex exec`) defaults to `RUST_LOG=error`, but messages are printed inline, so there is no need to monitor a separate file.
|
||||
|
||||
See the Rust documentation on [`RUST_LOG`](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) for more information on the configuration options.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
## Platform sandboxing
|
||||
|
||||
This content now lives alongside the rest of the sandbox guidance. See [Sandbox mechanics by platform](./sandbox.md#sandbox-mechanics-by-platform) for up-to-date details.
|
||||
@@ -1,96 +1,3 @@
|
||||
## Custom Prompts
|
||||
# Custom prompts
|
||||
|
||||
Custom prompts turn your repeatable instructions into reusable slash commands, so you can trigger them without retyping or copy/pasting. Each prompt is a Markdown file that Codex expands into the conversation the moment you run it.
|
||||
|
||||
### Where prompts live
|
||||
|
||||
- Location: store prompts in `$CODEX_HOME/prompts/` (defaults to `~/.codex/prompts/`). Set `CODEX_HOME` if you want to use a different folder.
|
||||
- File type: Codex only loads `.md` files. Non-Markdown files are ignored. Both regular files and symlinks to Markdown files are supported.
|
||||
- Naming: The filename (without `.md`) becomes the prompt name. A file called `review.md` registers the prompt `review`.
|
||||
- Refresh: Prompts are loaded when a session starts. Restart Codex (or start a new session) after adding or editing files.
|
||||
- Conflicts: Files whose names collide with built-in commands (like `init`) stay hidden in the slash popup, but you can still invoke them with `/prompts:<name>`.
|
||||
|
||||
### File format
|
||||
|
||||
- Body: The file contents are sent verbatim when you run the prompt (after placeholder expansion).
|
||||
- Frontmatter (optional): Add YAML-style metadata at the top of the file to improve the slash popup.
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Request a concise git diff review
|
||||
argument-hint: FILE=<path> [FOCUS=<section>]
|
||||
---
|
||||
```
|
||||
|
||||
- `description` shows under the entry in the popup.
|
||||
- `argument-hint` (or `argument_hint`) lets you document expected inputs, though the current UI ignores this metadata.
|
||||
|
||||
### Placeholders and arguments
|
||||
|
||||
- Numeric placeholders: `$1`–`$9` insert the first nine positional arguments you type after the command. `$ARGUMENTS` inserts all positional arguments joined by a single space. Use `$$` to emit a literal dollar sign (Codex leaves `$$` untouched).
|
||||
- Named placeholders: Tokens such as `$FILE` or `$TICKET_ID` expand from `KEY=value` pairs you supply. Keys are case-sensitive—use the same uppercase name in the command (for example, `FILE=...`).
|
||||
- Quoted arguments: Double-quote any value that contains spaces, e.g. `TICKET_TITLE="Fix logging"`.
|
||||
- Invocation syntax: Run prompts via `/prompts:<name> ...`. When the slash popup is open, typing either `prompts:` or the bare prompt name will surface `/prompts:<name>` suggestions.
|
||||
- Error handling: If a prompt contains named placeholders, Codex requires them all. You will see a validation message if any are missing or malformed.
|
||||
|
||||
### Running a prompt
|
||||
|
||||
1. Start a new Codex session (ensures the prompt list is fresh).
|
||||
2. In the composer, type `/` to open the slash popup.
|
||||
3. Type `prompts:` (or start typing the prompt name) and select it with ↑/↓.
|
||||
4. Provide any required arguments, press Enter, and Codex sends the expanded content.
|
||||
|
||||
### Examples
|
||||
|
||||
### Example 1: Basic named arguments
|
||||
|
||||
**File**: `~/.codex/prompts/ticket.md`
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Generate a commit message for a ticket
|
||||
argument-hint: TICKET_ID=<id> TICKET_TITLE=<title>
|
||||
---
|
||||
|
||||
Please write a concise commit message for ticket $TICKET_ID: $TICKET_TITLE
|
||||
```
|
||||
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
/prompts:ticket TICKET_ID=JIRA-1234 TICKET_TITLE="Fix login bug"
|
||||
```
|
||||
|
||||
**Expanded prompt sent to Codex**:
|
||||
|
||||
```
|
||||
Please write a concise commit message for ticket JIRA-1234: Fix login bug
|
||||
```
|
||||
|
||||
**Note**: Both `TICKET_ID` and `TICKET_TITLE` are required. If either is missing, Codex will show a validation error. Values with spaces must be double-quoted.
|
||||
|
||||
### Example 2: Mixed positional and named arguments
|
||||
|
||||
**File**: `~/.codex/prompts/review.md`
|
||||
|
||||
```markdown
|
||||
---
|
||||
description: Review code in a specific file with focus area
|
||||
argument-hint: FILE=<path> [FOCUS=<section>]
|
||||
---
|
||||
|
||||
Review the code in $FILE. Pay special attention to $FOCUS.
|
||||
```
|
||||
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
/prompts:review FILE=src/auth.js FOCUS="error handling"
|
||||
```
|
||||
|
||||
**Expanded prompt**:
|
||||
|
||||
```
|
||||
Review the code in src/auth.js. Pay special attention to error handling.
|
||||
|
||||
```
|
||||
For an overview of custom prompts, see [this documentation](https://developers.openai.com/codex/custom-prompts).
|
||||
|
||||
@@ -1,96 +1,3 @@
|
||||
## Sandbox & approvals
|
||||
|
||||
What Codex is allowed to do is governed by a combination of **sandbox modes** (what Codex is allowed to do without supervision) and **approval policies** (when you must confirm an action). This page explains the options, how they interact, and how the sandbox behaves on each platform.
|
||||
|
||||
### Approval policies
|
||||
|
||||
Codex starts conservatively. Until you explicitly tell it a working directory is trusted, the CLI defaults to **read-only**. Codex can inspect files and answer questions, but every edit or command requires approval.
|
||||
|
||||
When you mark a working directory as trusted (for example via the onboarding prompt or `/approvals` → “Trust this directory”), Codex upgrades the default preset to **Agent**, which allows writes inside the workspace. Codex only interrupts you when it needs to leave the workspace or rerun something outside the sandbox. Note that the workspace includes the working directory plus temporary directories like `/tmp`. Use `/status` to confirm the exact writable roots.
|
||||
|
||||
If you want maximum guardrails for a trusted repo, switch back to Read Only from the `/approvals` picker. If you truly need hands-off automation, use `Full Access`—but be deliberate, because that skips both the sandbox and approvals.
|
||||
|
||||
### Can I run without ANY approvals?
|
||||
|
||||
Yes, you can disable all approval prompts with `--ask-for-approval never`. This option works with all `--sandbox` modes, so you still have full control over Codex's level of autonomy. It will make its best attempt with whatever constraints you provide.
|
||||
|
||||
### Common sandbox + approvals combinations
|
||||
|
||||
| Intent | Flags | Effect |
|
||||
| ---------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Safe read-only browsing | `--sandbox read-only --ask-for-approval on-request` | Codex can read files and answer questions. Codex requires approval to make edits, run commands, or access network. |
|
||||
| Read-only non-interactive (CI) | `--sandbox read-only --ask-for-approval never` | Reads only; never escalates |
|
||||
| Let it edit the repo, ask if risky | `--sandbox workspace-write --ask-for-approval on-request` | Codex can read files, make edits, and run commands in the workspace. Codex requires approval for actions outside the workspace or for network access. |
|
||||
| Auto (preset; trusted repos) | `--full-auto` (equivalent to `--sandbox workspace-write` + `--ask-for-approval on-request`) | Codex runs sandboxed commands that can write inside the workspace without prompting. Escalates only when it must leave the sandbox. |
|
||||
| YOLO (not recommended) | `--dangerously-bypass-approvals-and-sandbox` (alias: `--yolo`) | No sandbox; no prompts |
|
||||
|
||||
> Note: In `workspace-write`, network is disabled by default unless enabled in config (`[sandbox_workspace_write].network_access = true`).
|
||||
|
||||
#### Fine-tuning in `config.toml`
|
||||
|
||||
```toml
|
||||
# approval mode
|
||||
approval_policy = "untrusted"
|
||||
sandbox_mode = "read-only"
|
||||
|
||||
# full-auto mode
|
||||
approval_policy = "on-request"
|
||||
sandbox_mode = "workspace-write"
|
||||
|
||||
# Optional: allow network in workspace-write mode
|
||||
[sandbox_workspace_write]
|
||||
network_access = true
|
||||
```
|
||||
|
||||
You can also save presets as **profiles**:
|
||||
|
||||
```toml
|
||||
[profiles.full_auto]
|
||||
approval_policy = "on-request"
|
||||
sandbox_mode = "workspace-write"
|
||||
|
||||
[profiles.readonly_quiet]
|
||||
approval_policy = "never"
|
||||
sandbox_mode = "read-only"
|
||||
```
|
||||
|
||||
### Sandbox mechanics by platform
|
||||
|
||||
The mechanism Codex uses to enforce the sandbox policy depends on your OS:
|
||||
|
||||
#### macOS 12+
|
||||
|
||||
Uses **Apple Seatbelt**. Codex invokes `sandbox-exec` with a profile that corresponds to the selected `--sandbox` mode, constraining filesystem and network access at the OS level.
|
||||
|
||||
#### Linux
|
||||
|
||||
Combines **Landlock** and **seccomp** APIs to approximate the same guarantees. Kernel support is required; older kernels may not expose the necessary features.
|
||||
|
||||
In containerized Linux environments (for example Docker), sandboxing may not work when the host or container configuration does not expose Landlock/seccomp. In those cases, configure the container to provide the isolation you need and run Codex with `--sandbox danger-full-access` (or the shorthand `--dangerously-bypass-approvals-and-sandbox`) inside that container.
|
||||
|
||||
#### Windows
|
||||
|
||||
Windows sandbox support remains experimental. How it works:
|
||||
|
||||
- Launches commands inside a restricted token derived from an AppContainer profile.
|
||||
- Grants only specifically requested filesystem capabilities by attaching capability SIDs to that profile.
|
||||
- Disables outbound network access by overriding proxy-related environment variables and inserting stub executables for common network tools.
|
||||
|
||||
Its primary limitation is that it cannot prevent file writes, deletions, or creations in any directory where the Everyone SID already has write permissions (for example, world-writable folders).
|
||||
See more discussion and limitations at [Windows Sandbox Security Details](./windows_sandbox_security.md).
|
||||
|
||||
## Experimenting with the Codex Sandbox
|
||||
|
||||
To test how commands behave under Codex's sandbox, use the CLI helpers:
|
||||
|
||||
```
|
||||
# macOS
|
||||
codex sandbox macos [--full-auto] [COMMAND]...
|
||||
|
||||
# Linux
|
||||
codex sandbox linux [--full-auto] [COMMAND]...
|
||||
|
||||
# Legacy aliases
|
||||
codex debug seatbelt [--full-auto] [COMMAND]...
|
||||
codex debug landlock [--full-auto] [COMMAND]...
|
||||
```
|
||||
For information about Codex sandboxing and approvals, see [this documentation](https://developers.openai.com/codex/security).
|
||||
|
||||
@@ -1,33 +1,3 @@
|
||||
## Slash Commands
|
||||
# Slash commands
|
||||
|
||||
### What are slash commands?
|
||||
|
||||
Slash commands are special commands you can type that start with `/`.
|
||||
|
||||
---
|
||||
|
||||
### Built-in slash commands
|
||||
|
||||
Control Codex’s behavior during an interactive session with slash commands.
|
||||
|
||||
| Command | Purpose |
|
||||
| --------------- | -------------------------------------------------------------------------- |
|
||||
| `/model` | choose what model and reasoning effort to use |
|
||||
| `/approvals` | choose what Codex can do without approval |
|
||||
| `/review` | review my current changes and find issues |
|
||||
| `/new` | start a new chat during a conversation |
|
||||
| `/resume` | resume an old chat |
|
||||
| `/init` | create an AGENTS.md file with instructions for Codex |
|
||||
| `/compact` | summarize conversation to prevent hitting the context limit |
|
||||
| `/diff` | show git diff (including untracked files) |
|
||||
| `/mention` | mention a file |
|
||||
| `/status` | show current session configuration and token usage |
|
||||
| `/mcp` | list configured MCP tools |
|
||||
| `/experimental` | open the experimental menu to enable features from our beta program |
|
||||
| `/skills` | browse and insert skills (experimental; see [docs/skills.md](./skills.md)) |
|
||||
| `/logout` | log out of Codex |
|
||||
| `/quit` | exit Codex |
|
||||
| `/exit` | exit Codex |
|
||||
| `/feedback` | send logs to maintainers |
|
||||
|
||||
---
|
||||
For an overview of Codex CLI slash commands, see [this documentation](https://developers.openai.com/codex/cli/slash-commands).
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Windows Sandbox Security Details
|
||||
|
||||
For overall context on sandboxing in Codex, see [sandbox.md](./sandbox.md).
|
||||
|
||||
## Implementation Overview
|
||||
|
||||
When commands run via `codex sandbox windows …` (or when the CLI/TUI calls into the same crate in-process for sandboxed turns), the launcher configures a restricted Windows token and an allowlist policy scoped to the declared workspace roots. Writes are blocked everywhere except inside those roots (plus `%TEMP%` when workspace-write mode is requested), and common escape vectors such as alternate data streams, UNC paths, and device handles are denied proactively. The CLI also injects stub executables (for example, wrapping `ssh`) ahead of the host PATH so we can intercept dangerous tools before they ever leave the sandbox.
|
||||
|
||||
## Known Security Limitations
|
||||
|
||||
Running `python windows-sandbox-rs/sandbox_smoketests.py` with full filesystem and network access currently results in **37/41** passing cases. The list below focuses on the four high-value failures numbered #32 and higher in the smoketests (earlier tests are less security-focused).
|
||||
|
||||
| Test | Purpose |
|
||||
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| ADS write denied (#32) | Ensures alternate data streams cannot be written inside the workspace, preventing tools from hiding payloads in ADS. The sandbox currently allows the write (process returns `rc=0`). |
|
||||
| protected path case-variation denied (#33) | Confirms that protected directories such as `.git` remain blocked even when attackers use case tricks like `.GiT`. The current allowlist treats `.GiT` as distinct, so the write succeeds. |
|
||||
| PATH stub bypass denied (#35) | Verifies that a workspace-provided `ssh.bat` shim placed ahead of the host PATH runs instead of the real `ssh`. The sandbox exits early before emitting the shim's `stubbed` output, so we cannot prove the interception works. |
|
||||
| Start-Process https denied (KNOWN FAIL) (#41) | Validates that read-only runs cannot launch the host's default browser via `Start-Process 'https://...'`. Today the command succeeds (exit code 0) because Explorer handles the ShellExecute request outside the sandbox. The failure is captured by `windows-sandbox-rs/sandbox_smoketests.py` (last case). |
|
||||
|
||||
## Want to Help?
|
||||
|
||||
If you are a security-minded Windows user, help us get these tests passing! Improved implementations that make these smoke tests pass meaningfully reduce Codex's escape surface. After iterating, rerun `python windows-sandbox-rs/sandbox_smoketests.py` to validate the fixes and help us drive the suite toward 41/41.
|
||||
@@ -1,3 +0,0 @@
|
||||
## Zero data retention (ZDR) usage
|
||||
|
||||
Codex CLI natively supports OpenAI organizations with [Zero Data Retention (ZDR)](https://platform.openai.com/docs/guides/your-data#zero-data-retention) enabled.
|
||||
Reference in New Issue
Block a user