Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

rcodex

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.


Features

  • Multiple Codex profiles
  • Complete profile isolation
  • Smart routing to the best-available profile based on live rate limits
  • Session carry-over so codex resume keeps 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

Installation

One-Line Install

curl -fsSL https://raw.githubusercontent.com/sc-starman/rcodex/main/install.sh | bash

Quick Start

Create a Profile

rcodex login personal

This creates:

~/.rcodex/personal

and starts the normal Codex login flow.


Launch a Profile

rcodex personal

Create Multiple Profiles

rcodex login personal
rcodex login work
rcodex login client1

Launch any profile:

rcodex personal
rcodex work
rcodex client1

Commands

Launch the Best Profile

Run with no arguments (or best) to automatically launch whichever logged-in profile currently has the most rate-limit headroom:

rcodex

This is equivalent to:

rcodex best

rcodex 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 best

Pass-Through to Codex

Anything 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)

Login

Create or login to a profile.

rcodex login <profile>

Example:

rcodex login work

Launch Codex

Start Codex using a profile.

rcodex <profile>

Example:

rcodex personal

Run a Non-Interactive Command

Run codex exec using a profile.

rcodex exec <profile> [args...]

Example:

rcodex exec work "fix the failing tests"

Rate Limit / Usage Status

Show the 5-hour and weekly Codex rate-limit usage for every profile:

rcodex limits

Example 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 --refresh

This is the same data rcodex / rcodex best use to pick a profile.


List Profiles

rcodex list

Disable or Re-enable a Profile

rcodex disable work
rcodex enable work

Disabled profiles are skipped by automatic routing and direct launches until they are re-enabled.

Example output:

Profiles:

✓ personal
✓ work
✓ client1

Profile Status

rcodex status <profile>

Example:

rcodex status work

Output:

Profile : work
Path    : /home/user/.rcodex/work
Login   : Yes
Size    : 42M

Rename Profile

rcodex rename <old> <new>

Example:

rcodex rename client1 customerA

Remove Profile

rcodex remove <profile>

Example:

rcodex remove customerA

The command asks for confirmation before deleting.


Directory Structure

Profiles are stored under:

~/.rcodex/

Example:

~/.rcodex/
├── personal/
├── work/
├── customerA/
└── production/

Each directory is a fully isolated Codex environment.


How It Works

When launching a profile:

rcodex personal

rcodex automatically sets:

CODEX_HOME=~/.rcodex/personal

before starting Codex.

This ensures complete separation between:

  • Authentication Tokens
  • Config Files
  • Sessions
  • MCP Servers
  • Chat History
  • Local State

No profile can affect another profile.


Session Carry-Over

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.


Running Multiple Accounts Simultaneously

You can run multiple Codex instances at the same time:

Terminal 1:

rcodex personal

Terminal 2:

rcodex work

Terminal 3:

rcodex customerA

Each instance uses its own authentication and configuration.


File Structure

Repository layout:

rcodex/
├── README.md
├── LICENSE
├── install.sh
├── rcodex
└── .gitignore

rcodex

Main executable script.

install.sh

Installer script that:

  • Downloads rcodex
  • Installs into ~/bin
  • Makes executable
  • Adds ~/bin to PATH if needed

LICENSE

MIT License.


Requirements

  • Linux
  • Bash
  • OpenAI Codex CLI

Example Workflow

Create profiles:

rcodex login personal
rcodex login work

List profiles:

rcodex list

Launch work profile:

rcodex work

Let rcodex pick whichever profile has the most rate-limit headroom:

rcodex

Check rate-limit usage across all profiles:

rcodex limits

Check profile information:

rcodex status work

Rename profile:

rcodex rename work company

Remove profile:

rcodex remove company

Why rcodex?

Codex 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.


License

MIT License.

Feel free to use, modify, and distribute.

About

Lightweight multi-profile manager and smart router for OpenAI Codex CLI. Run multiple Codex accounts and isolated environments from a single machine, and auto-route to whichever account has the most rate-limit headroom.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages