Oliver Drobnik

Codex Account Switcher

AIエージェントv1.4.3
作者:Oliver Drobnik更新日 2026-05-11全 12 バージョン · 最新版の公開日 2026-04-07codex-account-switcher@clawhub_odrobnik/codex-account-switcher
タスク自動化ツール呼び出し#Sync

AlphaMoatによると、2026-09時点でCodex Account Switcherのダウンロード数は4,568、スター数は3で、AIスキル全体5,078件中2,096位、AIエージェントでは969件中392位です。

インストール数
164
ダウンロード数
4568
スター数
3
総合順位
#2,096
全体の上位 42% · AIエージェントの上位 41%
プラットフォームインストール数ダウンロード数スター数コメント
ClawHub ↗14143173-
SkillHub ↗16445683—

プラットフォームごとに集計方法と集計時点が異なります。

このスキルでできること

このスキルはローカルの認証ファイルを読み取り、保存または置換し、アカウントの利用枠を比較できます。OpenClawへのトークン伝播には同期の明示的な選択が必要です。カードによると認証情報はローカルスナップショットに複製され、同期でagentの認証ファイルに伝わる可能性があります。アカウント名のパス検証や通知のない保存動作も確認が必要です。信頼できる端末だけで使い、認証ディレクトリを保護し、同期前に書き込み内容をプレビューして対象agentを限定し、実行後に結果を確認してください。 Python と設定済み Codex CLI が必要です。自動の利用枠確認は有効な認証ファイルを一時的に切り替えて Codex を実行するため、読み取り専用ではなく、古いキャッシュへ代替する場合もあります。パス検証が修正されるまで信頼できる単純なアカウント名を使い、確認・切替の影響を実行前に承認してください。

資料公開日 2026-10-27

できること

  • ローカルのアカウントスナップショットを保存・一覧表示する
  • 現在のアカウントを切り替える
  • 利用枠を比較するかOpenClaw同期範囲をプレビューする

使う場面

  • 同じ信頼できる端末で複数のCodex IDを管理する必要がある場合
  • ローカル認証ファイルの操作を確認し、同期先をプレビューして限定した場合

プロンプト例

スキルのドキュメントをもとに生成した例であり、実際の実行結果ではありません。

まず読み取りまたは書き込み対象となる認証ファイルと同期先を一覧表示してください。私が確認するまでアカウント切替やトークン同期は行わないでください。

月次の推移

ダウンロード数4568
2875378446932026-03 · ダウンロード数 30002026-05 · ダウンロード数 35732026-06 · ダウンロード数 37212026-07 · ダウンロード数 40322026-08 · ダウンロード数 41762026-09 · ダウンロード数 456826-0326-09
スター数3
2332026-03 · スター数 22026-05 · スター数 32026-06 · スター数 32026-07 · スター数 32026-08 · スター数 32026-09 · スター数 326-0326-09

2026-09 から集計方法を変更し、同名スキルを作者ごとに分けて集計し、全スキルを対象にしました。破線は変更前の月で、変更後のデータとは直接比較せず、変更をまたぐ増減も計算していません。

月ダウンロード数前月比スター数
2026-094568—3
2026-084176+3.6%3
2026-074032+8.4%3
2026-063721+4.1%3
2026-053573—3
2026-033000—2

SKILL.md 原文

作者が公開した元のファイルをテキストのまま表示しています。AlphaMoat による編集や審査はしていません。リンクはクリックできません。コマンドは内容を確認してから実行してください。取得日 2026-10-23。

6.6 KB・ClawHub v1.4.3
---
name: codex-account-switcher
version: 1.4.3
homepage: https://github.com/odrobnik/codex-account-switcher-skill
description: >
  Manage multiple OpenAI Codex accounts by capturing current login tokens,
  switching between saved accounts, and auto-selecting the best one based on
  quota budget scoring. Can also explicitly sync saved Codex tokens into
  OpenClaw agent auth stores on this machine. Sensitive: reads and writes local
  authentication files.
すべて表示(全 180 行)
summary: Save, switch, compare, and optionally sync Codex account tokens.
metadata:
  openclaw:
    emoji: "🎭"
    requires:
      bins: ["python3", "codex"]
      config:
        - "~/.codex/auth.json"
        - "~/.codex/accounts/"
        - "~/.codex/account-activity.jsonl"
        - "~/.openclaw/agents/*/agent/auth-profiles.json"
        - "~/.openclaw/agents/*/agent/auth.json"
---

# 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
```bash
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).

```bash
python3 {baseDir}/scripts/codex-accounts.py add
```

### Switch Account
Instantly swap the active login. Does **not** sync to OpenClaw unless you ask for it.

```bash
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.

```bash
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.

```bash
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 |
|----------|---------|--------|
| < 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 <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`:

```json
{"timestamp": 1774878000, "account": "oliver", "user_id": "user-UtCmyIUOTxc4D1OHV1e5Ibew"}
```

This enables the [quota-dashboard](../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](SETUP.md) for prerequisites and setup instructions.

AIエージェントの人気スキル

Oliver Drobnikのその他のスキル

データ月:2026-09 · ダウンロード数、スター数、インストール数は公開スキルレジストリ(ClawHub、SkillHub)から月単位で集計しています。詳しくはデータの方法論をご覧ください。