Codex Switcher
Use this skill to manage multiple local Codex accounts on one OpenClaw host with a simple snapshot workflow.
Bundled executable:
What this skill is
This is a small local account manager for Codex on OpenClaw.
Core idea:
- - keep OpenClaw's active Codex slot as INLINECODE1
- store each account as a separate snapshot under INLINECODE2
- switch accounts by injecting snapshot credentials into INLINECODE3
- inspect account identity and quota from the active token itself
- refresh snapshot tokens before expiry
This avoids filling openclaw.json with a growing roster of Codex aliases.
Commands
cs list
Show all saved snapshots with:
- - alias
- decoded email
- remaining time before expiry
cs current
Show the
real active account email, not just the internal profile id.
cs quota
Read the current active token and query remaining Codex usage quota.
cs switch <alias>
Switch to a saved account snapshot by updating only the active Codex credentials in:
After switching, show:
- - current active email
- current quota summary
cs add [alias]
Start a new OAuth login flow for a brand-new account.
Workflow:
- 1. run
cs add or INLINECODE12 - sign in in browser
- run INLINECODE13
- if alias was omitted, derive it from the email automatically
- create a new snapshot file for that account
cs refresh <alias>
Force-refresh one snapshot using its refresh token.
cs refresh-all
Scan every snapshot and automatically refresh only those expiring within 24 hours.
This is intended for cron usage.
Sensitive files
This skill touches high-sensitivity local auth material.
Main files involved:
- - INLINECODE16
- INLINECODE17
- INLINECODE18
- temporary pending OAuth state files under INLINECODE19
Treat all snapshot files as secrets.
Never expose full access tokens or refresh tokens in chat.
Safety rules
- - Do not run
curl | bash installers. - Do not fetch and execute third-party account-switch scripts blindly.
- Prefer local reviewed logic only.
- Back up auth material before risky operations.
- Validate alias names before writing files.
- Use atomic writes for snapshot and auth updates.
- Do not edit unrelated OpenClaw config unless truly required.
- Do not assume a snapshot alias is truthful; decode token email when verifying.
Recommended workflow
Add a new account
- -
cs add or INLINECODE22 - finish browser login
- INLINECODE23
- INLINECODE24
Switch accounts
- - INLINECODE25
- verify output shows the expected email and quota
Keep snapshots fresh
Run
cs refresh-all from cron once or twice per day.
References
- - For security concerns around third-party relogin installers, read
references/security-notes.md. - For local implementation notes, read
scripts/README-local-flow.md.
Codex Switcher
使用此技能通过简单的快照工作流,在单个 OpenClaw 主机上管理多个本地 Codex 账户。
捆绑的可执行文件:
此技能的用途
这是一个用于 OpenClaw 上 Codex 的小型本地账户管理器。
核心思路:
- - 将 OpenClaw 的活动 Codex 槽位保持为 openai-codex:default
- 将每个账户作为独立快照存储在 ~/.openclaw/auth-snapshots/ 下
- 通过将快照凭据注入 ~/.openclaw/agents/main/agent/auth-profiles.json 来切换账户
- 从活动令牌本身检查账户身份和配额
- 在过期前刷新快照令牌
这避免了用不断增长的 Codex 别名列表填充 openclaw.json。
命令
cs list
显示所有已保存的快照,包含:
cs current
显示
真实的活动账户邮箱,而非内部配置文件 ID。
cs quota
读取当前活动令牌并查询剩余的 Codex 使用配额。
cs switch <别名>
通过仅更新以下文件中的活动 Codex 凭据来切换到已保存的账户快照:
- - ~/.openclaw/agents/main/agent/auth-profiles.json
切换后显示:
cs add [别名]
为全新账户启动新的 OAuth 登录流程。
工作流程:
- 1. 运行 cs add 或 cs add <别名>
- 在浏览器中登录
- 运行 cs add --apply <回调地址> [别名]
- 如果省略了别名,则自动从邮箱中派生
- 为该账户创建新的快照文件
cs refresh <别名>
使用其刷新令牌强制刷新一个快照。
cs refresh-all
扫描每个快照,仅自动刷新那些在 24 小时内过期的快照。
此命令适用于 cron 定时任务。
敏感文件
此技能涉及高敏感度的本地认证材料。
涉及的主要文件:
- - ~/.openclaw/agents/main/agent/auth-profiles.json
- ~/.openclaw/auth-snapshots/.json
- ~/.openclaw/auth-snapshots/backups/
- ~/.openclaw/ 下的临时待处理 OAuth 状态文件
将所有快照文件视为机密。
切勿在聊天中暴露完整的访问令牌或刷新令牌。
安全规则
- - 不要运行 curl | bash 安装程序。
- 不要盲目获取并执行第三方账户切换脚本。
- 优先使用本地审查过的逻辑。
- 在风险操作前备份认证材料。
- 在写入文件前验证别名名称。
- 对快照和认证更新使用原子写入。
- 除非确实需要,否则不要编辑无关的 OpenClaw 配置。
- 不要假设快照别名是真实的;验证时需解码令牌中的邮箱。
推荐工作流程
添加新账户
- - cs add 或 cs add <别名>
- 完成浏览器登录
- cs add --apply <回调地址> [别名]
- cs list
切换账户
- - cs switch <别名>
- 验证输出显示预期的邮箱和配额
保持快照新鲜
通过 cron 每天运行一次或两次 cs refresh-all。
参考
- - 关于第三方重新登录安装程序的安全问题,请阅读 references/security-notes.md。
- 关于本地实现说明,请阅读 scripts/README-local-flow.md。