CLI to manage multiple Codex accounts by profile and promote one account to the default profile (~/.codex) used by Codex App + Codex CLI when CODEX_HOME is not set.
npm i -g @anewryzm/codex-use
- Primary:
codex-use - Short alias:
cdex
tools/codex-use
- Save login per profile:
codex-use login personalcodex-use login work
- Switch the active default account:
codex-use use personalcodex-use use workcodex-use use work --relaunch(recommended so Codex App refreshes the session automatically)codex-use use work --relaunch --from-action(for Actions: relaunches the app and closes the Terminal tab on success)
- Check usage/rate limits:
codex-use usagecodex-use usage --jsoncodex-use limits work --refreshcodex-use limits --allorcodex-use limits -a(compact limits view by profile)
codex-use login <profile>codex-use use <profile> [--force] [--relaunch] [--from-action]codex-use add switch action [--platform <macos|darwin>] [--icon <icon>] [--command-name <cdex|codex-use>] [--dry-run]codex-use delete switch action [--platform <macos|darwin>] [--dry-run]codex-use usage [--json]codex-use backup [--note "..."] [--dir <path>] [--delete]codex-use backup status [--dir <path>]codex-use backup init [--dir <path>]codex-use backup add remote <url> [--name <remote>] [--dir <path>]codex-use backup push [--remote <name>] [--branch <name>] [--dir <path>]codex-use backup restore [--dir <path>] [--relaunch] [--delete]codex-use limits [profile|default] [--all] [--json] [--refresh]codex-use listcodex-use whoamicodex-use status <profile> [--refresh]codex-use logout <profile>codex-use logout-default
usecreates an automatic backup of~/.codex/auth.jsonin~/.codex/backups/.- Avoid switching accounts while there are active tasks in Codex App.
--forceexists for advanced cases and may interrupt in-flight sessions.--relaunchcloses and reopens Codex App so the UI reads the newauth.json.--from-actionis intended for Codex Actions: after a successful--relaunch, it tries to auto-close the current Terminal tab.usagereads local history from~/.codex/sessions.backupsnapshots~/.codex/sessionsinto a Git repo (default:~/codex-history-backup).backupis copy-only by default (no deletions). Use--deleteonly when you intentionally want mirror mode.limitsqueriescodex app-serverusing JSON-RPC (initialize,account/read,account/rateLimits/read).
- Run
codex-use list. - Check the legend:
[*]= the profile uses exactly the same token as~/.codex.[~]= sameaccount_id, but different token/identity.
- If you switch while the app is open, use
codex-use use <profile> --relaunch. - Run
codex-use whoamito seeActive profileplus email/plan/account.
whoami: quick view of the active profile in~/.codex(the account used by app/CLI by default).status <profile>: diagnostics for a specific profile in~/.codex-profiles/<profile>, including:- identity summary (
plan,default_org,email,account_id) - usage limits (
5handweekly) with remaining percentage, horizontal bar, and reset timing - readable credits summary (
credits: none,credits: unlimited,credits: balance ...) - Use
--refreshto force a fresh backend query before showing limits.
usageshows historical consumption from~/.codex/sessionsin a compact table.- Columns:
in(M),out(M),cach(M)(millions of tokens).out(M)includes reasoning. usage --jsonreturns the raw aggregate (totalsandmodels) for scripting.
limits <profile>(without--json) shows dashboard-style output:5handweeklybars, natural-language reset, and credits summary.limits --all/limits -ashows a compact table with columnsprofile,email,5h (reset),weekly (reset)and aCurrent default profileline.limits --jsonkeeps the raw JSON output from rate limits for scripting/automation.
backup statusshows backup health in terminal-first format (key: value), including repo/git state, source vs backup file counts, session-id coverage, and pending copy/delete deltas.pending_copy_filesindicates what would be copied in default mode.pending_new_filesindicates brand-new rollouts not yet present in backup.pending_modified_filesindicates existing rollout files that changed (for example, more conversation appended to the same.jsonl).pending_mirror_deletesindicates what would be removed only in--deletemirror mode.runtime_unflushed_activityindicates there is fresh Codex runtime activity (logs_2.sqlite/state_5.sqlite) newer than the latestsessions/*.jsonlwrite.runtime_vs_sessions_lag_secondsindicates how far runtime activity is ahead of session-log writes.
backupcommits now include aSession notessection with only new/changed rollouts since the previous backup commit (not a cumulative list).- Each note line includes rollout file, resolved title (when available), model, token total snapshot, and latest timestamp.
add switch actionreads logged profiles from~/.codex-profilesand writes per-profile switch actions into.codex/environments/environment.toml.- Platform support for now:
macos(alias:darwin, written asdarwinin the TOML file). - Example:
codex-use add switch action --platform macos- Preview only:
codex-use add switch action --dry-run- Delete generated switch actions for macOS:
codex-use delete switch action --platform macos