Small Bash profile manager for the OpenAI Codex CLI.
codex-profile creates separate CODEX_HOME directories for different Codex
profiles while linking selected local context from the main profile. The common
use case is using a second Codex account or profile without losing access to
existing sessions, memories, rules, skills, and MCP configuration.
Authentication and runtime state stay profile-specific. Shared context is linked through symlinks.
Back up your current Codex home before using this tool:
cp -a "$HOME/.codex" "$HOME/.codex.backup.$(date +%Y%m%d-%H%M%S)"This project is intended for sequential profile switching. Do not run multiple
Codex profiles at the same time when they share sessions/, history.jsonl, or
session_index.jsonl; concurrent writes can corrupt local Codex state.
Shared from the main Codex home:
sessions/
session_index.jsonl
history.jsonl
memories/
rules/
skills/
shell_snapshots/
AGENTS.md
config.toml
models_cache.json
Kept separate per profile:
auth.json
installation_id
state_*.sqlite
logs_*.sqlite
cache/
log/
tmp/
version.json
The script does not move files out of the main Codex home. It creates symlinks
from ~/.codex-shared to the main profile, then from each profile to
~/.codex-shared.
Example:
~/.codex/config.toml
^
~/.codex-shared/config.toml -> ~/.codex/config.toml
^
~/.codex-profiles/backup/config.toml -> ~/.codex-shared/config.toml
git clone https://github.com/yalcin/codex-profile.git
cd codex-profile
./install.shThe installer copies codex-profile to ~/.local/bin/codex-profile by default.
Use INSTALL_DIR to choose a different location:
INSTALL_DIR="$HOME/bin" ./install.shMake sure the install directory is in your PATH, then verify:
codex-profile helpInitialize the shared link directory:
codex-profile initCreate a profile:
codex-profile add backupLog in with that profile:
codex-profile login backupRun Codex with that profile:
codex-profile run backupResume the latest session:
codex-profile resume backup --lastShow all profile paths and shared links:
codex-profile statuscodex-profile init
codex-profile add <profile-name>
codex-profile list
codex-profile path <profile-name>
codex-profile login <profile-name>
codex-profile run <profile-name> [codex args...]
codex-profile resume <profile-name> [codex resume args...]
codex-profile status
codex-profile help
Profile names may contain letters, numbers, dots, underscores, and hyphens.
main, shared, and default are reserved.
CODEX_MAIN_HOME Main Codex home. Default: ~/.codex
CODEX_PROFILE_BASE Profile directory. Default: ~/.codex-profiles
CODEX_SHARED_HOME Shared symlink directory. Default: ~/.codex-shared
Example:
CODEX_PROFILE_BASE="$HOME/.local/share/codex-profiles" codex-profile add backupalias codex-main='CODEX_HOME="$HOME/.codex" codex'
alias codex-backup='codex-profile run backup'
alias codex-backup-resume='codex-profile resume backup --last'
alias codex-backup-resume-all='codex-profile resume backup --all'config.toml is shared by default. To give a profile its own config file, replace
the symlink with a real file:
rm "$HOME/.codex-profiles/backup/config.toml"
cp "$HOME/.codex/config.toml" "$HOME/.codex-profiles/backup/config.toml"Check the current setup:
codex-profile statusIf a profile cannot see previous sessions, try:
codex-profile resume backup --all--last resumes the latest session for the current working directory. --all
includes sessions from other working directories.
shellcheck codex-profile install.sh
./codex-profile helpRun a local profile smoke test:
CODEX_MAIN_HOME=/tmp/codex-profile-main \
CODEX_PROFILE_BASE=/tmp/codex-profile-profiles \
CODEX_SHARED_HOME=/tmp/codex-profile-shared \
./codex-profile add testMIT