npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@loongphy/codex-auth

v0.3.0

Published

CLI for switching Codex accounts

Readme

Codex Auth latest release latest pre-release

command list

codex-auth is a command-line tool for switching Codex accounts.

Install

Install with npm:

npm install -g @loongphy/codex-auth

You can also run it without a global install:

npx @loongphy/codex-auth list

Supported Platforms

codex-auth works with these Codex clients:

  • Codex CLI
  • VS Code extension
  • Codex App

[!IMPORTANT] For Codex CLI and Codex App users, switch accounts, then restart the client for the new account to take effect.

If you want seamless automatic account switching without restarting, use the forked codext, an enhanced Codex CLI.

Install it with npm i -g @loongphy/codext and run codext.

Codex App users can use codex-auth app, but it is not stable. See Details.

Install the Codex CLI even if you mainly use the VS Code extension or the App, because it makes adding accounts easier:

npm install -g @openai/codex

After that, you can use codex-auth login, or codex-auth login --device-auth to sign in and add accounts more easily.

Commands

Detailed command documentation lives in docs/commands/README.md.

[!NOTE] This documentation is based on v0.3.x. Some commands described here may not be available in the current release.

To try the latest features, please install the alpha version via:

npm install -g @loongphy/codex-auth@next

If you want to downgrade to v0.2.x, you may need to manually update the ~/.codex/accounts/registry.json:

"schema_version": 3

Account Management

| Command | Description | |---------|-------------| | codex-auth list [--live] [--active] [--api\|--skip-api] | List stored accounts and usage state | | codex-auth login [--device-auth] | Run codex login, then add the current account | | codex-auth switch [--live] [--api\|--skip-api] | Switch the active account interactively | | codex-auth switch <query> | Switch directly by row number or account selector | | codex-auth remove [--live] [--api\|--skip-api] | Remove accounts interactively | | codex-auth remove <query> [<query>...] | Remove accounts by selector | | codex-auth remove --all | Remove all stored accounts | | codex-auth alias set <query> <alias> | Set an alias for an account | | codex-auth alias clear <query> | Clear the alias for an account |

Import and Maintenance

| Command | Description | |---------|-------------| | codex-auth import <path> [--alias <alias>] | Import a single auth file or batch import a folder | | codex-auth import --cpa [<path>] | Import CLIProxyAPI token JSON | | codex-auth import --purge [<path>] | Rebuild registry.json from auth files | | codex-auth export [<dir>] | Export stored account auth files | | codex-auth export --cpa [<dir>] | Export CLIProxyAPI token JSON | | codex-auth clean | Delete managed backup and stale account files |

Configuration

| Command | Description | |---------|-------------| | codex-auth config live --interval <seconds> | Configure live TUI refresh interval |

Quick Examples

codex-auth list
codex-auth list --active
codex-auth switch
codex-auth switch 02
codex-auth remove work
codex-auth import /path/to/auth.json --alias personal
codex-auth list --skip-api

Codex App

[!IMPORTANT] The app command is experimental and may never become a stable feature.

It is designed to enable seamless account switching without restarting the Codex App. By leveraging the CODEX_CLI_PATH environment variable, it dynamically injects our managed codext CLI to handle authentication on the fly.

The app command is constrained by ongoing changes in the official Codex App and Codex CLI. It may not always take effect and may also break your app.

| Command | Description | |---------|-------------| | codex-auth app [--id <id>] [--codex-cli-path <path>] | Experimental: launch Codex App with detected defaults, CODEX_HOME, CODEX_CLI_PATH, and platform overrides |

Support seamless account switching including:

  • New Chat
  • Restoring or resuming an existing conversation
  • Continuing a previously completed, interrupted, or manually stopped conversation

Uninstall

Remove the npm package:

npm uninstall -g @loongphy/codex-auth

Q&A

Why is my usage limit not refreshing?

API-backed refresh is the default. When you pass --skip-api, codex-auth reads the newest ~/.codex/sessions/**/rollout-*.jsonl file instead. Recent Codex builds often write token_count events with rate_limits: null. The local files may still contain older usable usage limit data, but in practice they can lag by several hours, so local-only refresh may show a usage limit snapshot from hours ago instead of your latest state.

Run the API-backed default with:

codex-auth list

Run one local-only command with:

codex-auth list --skip-api

Verify with:

codex exec "say hello"

Build a GUI with JSON

If you are building a GUI on top of the current codex-auth client, use the supported --json command variants to receive machine-readable results. See the JSON API documentation for supported commands and the compatibility contract.

Disclaimer

This project is provided as-is and use is at your own risk.

Usage Data Refresh Source: codex-auth supports two sources for refreshing account usage/usage limit information:

  1. API (default): The tool makes direct HTTPS requests to OpenAI's endpoints using your account's access token. This enables both usage refresh and team name refresh. curl must be available at runtime.
  2. Local-only: With per-command --skip-api, the tool scans local ~/.codex/sessions/*/rollout-*.jsonl files for usage data and skips team name refresh API calls. This mode is safer, but it can be less accurate because recent Codex rollout files often contain rate_limits: null, so the latest local usage limit data may lag by several hours.

API Call Declaration: By using the default API-backed refresh, this tool will send your ChatGPT access token to OpenAI's servers for usage limit and team name refresh. The exact endpoints are:

  • GET https://chatgpt.com/backend-api/wham/usage
  • GET https://chatgpt.com/backend-api/accounts

This behavior may be detected by OpenAI and could violate their terms of service, potentially leading to account suspension or other risks. The decision to use this feature and any resulting consequences are entirely yours.