Skip to content

About

把几个 Codex / Claude Code 账号缝成一个池子:撞额度自动换号接着跑、按额度平衡、合盖也能准点预热 5 小时窗口,每个功能都能单独用 | Pool Codex & Claude Code accounts: failover + resume, quota balancing, scheduled window priming; use only what you need

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

Repository files navigation

🧵 codex-pool

Stitch several Codex and Claude Code accounts into one pool. Hit a usage limit and it switches accounts and picks up where it left off. Quota that would expire unused gets spent first. And your 5-hour windows start right on schedule, even with the lid closed.

Python macOS Dependencies License

English · 简体中文


😩 The problem

Codex and Claude Code subscription limits are per account: every account gets a rolling 5-hour window plus a weekly cap. If you juggle a few accounts, this probably sounds familiar:

  • A task hits the limit halfway through → you switch accounts by hand → you explain the whole task all over again
  • You always reach for the first account, so it runs dry while the others sit idle
  • The 5-hour window only starts at your first request: start work at 10 a.m. and it won't refresh until 3 p.m.

codex-pool automates all three, for any number of Codex and Claude Code accounts. Despite the name, Claude Code is a first-class citizen.

🧩 Use only what you need

Every feature works on its own, and the logins you already use can join as they are (--home default), so nothing has to move. Want only the early 5-hour countdown? Only a Codex pool? Only a Claude pool? Pick your recipe in Quick start.

📖 Glossary

Word Meaning
seat One account, Codex or Claude Code, with its own login folder: ~/.codex-pool/seats/NAME, your usual ~/.codex / ~/.claude (--home default), or a folder you pick (--home PATH).
usual login The login your plain codex / claude commands use: ~/.codex, and ~/.claude (Claude Code keeps that account in ~/.claude.json). A seat added with --home default is your usual login, on whichever account that is at the moment.
shim A small stand-in codex / claude command that sits in front of the real one on your PATH. It sends codex exec / codex review / claude -p through the pool and hands everything else to the real CLI untouched.
prime Starting a seat's idle 5-hour window early with one tiny request, so the window also refreshes earlier.
cooldown After hitting a limit, a seat sits out until its reset time (after a 429, for 2 minutes). codex-pool reset clears it by hand.
reserve seat A seat whose 5-hour window the pool goes easy on: it takes part in the balancing at half its score, and while that window has under 50% left it's kept for you, used only when no other seat of its kind is available. One you added with --reserve, or, with codex-pool reserve-usual on, whichever seat is on the same account as your usual login. Good for the account you also use in the Claude or ChatGPT app.
delegate A Claude seat doing a task that another Claude session handed it with codex-pool delegate; only its short report goes back.

✨ What it does

Feature What you get
🔁 Fail over, keep going On a usage limit, the seat cools down until its real reset time (a 429 cools it down for 2 minutes). The session moves to the next seat and the task continues there with resume, so nothing starts over (a codex review simply runs again). Works for codex exec / codex review and claude -p.
💬 Claude Code, interactively codex-pool claude starts Claude Code on the Claude account with the most quota to spare. Hit a limit mid-chat? Exit, run codex-pool claude -c, and the same conversation continues on another account.
⚖️ Quota-aware balancing Seats are scored weekly % left ÷ hours until the weekly reset. Quota that's about to expire gets used first, so your accounts drain together instead of one running empty early.
🛟 A reserve seat for your apps Make the account you also use in the Claude or ChatGPT app a reserve seat (--reserve). The pool still draws on its weekly quota before that expires, less eagerly than on other seats, and once its 5-hour window is under 50% it leaves the seat alone unless no other seat of its kind is available, so you keep room to work in the app. Or let the reserve follow your usual login (codex-pool reserve-usual claude on): whichever seat is on the same account as your usual login becomes the reserve seat, even after you switch accounts.
📨 Hand off big tasks In a Claude session (the desktop app, say), codex-pool delegate "brief" has another Claude seat do the work, failing over like any pooled task, and prints only its short report, so the session that asked spends next to nothing. Publishing commands like git push are always denied.
🪄 Invisible to you and your agents With the shims installed, codex exec / codex review and claude -p go through the pool, while everything else (the interactive TUIs, login, mcp…) passes straight to the real CLI. Scripts and agents that call them get the pool for free.
⏰ Start the clock early If a seat's 5-hour window hasn't started yet, codex-pool sends it one tiny request (Reply with exactly: OK) so the countdown starts. Codex seats are checked with a free quota query first, so running windows are never touched. Claude has no free query, so a Claude seat is pinged once its last known window has ended.
🌙 On time, lid closed With the optional wake schedule, the Mac wakes at 6:00, 12:00 and 17:00 even with the lid closed: the screen stays dark, it's awake for about 45 seconds, then it goes back to sleep. Scheduled priming pauses from 22:00 to 6:00.
🪶 Featherweight No resident process, pure Python standard library, zero dependencies. When nothing is due, the 10-minute tick just checks the clock: 0.07 s, no network.

🧠 How it works

A task that goes through a shim:

flowchart TD
    A["codex exec / claude -p task"] --> S{"shim picks the seat<br/>with the most quota to spare"}
    S --> P["seat A runs the task"]
    P -->|"done"| D["you get the final reply"]
    P -->|"usage limit / 429"| C["seat A cools down<br/>until its real reset time<br/>(after a 429: 2 minutes)"]
    C -->|"session copied over, resumed"| Q["seat B finishes the task"]
    Q --> D
Loading

The scheduled priming job:

flowchart TD
    T["every 10 minutes, 6:00–22:00<br/>(lid closed: only at the 6 / 12 / 17 o'clock wakes)"] --> R{"any seat due?"}
    R -->|"no: 0.07 s, no network"| Z["wait for the next tick"]
    R -->|"a Codex seat"| Q{"free quota query:<br/>window running?"}
    R -->|"a Claude seat"| P["send one tiny request:<br/>an idle window starts"]
    Q -->|"no"| P
    Q -->|"yes"| N["note the reset time,<br/>check again just after it"]
    P --> N
Loading

🚀 Quick start

Requirements: macOS or Linux, Python 3.9+ as /usr/bin/python3 (on macOS it comes with the Command Line Tools, which git needs too), ~/.local/bin on your PATH, and the CLI you want to pool: Codex CLI (npm i -g @openai/codex, or the copy inside the ChatGPT desktop app) and/or Claude Code (or the copy inside the Claude desktop app). Scheduled priming and lid-closed wakes are macOS-only (for Linux, see the FAQ).

1. Get it

git clone https://github.com/yaaleo/codex-pool.git && cd codex-pool

2. Pick your setup. Each recipe works on its own; combine them freely. Seat names (main, codex2…) are up to you, and running the same add line twice is harmless: it just updates the seat.

⏰ A. Just start the 5-hour clock early, for the accounts you already use

sh install.sh --prime                         # check every 10 minutes (macOS launchd)
codex-pool add main --home default            # your current Codex login (~/.codex)
codex-pool add me --claude --home default     # your current Claude Code login (~/.claude)
codex-pool prime --dry-run                    # see what it would do right now

Keep only the lines for the CLIs you use. From now on, between 6:00 and 22:00 while the Mac is awake, whenever one of these accounts has an idle 5-hour window, codex-pool sends it one tiny request so the countdown starts. Optional: to stay on time with the lid closed too, run sudo sh wake/install.sh. It wakes the Mac at 6:00, 12:00 and 17:00; booking wakes needs root, which is why it asks for your password (details).

🔁 B. Several Codex accounts behind one codex exec

sh install.sh --shim                  # codex exec / codex review now go through the pool
codex-pool add main --home default    # the Codex login you already have, as is
codex-pool add codex2                 # each extra account gets its own seat (its own CODEX_HOME)
codex-pool login codex2               # sign that seat in to its own account

Repeat the last two lines for every extra account. A login takes whichever account the browser is signed into, so sign in from a private window (how). Then use codex exec "…" exactly as before: each task goes to the seat with the most quota to spare and moves to the next seat if it hits a limit. New Codex seats start out with the settings in your ~/.codex/config.toml (what seats share).

🤝 C. Several Claude Code accounts

sh install.sh --claude-shim                   # claude -p now goes through the pool
codex-pool add me --claude --home default     # the Claude login you already have, as is
codex-pool add claude2 --claude               # each extra account gets its own seat (its own CLAUDE_CONFIG_DIR)
codex-pool login claude2                      # no browser pops up: paste the link it gives you into a private window

Repeat the last two lines for every extra account (login tips). Then:

  • run codex-pool claude instead of claude: Claude Code opens on the account with the most quota to spare;
  • hit a limit mid-chat? Quit, then run codex-pool claude -c: the same conversation continues on another account;
  • claude -p "…" (scripts and agents) fails over on its own;
  • in a Claude session, codex-pool delegate "…" hands a big task to another account and brings back only a short report (details).

🧵 D. All of it

sh install.sh --shim --claude-shim --prime    # both shims + scheduled priming
sudo sh wake/install.sh                       # lid-closed wakes at 6:00, 12:00, 17:00 (asks for your password)
codex-pool add main --home default            # your usual Codex login
codex-pool add me --claude --home default     # your usual Claude login
codex-pool add codex2 && codex-pool login codex2              # one more Codex account
codex-pool add claude2 --claude && codex-pool login claude2   # one more Claude account

Only the two wake/ scripts need sudo; run install.sh and every codex-pool command as yourself.

There's no limit on seats of either kind. Each seat can switch pieces off: --no-pool (never route tasks to it), --no-prime (never prime it) or --reserve (go easy on its 5-hour window; details under Picking a seat below). For example, codex-pool add me --reserve if you also use that account in the Claude app. Turn them back with --pool, --prime and --no-reserve.

🔀 Switch accounts in the Claude or ChatGPT app? Then give every account a seat of its own instead of using --home default. A --home default seat is your usual login, so when that switches accounts, the seat switches with it: it can turn into a second seat for an account that already has one, while your old account drops out of the pool. Let the pool go easy on whichever account your usual login is on:

codex-pool remove me                    # drops only the pool's record; your usual login stays logged in
codex-pool add claude1 --claude         # a seat for each account that doesn't have one yet,
codex-pool login claude1                # signed in from a private window
codex-pool reserve-usual claude on      # for Codex seats: codex-pool reserve-usual codex on

From then on, the seat on the same account as your usual login is a reserve seat, and when you switch accounts the reserve moves with it, no command needed. codex-pool status shows which seat that is.

3. Check that it works

codex-pool status    # every seat, its account, and whether it's available
codex-pool limits    # quota per seat, and which seat gets the next task
  • Shims: if install.sh printed an export PATH=… line, add it to your shell profile (e.g. ~/.zshrc) first. Then open a new terminal (or run hash -r) and run type -a codex / type -a claude: the shim (~/.local/bin/… or ~/.codex-pool/bin/…) should be listed first and your real CLI after it. Tasks that go through the pool print [pool …] lines on stderr saying which seat ran them.
  • Priming: cat ~/.codex-pool/prime_last_run shows when the scheduled job last ran (every 10 minutes from 6:00 to 22:00, while the Mac is awake); ~/.codex-pool/prime.log shows what it did. launchctl print gui/$(id -u)/com.codexpool.prime shows the job itself.
  • Wakes: pmset -g sched | grep codex-pool lists the wakes that are booked. To try one, run sudo sh wake/install.sh test 14:30:30 with a time later today, just past a 10-minute mark like the real wakes (and outside 22:00–6:00). Close the lid, open it a few minutes after that time, and prime_last_run should show it.
  • macOS shows a "Background Items Added" notification when the scheduled job or the wake daemon is installed. That's expected.

🌐 Output follows your system language (English or Chinese). Pin it with codex-pool lang en / codex-pool lang zh, or set CODEX_POOL_LANG.

⬆️ Upgrading? Run git pull, then sh install.sh again with the options you use (for example sh install.sh --shim --prime; --prime makes the scheduled job pick up your current PATH). Seats and logins stay as they are. Run codex-pool add NAME once per existing seat to link in what seats now share; the shared Codex config.toml isn't copied again, so if you want your settings in it, run cp ~/.codex/config.toml ~/.codex-pool/shared/config.toml. State from 1.x upgrades itself on the next run: your Codex seats stay exactly as they were, and if the Claude CLI was logged in, it becomes a seat named claude (your usual login), so priming carries on as before.

🔑 Logging in seats

Each seat should be a different account. A login binds whichever account the browser is signed into, so sign in from a private window.

  • Claude seats: codex-pool login NAME doesn't let the browser open by itself. Your everyday browser is probably signed in to your main account, and one click on "Authorize" there would give it to this seat. Instead, the login link is copied to your clipboard (pbcopy on macOS; on Linux wl-copy under Wayland or xclip under X11, if installed) and printed in full in the terminal. Then:

    1. Close all private windows first: in Chrome they share one session, so an old one may still be signed in.
    2. Open a new private window (Chrome: Cmd+Shift+N).
    3. Paste the link and sign in with the account meant for this seat.
    4. If the page shows a code, paste it back into the terminal.

    To let the browser open by itself instead, add --open-browser; seats on your usual login (--home default) do that by default.

  • Codex seats: codex login opens your default browser. Copy the link it prints into a private window instead, or run codex-pool login NAME --device-auth to sign in with a one-time code, which also works on a remote machine. --device-auth is for Codex seats only.

  • Check: codex-pool status lists the account behind every seat. If two seats of the same kind are on the same account, login warns you right away and status keeps warning: one account means one quota.

  • Switching a seat to another account: just log in again. The old account's cached quota, cooldown and last error are dropped, and so is the seat's prime schedule, so the next prime round checks it from scratch.

📟 Commands

Command What it does
codex-pool add NAME [--claude] [--home PATH|default] [--no-share] Add a seat: Codex by default, Claude Code with --claude. --home default uses the login you already have (~/.codex / ~/.claude); --home PATH uses a folder of yours. --no-share links none of your setup into it (what seats share)
codex-pool add NAME [--no-pool] [--no-prime] [--reserve] Per-seat switches, on a new seat or an existing one (no need to repeat --claude). Turn them back with --pool, --prime, --no-reserve
codex-pool init NAME… [--config-from FILE] Shortcut: add several Codex seats at once. --config-from makes FILE the config.toml all Codex seats share
codex-pool login NAME [--device-auth] [--open-browser] Log a seat in (tips). --device-auth: Codex, sign in with a one-time code. --open-browser: Claude, let the browser open by itself
codex-pool remove NAME [--delete-login] Take a seat out of the pool. --delete-login also deletes its folder (logging a Claude seat out first), but never a folder of yours from --home
codex-pool status [--check] Accounts, cooldowns, disabled and reserve seats; warns if one account is logged into two seats. With reserve-usual on, also says which account your usual login is on. --check also asks codex login status / claude auth status
codex-pool limits [NAME…] [--no-sync] Quota for every seat and who gets the next task. Codex: read live from the backend (free, starts no window), and cooldowns are corrected to match (--no-sync only looks). Claude: the latest snapshot
codex-pool claude [--seat NAME] [claude args] Claude Code on the Claude seat with the most quota to spare (--seat picks one yourself). -c / -r ID bring the conversation along from whichever seat has it
codex-pool run [--claude] [--wait] "task" [-- extra args] Run one task on the pool without installing a shim (- reads the task from stdin)
codex-pool delegate [--review] [--resume ID] [--seat NAME] "brief" From a Claude session: another Claude seat does the task and only its short report comes back (details). It edits files and runs Bash without asking, except publishing commands (git push, gh, …)
codex-pool prime [NAME…] [--dry-run] [--force] [--no-claude] Start idle 5-hour windows now. --dry-run only says what it would do; --force sends even if a window is already running
codex-pool strategy [balance|order] Seat selection: quota-balanced (default) or the order seats were added in
codex-pool reserve-usual [claude|codex] [on|off] Reserve follows your usual login: when it's on for a kind, any seat of that kind on the same account as your usual login is a reserve seat (details under Picking a seat below). Off by default. Without on / off it only shows: the setting, which account your usual login is on, and which seat that keeps in reserve
codex-pool lang [auto|zh|en] Output language: follow the system (default), or pin Chinese / English
codex-pool reset [NAME…] Clear cooldown / disabled flags

codex-pool --help lists the commands, and every command has its own --help (codex-pool login --help, …). Everything after codex-pool claude goes to Claude Code, so codex-pool claude --help shows Claude Code's own help.

Exit code 75 means every seat of that kind is cooling down. codex-pool limits shows which seat frees up first, and when. codex-pool run --wait … sleeps until then instead of exiting.

sh install.sh … Adds
(no options) the codex-pool command (~/.local/bin/codex-pool; the program itself is copied to ~/.codex-pool)
--shim codex exec / codex review go through the pool
--claude-shim claude -p goes through the pool; interactive claude and its subcommands are untouched
--prime scheduled priming every 10 minutes (macOS launchd; quiet 22:00–6:00)
--claude a plain claude command that runs the copy bundled with the Claude desktop app (macOS)

Options combine (sh install.sh --shim --claude-shim --prime), and running it again is safe. The shims go to ~/.local/bin. If your own codex / claude is already there, they go to ~/.codex-pool/bin instead, and the installer prints the export PATH="…/.codex-pool/bin:$PATH" line to add to your shell profile (e.g. ~/.zshrc). Lid-closed wakes are installed separately: sudo sh wake/install.sh.

Environment variable What it does
CODEX_POOL_ROOT Where seats, state and logs live (default ~/.codex-pool). Set it in your shell profile before you run install.sh
CODEX_BIN The real codex. Default: the first codex on your PATH that isn't the shim, then the copy inside the ChatGPT app
CLAUDE_BIN The real claude. Default: the first claude on your PATH (or in ~/.local/bin) that isn't the shim, then the copy inside the Claude app
CODEX_POOL_LANG zh or en: overrides the output language
CODEX_POOL_BYPASS 1: the shims hand everything straight to the real CLI (e.g. CODEX_POOL_BYPASS=1 codex exec …)
CODEX_POOL_NO_CLIPBOARD 1: Claude logins leave your clipboard alone (the link is still printed)
CODEX_POOL_DELEGATE_MODEL / CODEX_POOL_DELEGATE_EFFORT The model and effort delegate uses (default opus / max); --model / --effort override them per call
CODEX_POOL_DELEGATE Set to 1 for a delegate's Claude session; codex-pool delegate refuses to run while it's set

The scheduled job doesn't read your shell profile: sh install.sh --prime records your PATH and CODEX_POOL_ROOT for it, plus CODEX_BIN / CLAUDE_BIN if they're set when you run it.

⚖️ Picking a seat: use it or lose it

score = weekly % left ÷ hours until the weekly reset
Seat Weekly left Resets in Score
A 60% 1 day 2.50 ← goes first: resets tomorrow, so anything left is wasted
B 90% 6 days 0.62
C 30% 6 days 0.21 saved for later

A few extra rules:

  • A seat with less than 15% left in its 5-hour window moves to the back, so tasks aren't forced to switch seats mid-run.
  • When scores are close, it sticks with the last seat: fewer switches, warmer cache.
  • resume prefers the seat that owns the session, unless that seat is nearly out (under 15% of its 5-hour window or 5% of its week).
  • codex-pool strategy order ignores the score and takes the first available seat in the order you added them instead, reserve seats after the others.
  • Cooldowns: a usage limit benches the seat until its real reset time. When the error doesn't say, a Codex seat asks the backend and waits 1 hour if that fails too; a Claude seat can't ask, so it waits 1 hour straight away (run --limit-cooldown). A 429 benches the seat for 2 minutes (run --rate-cooldown). An expired login disables the seat until you log in again.
  • Codex quota is re-read at most every 10 minutes (the query is free and takes about a second). Claude has no free query, so Claude snapshots come from every prime and every pooled task, plus the exact reset time Claude Code writes into a transcript when an interactive session hits a limit.

🛟 Reserve seats: easy on the 5-hour window

A reserve seat's weekly quota expires like any other, so it still takes part in the balancing, at half its score:

reserve seat's score = weekly % left ÷ hours until the weekly reset × 0.5

What it guards is its 5-hour window, the part you notice first when you use the account yourself. While its last known 5-hour window has under 50% left, the seat is kept for you: it gets tasks only when no other seat of its kind is available (cooling down, disabled or logged out), and a session on it moves to another seat when you resume it. A window with no reading yet counts as fine, and one past its reset time as full. For example, with R a reserve seat and A from the table above:

Seat Weekly left Resets in 5-hour left Score
R 90% 3 hours 80% 30 × 0.5 = 15.00 ← goes first: most of its week would go to waste
A 60% 1 day 70% 2.50

Once R's 5-hour window drops under 50%, A gets the tasks until R's window resets. limits shows the halved score in its priority line, R 15.00 (reserve ×0.5), and while R is kept, Claude reserve seat R kept for you: 5h 40% < 50%. Reserve seats are primed like any other.

Reserve can follow your usual login. After codex-pool reserve-usual claude on (or codex), any pooled seat on the same account as your usual login counts as a reserve seat too, on top of the ones you marked --reserve. Accounts are compared by email, read from ~/.claude.json / ~/.codex/auth.json just as for a --home default seat, so such a seat always matches; a login that isn't there, or has no readable email, matches nothing. Every command reads your usual login afresh, so when you switch accounts the reserve moves to the matching seat by itself. status marks these seats reserve (your usual login) and adds a line saying which account your usual login is on and which seat it keeps in reserve.

🧳 What a seat shares with your usual setup

Every seat keeps its own login, history and sessions, but picks up your usual configuration, so a pooled codex / claude behaves like yours.

Codex seats

  • Codex seats in ~/.codex-pool/seats share one config.toml, ~/.codex-pool/shared/config.toml. When the first such seat is added, it starts as a copy of your ~/.codex/config.toml, so models, MCP servers and the rest carry over. It's a copy: later changes for the pool go into the shared file (or replace it with codex-pool init … --config-from FILE).
  • AGENTS.md, AGENTS.override.md, prompts/, skills/ and rules/ are symlinked from ~/.codex: edit once, and every seat sees it.

Claude Code seats

  • CLAUDE.md, settings.json, keybindings.json, agents/, commands/, skills/, output-styles/ and plugins/ are symlinked from ~/.claude.
  • MCP servers are not shared. Claude Code keeps them in each config folder's own .claude.json, next to the account. Add them per seat with CLAUDE_CONFIG_DIR=~/.codex-pool/seats/NAME claude mcp add --scope user …, or put them in a project's .mcp.json, which every seat reads. (codex-pool claude mcp … goes to your usual login, not to a seat.)

Both kinds

  • Only what exists when you run add gets linked. Created something since? Run codex-pool add NAME again to link it.
  • --no-share links nothing (Codex seats still use the shared config.toml).
  • Seats on folders of your own (--home PATH or --home default) are left exactly as they are.

🤝 Claude Code seats in detail

  • Separate logins, shared setup. Each Claude seat is its own CLAUDE_CONFIG_DIR (login, history, sessions), with your setup linked in as described above, so every seat behaves like your usual Claude Code.
  • claude -p fails over mid-task. On a usage limit the transcript is copied to the next seat and the task continues there with --resume. Text, json and stream-json output all work; with stream-json you see every attempt's events and exactly one final result. With --no-session-persistence there's no transcript to carry over, so the task starts again on the next seat.
  • Interactive sessions switch accounts when you restart them. The TUI is yours, so codex-pool never hijacks it mid-chat. When an account runs dry, quit and run codex-pool claude -c: the limit is read from the transcript, that seat cools down, and the conversation continues on the next account.
  • The shim is conservative. Only claude -p with text input is pooled. Interactive claude, subcommands, --help, and --input-format stream-json (which can't be replayed) go straight to the real CLI.

📨 Delegating from a Claude session

Every reply in a Claude session re-reads the whole conversation, so a big task done inside a long conversation burns through the quota of the account that session is on, often the one you also use in the app. codex-pool delegate lets the session hand the task to another Claude seat and get back only a short report:

codex-pool delegate "Add input validation to src/parser.py and cover it with tests"
codex-pool delegate --brief-file brief.md     # a long brief (or: codex-pool delegate - < brief.md)
codex-pool delegate --review "Replace the hand-written CSV parsing with the csv module"
codex-pool delegate --resume 3f2c9a1e-… "Also update the README"
  • The seat is picked like any pooled task's: balancing, reserve seats, and failover with the session carried over when a seat hits a limit. --seat NAME starts on a seat you choose.

  • stdout gets only the delegate's final report, at most 25 lines under Result (done / partial / failed), Changes, Checks and Open issues, then one summary line, then any permission it was denied:

    [delegate] seat claude2 · 6.4 min · 31 turns · $2.87 API-equivalent · log ~/.codex-pool/delegate-logs/20261205-141502-claude2.jsonl · session 3f2c9a1e-… · follow up: codex-pool delegate --resume 3f2c9a1e-… "follow-up"
    permission denied: Bash: git push origin main
    

    The full run, every tool call with its output, is in ~/.codex-pool/delegate-logs/ (readable only by you; the newest 50 runs are kept). [pool …] lines go to stderr. The cost is what Claude Code reports the run would cost on the API; on a subscription it comes out of the seat's quota instead. A report over 60 lines is cut short on stdout, never in the log.

  • The brief gets a short header: the current folder and, in a git repo, the branch and the first 30 lines of git status --short. The delegate is told that it works for another Claude session, that it must do the task itself and check its own work (running the tests if there are any), that it must not commit, push or publish, and how to write the report.

  • --resume ID sends a follow-up to the same delegate session, on its seat when that seat is available. --review has a second delegate, on a different seat, review the changes afterwards (git diff in a repo, otherwise the files the report names), fix only clear bugs and report in at most 15 lines; if no other seat is ready, it says so and skips the review. No review by default.

  • Model and effort: opus at max effort, unless you set CODEX_POOL_DELEGATE_MODEL / CODEX_POOL_DELEGATE_EFFORT or pass --model / --effort (low, medium, high, xhigh or max).

  • Start it in the background. A big task takes a while, and Claude Code's Bash tool stops a foreground command after 2 minutes by default. The session id goes to stderr as soon as the delegate starts. If it's interrupted anyway (Ctrl-C, or the SIGTERM a timeout sends), its Claude Code stops too, the log is kept, and --resume ID picks the work up again.

  • The exit code is the delegate's own: 0 when it finished, 75 when every Claude seat is cooling down, 130 when it was interrupted.

What a delegate may do without asking. It runs with --permission-mode acceptEdits: it edits files and runs Bash commands without asking you, so tests and builds run unattended. The only exceptions are commands that publish, send or escalate, which are always denied: git push, git commit, git tag, gh, sudo, rm -rf, npm / yarn / pnpm / cargo publish, twine upload, gem push, docker push, osascript, mail / sendmail. --allow-git lifts only the git commit / git tag denial; --add-dir DIR gives it one more folder to work in. It's started with --strict-mcp-config and no MCP config, so your MCP servers (Slack, mail and the like) aren't loaded. These are Claude Code permission rules matched against the start of a command, not a sandbox (git -C repo push, or a script that pushes, would get through), so delegate only in folders where you'd let Claude Code work unattended, and read the diff before you commit.

A delegate can't delegate. It runs with CODEX_POOL_DELEGATE=1, and codex-pool delegate refuses to start when that's set (exit code 3).

What it costs the calling session: roughly the number of its own replies × the size of its context, since every reply re-reads the whole conversation. A delegated task adds one command and one short report, however long the delegate works. So keep the calling conversation short (one brief, one report, follow-ups through --resume), open the log only when the report says something went wrong, and don't have the calling session re-review the work by default. For a risky change, --review spends another seat's quota instead of the caller's.

A suggested rule for your CLAUDE.md:

- For a big, self-contained task (many files, long test or debug loops), run `codex-pool delegate "brief"` in the background (long briefs: `--brief-file FILE`) instead of doing it here.
- Write the brief for someone with no context: the goal, the files involved, the constraints, and how to check it's done.
- Read only the report it prints; open the log it names only if the report says partial or failed.
- Follow up with `codex-pool delegate --resume ID "…"`. Don't redo or re-review its work; add `--review` only for risky changes.
- If CODEX_POOL_DELEGATE is set, you are the delegate: never delegate, do the task yourself.

⏰ Priming and the wake schedule

How a seat gets primed

  • Codex seats: a free quota query shows whether the 5-hour window is running. If it isn't, one codex exec starts it (Reply with exactly: OK, low reasoning effort, read-only, in an empty folder, nothing saved). A running window is left alone and looked at again just after it resets.
  • Claude seats: Claude has no free quota query, so a Claude seat is pinged (one line to Haiku, no tools) once its last known window has ended, or the first time round. The reply says when the new window resets, and that's when the seat is looked at again.
  • codex-pool prime --dry-run shows what it would do right now. --no-prime takes a seat out of priming; reserve seats are primed like any other.

The scheduled job (sh install.sh --prime) is a launchd agent, com.codexpool.prime, that runs as you every 10 minutes and does nothing from 22:00 to 6:00. When no seat is due, it only reads its notes: no network.

  • It finds codex / claude through the PATH you had when you ran sh install.sh --prime, so copies installed with npm, Homebrew and so on are found. Moved them? Run sh install.sh --prime again. If prime.log still says "codex not found" or "claude not found", pin them: CODEX_BIN=/path/to/codex CLAUDE_BIN=/path/to/claude sh install.sh --prime.
  • To change the quiet hours, change the 22-6 that follows --quiet-hours in launchd/com.codexpool.prime.plist (none turns them off), then run sh install.sh --prime again.
  • Errors from the job itself (a Python traceback, say) go to ~/.codex-pool/prime.err.log.

Lid-closed wakes (sudo sh wake/install.sh): with the lid closed the Mac sleeps, and so does the job; without wakes, priming simply waits until you open the lid. The wake part is a small root launchd daemon, com.codexpool.wake. It runs once an hour and makes sure wakes are booked (pmset schedule wake, named codex-pool) for the next three days at 06:00:30, 12:00:30 and 17:00:30. A wake only works from sleep, not from a Mac that's shut down.

  • Why those times: so the morning, midday and afternoon 5-hour windows have already started before you sit down. A window started at 6:00 is fresh again at 11:00.
  • What it does, and what it doesn't: the root daemon only books wakes, which is the part that needs root. It doesn't run codex-pool, read your seats or touch your accounts. When the Mac wakes, your own scheduled job, running as you, does the priming.
  • Changing the times: edit the line for t in 06:00:30 12:00:30 17:00:30 in wake/com.codexpool.wake.plist, then run sudo sh wake/uninstall.sh and sudo sh wake/install.sh (uninstalling first cancels the wakes already booked for the old times).

💡 Good to know

  • Pooled sessions live in the seat folders. A plain codex resume or claude -c only looks in your usual login, so it misses sessions that ran on other seats. Continue through the pool instead: codex-pool claude -c (or -r ID) for Claude, codex exec resume --last "…" through the shim for Codex.
  • Interactive codex is never pooled. The codex shim only takes codex exec / codex review; the TUI, codex login, codex mcp and the rest run on your usual ~/.codex. For an interactive Claude session on the pool, use codex-pool claude.
  • [pool …] lines go to stderr, so stdout carries only what the CLI itself prints (for codex exec, the final reply), and scripts that parse it keep working.
  • Bypass the pool for one command: CODEX_POOL_BYPASS=1 codex exec … or CODEX_POOL_BYPASS=1 claude -p ….

🧹 Uninstall

Every piece comes off on its own.

To remove Run
one seat codex-pool remove NAME (its login folder stays). Add --delete-login to delete the folder too; a Claude seat is logged out first, and folders of yours from --home are never deleted
one feature for one seat codex-pool add NAME --no-pool or --no-prime
the codex shim grep -q codex-pool-shim ~/.local/bin/codex && rm ~/.local/bin/codex (or the same with ~/.codex-pool/bin/codex)
the claude shim grep -q codex-pool-claude-shim ~/.local/bin/claude && rm ~/.local/bin/claude (or the same with ~/.codex-pool/bin/claude)
the claude command from --claude grep -q claude-cli-wrapper ~/.local/bin/claude && rm ~/.local/bin/claude
scheduled priming launchctl bootout gui/$(id -u)/com.codexpool.prime; rm -f ~/Library/LaunchAgents/com.codexpool.prime.plist
lid-closed wakes sudo sh wake/uninstall.sh (also cancels the wakes already booked)
everything except your seats sh uninstall.sh: the codex-pool command, both shims, the claude command from --claude and the scheduled job. ~/.codex-pool (seat logins, sessions) stays, so reinstalling picks up where you left off
everything sh uninstall.sh --purge: the same, plus it logs out the Claude seats it created and deletes ~/.codex-pool. Your usual ~/.codex / ~/.claude logins are never touched. The wake daemon is separate; uninstall.sh reminds you if it's still installed

Uninstalling never deletes the folder you cloned. Remove it yourself when you're done, after sudo sh wake/uninstall.sh (that script lives in it). If you added the export PATH="…/.codex-pool/bin:$PATH" line for a shim, take it out of your shell profile too.

📊 Measured

Question Result
Does checking Codex quota start the window? No. An idle window's reset time simply slides forward with each query
Cost of one Codex prime ~17k input tokens (mostly cache hits), 5 output tokens; the dashboard still shows 100% left
Cost of one Claude prime Haiku with a replaced system prompt: ~600 input tokens, 4 output tokens
Idle check 0.07 s, ~18 MB, no network
Lid-closed scheduled wake Awake ~45 s; checks finish within 2 s; no visible battery drain
Quota refresh 3 Codex seats queried in parallel in ~1 s; checking 45 Claude transcripts for limit hits takes 3 ms

🛠 How it was built

This project grew step by step out of one long conversation with Claude Code. Every stage is preserved in the commit history and tags (v0.1 → v2.0.2), including the wrong turn along the way (early commit messages are in Chinese):

Version What changed
v0.1 First cut: multiple seats, automatic failover, cross-account resume
v0.2 Seats that aren't logged in are skipped
v0.3 Detect "workspace out of credits". ⚠️ Assumed quota was shared across the whole workspace, so every seat in it was cooled down together
v0.4 Correction: testing showed two members of the same workspace have independent quotas, so limits are per member. Now only the seat that hit the limit cools down, and the new limits command reads real usage and reset times from the backend
v0.5 limits shows "% left", matching the Codex app
v0.6 The shim: codex exec / review go through the pool; scheduler core rewritten
v0.7 prime: send one line to start an idle 5-hour window
v0.8 Lid-friendly: skip when offline, time-boxed runs, a sharper "has this window started?" check
v0.9 Next check scheduled from real reset times; quiet hours; Claude Code CLI added
v0.10 Lid-closed wakes (wake/: a small root job books wakes at 6:00, 12:00 and 17:00); windows due within a few minutes are waited for and handled together
v0.11 Seats primed in parallel to fit inside the ~45 s lid-closed wake
v0.12 Handled within seconds of a reset; sleep is held off only for the few seconds of network work
v0.13 Quota-aware seat balancing
v1.0 Packaging: README, one-step install / uninstall, the launchd template for scheduled priming
v1.1 Bilingual output: English or Chinese, following the system language (codex-pool lang to pin)
v2.0 Generalized. Any number of Codex and Claude Code seats; every feature usable on its own (add / remove, --home default, --no-pool, --no-prime); Claude pooling: claude -p failover with session handoff, the codex-pool claude launcher with -c across accounts, the claude shim. 1.x state upgrades automatically
v2.0.1 Safer logins, reserve seats, fewer setup surprises. Claude logins no longer open your everyday browser: the link goes to the clipboard and the terminal for a private window (--open-browser keeps the old way). Logging a seat into an account another seat already uses warns right away, and logging in again clears the old account's quota, cooldown and prime schedule. add --reserve keeps a seat for when no other seat is available, e.g. the account you use in the apps, and changing an existing seat with add no longer needs --claude. New Codex seats inherit ~/.codex/config.toml and link AGENTS.md, prompts, skills and rules; Claude seats also link keybindings.json and plugins/. The scheduled job records your PATH (and CODEX_BIN / CLAUDE_BIN / CODEX_POOL_ROOT), and a missing codex / claude is reported as such instead of as "offline" / "not logged in". The codex shim, like the claude shim, now falls back to ~/.codex-pool/bin when ~/.local/bin holds your own CLI; uninstall.sh --purge logs out the Claude seats it created; the wake scripts' comments point to the right paths
v2.0.2 Reserve seats guard their 5-hour window; reserve can follow your usual login; Claude sessions can delegate. A reserve seat now takes part in the balancing at half its score, so its weekly quota doesn't just expire unused, and is kept for you only while its 5-hour window has under 50% left (it's still the last resort when no other seat is available); limits shows it as (reserve ×0.5) or says why it's kept. The new codex-pool reserve-usual claude|codex on (off by default) makes whichever seat is on the same account as your usual login a reserve seat, read afresh by every command, so switching accounts moves the reserve with no other command; seats marked --reserve stay reserve. status marks these seats reserve (your usual login) and says which account your usual login is on. The README now recommends one seat per account, not --home default, if you switch accounts in the Claude or ChatGPT app. The new codex-pool delegate "brief" lets a Claude session hand a big task to another Claude seat and get back only a short report and a summary line (the full run is logged in delegate-logs/); it fails over like any pooled task, takes follow-ups with --resume, can have a second seat review the changes (--review), always denies publishing commands such as git push, and can't be nested

❓ FAQ

Where are my logins stored? Are they uploaded anywhere?

Each seat has its own directory, ~/.codex-pool/seats/<seat>/ (a CODEX_HOME or a CLAUDE_CONFIG_DIR), unless you pointed it elsewhere with --home. Codex keeps its credentials in auth.json there; Claude Code keeps a separate login for each config directory (on macOS, in the Keychain). codex-pool has no server and sends nothing anywhere itself: it only runs the codex / claude commands already on your computer.

Does it work on Linux?

The pool itself (failover, resume, balancing, both shims, the Claude launcher, logins) only needs the Python standard library and Unix file locks, so it works on Linux too; Claude logins copy the link with wl-copy or xclip if one is installed. Scheduled priming and lid-closed wakes use macOS launchd / pmset; on Linux, run codex-pool prime --auto every 10 minutes from cron or a systemd timer (set CODEX_BIN / CLAUDE_BIN there if it can't find the CLIs).

My ~/.local/bin/claude (or codex) is my own install. Will the shims overwrite it?

No. If that file isn't ours, the shim goes to ~/.codex-pool/bin/ instead, and the installer prints the one-line PATH change that puts it in front. The shim always finds and runs your real CLI underneath.

Can I keep using one of these accounts in the Claude or ChatGPT app?

Yes. Make its seat a reserve seat (codex-pool add NAME --reserve): the pool still draws on its weekly quota, less eagerly than on other seats, and while its 5-hour window has under 50% left it's kept for you, used only when no other seat of its kind is available. It's still primed. If you switch accounts in the app, run codex-pool reserve-usual claude on (or codex) instead, and give every account its own seat rather than using --home default (how, under step 2): the reserve then follows your usual login to whichever account it's on. codex-pool never changes which account the desktop apps themselves use.

Does starting windows early give me more quota?

No. The weekly cap doesn't change; your 5-hour windows just start, and refresh, earlier. If you usually hit the weekly cap first, it won't help much.

⚠️ Disclaimer

This project is not affiliated with OpenAI or Anthropic. Use it only with accounts you legitimately hold, and follow each service's terms. Rotating between accounts or sending automated requests may not be allowed under some terms of service. Judge for yourself; use at your own risk.

📄 License

MIT

About

把几个 Codex / Claude Code 账号缝成一个池子:撞额度自动换号接着跑、按额度平衡、合盖也能准点预热 5 小时窗口,每个功能都能单独用 | Pool Codex & Claude Code accounts: failover + resume, quota balancing, scheduled window priming; use only what you need

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages