Guide

CODEX_HOME, explained.

CODEX_HOME tells Codex where its state lives. By default that's ~/.codex. Change it and Codex behaves like a fresh install there.

What's inside

In CODEX_HOMEWhat it is
auth.jsonYour login: ChatGPT tokens, or an API key
config.tomlModel, approval and sandbox settings, MCP servers, profiles
AGENTS.mdYour personal instructions for every project
sessions/Transcripts of your sessions, so you can resume them
history.jsonlYour prompt history
prompts/, skills/, rules/Custom prompts, skills and rules, if you use them
log/Logs

What exactly is there depends on your Codex version and which features you use.

How to set it

mkdir -p ~/.codex-work                     # must exist before Codex starts
CODEX_HOME=~/.codex-work codex             # one run
export CODEX_HOME=~/.codex-work            # the rest of this shell

The folder has to exist already; Codex doesn't create it for you when the variable is set.

What people use it for

Several accounts

One folder per account, each signed in once. Work and personal run side by side. The full setup.

A clean test setup

Try a new MCP server or config.toml change in a throwaway folder without touching your real one.

CI and scripts

Point CI at a folder that holds only what the job needs, so a build never picks up your personal setup.

Things to know

Questions

What is CODEX_HOME?

An environment variable that sets the folder where Codex keeps its state: login, config, sessions, history and logs. It defaults to ~/.codex.

Does the CODEX_HOME folder have to exist?

Yes. When you set CODEX_HOME, create the folder first; Codex expects it to exist.

Can I share config.toml between two CODEX_HOME folders?

Yes, with a symlink from one folder to the other. Only the login and history then stay separate.

Switch for Codex does this with one click on a Mac: every account in its own Codex app window and in your terminal, all open at once, from the app or the menu bar. $9.99 once, no subscription.

Checked November 24, 2026 · All guides