codex-account-switcher

0
0
Source

Manage multiple OpenAI Codex accounts. Capture current login tokens and switch between them instantly.

Install

mkdir -p .claude/skills/codex-account-switcher && curl -L -o skill.zip "https://mcp.directory/api/skills/download/8476" && unzip -o skill.zip -d .claude/skills/codex-account-switcher && rm skill.zip

Installs to .claude/skills/codex-account-switcher

About this skill

Codex Account Switcher

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.json

These 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.
  • OpenClaw token propagation is now explicit via sync or --sync.
  • Use --agent <name> to limit writes to specific OpenClaw agents.
  • Use sync --dry-run to inspect planned writes before changing auth files.

Usage

List Accounts

python3 {baseDir}/scripts/codex-accounts.py list
python3 {baseDir}/scripts/codex-accounts.py list --verbose
python3 {baseDir}/scripts/codex-accounts.py list --json

Add an Account

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

Switch Account

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

Auto-Switch to Best Quota

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

Sync Saved Profiles to OpenClaw

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

Auto Mode — How It Works

1. Quota Probing

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:

  • prefers the exact session file from that probe if it contains valid rate_limits
  • falls back to the most recent session file with valid rate_limits (same approach as codex-quota)
  • falls back again to the account's cached quota file if no fresh session data is available

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.

2. Budget-Based Scoring

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
  • Negative score = under budget (good — has headroom)
  • Positive score = over budget (burning too fast)
  • Lowest score wins

3. 5-Hour Penalty

The 5h window can block you even with weekly headroom. Penalties prevent picking an account that's about to hit the wall:

5h UsagePenaltyReason
< 75%0Fine
75–89%+10Getting warm
90–99%+50About to be blocked
100%+200Blocked right now

4. Example

Three accounts, 5 days into the weekly window:

AccountWeeklyBudgetΔ5hPenaltyScore
Oliver60%71%-111%0-11 ← best
Elise62%69%-775%+10+3
Sylvia100%71%+290%0+29

Oliver wins: most headroom relative to pace, and 5h is clear.

OpenClaw Integration

Token Sync

The sync command, or --sync on selected commands, syncs saved account tokens to OpenClaw agents' auth-profiles.json:

  • Profile key format: openai-codex:oliver@drobnik.com (email extracted from JWT)
  • Old name-based keys (e.g. openai-codex:oliver) are migrated automatically
  • Each profile includes: type, provider, access, refresh, expires, accountId, email
  • Also updates each selected agent's auth.json when it already has an openai-codex entry
  • --agent <name> narrows the write scope to specific agents
  • sync --dry-run shows what would be changed without writing files

This allows OpenClaw to use Codex accounts internally without requiring every local agent to be updated automatically.

Account Activity Log

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.

Setup

See SETUP.md for prerequisites and setup instructions.

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,1421,171

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

969933

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

683829

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

691549

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

797540

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

697374

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.