← 返回 Skills 市场
odrobnik

Codex Account Switcher

作者 Oliver Drobnik · GitHub ↗ · v1.4.3 · MIT-0
cross-platform ✓ 安全检测通过
3082
总下载
3
收藏
3
当前安装
12
版本数
在 OpenClaw 中安装
/install 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...
使用说明 (SKILL.md)

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 \x3Cname> 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 Usage Penalty Reason
\x3C 75% 0 Fine
75–89% +10 Getting warm
90–99% +50 About to be blocked
100% +200 Blocked right now

4. Example

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.

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:[email protected] (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 \x3Cname> 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.

安全使用建议
This skill does what it says: it will read and overwrite Codex and OpenClaw agent authentication files and keep an activity log tying timestamps to user_ids. Before installing or running: (1) review the full script yourself (or have someone you trust do so) paying special attention to any network calls or unexpected file writes; (2) keep backups of ~/.codex/auth.json and any OpenClaw agent auth files you care about; (3) use the provided sync --dry-run and --agent flags to restrict and preview changes before committing; (4) set restrictive file permissions on ~/.codex and ~/.openclaw files; (5) be cautious about enabling autonomous agent invocation for this skill — an agent could run a sync command and propagate tokens to agents without further prompts. If you cannot review the code, run it in an isolated environment (container or disposable VM) first.
功能分析
Type: OpenClaw Skill Name: codex-account-switcher Version: 1.4.3 The Codex Account Switcher is a utility designed to manage multiple OpenAI Codex authentication tokens locally. It performs legitimate operations such as reading and writing tokens to '~/.codex/auth.json' and syncing them to OpenClaw agent directories. The script uses the standard 'codex' CLI for authentication and quota probing, handles JWT decoding locally for identity verification, and includes safety checks to prevent overwriting tokens with different identities. No evidence of data exfiltration, obfuscation, or malicious intent was found; the sensitive file access is consistent with the tool's stated purpose.
能力标签
cryptorequires-oauth-token
能力评估
Purpose & Capability
Name/description say it manages Codex tokens and can sync into OpenClaw agents; the skill requires python3 and the codex CLI and declares the exact Codex and OpenClaw auth files it reads/writes. Those requirements are coherent with the stated features (capture, switch, probe quota, and sync).
Instruction Scope
SKILL.md and SETUP.md explicitly state the script will read/write ~/.codex/* and OpenClaw agent auth files and run codex login/logout for capture and codex exec probes for quota. That scope is narrow and documented, but it legitimately includes modifying authentication files and writing a timestamped account-activity.jsonl log (which records account→user_id mappings).
Install Mechanism
No install spec — the user runs the included Python script. No network download/install occurs during registry install, which reduces supply-chain risk. The code is provided for review instead of being fetched at runtime.
Credentials
The skill asks for no environment variables but declares and accesses sensitive config paths (~/.codex/* and ~/.openclaw/agents/*/agent/{auth-profiles.json,auth.json}). Those are necessary for the sync feature but are high-privilege: writing to agent auth stores can grant access to running agents. The script decodes JWTs to extract emails/user_ids and logs activity; this is expected for identity mapping but increases privacy exposure.
Persistence & Privilege
always is false (good). The skill can be invoked autonomously by agents (disable-model-invocation=false), which is platform default; combined with its ability to update agent auth files, this increases blast radius if an agent were to run sync without explicit user intent. SKILL.md emphasizes that sync is explicit and offers --agent and --dry-run to limit writes, which mitigates risk if used correctly.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install codex-account-switcher
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /codex-account-switcher 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.4.3
Use structured requires.config metadata; make OpenClaw sync explicit; align quota probing with codex-quota; improve security disclosure.
v1.4.2
codex-account-switcher 1.4.2 - Documentation or metadata updated (SKILL.md changed). - No functional changes to user-facing commands noted.
v1.4.1
codex-account-switcher v1.4.1 - Minor update with improvements and fixes. - Documentation in SKILL.md updated to reflect latest behavior and usage instructions. - No user-facing command or configuration changes.
v1.4.0
codex-account-switcher 1.4.0 introduces automatic quota-based account selection and full OpenClaw agent token syncing. - Added smart quota scoring and auto-switch (auto-selects the best account based on usage versus budget) - Syncs all saved account tokens to OpenClaw agent auth-profiles, keyed by email - Now logs all account switches for accurate quota tracking and dashboard support - Supports new command for syncing tokens (`sync`) - Updated script path to `scripts/codex-accounts.py` and improved documentation - Updated requirements to include both python3 and codex CLI; expanded config paths documentation
v1.2.4
fix: use /Users/oliver/clawd for workspace root to preserve symlink paths
v1.2.3
Remove invented sensitivity metadata field
v1.2.2
Declare missing dependencies, env vars, and sensitivity in metadata
v1.2.1
Rename .clawdhubignore to .clawhubignore
v1.2.0
Refactor: move setup/prerequisites to SETUP.md, keep SKILL.md lean
v1.1.2
Clarify sensitive ~/.codex token files + add README (OpenClaw scan alignment).
v1.1.1
- Added README.md with instructions and documentation. - Added version metadata (1.1.1) and updated the skill description in SKILL.md, warning about the use of sensitive authentication token files. - Updated metadata for compatibility with multiple automation bots. - Minor documentation updates (e.g., changed "Clawdbot" to "Moltbot" in usage notes).
v1.1.0
Add auto command: checks all accounts and switches to best quota
元数据
Slug codex-account-switcher
版本 1.4.3
许可证 MIT-0
累计安装 3
当前安装数 3
历史版本数 12
常见问题

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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 3082 次。

如何安装 Codex Account Switcher?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install codex-account-switcher」即可一键安装,无需额外配置。

Codex Account Switcher 是免费的吗?

是的,Codex Account Switcher 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Codex Account Switcher 支持哪些平台?

Codex Account Switcher 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Codex Account Switcher?

由 Oliver Drobnik(@odrobnik)开发并维护,当前版本 v1.4.3。

💬 留言讨论