Skip to content

Feature request: one-shot automatic account switch #147

Description

@bjspi

Hi, thanks for this project — it is very useful for managing multiple Codex accounts.

I would like to request a one-shot auto-switch command, for example:

codex-auth switch --auto

or alternatively:

codex-auth auto-switch --once

Use case

I want to integrate codex-auth into a Codex hook/script.

The script should be able to trigger an account switch on demand without knowing:

  • which accounts are currently logged in
  • which accounts are available
  • which account still has free usage limits
  • which concrete account name/email should be passed to codex-auth switch

Desired behavior

The command should check the locally known accounts and switch once to the next account that still has available/free limits.

Important: this should not enable automatic background switching or start a daemon. It should only perform a single switch when explicitly called.

So the behavior would be:

  1. User/script calls codex-auth switch --auto
  2. codex-auth checks available accounts / usage state
  3. It selects the next suitable account with remaining limits
  4. It switches the active Codex session once
  5. The command exits

Why this is useful

This would make codex-auth much easier to use in automation hooks.

For example, a Codex hook could simply call:

codex-auth switch --auto

without needing to parse account names, emails, aliases, or usage status manually.

This would provide the benefits of automatic account selection, but only as an explicit one-time action, without background behavior.

Possible command names

Possible options could be:

  • codex-auth switch --auto
  • codex-auth switch --auto --once
  • codex-auth auto-switch --once
  • codex-auth auto --once

The main point is: automatic account selection, but only for one explicit command execution.

This would be especially useful for scripting hooks that just want to switch to any currently usable account without having to know the concrete account name in advance.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions