Documentation

How ccam works

By jhyunwoo
Last updated November 29, 2026
Checked with ccam 0.16.1 and Claude Code 2.1.302

On this page

ccam is a launcher. It gives each account its own Claude Code config folder, starts Claude Code with that folder and then gets out of the way: Claude Code does everything else as usual. Knowing the few pieces involved helps you predict what ccam does, such as which account a command uses, what the accounts share, where the usage numbers come from and when ccam is still running.

An account is a folder

Claude Code keeps its login, settings and conversation history in one folder, ~/.claude by default, and uses another folder when CLAUDE_CONFIG_DIR names one. A ccam account is such a folder: ~/.local/share/ccam/profiles/<name>/ for an account ccam created, or a folder you registered in place with ccam import, such as ~/.claude. CLAUDE_CONFIG_DIR explained lists what the folder holds.

The login stays where Claude Code put it: in .credentials.json inside the folder, or on macOS in the Keychain under the folder's path. ccam never copies or moves a login. ~/.config/ccam/config.toml lists the accounts, the groups and the folder rules, and it is the only configuration file a launch reads.

Starting Claude Code

A launch takes the same steps every time, from the command line to Claude Code:

  1. ccam reads config.toml and finds the account by name or number. Without a name, it takes the folder's account or the default one (How ccam picks an account).
  2. It finds the claude executable. The path is cached in ~/.local/state/ccam/claude-path with the file's modification time and a hash of PATH, so ccam searches PATH again only when one of them changes. claude_bin in config.toml names a path of your own (~/ is expanded); one that is not an executable file stops the launch with claude_bin X is not an executable file. Check claude_bin in config.toml before anything is written. A claude that is ccam itself is refused, because it would loop.
  3. It checks the links between the account folder and its groups, with one or two system calls per item. A missing link is created on the spot. Anything that could lose data stops the launch and points to ccam doctor --fix.
  4. It adds the group's MCP servers as one --mcp-config=<path> argument before your own (Shared MCP servers).
  5. It records the session in ~/.local/state/ccam/locks/profile-<name>/, so other ccam commands know the account is running, and warns when another session that shares this account's conversation history is running in the same folder. A record that cannot be written does not stop the launch: ccam: could not mark the session as running (…); starting Claude Code anyway. Checks of whether an account is running also read Claude Code's own records in the account folder, so they see Claude Code started without ccam too: plain claude, an IDE, background sessions.
  6. It sets the terminal title to claude · <name>, writes the launch time to ~/.local/state/ccam/last-used/<name> and replaces itself with claude through exec.

Claude Code starts with CLAUDE_CONFIG_DIR set to the account folder and CCAM_PROFILE set to the account name. ccam clears any inherited values of these variables, and an inherited CCAM_RELAY. For a ~/.claude registered with ccam import, it also sets CLAUDE_SECURESTORAGE_CONFIG_DIR to an empty value on macOS and Windows, so that the account and plain claude use the same stored login (the Keychain, or Credential Manager).

Replacing itself with claude means ccam does not stay in memory, your keystrokes, signals and exit code are Claude Code's own, and the arguments reach Claude Code as you typed them, never through a shell string. Windows has no exec, so there ccam starts claude.exe as a child process with the same environment, arguments and console, waits for it and exits with its exit code. Ctrl+C reaches Claude Code from the console directly, so ccam ignores it while it waits.

Work after a session, such as noticing an MCP server you added with claude mcp add, happens at the next launch.

A shortcut such as ccwork takes the same path. ccam recognizes it by the name it was started under, and ccam <name> by its first argument; only a ccam command such as ccam usage goes through ccam's full command parser:

ccam adds about 4 ms before Claude Code starts, against a budget of 10 ms that scripts/perf-check.sh enforces. To see the time each step takes, set CCAM_TRACE=1:

$ CCAM_TRACE=1 ccam --dry-run work >/dev/null
ccam trace: start                 2.830ms (total 2.830ms)
ccam trace: load config           0.397ms (total 3.227ms)
ccam trace: prepare               0.112ms (total 3.339ms)
ccam trace: check links           0.238ms (total 3.578ms)
ccam trace: prelaunch             0.083ms (total 3.661ms)

Sharing through groups

A group shares chosen items between its accounts through one folder, ~/.local/share/ccam/groups/<group>/. Each account's copy of a shared item is a link to the group's, so a change made in one account appears in all of them. The items are MCP servers, settings.json, the global CLAUDE.md, extensions (agents, commands, skills, plugins, output styles and rules) and conversation history. Your first account creates the default group, which shares everything except conversation history.

The login files .credentials.json and .claude.json are never shared: ccam links only paths from a fixed list, and these two are not on it. Before it moves anything, ccam shows a plan and keeps a backup of what it replaces. Sharing between accounts explains groups in full.

Where usage numbers come from

ccam usage asks Anthropic's usage endpoint about every account at once, each with that account's own login, and waits at most 3 seconds per account. Numbers less than 60 seconds old are reused. When an account does not answer, ccam shows the last numbers it saved, including those the status line saved while you worked. With usage_source = "claude", Claude Code looks the numbers up itself and ccam sends no token.

When Claude Code stops a session at a usage limit, the ccam plugin records which window was full and when it resets. Until then that window counts as 100%, whatever the other numbers say, unless a usage lookup made 5 minutes or more after the limit shows room in it again, so ccam does not choose the account again too early. Usage of every account covers the sources, the cache and the limit record.

The Claude Code plugin

The ccam plugin connects Claude Code to ccam:

  • A hook runs when a turn stops at a usage limit. It shows a notification, records the limit and notes the conversation, so ccam next --continue continues exactly that conversation. With auto_switch on, it also starts the move to another account.
  • /ccam:switch notes the conversation and ends the turn, to continue it as another account (Continuing at the limit).
  • /ccam:usage and /ccam:ext show the usage and the extensions of every account inside Claude Code.
  • A skill tells Claude how to use ccam: which account has room, how to run work as another account with ccam agent and when not to change ccam's settings.

Without the plugin, everything else works, but ccam learns of a limit in an interactive session only from the usage numbers; --fallback and ccam agent still read the limit from Claude Code's own output.

When ccam keeps running

By default nothing of ccam runs while you work: it replaces itself with Claude Code. It keeps running only in these cases:

  • with relay = true or auto_switch = true (Linux and macOS), alongside each interactive session, so it can continue the conversation as another account after /ccam:switch or at a limit (Relay);
  • with --fallback, which runs claude -p as a child process so it can run the command again as another account (Run again at the limit);
  • for ccam agent, which runs claude -p as another account and prints Claude's reply;
  • on Windows, which has no exec, while it waits for Claude Code to exit.

What ccam never does

  • It never runs in the background or watches your usage. auto_switch acts only after Claude Code has stopped a session at its limit.
  • It never copies, shares or passes on a login, and never copies the sign-ins of MCP servers. It renews an expired access token only when you ask, with ccam usage --refresh or r in the dashboard, and then only for accounts that are not running.
  • It does not move an account's files while Claude Code is running as that account: group changes, renames and removals refuse until you quit the session.
  • It has no telemetry. Its only requests on its own are usage lookups with each account's own login and the dashboard's check on GitHub for a newer ccam release.

Files ccam keeps

  • ~/.config/ccam/config.toml: accounts, groups, folder rules and settings.
  • ~/.local/share/ccam/profiles/<name>/: each account's Claude Code folder.
  • ~/.local/share/ccam/groups/<group>/: what each group shares.
  • ~/.local/state/ccam/: usage caches and limit records, launch times, session markers, notes for ccam next --continue and other state.
  • ~/.local/bin/<shortcut>: shortcut commands, which are links to ccam.

XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME move these folders. The command reference lists every file.