A command-line tool that lets you manage and switch between multiple Codex accounts.
Warning
Not affiliated with OpenAI or Codex. Not an official tool.
Codex stores your authentication session in a single auth.json file. This tool works by creating named snapshots of that file for each of your accounts. When you want to switch, codex-auth swaps the active ~/.codex/auth.json with the snapshot you select, instantly changing your logged-in account.
These are only needed when building from source or running repository checks:
- Go 1.24 or newer.
- Node.js 22 or newer for npm packaging tests and release helpers.
make.
No Go or Node.js installation is required when installing a prebuilt release through Homebrew, npm, or GitHub Releases.
- Save multiple Codex logins as named local account snapshots.
- Switch accounts by exact name, detected email, or an arrow-key terminal picker.
- Suggest the closest saved account when a name is mistyped.
- Detect account emails from saved auth files and show them in prompts, lists, and rename flows.
- Ask whether to save an unsaved live Codex login before switching away from it.
- Sync the active account on startup by matching the live Codex auth file against saved snapshots.
- Rename saved accounts without losing the active account marker.
- Render a bordered account table for
list. - Keep script-friendly
--jsonoutput and configurable color with--color auto|always|never.
brew tap shayyz-code/tap
brew install codex-authnpm install -g @shayyz-code/codex-authDownload the binary for your platform from the latest release, then put it somewhere on your PATH.
go install github.com/shayyz-code/codex-auth/cmd/codex-auth@latestmake build# save the current logged-in token as a named account
codex-auth save <name>
# switch active account
codex-auth use <name>
# or pick interactively with arrow keys
codex-auth use
# rename a saved account
codex-auth rename <old-name> <new-name>
# or pick the account to rename interactively
codex-auth rename
# list accounts
codex-auth list
# show current account name
codex-auth currentSee current account and interactive use command for account switching:

codex-auth save <name>- validates<name>, ensuresauth.jsonexists, then snapshots it to~/.codex/accounts/<name>.json. The requested name is always honored, sosave new-accountwrites that account even if the active auth matches another saved snapshot.codex-auth use [name]- accepts a name or launches an interactive selector with saved names and detected account emails. In a terminal, use up/down arrows and Enter to choose; piped input can still provide a saved name or email. On startup, the live Codexauth.jsonis matched against saved snapshots andcurrentis refreshed before commands run. If<name>is mistyped, the closest saved account is suggested. Before switching away from an unsaved live Codex login, interactive mode asks whether to save it. Copies the saved snapshot into place and records the active name. Interactive terminal output uses color when supported; piped output and--jsonremain stable for automation.codex-auth rename [old-name] [new-name]- renames a saved snapshot and shows both the saved name and detected account email when available. Without arguments, it opens the same email-aware picker used byuse.codex-auth list- renders a table of saved snapshots alphabetically, shows detected emails when available, and marks the active one with*.codex-auth current- prints the active account name and detected email when available, or a friendly message if none is active.--color auto|always|never- controls terminal color.autorespects TTY detection andNO_COLOR; usealwaysto force the enhanced interactive styling.
- This is an unofficial tool and is not affiliated with OpenAI or Codex.
codex-authmanages local Codex auth snapshots. Treat files under~/.codexas sensitive credentials.- The tool uses regular file copies on all platforms so external Codex logins cannot overwrite saved account snapshots through
auth.json. Older symlink-based activations are detached automatically if Codex appears to have written through the symlink. - Release binaries are built for macOS, Linux, and Windows from tagged releases. Scoop, Winget, Arch AUR, Docker, and other distribution channels are release follow-ups, not blockers for
v0.2.1. - Set
CODEX_HOMEor pass--codex-home <path>to use a nonstandard Codex config directory for tests, automation, or isolated environments.
Tagged releases publish GitHub binaries, npm packages, and the Homebrew tap formula. Configure these GitHub Actions secrets before creating a release tag:
NPM_TOKEN- npm automation token with publish access to@shayyz-code/codex-authand the platform binary packages.HOMEBREW_TAP_TOKEN- GitHub token with write access toshayyz-code/homebrew-tap.
Release tags must use the v*.*.* format, for example v0.2.1.
- Update package metadata with
make version VERSION=0.2.1. - Update
CHANGELOG.mdwith the release date and user-facing changes. - Run
make check. - Commit the release preparation changes.
- Create and push the tag:
git tag v0.2.1
git push origin main v0.2.1The release workflow builds binaries, attaches checksums and Sigstore bundles to the GitHub Release, publishes npm packages, and updates the Homebrew tap.
codex-auth stores account snapshots in ~/.codex/accounts and records the active account in ~/.codex/current. Existing snapshots in that layout are recognized automatically.
