Codex Account Switcher
Manage multiple OpenAI Codex accounts by capturing current login tokens, switching between saved accounts, and auto-selecting the best one based on quota bud...
Manage multiple OpenAI Codex accounts by capturing current login tokens, switching between saved accounts, and auto-selecting the best one based on quota bud...
Real data. Real impact.
Emerging
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
Manage multiple OpenAI Codex identities (e.g. personal, family, work) by swapping the authentication token file. Includes smart auto-selection based on quota budget scoring.
⚠️ Sensitive files touched:
~/.codex/auth.json~/.codex/accounts/*.json~/.codex/account-activity.jsonl~/.openclaw/agents/*/agent/auth-profiles.json~/.openclaw/agents/*/agent/auth.jsonThese paths are also declared in
metadata.openclaw.requires.config so the registry/security scan can see them in structured metadata.
⚠️ Security model:
add, save, use, and auto only manage local Codex snapshots by default.sync or --sync.--agent <name> to limit writes to specific OpenClaw agents.sync --dry-run to inspect planned writes before changing auth files.python3 {baseDir}/scripts/codex-accounts.py list python3 {baseDir}/scripts/codex-accounts.py list --verbose python3 {baseDir}/scripts/codex-accounts.py list --json
Interactive wizard — starts a fresh browser login (
codex logout && codex login) so you explicitly choose the identity to capture. Press Enter to accept the default name (local-part of the email).
python3 {baseDir}/scripts/codex-accounts.py add
Instantly swap the active login. Does not sync to OpenClaw unless you ask for it.
python3 {baseDir}/scripts/codex-accounts.py use oliver python3 {baseDir}/scripts/codex-accounts.py use oliver --sync python3 {baseDir}/scripts/codex-accounts.py use oliver --sync --agent main
Probes each account for current quota, scores them, and switches to the best one. Does not sync to OpenClaw unless you ask for it.
python3 {baseDir}/scripts/codex-accounts.py auto python3 {baseDir}/scripts/codex-accounts.py auto --json python3 {baseDir}/scripts/codex-accounts.py auto --sync --agent main
Example output:
Account 7d 5h Score 7d Resets 5h Resets ──────────── ───── ───── ─────── ────────────── ────────────── oliver 60% 1% +12.0 Apr 03 08:08 in 4h 40m ← elise 62% 75% +25.3 Apr 03 10:15 in 2h 01m sylvia MAX 0% +51.8 Apr 03 07:51 in 5h 00m
Explicitly push saved account tokens to OpenClaw.
python3 {baseDir}/scripts/codex-accounts.py sync python3 {baseDir}/scripts/codex-accounts.py sync oliver sylvia python3 {baseDir}/scripts/codex-accounts.py sync --agent main python3 {baseDir}/scripts/codex-accounts.py sync --agent main --dry-run
For each saved account,
auto temporarily switches ~/.codex/auth.json and runs a lightweight codex exec --skip-git-repo-check "reply OK" probe.
It then:
rate_limitsrate_limits (same approach as codex-quota)This keeps probing simple and robust while still using Codex's session logs as the source of truth for primary/5h and secondary/7d windows.
The ideal usage pace is 100% spread evenly over 7 days. At any point in the week, the budget is where usage should be:
budget = (elapsed_hours / 168) × 100%
The score measures how far ahead or behind budget an account is:
score = (actual_weekly% - budget%) + daily_penalty
The 5h window can block you even with weekly headroom. Penalties prevent picking an account that's about to hit the wall:
| 5h Usage | Penalty | Reason |
|---|---|---|
| < 75% | 0 | Fine |
| 75–89% | +10 | Getting warm |
| 90–99% | +50 | About to be blocked |
| 100% | +200 | Blocked right now |
Three accounts, 5 days into the weekly window:
| Account | Weekly | Budget | Δ | 5h | Penalty | Score |
|---|---|---|---|---|---|---|
| Oliver | 60% | 71% | -11 | 1% | 0 | -11 ← best |
| Elise | 62% | 69% | -7 | 75% | +10 | +3 |
| Sylvia | 100% | 71% | +29 | 0% | 0 | +29 |
Oliver wins: most headroom relative to pace, and 5h is clear.
The
sync command, or --sync on selected commands, syncs saved account tokens to OpenClaw agents' auth-profiles.json:
openai-codex:oliver@drobnik.com (email extracted from JWT)openai-codex:oliver) are migrated automaticallytype, provider, access, refresh, expires, accountId, emailauth.json when it already has an openai-codex entry--agent <name> narrows the write scope to specific agentssync --dry-run shows what would be changed without writing filesThis allows OpenClaw to use Codex accounts internally without requiring every local agent to be updated automatically.
Every account switch is logged to
~/.codex/account-activity.jsonl:
{"timestamp": 1774878000, "account": "oliver", "user_id": "user-UtCmyIUOTxc4D1OHV1e5Ibew"}
This enables the quota-dashboard skill to attribute Codex Desktop session rate_limit data to the correct account, since session files don't record which user created them.
See SETUP.md for prerequisites and setup instructions.
No automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
© 2026 Torly.ai. All rights reserved.