Lightweight multi-profile manager and smart router for OpenAI Codex CLI.
rcodex allows you to maintain multiple isolated Codex environments on a single machine without logging in and out repeatedly.
Each profile gets its own:
- Authentication
- Configuration
- Sessions
- Chat History
- MCP Configuration
- Local Settings
Perfect for developers managing multiple OpenAI accounts, client environments, work/personal setups, or separate AI agents.
On top of profile management, rcodex acts as a router: run it with no
arguments and it checks the live Codex rate limits of every logged-in
profile and automatically routes you to whichever account currently has the
most headroom. When one account gets close to its limit, rcodex quietly
starts steering you to the next-best one — no manual account juggling.
Codex sessions are stored per-profile, so switching profiles normally means
losing access to your most recent conversation. rcodex works around this:
whenever it launches a different profile than last time, it carries over the
most recent session for your current directory so codex resume can pick up
where you left off.
- Multiple Codex profiles
- Complete profile isolation
- Smart routing to the best-available profile based on live rate limits
- Session carry-over so
codex resumekeeps working across profile switches - Simple Unix-style CLI
- No external dependencies
- Pure Bash implementation
- Safe account separation
- Supports running multiple Codex instances simultaneously
- Per-profile rate-limit caching for fast, repeated invocations
curl -fsSL https://raw.githubusercontent.com/sc-starman/rcodex/main/install.sh | bashrcodex login personalThis creates:
~/.rcodex/personal
and starts the normal Codex login flow.
rcodex personalrcodex login personal
rcodex login work
rcodex login client1Launch any profile:
rcodex personal
rcodex work
rcodex client1Run with no arguments (or best) to automatically launch whichever
logged-in profile currently has the most rate-limit headroom:
rcodexThis is equivalent to:
rcodex bestrcodex checks each profile's 5-hour and weekly Codex rate limits (via
codex app-server) and picks the one with the most remaining headroom on
its most-constrained window. Results are cached per-profile for
RCODEX_RATE_LIMIT_CACHE_TTL seconds (default 120) so repeated
invocations are instant.
best can also be used in place of a profile name elsewhere:
rcodex exec best "fix the failing tests"
rcodex status bestAnything that isn't a recognized rcodex subcommand or an existing profile
name is forwarded as-is to codex (or codex exec), using whichever
profile currently has the most rate-limit headroom. This means normal
codex flags, prompts, and subcommands work transparently through rcodex:
rcodex --help # -> codex --help (best profile)
rcodex resume --last # -> codex resume --last (best profile)
rcodex "fix the bug" # -> codex "fix the bug" (best profile)
rcodex exec --help # -> codex exec --help (best profile)If a profile name is given, it's used directly and any remaining arguments are passed straight through:
rcodex personal "fix the bug" # -> codex "fix the bug" (personal profile)Create or login to a profile.
rcodex login <profile>Example:
rcodex login workStart Codex using a profile.
rcodex <profile>Example:
rcodex personalRun codex exec using a profile.
rcodex exec <profile> [args...]Example:
rcodex exec work "fix the failing tests"Show the 5-hour and weekly Codex rate-limit usage for every profile:
rcodex limitsExample output:
PROFILE 5H USED 5H LEFT WEEK USED WEEK LEFT
personal 1% 99% 0% 100%
work 42% 58% 10% 90%
client1 (not logged in)
Cached values up to RCODEX_RATE_LIMIT_CACHE_TTL seconds old (default
120) may be shown. Pass --refresh to force a live check:
rcodex limits --refreshThis is the same data rcodex / rcodex best use to pick a profile.
rcodex listrcodex disable work
rcodex enable workDisabled profiles are skipped by automatic routing and direct launches until they are re-enabled.
Example output:
Profiles:
✓ personal
✓ work
✓ client1
rcodex status <profile>Example:
rcodex status workOutput:
Profile : work
Path : /home/user/.rcodex/work
Login : Yes
Size : 42M
rcodex rename <old> <new>Example:
rcodex rename client1 customerArcodex remove <profile>Example:
rcodex remove customerAThe command asks for confirmation before deleting.
Profiles are stored under:
~/.rcodex/
Example:
~/.rcodex/
├── personal/
├── work/
├── customerA/
└── production/
Each directory is a fully isolated Codex environment.
When launching a profile:
rcodex personalrcodex automatically sets:
CODEX_HOME=~/.rcodex/personalbefore starting Codex.
This ensures complete separation between:
- Authentication Tokens
- Config Files
- Sessions
- MCP Servers
- Chat History
- Local State
No profile can affect another profile.
Codex stores session history under $CODEX_HOME/sessions/, so each profile
normally has its own, separate session history. If rcodex routes you to a
different profile than last time (e.g. your previous profile hit its rate
limit), codex resume would otherwise show no record of your last
conversation.
To avoid this, every time rcodex launches a profile it checks which
profile was used last (tracked in ~/.rcodex/.last_profile). If it differs
from the one being launched now, rcodex looks for the most recent session
in the old profile whose working directory matches your current directory,
and copies that session's file into the new profile's session store. This
is a one-time copy (it won't overwrite or duplicate on later launches), and
each profile's session history otherwise remains fully independent.
After the copy, codex resume / codex resume --last under the new profile
will see and can continue that session.
You can run multiple Codex instances at the same time:
Terminal 1:
rcodex personalTerminal 2:
rcodex workTerminal 3:
rcodex customerAEach instance uses its own authentication and configuration.
Repository layout:
rcodex/
├── README.md
├── LICENSE
├── install.sh
├── rcodex
└── .gitignore
Main executable script.
Installer script that:
- Downloads rcodex
- Installs into ~/bin
- Makes executable
- Adds ~/bin to PATH if needed
MIT License.
- Linux
- Bash
- OpenAI Codex CLI
Create profiles:
rcodex login personal
rcodex login workList profiles:
rcodex listLaunch work profile:
rcodex workLet rcodex pick whichever profile has the most rate-limit headroom:
rcodexCheck rate-limit usage across all profiles:
rcodex limitsCheck profile information:
rcodex status workRename profile:
rcodex rename work companyRemove profile:
rcodex remove companyCodex CLI currently stores all state in a single CODEX_HOME directory.
rcodex provides a lightweight solution for:
- Multiple OpenAI accounts
- Client environments
- Work vs Personal separation
- Agent-specific configurations
- Isolated MCP environments
without requiring logouts, file copying, or manual environment management.
On top of that, rcodex doubles as a best-effort router across your
accounts. Codex usage limits reset on rolling 5-hour and weekly windows —
if you juggle several accounts (e.g. multiple Plus/Pro plans), rcodex
saves you from manually checking /status in each one and switching by
hand. Just run rcodex, and it routes you to whichever profile has the
most rate-limit headroom right now.
MIT License.
Feel free to use, modify, and distribute.