Multi-account CLI manager for the OpenAI Codex desktop app
Project description
codex-accounts
A multi-account CLI manager for the OpenAI Codex desktop app.
中文文档 · Install · Add an account · FAQ
The OpenAI Codex desktop app stores all sessions, logs, and UI state in
~/.codex/ — and the underlying SQLite database has no notion of which
account a row belongs to. The moment you switch to a different ChatGPT
account, every previous session disappears from the sidebar.
codex-accounts fixes this by swapping the relevant files in and out of
~/.codex/, giving you clean multi-account isolation with a single command:
$ codex-accounts use work
✓ switched to: work (auth mode)
$ codex-accounts list
Accounts (/Users/you/.codex-accounts):
▶ work work@example.com Plus 5d left 2h ago ← current
personal personal@me.io Plus 9d left yesterday
research lab@university.edu Pro 1d left ⚠ 3d ago
Features
- One-command switching —
codex-accounts use <name>saves the current account and activates the target in a single step. - Two isolation modes — share session history across all accounts
(default) or fully isolate sessions, history, and shell snapshots per
account (
--no-share-sessions). - Live quota —
quotaandlist -aquery the same private endpoint the Codex client uses for its 5h/weekly progress bars. - Local usage stats —
statsreads the Codex SQLite database directly for offline token-usage breakdowns. - Auto-refresh —
refreshopens the 5-hour window across every account so a sliding daily allotment never goes unused (see docs/auto-refresh.md). - Zero dependencies — pure stdlib Python; ships as a single console script.
Requirements
| Supported | |
|---|---|
| OS | macOS 12+ (primary), Linux (best-effort, PRs welcome) |
| Python | 3.9+ |
| Codex desktop app | already installed and signed in at least once |
Windows is not currently supported. The path conventions and process detection in
codex_switch.utilswould need to be extended; PRs welcome.
Install
# Recommended: isolated install with pipx
pipx install codex-accounts
# Or with pip
pip install --user codex-accounts
For a no-package-manager install of the bundled launcher script, see
docs/installation.md.
Quick start
# 1. Snapshot the account you're already logged in to
codex-accounts save work
# 2. Add a second account (interactive)
codex-accounts init personal # placeholder dir
codex-accounts use personal # clears auth.json so Codex prompts you to log in
open -a Codex # finish OAuth in the browser
codex-accounts save personal # capture the new account's data
# 3. Day-to-day
codex-accounts list # see everything at a glance
codex-accounts use work # switch back
codex-accounts quota # check 5h / weekly limits
codex-accounts stats # local token usage
See docs/add-account.md for a full walkthrough.
Commands
| Command | What it does |
|---|---|
list [-a] |
List saved accounts (-a adds live quota) |
current |
Print the active account |
info [name] |
Email, plan, token expiry, notes |
save <name> [--auth-only] |
Snapshot current Codex state under <name> |
use <name> [--no-share-sessions] |
Activate <name> (auto-saves the current one first) |
init <name> |
Create an empty snapshot directory (no copy) |
note <name> <text> |
Attach a free-text note |
rename <old> <new> |
Rename an account snapshot |
delete <name> |
Remove a snapshot directory |
stats [name] |
Token usage from local SQLite |
quota [name] |
Live quota via private API (requires network) |
refresh |
Open the 5h window on every account (cron-friendly) |
doctor |
Environment dump for bug reports |
Run codex-accounts <cmd> --help for command-specific options.
How it works
~/.codex/ ~/.codex-accounts/work/
├── auth.json <─ swap ─> ├── auth.json
├── state_*.sqlite <─ swap ─> ├── state_*.sqlite (FULL mode only)
├── sessions/ <─ swap ─> ├── dirs/sessions/ (FULL mode only)
├── config.toml └── meta.json (notes, timestamps)
├── skills/ rules/ memories/ (shared across all accounts — never swapped)
└── installation_id
- AUTH mode (default for
use) — onlyauth.jsonis swapped. Sessions and history live in~/.codex/and are visible from every account. This is what most people want. - FULL mode (
use --no-share-sessions) — session DBs, log DBs, JSONL index, thesessions//archived_sessions//shell_snapshots/directories, and the global UI state file are all swapped. Use this when you genuinely want separate session sidebars per account.
The exact file list lives in
src/codex_switch/config.py and uses
glob patterns (state_*.sqlite, logs_*.sqlite) so future Codex
schema bumps don't silently miss files.
Security & privacy
~/.codex-accounts/and every snapshot directory inside it are created with mode0700.- Account names are validated against
^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$to prevent path traversal. auth.jsonis the same plaintext OAuth bundle the Codex client itself stores. Treat snapshot directories with the same care you'd treat~/.codex/— back them up, but do not check them into git or sync them to anywhere unencrypted.quota,list -a, andrefreshmake network calls tochatgpt.com/backend-api. All other commands are fully offline.- See
SECURITY.mdfor vulnerability reporting.
Disclaimers
- This project is not affiliated with OpenAI in any way.
quota,list -a, andrefreshrely on private endpoints (/backend-api/wham/usageand/backend-api/codex/responses) that were located by reverse-engineering the Codex desktop client. They can change at any time. Seedocs/internals/codex-app-internals.mdfor the methodology used to re-discover them when a Codex update breaks the integration.refreshsends low-cost API requests on your behalf. Readdocs/auto-refresh.md— including the rate-limit and abuse-prevention caveats — before enabling the cron job.
Contributing
Pull requests, bug reports, and "I tried it on Linux and X broke" notes
are all welcome. See CONTRIBUTING.md for the dev
loop, and CODE_OF_CONDUCT.md for community
expectations.
License
MIT © codex-accounts contributors.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_accounts-0.1.0.tar.gz.
File metadata
- Download URL: codex_accounts-0.1.0.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b82a5193baca4f2286cfafcc1cefecb205a91621d0438ef26c2ef4e65aa20fb
|
|
| MD5 |
68cc305c927e6bf8c7194da7249e2658
|
|
| BLAKE2b-256 |
b3f6cdebcf7776bb27c4deb4abc7a4da5834d118b79f8f452781ca7ccc156fc0
|
Provenance
The following attestation bundles were made for codex_accounts-0.1.0.tar.gz:
Publisher:
release.yml on wikty/codex-accounts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_accounts-0.1.0.tar.gz -
Subject digest:
9b82a5193baca4f2286cfafcc1cefecb205a91621d0438ef26c2ef4e65aa20fb - Sigstore transparency entry: 1678431877
- Sigstore integration time:
-
Permalink:
wikty/codex-accounts@06a14b4bf5bca35a1e2f7da9373cd02adeee890c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wikty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@06a14b4bf5bca35a1e2f7da9373cd02adeee890c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_accounts-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codex_accounts-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f38272cbd9f4a2231ae384bb56e431e6d3a8ac24f773a3bd35ea5d654921df5a
|
|
| MD5 |
50a39b04a0f07df2e9e4309381558b0c
|
|
| BLAKE2b-256 |
2b0802d88bc3fdc1ba30602167f08b200a149d75f453ebb1ac4d870af168d190
|
Provenance
The following attestation bundles were made for codex_accounts-0.1.0-py3-none-any.whl:
Publisher:
release.yml on wikty/codex-accounts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_accounts-0.1.0-py3-none-any.whl -
Subject digest:
f38272cbd9f4a2231ae384bb56e431e6d3a8ac24f773a3bd35ea5d654921df5a - Sigstore transparency entry: 1678431973
- Sigstore integration time:
-
Permalink:
wikty/codex-accounts@06a14b4bf5bca35a1e2f7da9373cd02adeee890c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wikty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@06a14b4bf5bca35a1e2f7da9373cd02adeee890c -
Trigger Event:
push
-
Statement type: