Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fa8199b
core(config): prefer project-local .codex as CODEX_HOME; update docs
cemilcolak Sep 21, 2025
e2a4281
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 2, 2025
db7107c
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 3, 2025
0e8b8cb
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 3, 2025
b76ebc5
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 4, 2025
fee05dc
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 5, 2025
000f7ba
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 5, 2025
3ca54e0
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 6, 2025
db30509
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 6, 2025
f434a59
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 6, 2025
ed9cd2f
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 6, 2025
1993eb4
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 7, 2025
36d368c
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 7, 2025
4978241
feat(card): add codex home path to card model and display
cemilcolak Oct 7, 2025
1f0c2d0
feat(tests): update snapshots to include codex home path and refactor…
cemilcolak Oct 8, 2025
ed99130
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 8, 2025
146589c
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 8, 2025
9d1f512
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 8, 2025
4d6cda2
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 14, 2025
452bade
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 19, 2025
7c7de70
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 20, 2025
e0795da
Merge branch 'main' into feat/project-local-codex-home
cemilcolak Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions codex-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The Rust implementation is now the maintained Codex CLI and serves as the defaul

Codex supports a rich set of configuration options. Note that the Rust CLI uses `config.toml` instead of `config.json`. See [`docs/config.md`](../docs/config.md) for details.

Project-local overrides: When running Codex inside a project that contains a `.codex/` directory at the repository root (current working directory), Codex will use that directory as `CODEX_HOME`. This means files like `config.toml`, `config.json`, `auth.json`, and history will be read from and written to the project’s `.codex/` instead of the global `~/.codex/`. If no project-local `.codex/` exists, Codex falls back to `CODEX_HOME` (when set) or `~/.codex/`.

### Model Context Protocol Support

#### MCP client
Expand Down
13 changes: 11 additions & 2 deletions codex-rs/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,14 +1226,23 @@ fn default_review_model() -> String {
/// - If `CODEX_HOME` is not set, this function does not verify that the
/// directory exists.
pub fn find_codex_home() -> std::io::Result<PathBuf> {
// Honor the `CODEX_HOME` environment variable when it is set to allow users
// (and tests) to override the default location.
// First preference: project-local ./.codex directory, if it exists.
// This enables per-project overrides without requiring --config or env vars.
let cwd = std::env::current_dir()?;
let project_codex = cwd.join(".codex");
if project_codex.is_dir() {
return Ok(project_codex);
}

// Next: honor the `CODEX_HOME` environment variable when it is set to allow
// users (and tests) to override the default location.
if let Ok(val) = std::env::var("CODEX_HOME")
&& !val.is_empty()
{
return PathBuf::from(val).canonicalize();
}

// Fallback: ~/.codex (do not require it to exist).
let mut p = home_dir().ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::NotFound,
Expand Down
9 changes: 7 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ This key must, at minimum, have write access to the Responses API.
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`)
2. Delete `$CODEX_HOME/auth.json`.
- `CODEX_HOME` resolution order:
1) Project-local `.codex/` in the current working directory, if present.
2) `CODEX_HOME` environment variable, if set.
3) Default `~/.codex/` (on Windows: `C:\\Users\\USERNAME\\.codex\\auth.json`).
3. Run `codex login` again

## Connecting on a "Headless" Machine
Expand All @@ -32,7 +36,8 @@ Today, the login process entails running a server on `localhost:1455`. If you ar

### 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`).
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`.
Recall `CODEX_HOME` resolves to the project-local `.codex/` if present; otherwise to the `CODEX_HOME` env var; otherwise to the default user directory (on Mac/Linux: `~/.codex`, on Windows: `%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:

Expand Down
6 changes: 5 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ Codex supports several mechanisms for setting config values:
- If `value` cannot be parsed as a valid TOML value, it is treated as a string value. This means that `-c model='"o3"'` and `-c model=o3` are equivalent.
- In the first case, the value is the TOML string `"o3"`, while in the second the value is `o3`, which is not valid TOML and therefore treated as the TOML string `"o3"`.
- Because quotes are interpreted by one's shell, `-c key="true"` will be correctly interpreted in TOML as `key = true` (a boolean) and not `key = "true"` (a string). If for some reason you needed the string `"true"`, you would need to use `-c key='"true"'` (note the two sets of quotes).
- The `$CODEX_HOME/config.toml` configuration file where the `CODEX_HOME` environment value defaults to `~/.codex`. (Note `CODEX_HOME` will also be where logs and other Codex-related information are stored.)
- The `$CODEX_HOME/config.toml` configuration file. `CODEX_HOME` is resolved in this order:
1) A project-local `.codex/` directory in the current working directory, if present.
2) The `CODEX_HOME` environment variable, if set.
3) The default `~/.codex/` directory.
(Note `CODEX_HOME` will also be where logs and other Codex-related information are stored.)

Both the `--config` flag and the `config.toml` file support the following options:

Expand Down