Skip to main content

📦 Codex Manager

The ultimate CLI tool for managing OpenAI Codex account snapshots, tracking quotas, and ensuring seamless workflow continuity.

License: MIT Python Version Code Style: Black Linter: Ruff Maintenance Status


⚡ Quick Start

Get up and running in under 5 minutes.

Prerequisites

  • Python 3.10 or higher
  • uv (recommended for fast dependency management)

Install

Clone the repository and install using uv:

git clone https://github.com/dhruv13x/codex-manager.git
cd codex-manager
uv pip install --system -e .

Run

Verify the installation by viewing the CLI help menu:

codex-manager --help
# Or use the shorter alias:
cm --help

Demo

Here's a quick 5-line workflow to backup your current account, view recommendations, and switch to a new one:

# 1. Take a live snapshot of your active Codex account state
cm backup --cloud

# 2. Check cooldown statuses for all accounts
cm cooldown

# 3. Get the smartest recommendation for the next account to use
cm recommend

# 4. Switch to a new account using the 'auth-only' method
cm use --email new_user@example.com

[🖼️ Suggestion: Add an animated GIF here demonstrating the cm use command in action with the Rich UI]


✨ Features

Core

  • Live Status Tracking: Automatically parses live Codex /status output to capture account email, quota text, and weekly reset timestamps.
  • Smart Recommendations: Recommends the optimal account to use next based on calculated cooldowns and real-time metadata.
  • Full State Recovery: Backup and restore full Codex runtime states (auth.json, history, logs) via *.tar.gz archives and *.metadata.json.

Performance & Reliability

  • Offline & Fallback Mode: Employs an emergency --without-status-check fallback that gracefully estimates cooldowns even when the live tracker is temporarily unavailable.
  • Lightning Fast UI: Employs the rich library for beautiful terminal output, tables, and status animations.

Security & Cloud

  • Cloud Synchronization: First-class support for Backblaze B2 (and S3-compatible buckets) for remote backup metadata and archive storage.
  • Safe Operations: Every modifying command supports a --dry-run flag to safely simulate actions without touching your files.

🛠️ Configuration

Codex Manager prioritizes configuration via environment variables and CLI arguments for flexibility.

Environment Variables

Name Description Default Required
CODEX_MANAGER_HOME The primary home directory for the manager config and backups. ~/.codex-manager No
CODEX_HOME The target directory where Codex state resides. ~/.codex No

Note: You can also place a config.json inside your CODEX_MANAGER_HOME to persist configuration settings.

Key CLI Arguments

Most commands support these primary flags. Use cm <command> --help for a complete list.

Flag Description
--dry-run Safely preview the changes without modifying local or cloud state.
--cloud Enable Backblaze B2/S3 cloud capabilities for the command.
--email <email> Specify a target account email for use, restore, or listing.
--backup-dir <dir> Override the directory used for reading/writing backups.
--without-status-check Bypass live capture and calculate cooldowns statically (+7 days).
--auth-only During use or backup, target only identity/auth files instead of the full state.

🏗️ Architecture

Directory Tree

~/.codex-manager/ (CODEX_MANAGER_HOME)
├── backups/                # Local archives and metadata
│   ├── backup_1.tar.gz
│   └── backup_1.metadata.json
├── config.json             # Persistent local configurations
└── cooldown.json           # Registry caching overall account cooldowns

High-Level Data Flow

  1. Capture: cm backup or cm status reads live text from a tmux session running Codex.
  2. Process: The CLI parses the text to build a state model (Quota, Cooldown, Email) and packages the ~/.codex directory into an archive.
  3. Store: Archives and adjacent JSON metadata are saved locally and pushed to the cloud (if configured).
  4. Evaluate: When cm recommend or cm cooldown is invoked, local and cloud metadata are fetched, evaluated against real-time, and ranked to find the optimal active account.
  5. Switch: cm use restores the selected account's data into the ~/.codex home, rotating your session seamlessly.

🐞 Troubleshooting

Common Issues

Error Message Cause Solution
TokenExpiredError: TOKEN EXPIRED The active Codex session token has expired. Re-authenticate in Codex manually, or run with --without-status-check to bypass.
Could not resolve Cloud (B2) credentials. Missing B2 credentials for cloud sync. Pass --b2-id and --b2-key flags, or ensure your credentials are set up.
No backups found in Cloud for <email>. The requested account isn't backed up to the specified bucket. Run cm list-backups --cloud to verify the email and backup availability.

Debug Mode

While the CLI does not have a single --debug flag, you can often reveal more information by viewing the full exception traces or by utilizing the built-in doctor command:

cm doctor

The doctor command verifies your dependencies, runtime directories, and validates the status parser setup.


🤝 Contributing

We welcome contributions to Codex Manager! Please review our CONTRIBUTING.md (coming soon) before submitting PRs.

Dev Setup

To set up your local development environment:

# 1. Install all development dependencies
uv pip install --system -e .[dev]

# 2. Run the tests (Ensure 90%+ coverage)
python -m pytest tests --cov=src --cov-report=term-missing

# 3. Format and lint the codebase
uv run ruff check --fix src/ tests/
uv run black src/ tests/

🗺️ Roadmap

  • Plugin Architecture: Allow custom plugins to manage other CLI authentication tokens.
  • Enhanced Cloud Coverage: Add direct first-class integrations for Google Cloud Storage and Azure Blob.
  • Automated Rotation Daemon: A background worker to automatically rotate accounts when token limits are reached in real-time.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_manager-23.0.0.tar.gz (85.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_manager-23.0.0-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

File details

Details for the file codex_manager-23.0.0.tar.gz.

File metadata

  • Download URL: codex_manager-23.0.0.tar.gz
  • Upload date:
  • Size: 85.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codex_manager-23.0.0.tar.gz
Algorithm Hash digest
SHA256 c8083cf99680dd1929ea87a9aa4701eeefd1694dcc656dee682ebced75d5e895
MD5 c8a884a250c717a8f9e4ceb69870ad09
BLAKE2b-256 201312dd1f0c9ef5958123bc4b9ea83f952cdf8748cdc6669cc3fdfd5786fbf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_manager-23.0.0.tar.gz:

Publisher: publish.yml on dhruv13x/codex-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_manager-23.0.0-py3-none-any.whl.

File metadata

  • Download URL: codex_manager-23.0.0-py3-none-any.whl
  • Upload date:
  • Size: 59.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codex_manager-23.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0814d8aca28d9069f1843fca5bf26d91147f5c50ccd1424290c2b4134957f0d
MD5 e7db7b0fc05f8a6818b63853686b4244
BLAKE2b-256 8585c8b553b9c45b13078fc75781b23d40cf45adfea1ad19314279a40358a422

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_manager-23.0.0-py3-none-any.whl:

Publisher: publish.yml on dhruv13x/codex-manager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

23.0.0 This release

2 files

22.0.0

2 files

21.0.0

2 files

20.0.0

2 files

19.0.0

2 files

18.0.1

2 files

18.0.0

2 files

17.0.0

2 files

16.0.0

2 files

15.0.0

2 files

14.0.0

2 files

13.0.0

2 files

12.0.0

2 files

11.0.0

2 files

10.0.0

2 files

9.0.0

2 files

8.0.0

2 files

7.0.0

2 files

6.0.0

2 files

5.0.0

2 files

4.0.0

2 files

3.0.0

2 files

2.0.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page