# How ccam picks an account

> When you name no account, ccam chooses one by folder, by turn or by usage. The rules behind ccam next, --fallback, ccam pick, ccam agent and auto_switch.

Source: https://ccam.dev/en/docs/account-selection/ · Updated 2026-11-30

When you name an account, as in `ccam work` or with a shortcut such as `ccwork`, ccam starts that account. Every other launch chooses one for you by one of three rules: the folder you are in, taking turns or how much of its limits each account has used. This page explains the three rules, which command uses which, and which accounts are never chosen.

## Which commands choose for you

| Command | How it chooses | Other organizations |
| --- | --- | --- |
| `ccam -p "…"`, `ccam run`, `ccam --dry-run` | The folder's account, else the default account ([below](#starting-without-an-account-name)) | Not a choice: the account is set |
| `ccam next` | The account after the one you used last ([taking turns](#taking-turns)) | Yes; with `--continue`, only with `cross_org = true` |
| `ccam next --auto`, the dashboard's `n` | The account with the most room ([by usage](#choosing-by-usage)) | Only with `--cross-org` or `cross_org = true` |
| `ccam --fallback` | The account you name, or the folder's; at its limit, the next one by usage ([details](https://ccam.dev/en/features/next.md#run-again-at-the-limit)) | Only with `cross_org = true` |
| `ccam pick` | By usage, and workers started together get different accounts ([details](#spreading-parallel-work)) | Only with `--cross-org` or `cross_org = true` |
| `ccam agent` | By usage, never the account that calls it | Only with `--cross-org` or `cross_org = true` |
| [`auto_switch`](https://ccam.dev/en/features/auto-switch.md) | By usage, with more conditions ([details](#when-auto-switch-chooses)) | Never |
| `/ccam:switch` with `relay = true` | The account you name, else by usage | Asks you first |

**Team and Enterprise seats.** Automatic choices (`ccam next`, `--fallback`, `ccam pick`, `ccam agent`, the dashboard's `n` and, once you turn it on, [`auto_switch`](https://ccam.dev/en/features/auto-switch.md)) also switch between seats of the same Claude Team or Enterprise organization, which may violate Anthropic's terms. Read the [FAQ](https://ccam.dev/en/docs/faq.md#am-i-allowed-to-use-several-claude-code-accounts) and check with your organization and Anthropic before you rely on it.

## Starting without an account name

A launch without an account name uses:

1. the account set with [`ccam folder`](https://ccam.dev/en/features/folder.md) for the folder you are in, or for the closest folder above it;
2. otherwise the default account, which `ccam use` sets;
3. if there is no default account, the account with the lowest number in `ccam list`.

These launches name no account: `ccam -p "…"` and any other launch whose first argument is an option for Claude Code, `ccam run` and `ccam --dry-run` on their own, and the first attempt of `ccam --fallback -p "…"`. The dashboard (`ccam` alone) opens with its cursor on that account.

`ccam next` does not look at folders. `ccam pick` uses the folder's account only to know which organization to stay in.

## Taking turns

Plain `ccam next` takes turns in number order. Every launch through ccam writes its time to `~/.local/state/ccam/last-used/<name>`, so ccam knows which account you used last. From that account it walks forward through the numbers, wraps from the last back to the first, and takes the first account that is logged in:

`work` was launched most recently, so the walk starts after it. `side` has no login and is skipped, and `lab` is chosen. Had `lab` been logged out too, the walk would have wrapped around to `personal` (`% len` in the diagram).

- Taking turns never returns the account you started from. With no other logged-in account, it stops with `no logged-in account other than <name>`.
- It does not look at usage, so it can land on an account that has reached its limit. `--auto` avoids that.
- With `--continue`, the walk starts at the account that holds the conversation and skips accounts of another organization, unless `cross_org = true` ([below](#staying-in-one-organization)).
- A dry run (`ccam --dry-run next`) records no launch, so it does not move the turn forward.

## Choosing by usage

`ccam next --auto`, the dashboard's `n`, `--fallback`, `ccam pick`, `ccam agent`, `auto_switch` and the relay choose the account with the most room: the most of its limits left. ccam looks up every candidate's usage at once, as [`ccam usage`](https://ccam.dev/en/features/usage.md) does, and judges each account by its 5-hour window and its weekly window. When a model is named (`--model` for Claude Code, `ccam pick` or `ccam agent`), that model's own weekly window counts too (`opus`, `sonnet`, `haiku` or `fable` in the name). The relay and `auto_switch` count the model the conversation runs on; for a `ccam next --continue --auto` you type yourself, add the model after `--` (`-- --model opus`) to count it.

ccam sorts the accounts into three tiers:

1. **Room**: every window is below `auto_max_usage` (default 100). The strategy chooses among these accounts.
2. **Over**: below 100% but at or over `auto_max_usage`. Used only when no account has room, and then the `headroom` strategy chooses. When work is spread over the accounts, an account picked a moment ago goes last even if that means taking one over `auto_max_usage` ([below](#spreading-parallel-work)).
3. **Full**: a window at 100%, or 5-hour usage that ccam does not know. Never chosen, except that `--fallback`, and `ccam agent` going on after a limit, try accounts with unknown usage last.

The strategy is `auto_strategy` in `config.toml`, or `--strategy` for one command:

| Strategy | Takes | Good for |
| --- | --- | --- |
| `headroom` (default) | Of the accounts within 3 points of the lowest 5-hour usage, the one with the least of its week used. An account at 12% beats one at 10% when less of its week is used, but one at 14% does not | The most room right now |
| `expiring` | The account whose 5-hour window resets soonest | Using 5-hour quota before it resets unused |
| `balance` | The account with the most weekly quota left per day until its week resets, counting each running ccam session against it | Spending the weekly quotas evenly over several sessions |

The numbers follow the rules of `ccam usage`: numbers less than 60 seconds old are reused, and an account that does not answer, or whose access token has expired, is judged by its saved numbers. A saved window whose reset time has passed counts as 0%. With the default `live` source each account's lookup gets 3 seconds and choosing never renews a login; with `usage_source = "claude"`, Claude Code looks the numbers up itself (up to 20 seconds, or 50 when the token is about to expire) and renews the token as it starts.

A window where Claude Code refused a request counts as 100% until its reset, whatever the numbers say: the [ccam plugin](https://ccam.dev/en/docs/install.md#claude-code-plugin) records the limit ([the limit record](https://ccam.dev/en/features/usage.md#the-limit-record)). So an account that has just hit its limit is not chosen again before its reset, even when its saved numbers are old. Only a usage lookup made 5 minutes or more after the limit that shows room in that window ends it sooner, as after a limit reset (`/limit-reset` in Claude Code).

Unlike taking turns, `--auto` can choose the account you used last if it still has the most room.

## Accounts that are never chosen

`ccam next`, `--auto`, `--fallback`, `ccam pick`, `ccam agent` and `auto_switch` leave out:

- accounts without a working login: never logged in, logged out, or with a login that has fully expired (`ccam login <name>` fixes that);
- accounts that use an API key, including Console logins, since they have no plan limits ([API key accounts](https://ccam.dev/en/features/api.md));
- for choices by usage, accounts at 100% and accounts whose 5-hour usage is unknown (but see the Full tier above);
- for `ccam agent`, the account that calls it.

The dashboard's `n` and the last line of `ccam usage` look at the usage numbers only and do not check the login, so they can name an account whose login has expired. `ccam next --auto` skips it.

## Staying in one organization

Choices by usage, and `ccam next --continue`, stay among accounts of the same kind as the one you leave: seats of the same Claude Team or Enterprise organization, or personal plans (Pro and Max). So work from a company account does not continue on a private one, or the other way around. The account you leave is the conversation's account with `--continue`, the account you used last for `ccam next --auto`, the folder's account for `ccam pick`, the calling account for `ccam agent` and the account under the cursor in the dashboard.

- ccam knows each account's organization from its `.claude.json`, or from what `ccam login` recorded when that file does not say. An account whose organization ccam cannot tell can be matched with any account.
- Two folders logged in to the same Claude account share its limits, so one never takes over from the other, even with `cross_org`.
- `--cross-org`, or `cross_org = true` in `config.toml`, lets ccam choose in other organizations too. `--fallback` and the dashboard's `n` follow `cross_org = true` only.
- `auto_switch` never leaves the organization, whatever `cross_org` says.
- After `/ccam:switch`, a move to another organization always waits for your yes ([details](https://ccam.dev/en/features/next.md#inside-claude-code)).

When this rule leaves no account for a choice by usage, ccam says so: `` no logged-in account to pick among <name>'s (<organization>); --cross-org also looks at the others ``.

## Spreading parallel work

A new job's usage takes a while to show in the numbers, so workers started together would all see the same account as the one with the most room. `ccam pick` and `ccam agent` record each pick in `~/.local/state/ccam/picks/<name>` and put accounts picked in the last 2 minutes after the others. Workers started together therefore get different accounts while enough accounts have room. When every account with room was picked recently, the rules choose among all of them again: with three accounts, a fourth worker shares one of them. `auto_switch` records its moves the same way.

Picks happen one at a time under a lock (`~/.local/state/ccam/picks.lock`), so two scripts starting together see each other's pick. A pick does not reserve the account; give a job that must survive a limit `--fallback`. The `balance` strategy spreads sessions too, since each running session counts against its account.

## When auto_switch chooses

[`auto_switch`](https://ccam.dev/en/features/auto-switch.md) chooses by usage like `--auto` (`auto_max_usage`, `auto_strategy` and the conversation's model), among accounts of the same kind as the one it leaves. The account must also:

- be logged in with a login Claude Code can renew;
- not be logged in to the same Claude account;
- not use an API key;
- have a plan ccam knows;
- not have usage credits on, as far as ccam's own usage lookup shows;
- have trusted this folder in Claude Code;
- if the conversation runs as an agent, share the agents of the account it leaves: its `agents` and `plugins` folders and its `settings.json` must each be the very same (through a group), or missing in both.

An account another session moved to in the last 2 minutes comes after the others. The choice has to be made within about 6 seconds; when the usage lookups take longer, the session stays. With `usage_source = "claude"`, `auto_switch` decides from saved numbers alone, and since ccam cannot then tell whether usage credits are on, it assumes they are off.

## When no account has room

When a choice by usage finds nothing, ccam exits with code 75 (`EX_TEMPFAIL`), so a script can tell "try later" from a failure; taking turns instead stops with `no logged-in account other than <name>` and code 1. It says `no logged-in account to pick` when no account is logged in, and `` no account with known usage and headroom (see `ccam usage`) `` when every account is full or its usage is unknown.

With `--wait`, `ccam next --auto`, `ccam pick` and `ccam agent` wait instead. ccam sleeps until the first full account's window resets (30 seconds after the reset time, when the usage lookup shows the new window), prints `ccam: no account has room; waiting until 15:10`, and chooses again. When no account says when it resets, it looks again after 10 minutes. `--wait` alone waits up to 5 hours, and `--wait=2h` sets the limit; the value goes after `=`. If nothing frees up in time, ccam exits with 75. `--fallback` waits the same way with `--wait` before the account name ([details](https://ccam.dev/en/features/next.md#run-again-at-the-limit)).

`auto_switch` never waits: when no other account has room, Claude Code handles the limit as usual ([what you see](https://ccam.dev/en/features/auto-switch.md#when-nothing-moves)).

## Settings

Settings for all accounts go at the top of `config.toml`, above the first `[[group]]`, `[[profile]]` or `[[folder]]`. A setting below one of them belongs to that table: ccam warns about it at every launch, and commands that save the config refuse until it is moved.

```toml
# ~/.config/ccam/config.toml
auto_max_usage = 80        # keep 20% of each account for interactive work
auto_strategy = "expiring" # or "headroom" (the default) or "balance"
cross_org = false          # true: --auto, pick and agent may choose in other organizations
```

| Setting | For one command | Default |
| --- | --- | --- |
| `auto_max_usage` | `--max-usage <1-100>` | 100 |
| `auto_strategy` | `--strategy headroom\|expiring\|balance` | `headroom` |
| `cross_org` | `--cross-org` | `false` |

## Related

- [Continuing at the limit](https://ccam.dev/en/features/next.md)
- [Automatic switching](https://ccam.dev/en/features/auto-switch.md)
- [Usage of every account](https://ccam.dev/en/features/usage.md)
- [Picking an account for scripts](https://ccam.dev/en/features/pick.md)
- [Subagents on other accounts](https://ccam.dev/en/features/agent.md)
