Skip to content

How to Manage Multiple Claude Code Logins with Profiles

A Claude login profile is a named Claude Code configuration directory. For claude.ai logins and API-key accounts, separate profiles let you keep, for example, work and personal configurations side by side and choose between them manually. There is one authentication exception: Claude Code does not isolate two Claude Console sign-ins made without an API key because those credentials live outside the configuration directory. See Claude Code's multiple-account documentation.

Not to be confused with component profiles, which filter staged files during install. Login profiles only select which CLAUDE_CONFIG_DIR Claude Code runs with.

Profiles rely on Claude Code's documented CLAUDE_CONFIG_DIR variable. Logins stay separate, but sessions are shared: every profile's projects/, file-history/ and session-env/ is a link to the same directory in ~/.claude, so claude --resume <id> finds a session whatever profile started it. Apart from those three directories, amplihack never modifies ~/.claude for this feature, and its only network calls are the usage reads of profile usage and the rotator. See What a new profile inherits and Share sessions across profiles. To see which accounts have quota left, see Check usage across profiles. To move work to another account automatically when one runs out of quota, see Switch accounts automatically. To keep the default ~/.claude login on the account with the most capacity, see Rotate Claude logins automatically. To be told when every account is out of capacity, see When no account has capacity. For what a recipe step does when every account is out of quota, see Waiting for a usage-limit reset. For a profile that uses a Claude Platform API key, billed per token, see API-key profiles and usage limits.

What a new profile inherits

amplihack profile add seeds the new profile with an allowlist of shared, non-auth assets copied from ~/.claude (resolved from $HOME). Authentication and history stored in the selected configuration directory stay with that profile, subject to the Console sign-in exception above.

Profiles preserve the calling process environment. An inherited ANTHROPIC_API_KEY can select API billing instead of a subscription login; see the official environment variable reference.

Copied Details
CLAUDE.md Your global instructions
agents/, commands/, output-styles/, rules/, skills/ Copied recursively
settings.json (filtered) Only allowlisted top-level keys: alwaysThinkingEnabled, attribution, cleanupPeriodDays, hooks, includeCoAuthoredBy, language, model, outputStyle, permissions, respectGitignore, spinnerVerbs, statusLine

The copy is made once, when the profile is added. After that, amplihack install keeps the amplihack hooks in each profile's settings.json current: it replaces amplihack's hook entries with the ones it writes to ~/.claude/settings.json and leaves the rest of the file alone. A profile without a settings.json is left without one.

Never copied: .credentials.json, .claude.json, history*, sessions/, todos/, statsig/, shell-snapshots/, ide/, and anything else not on the allowlist (so plugins and MCP server settings are not carried over), and the env and apiKeyHelper settings keys (and any other key not on the allowlist). projects/, file-history/ and session-env/ are not copied either: they are linked, see Share sessions across profiles. If ~/.claude does not exist, the profile is simply created empty and gets no links. If the path exists but is not a directory, profile add fails and removes the new profile directory rather than silently creating an unseeded profile.

Caveats:

  • Copy by value. The allowlisted assets are copies, not links. Later edits to ~/.claude do not propagate to existing profiles; re-add the profile to pick them up. The only links are the three session directories.
  • Allowlisted setting values are copied verbatim. Review hooks and status-line commands for embedded secrets or machine-specific paths before adding a profile; what they contain is your responsibility. Values are never logged.
  • Symlinks. A symlinked ~/.claude is refused (SymlinkRefused); symlinked ancestors of it are resolved normally. A missing CLAUDE.md or settings.json is skipped. Symlinks and special files (FIFOs, sockets, devices) inside the shared directories are skipped, never followed or copied. On Unix the copy is descriptor-based: ~/.claude is opened once with O_NOFOLLOW and everything else is read with openat relative to that descriptor, so swapping ~/.claude or a directory for a symlink mid-copy is not followed and no outside data is copied. On Windows, source file handles open the final component without following a reparse point and reject reparse-point handles; path-based directory traversal still leaves same-user ancestor/directory races.
  • Permissions. On Unix, copied directories are 0700 and files 0600. Windows inherits the destination's ACLs. Existing files are never overwritten.
  • Limits. Copying is bounded (16 directory levels, 5,000 entries, and 64 MiB per copied asset file, and 1 MiB for settings.json); exceeding a bound is an error that fails the add (it is not silently truncated).
  • Non-Unix / Windows. On Unix, source files are opened relative to a no-follow root descriptor to close the check-then-open race. Non-Unix platforms, including Windows, have no equivalent root descriptor, so a same-user race in ancestor or directory traversal remains possible there.
  • Hardlinks. A hardlink is indistinguishable from a regular file, so a hardlink inside ~/.claude to another file you own is copied like any other file. Only files the invoking user can already read are reachable.
  • Failure is rolled back. If seeding fails (for example invalid settings.json gives InvalidSharedSettings), the private staging directory created by that call is removed and no profile is published. If cleanup also fails, the error reports both the seeding and cleanup failures. A pre-existing profile is never deleted.
  • Root overlap. A profile root inside ~/.claude is rejected before the profile root is created, including when the shared source or profile root contains not-yet-existing path components.

Example:

amplihack profile add work
# error: InvalidSharedSettings: ~/.claude/settings.json is not valid JSON
# (exact wording may vary; no profile directory is left behind)

Share sessions across profiles

Every profile uses the same session store, so a conversation started under one account can be resumed under another. Logins are never shared.

Shared (one copy, in ~/.claude) Per profile (never shared)
projects/: session transcripts (<session-id>.jsonl), grouped by working directory .credentials.json, .claude.json (login and account)
file-history/: file snapshots, one directory per session id settings.json, CLAUDE.md and the other seeded assets
session-env/: per-session environment, one directory per session id history*, todos/, statsig/, shell-snapshots/, ide/

file-history/ and session-env/ are shared along with projects/ because both are keyed by session id and --resume needs them: without them a resumed session can't rewind file edits or restore its environment.

In each profile directory the three names are symbolic links:

ls -l ~/.amplihack/claude-profiles/work/
# lrwxrwxrwx ... file-history -> /home/you/.claude/file-history
# lrwxrwxrwx ... projects -> /home/you/.claude/projects
# lrwxrwxrwx ... session-env -> /home/you/.claude/session-env

Resume a session from another profile

amplihack claude --profile work      # session 0f6c…e1 is written to ~/.claude/projects
amplihack claude --profile personal -- --resume 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1

Plain claude --resume (no profile) sees the same sessions, because the store is ~/.claude itself.

amplihack makes or checks the links at each of these points. When there is nothing to do it prints nothing.

Command What happens
profile add <name> Links are created in the new profile. Nothing is printed unless something went wrong.
profile switch <name>, profile login <name> The profile's links are checked and fixed: by switch after the login has moved and the pointer is written, for <name> and for the profile whose login it replaced; by login before claude starts.
amplihack claude / launch with any profile (--profile, inherited, default pointer), profile run Checked just before spawn, after the usual directory check.
profile rotate After a swap that actually ran, for both profiles in it. --dry-run and refused rotates change nothing.

Auto-switch makes no check of its own. Its swap moves only the login files, and the rerun after a usage limit is an ordinary launch, so the launch row covers it.

Problems are printed to stderr as warnings, for example amplihack: profile work: projects is a symlink to /mnt/old/projects; left alone. They never stop a launch, an add, a switch, a login or a rotate.

Moving an existing profile's sessions into the shared store

Profiles made before sessions were shared have real projects/, file-history/ and session-env/ directories. The first launch, switch or login of such a profile merges them into ~/.claude and replaces each with a link. The merge runs before claude starts. It prints amplihack: profile work: merging session history into ~/.claude (one-time; may take a while) when it begins and the results when it finishes. When the profile and ~/.claude are on different filesystems every file is copied, so a profile with gigabytes of history can take minutes; let it finish rather than interrupting it (an interrupted merge is safe and resumes on the next launch, but it starts by re-checking every file).

amplihack: profile work: projects: moved 41 files into ~/.claude/projects, 2 identical, 1 conflict
amplihack: profile work: projects: conflict: -home-you-src-app/0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl kept the shared copy; this profile's copy saved as ~/.claude/projects/-home-you-src-app/0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl.conflict-work
amplihack: profile work: projects: old directory kept as ~/.amplihack/claude-profiles/work/projects.pre-share-20261020T141503Z

The merge never deletes or overwrites a session:

  • Only in the profile: the file is moved into the shared store, keeping its modification time. Its mode is limited to the owner (a 0644 transcript becomes 0600), because ~/.claude may be readable by other users where the profile directory was not.
  • Same bytes in both: the shared copy stays. The profile's copy is left behind and ends up in the backup.
  • Different contents: the shared copy always keeps the real name. The profile's copy is moved beside it as <file>.conflict-<profile>, or .conflict-<profile>-2, -3 and so on if that name is taken. The shared file is never renamed, so a session another profile has open is never split and its name never goes missing, even for a moment. If the profile's copy was the one you wanted, see Resume the losing copy of a conflict.
  • Claude's memory index: Claude reads per-project memory only through projects/<project>/memory/MEMORY.md, which lists the memory files beside it. When the profile's MEMORY.md differs from the shared one, the shared file keeps its name and the profile's copy is saved as MEMORY.md.conflict-<profile> like any conflict, and then every entry of the profile's index that the shared index lacks is appended to the shared MEMORY.md (headings and blank lines are left out; a link to a memory file that was itself saved under a conflict name points at that name). This append is the only change the merge ever makes to an existing shared file. amplihack prints projects: memory index <project>/memory/MEMORY.md: added <n> entries from this profile to the shared copy. Read the shared MEMORY.md afterwards and tidy any entries that now say the same thing twice.
  • Skipped and left in the backup: credential files (.credentials*, .claude.json) at any depth, symbolic links, and special files.

When the merge finishes, the old directory is renamed to <name>.pre-share-<UTC time> inside the profile, holding whatever was left behind, and the link takes its place. The merge is safe to stop and re-run; the next launch picks up where it stopped. A second run on a merged profile changes nothing.

If the link is put in place but the old directory can't then be renamed to its .pre-share- backup name, amplihack warns rename failed: ...; nothing removed, the old directory is at <profile>/.<name>.share-tmp. That warning is printed only once: on later runs <name> is a correct link and the leftover isn't mentioned again. Check its contents, move anything you still want into ~/.claude/<name>, then remove it by hand. While it is still there, a later swap of the same name refuses to run.

Resume the losing copy of a conflict

The .conflict-<profile> suffix stops Claude from listing the file as a second session. To resume that copy instead, end every session that has the shared copy open, then put the losing copy under the session's own name and keep the shared copy aside:

cd ~/.claude/projects/-home-you-src-app
mv 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl.conflict-shared
mv 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl.conflict-work 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1.jsonl
amplihack claude --profile work -- --resume 0f6c9b2a-4d1e-4c7a-9a55-3b8f2f7d10e1

Delete the backups

Backups are never deleted automatically. They can hold full transcripts, so once you have checked the merge, delete them rather than copying them anywhere:

ls -d ~/.amplihack/claude-profiles/*/*.pre-share-*
rm -rf ~/.amplihack/claude-profiles/work/projects.pre-share-20261020T141503Z

profile remove deletes a profile's backups along with its directory. It removes only the links, never the shared sessions they point to.

A running session delays the merge

If a Claude session is running with the profile's directory, its real directories are not merged; you see amplihack: profile work: projects: migration deferred: live session. If amplihack can't read the list of running processes (on Linux, /proc), it also waits, and says projects: migration deferred: could not check for running sessions (retried next launch) instead. Missing names still get links straight away. The merge happens on the first launch, switch or login after every session using that profile has ended.

On systems other than Linux, amplihack can't see which sessions are running, so it never merges automatically there. New profiles and missing names still get links. While a profile still has a real directory, each launch, switch and login of it prints amplihack: profile work: projects: not merged: running sessions can't be checked on this system; merge by hand, see docs/howto/claude-profiles.md#merge-by-hand-on-macos until you merge it as shown below.

On Windows the store is not shared and each profile keeps its own directories. profile add prints shared session dirs not supported on this platform; profiles keep separate projects/ once; other commands log it at debug level only.

Merge by hand on macOS

End every session that uses the profile, then run:

p=~/.amplihack/claude-profiles/work
for d in projects file-history session-env; do
  [ -d "$p/$d" ] && [ ! -L "$p/$d" ] || continue      # only real directories
  rsync -a --no-links --ignore-existing \
    --exclude='.credentials*' --exclude='.claude.json' \
    "$p/$d/" "$HOME/.claude/$d/" &&
  mv "$p/$d" "$p/$d.pre-share-manual" &&
  ln -s "$HOME/.claude/$d" "$p/$d" ||
  { echo "stopped at $d; nothing was linked for it" >&2; break; }
done
  • --ignore-existing never overwrites a shared file.
  • --no-links (after -a) skips symbolic links, and the two --exclude options keep credential files out of the shared store.
  • A file that exists in both places with different contents is not copied: the profile's copy stays only in $d.pre-share-manual. Run diff -rq "$p/projects.pre-share-manual" ~/.claude/projects to list them before you delete the backup.

If the system rsync rejects one of these options, install rsync 3 (for example brew install rsync) and run the loop again.

Privacy: every profile can read every session

With a shared store, any profile, and anyone using it, can read every transcript and file snapshot from every other profile. Only the logins stay separate. Stop sharing for one profile keeps that profile's new sessions out of the shared store, so other profiles don't list them, but they are still files your OS user can read. If you need an account whose sessions the others can't read, use a different OS user rather than a profile.

All profiles also share one session-env/. If you keep accounts separate for trust reasons, for example a client's account next to your own, create .no-shared-sessions in that profile before its first launch after the upgrade (see Stop sharing for one profile).

When nothing is linked

amplihack leaves a profile's directories as they are, with a warning, when:

  • the profile has a .no-shared-sessions file (no warning; see Stop sharing for one profile);
  • $HOME is unset, or ~/.claude doesn't exist (no warning in this case; amplihack doesn't create ~/.claude);
  • ~/.claude is itself a symlink, as in many dotfile setups (a warning is printed). Point the profiles at the real directory instead, or keep sharing off;
  • ~/.claude is not owned by you, or is writable by group or others (a group-writable directory is accepted when the group is your own private group, as with Ubuntu's default umask of 002);
  • the profile directory is not owned by you, or has any group or other permission bit (mode & 0o077 is not zero, the same rule as the launch check);
  • ~/.claude/projects (or one of the other two) is a symlink, not a directory, not owned by you, or writable by group or others (same rule as ~/.claude). Only that name is skipped;
  • the profile directory is inside ~/.claude (a warning is printed; move the profile root elsewhere to share sessions);
  • the profile's projects/ is already a symlink to somewhere else, or is a file rather than a directory. amplihack never follows or replaces it.

A missing ~/.claude/projects (or file-history/, session-env/) is created with mode 0700.

Stop sharing for one profile

A .no-shared-sessions file in the profile directory turns sharing off for that profile. amplihack checks for it before anything else and, when it is there, never links or merges that profile's directories. End the profile's sessions, then create the file and replace each link with a real directory:

p=~/.amplihack/claude-profiles/work
touch "$p/.no-shared-sessions"
for d in projects file-history session-env; do
  [ -L "$p/$d" ] && rm "$p/$d"        # removes the link only, never the shared files
  [ -e "$p/$d" ] || mkdir -m 700 "$p/$d"
done

Sessions the profile wrote while it was shared stay in ~/.claude. Copy back the ones you want, or move a *.pre-share-* backup into place instead of the mkdir; a backup holds only what the merge left behind.

To share again, delete .no-shared-sessions. The next launch, switch or login merges the profile's directories into ~/.claude as described in Moving an existing profile's sessions into the shared store.

Create and log in

amplihack profile add work
amplihack profile login work      # interactive claude; complete login inside it
amplihack profile add personal
amplihack profile login personal

add copies the allowlisted shared assets into a private staging directory and publishes ~/.amplihack/claude-profiles/work/ atomically after seeding succeeds (mode 0700 on Unix); it fails if the profile already exists. The first add also saves the profile root it used; see Choose where profiles live. login always runs the claude binary (not the configured launch binary) with CLAUDE_CONFIG_DIR pointing at the profile so the login is stored there. If the new login is an account another profile already has, login refuses it and puts the previous login back; see Duplicate logins. An accepted login also records the account as the one the profile is meant to hold. The duplicate-login warning and the rotator compare against this record; see Recorded account.

Choose a profile

Per launch:

amplihack claude --profile work
amplihack profile run personal -- --model sonnet

As the login in ~/.claude and the default:

amplihack profile switch work
# Live login moved: personal -> work
# Default for new launches: work
# Rotation held on work until `amplihack profile switch --none`.
amplihack claude              # runs as "work", against ~/.claude
claude                        # plain claude is "work" too
amplihack profile show        # prints name and directory, or "none"
amplihack profile switch --none   # no default, rotation released

switch moves work's login into ~/.claude with the same swap profile rotate uses, and holds rotation on work until you run switch --none. Claude launches that use ~/.claude then run as work. Moving the login needs Linux and a profile that has a login of its own. When the login cannot be moved (on macOS or Windows, or when work is open in a session of its own), switch still makes work the default for launches outside recipes, prints Live login not moved; ..., holds nothing, and exits 1; see Switch to a login by hand for the details and the refusals.

See Clearing the default profile and Launching the rotator's live profile.

Amplihack first checks the --profile flag, then an inherited AMPLIHACK_CLAUDE_PROFILE, then the default pointer outside recipe runs. An explicit --profile never reads the inherited value or the pointer, so it works even if the pointer is dangling or corrupt. With no profile, Claude uses the inherited CLAUDE_CONFIG_DIR if set, or the live login in ~/.claude. When a profile is selected, it overrides the ambient value for the child process only.

Nested sessions keep the parent's profile

Once a launch picks a profile, every amplihack launch started from it uses the same profile: recipe agent steps, multitask workstreams, and any amplihack claude you run inside the session. This holds for sessions started with amplihack claude, amplihack launch, amplihack profile run and amplihack profile login. The launch passes the name to its children in AMPLIHACK_CLAUDE_PROFILE (and the root in AMPLIHACK_CLAUDE_PROFILE_ROOT, if you set one), and nested launches use it ahead of the pointer.

amplihack profile switch personal
amplihack claude --profile work
# inside the session, and in every recipe step or workstream it starts:
echo "$AMPLIHACK_CLAUDE_PROFILE"   # work
amplihack profile switch personal  # moves personal's login into ~/.claude
amplihack claude                   # still runs as "work"

A profile switch therefore never moves a session started with a profile, or the orchestration it runs, to another account part way through: those run with CLAUDE_CONFIG_DIR=<root>/<name>, which switch does not touch. It changes the login in ~/.claude, so sessions of plain claude (no CLAUDE_CONFIG_DIR) use the new account when they next read their credentials, exactly as after a rotator swap. Outside recipe runs, launches without a profile flag or inherited profile use the new default pointer.

To pin a profile for a run started from a plain shell, set the variable yourself:

AMPLIHACK_CLAUDE_PROFILE=work amplihack recipe run default-workflow

If the inherited name is invalid or the profile has been removed, the launch fails and does not fall back to the pointer:

error: inherited AMPLIHACK_CLAUDE_PROFILE "work": not found
hint: unset AMPLIHACK_CLAUDE_PROFILE, or create the profile with `amplihack profile add <name>`

See the resolution reference for how the name reaches each kind of nested launch.

Clearing the default profile

amplihack profile switch --none
# Default profile cleared.
# Rotation released; the rotator picks the best login on its next cycle.
amplihack profile show
# none

After this, amplihack claude runs with no profile and leaves CLAUDE_CONFIG_DIR alone. The login in ~/.claude does not move; the rotator is free to swap it again on its next cycle. The second line appears only when a switch had held rotation. Clear the default when the rotator uses a credit-backed overflow profile: a launch that selects the overflow profile through the default pointer can spend credits even while the rotator has a plan login live. If no default was set, the command prints No default profile was set. and still exits 0. --none cannot be combined with a name, and switch with neither is a usage error (exit 2).

There is no switch default form: default is a valid profile name, so amplihack profile switch default selects a profile called default.

Launching the rotator's live profile

When amplihack profile rotate has moved a profile's login into ~/.claude, that profile's own directory has no login. Launching Claude in that directory would ask you to log in, and logging in there would create a duplicate login.

So when the profile a launch resolves to is the rotator's live profile, amplihack claude and amplihack launch run against ~/.claude instead, with CLAUDE_CONFIG_DIR unset and no profile pinned. This applies whether the profile came from --profile, an inherited AMPLIHACK_CLAUDE_PROFILE, or the default pointer. One line goes to stderr:

note: profile 'team' is the rotator's live login, which is in ~/.claude; launching against ~/.claude.

The session uses the right account because ~/.claude is where that account's login is. Because no profile is pinned, nested launches inside the session also run against ~/.claude.

The live profile is the one shown as live in ~/.claude by profile usage. If amplihack cannot tell which profile is live (no ledger and no single account match, or Windows or another platform without Unix file semantics), it launches the profile directory as before and prints nothing. Docker and --auto launches are not affected.

amplihack profile run <name> does not redirect; it always uses the profile's own directory. Use amplihack claude --profile <name> for the live profile.

Choose where profiles live

Profiles live under one profile root. amplihack picks it in this order:

  1. AMPLIHACK_CLAUDE_PROFILE_ROOT, if set and non-empty.
  2. The root saved in ~/.amplihack/profile-root.
  3. ~/.amplihack/claude-profiles.

Save a root once and every shell finds it, whether or not it reads ~/.bashrc:

amplihack profile root /home/you/.claude-profiles
saved profile root: /home/you/.claude-profiles (/home/you/.amplihack/profile-root)

Check which root is in use and where it came from:

amplihack profile root
root: /home/you/.claude-profiles (source: config)

amplihack profile list prints the same line first.

You may not need to run profile root at all. The first amplihack profile add saves the root it used when nothing is saved yet, so if you export AMPLIHACK_CLAUDE_PROFILE_ROOT in ~/.bashrc, your first add records that path:

recorded profile root /home/you/.claude-profiles in /home/you/.amplihack/profile-root

Later adds never change it.

If you created profiles before this feature existed, save the root once from a shell that has the variable:

amplihack profile root "$AMPLIHACK_CLAUDE_PROFILE_ROOT"

The variable still takes precedence while it is set and non-empty; an empty value counts as unset. When it is set, profile root <dir> saves anyway and adds a note on stderr:

note: AMPLIHACK_CLAUDE_PROFILE_ROOT=/tmp/scratch overrides the saved root in this shell

To go back to the default, delete ~/.amplihack/profile-root. Changing the root does not move existing profiles.

profile root <dir> refuses a relative or empty path, a path with a .. component (the variable is refused for the same reasons), a symlink, and a path inside ~/.claude, and saves nothing when it refuses. A quoted '~/x' is relative; let the shell expand ~ instead. The directory does not have to exist yet; profile add creates it.

Use profiles from non-interactive shells

cron, systemd, tmux new-session -d '<cmd>', ssh host cmd and env -i do not read ~/.bashrc, so a root exported there is missing. With a saved root they need no extra setup:

env -i HOME="$HOME" PATH="$PATH" amplihack profile list
root: /home/you/.claude-profiles (source: config)
* personal
  work
*/30 * * * * amplihack profile usage --json > /tmp/claude-usage.json

The saved file is the array of Claude rows, so a script reads it with jq '.[]'. It has no Codex rows; save --summary-json instead for those.

tmux new-session -d -s work 'amplihack claude --profile work'

If a command reports source: default where you expected your own root, no root is saved yet; run amplihack profile root <dir>.

A launch exports AMPLIHACK_CLAUDE_PROFILE_ROOT to its children only when it was set and non-empty. Otherwise nested launches read ~/.amplihack/profile-root themselves, so changing the saved root while a session runs moves that session's later nested launches to the new root. Set the variable before starting a session if it must stay on one root. The background rotator is always pinned to the root it started with; see Which root the rotator uses.

Repair a damaged saved root

If ~/.amplihack/profile-root is empty, relative, a symlink, writable by others or otherwise invalid, every command that needs the root fails rather than quietly using another one:

error: saved profile root in "/home/you/.amplihack/profile-root" is invalid: not an absolute path
hint: fix or remove ~/.amplihack/profile-root, or run: amplihack profile root <absolute dir>

Run amplihack profile root <absolute dir> to replace it; it never reads the damaged file. Deleting the file returns you to the default. Setting AMPLIHACK_CLAUDE_PROFILE_ROOT also works, because the file is not read while the variable is set and non-empty.

If the file was written by sudo and is owned by root, remove it with sudo rm ~/.amplihack/profile-root first.

See the profile root reference for every rule.

List and remove

amplihack profile list
amplihack profile remove personal --yes

list starts with the root in use, for example root: /home/you/.claude-profiles (source: config), then one profile per line with the default marked *.

remove deletes only the verified profile directory, requires --yes, and clears the default pointer if it named that profile. This deletes that account's local Claude login, its history and any *.pre-share-* backups. The shared session links are removed without being followed, so sessions in ~/.claude/projects, file-history/ and session-env/ are kept.

remove reads the default pointer before deleting anything. A missing pointer means "no default" and removal proceeds. A corrupt, unreadable or dangling pointer makes remove fail with the pointer error and leaves every profile directory untouched. Repair it with amplihack profile switch <name>, then re-run remove.

remove also refuses a profile that auto-switch is still using: one whose account is live in another profile's directory, whose own login is parked, or whose directory is hosting another account. End the sessions involved and run amplihack profile auto-switch status until it shows hosted directories: none.

Check usage across profiles

To see which accounts have quota left, run:

amplihack profile usage
PROFILE      WEEK             W-RESET      SESSION           S-RESET     STATE
review       █░░░░░░░░░  10%  11-05 09:00  ░░░░░░░░░░   5%   11-01 14:00 ok
work         ███░░░░░░░  30%  11-05 09:00  ██░░░░░░░░  20%   11-01 12:00 ok                 *
example-org  █████░░░░░  52%  11-05 09:00  ███░░░░░░░  35%   11-01 13:00 ok                 spend:not_probed
team         █████░░░░░  55%  11-05 09:00  ██████████ 100%   11-01 23:50 session_exhausted
scratch      not signed in (no credentials file)                         not_logged_in      spend:unknown
times: Europe/London
order: rotator pick (most room in the worse of session and week, then name)

For each profile, amplihack first uses a reading the status line stored in the last 300 seconds, if there is one. Otherwise it reads the profile's stored login and asks Anthropic's OAuth usage endpoint for the session and weekly figures itself, which takes well under a second and starts no claude process. With 16 profiles the whole command normally finishes in a few seconds. The token is read in memory only and is never printed, logged or passed to another process; an expired one is refreshed and saved back to the profile, as claude would do.

A profile with no login to use, such as scratch above, which has no .credentials.json, is shown as not signed in (<reason>) at once, with no warning on stderr. In --json the row has "state": "not_logged_in" and "error": null, as it would if claude had reported it; the reason is in the bar and table text only. No claude is started for it: claude would find the same empty profile. The same happens for a file with no OAuth token (no oauth token) and for an expired token with nothing to refresh it with (no refresh token). A file that is there but cannot be read as a login (not JSON, an unknown shape, or a rejected token) is unreadable credentials, not not signed in: that profile still goes to claude. The bar view shows the text in place of the bars; --table shows it in the MARKS column. Run amplihack profile login scratch to fix it.

A missing .credentials.json counts as not signed in on Linux only. On macOS, Claude Code keeps the login in the Keychain, so such a profile still goes to claude. An expired token that does have a refresh token is not treated as signed out either: amplihack refreshes it, or, for the live ~/.claude login, leaves claude to refresh it.

Only when the direct read fails for another reason, such as a timeout or an HTTP error from the endpoint, does amplihack start claude with CLAUDE_CONFIG_DIR set to that profile. It asks with a get_usage request, then runs claude -p /usage and reads its Current session and Current week lines if it cannot use the answer. Such rows are marked (fallback), and with --raw a note: line on stderr says why the direct read failed. A profile marked as overflow is always read with /usage, because only /usage shows a used-up spend limit. For any other account with usage credits turned on, such as example-org above, the session and weekly figures still come from the direct read, no claude is started, and the row ends in spend:not_probed (the SPEND column with --table). To read the spend limit too, add --spend:

amplihack profile usage --spend example-org

That runs one /usage probe per such account, only to fill its spend status. /usage can take 10 to 20 seconds per profile on a busy host, so --spend makes the command slower; each probe gets the same 120-second deadline as a fallback, and one that does not answer by then shows unknown. Checking does not appear to use quota, and an exhausted account still answers. A profile at its session limit shows its weekly figure as reported (55% for team above).

Reading the bar view

Each row shows the all-models week (WEEK) and the current session (SESSION) as a bar of 10 cells and a percentage, and when each resets (W-RESET, S-RESET). Reset times are in your local time zone, as MM-DD HH:MM, and the times: line names the zone. * marks the default profile, and (live) after a name marks the profile whose login is in ~/.claude.

The rows are sorted by the rotator's headroom, as the order: line says: the most room in the worse of the session and the week first, then by name. A profile with no session limit is ranked by its week. Exhausted profiles follow, soonest back first, then API-key profiles, then the profiles that could not be read. Only the headroom rule is applied: overflow profiles and profiles on the exclude list are sorted like any other, so the first row is not always the login the rotator would pick next. The full rule is in the reference.

Percentages in the bar view are whole numbers, rounded down; --table and --json show one decimal place where there is one.

In a terminal, the bars are green below 70%, yellow from 70% and red from 90%. To turn colour off, set NO_COLOR:

NO_COLOR=1 amplihack profile usage

Piped output is never coloured, so amplihack profile usage | less and amplihack profile usage > usage.txt contain plain text.

To read reset times in UTC, for example to compare them with the rotate log, use --utc. The cells then read MM-DD HH:MMZ:

amplihack profile usage --utc

To see the older table, with Claude's own reset text for a profile read with /usage (Oct 16, 4:50pm (America/Los_Angeles)), use --table:

amplihack profile usage --table

--utc applies only to the bar view, so --utc --table and --utc --json are refused, as is --table --json.

Selected profiles, states and scripts

What the spend status means. The bar view shows it as a spend:<value> mark when it is not n/a; --table shows it in its SPEND column:

Spend Meaning
n/a No spend limit was read for this row, and none was needed: usage credits are off, or the row came from a stored reading or is an API-key profile. It does not prove that credits are off.
ok /usage gave a usage reading and reported no used-up spend limit.
limit_reached The account's spend limit is used up. It cannot work past its plan limits on credits until the limit is raised or resets.
unknown A probe ran and the spend limit could not be read: a --spend probe did not answer in time or claude could not be found, claude did not give a usage reading, the profile is not signed in (as for scratch), or the row could not be read at all.
not_probed Usage credits are on and no spend probe was asked for: run with --spend to read it. Says nothing about the spend limit.

To check only some profiles, name them:

amplihack profile usage work team

What the STATE column means:

State What to do
ok Ready to use.
session_exhausted / weekly_exhausted Wait for the reset shown, or use another profile.
spend_limit Your organisation's spend limit was reached.
api_key An API-key profile, billed per token; its row reads api-key (billed per token) instead of bars and nothing is probed. Nothing to fix. See API-key profiles and usage limits.
not_logged_in amplihack profile login <name>. A row that reads not signed in (<reason>) was found without starting claude; see Logins with no token.
timeout The claude fallback did not answer in time (120 seconds by default, for the get_usage request and any /usage fallback together). The usage is unknown, not exhausted. Try again, or see Probes on a busy host.
unparsed Claude printed something unexpected. Run with --raw to see it.
error The probe could not run (the profile directory was refused, claude was needed but could not be found, started, read or waited for, or a direct read failed under AMPLIHACK_PROFILE_USAGE_PROBE=direct); the reason is printed on stderr.

Claude's own text is shown only when you ask for it, for example to report output amplihack does not recognise:

amplihack profile usage --raw spare

--raw output can include your e-mail address, organisation name or subscription type. Read it before you share it. For a (fallback) row it shows everything claude printed in the attempt that gave the row: for a get_usage answer, every JSON line, starting with the one claude prints when it starts; for /usage, the text. Other rows print (direct: no claude output) or (passive: no claude output); a not signed in row prints nothing. With --raw, a row whose direct read failed also prints why on stderr, for example note: profile "spare": direct read gave http 5xx; using claude; without --raw that line is not printed.

To see how each row was read, use the source key of --json:

amplihack profile usage --json | jq -r '.[] | "\(.profile) \(.source)"'
review direct
work passive
example-org direct
team direct
scratch direct

For scripts, use --json. This picks the profile with the most capacity:

amplihack profile usage --json | jq -r '[.[] | select(.state == "ok")][0].profile'
review

Each JSON row also has the per-model week lines (week_models), each reset as Unix time (resets_at) and the spend status as spend; see the reference.

If auto-switch is set up, profile usage also refreshes its readings, so it can choose accounts using numbers taken now instead of the last status-line update. While auto-switch has state (<root>/.auto-switch.d/), the output also shows where logins are: leased→work on a profile whose login is lent to work's session, and hosts:personal on the profile holding it. The numbers on a hosts: row belong to the hosted account. See Refreshing auto-switch readings for when a reading is not recorded.

A profile marked as credit-backed overflow (amplihack profile overflow add <name>) shows the mark overflow, and overflow, blocked until <time> after the rotator has blocked it on a spend limit. When its login is the one in ~/.claude and its probe shows the session or all-models weekly limit reached, the rows are followed by running on overflow: <name>. In --json, every row has overflow and overflow_blocked_until. See Use usage credits when every plan login is exhausted.

Below the bars, a six-line summary gives the weekly headroom across all logins, how many can take work now, the next session reset and how long the weekly capacity lasts at the recent rate; see See how much capacity is left. --summary-json prints the rows and that summary as one JSON object.

See your Codex accounts in the same view

With no profile names, profile usage also asks each Codex account under ~/.codex-profiles (or CODEX_PROFILES_ROOT) for its rate limits, live, and lists it after the Claude output. ~/.codex is included when it is signed in. Each row shows the five-hour and weekly use with their resets, any credit balance, the plan and the time of the reading, and <- next marks the account codex-pick's rule picks from these live readings (codex-pick itself reads session files, which can be older, so the two can disagree):

Codex accounts under /home/you/.codex-profiles
login-af  signed in      5h █░░░░░░░░░  12% 11-06 21:40 in 2h 31m  7d ████░░░░░░  41% 11-12 08:00 in 132h 51m  plan plus  read 19:09:00
login-ag  signed in      7d ███░░░░░░░  34% 11-10 14:30 in 91h 21m  plan pro  read 19:09:00  <- next
mjones    not signed in  read 19:09:00

The Codex block is printed last. The Claude rows and the capacity summary appear as soon as the Claude profiles are read, without waiting for a slow Codex account; the Codex block follows once every account has answered or timed out. The accounts are read at once, each with a 20-second limit (AMPLIHACK_CODEX_USAGE_TIMEOUT_SECS); one that does not answer shows timed out, never an older figure. amplihack does not open auth.json; Codex reads its own login. --json stays the array of Claude rows and does not read Codex; the Codex rows are under codex in --summary-json:

amplihack profile usage --summary-json | jq -r '.codex[] | select(.next_choice) | .account'
login-ag

See Codex accounts for the states, the choice rule and every JSON key.

The command exits with status 0 whenever the probes ran, whatever their states. Like profile run, it is refused under Docker.

See why an account counts as having usage credits on

If a row without the (fallback) mark shows a spend: mark (with --table, a SPEND value other than n/a), amplihack found usage credits on for that account. If you did not expect that, run the profile with --raw (here with --spend as well):

amplihack profile usage --raw --spend example-org

Two note: lines on stderr describe what the usage endpoint sent in its extra_usage field:

note: profile "example-org": direct read gave usage credits on; windows direct, spend from claude
note: profile "example-org": extra_usage: object; keys: currency, is_enabled, monthly_limit, org_id, used_credits; is_enabled: bool true

The second line lists the key names and shows is_enabled with its JSON type. is_enabled: bool true means credits are on. is_enabled: string "false" or is_enabled: number 0 means the server sent a string or a number where amplihack expects false, and amplihack treats that as on. Credits count as off only when extra_usage is absent, null, or an object whose is_enabled is the JSON value false; no shape line is printed then.

The line never contains an e-mail address, an account or organisation identifier, a currency or an amount: only key names, types, and bool or null values. Key names come from Anthropic's server and have every character other than letters, digits, _, . and - replaced by ?. Read the line before you share it all the same, since a key name could look like an identifier. If the first line ends spend probe failed, the --spend probe ran but did not finish in time or gave no usage reading, and the spend status is unknown. If it ends spend not probed, no /usage probe was asked for: the run had no --spend, or AMPLIHACK_PROFILE_USAGE_PROBE=direct was set. Then the spend status is not_probed. See Usage credits on for every form the line can take.

Probes on a busy host

Passive and direct reads cost almost nothing. The claude fallback does: the /usage attempt reads every transcript the profile can see, which can take a minute or more of CPU on a busy host. So amplihack gives each fallback 120 seconds, for the get_usage request and any /usage attempt together, and runs between 2 and 4 of them at once, fewer when the host's load average is close to its number of CPUs. Direct reads run up to 8 at once.

A profile in state timeout or error shows - for its percentages, and --json gives null for session and week_all. Its usage is unknown, never 100%, and it is not recorded for auto-switch. Check which profiles timed out:

amplihack profile usage --json | jq -r '.[] | select(.state == "timeout") | .profile'
spare

If fallbacks keep timing out, give them longer, run fewer at once, or both:

AMPLIHACK_PROFILE_USAGE_TIMEOUT_SECS=300 AMPLIHACK_PROFILE_USAGE_PARALLEL=1 amplihack profile usage

AMPLIHACK_PROFILE_USAGE_TIMEOUT_SECS takes 1 to 600 seconds and AMPLIHACK_PROFILE_USAGE_PARALLEL takes 1 to 16. An invalid value prints one warning and the default is used.

To read every profile afresh, ignoring stored readings, set the passive age to 0:

AMPLIHACK_PROFILE_USAGE_PASSIVE_MAX_AGE_SECS=0 amplihack profile usage

To make sure no claude process is started for a reading, use direct. A profile whose direct read fails then reads error, with the reason on stderr, instead of falling back; a profile with no login reads not_logged_in, as it does without the variable. A profile marked as overflow can only be read with /usage, so under direct it reads error with direct read: overflow needs /usage:

AMPLIHACK_PROFILE_USAGE_PROBE=direct amplihack profile usage
warning: profile "spare": direct read: http 5xx

The rotator uses the same variables. The limits, the formula, the direct-read bound (AMPLIHACK_PROFILE_USAGE_DIRECT_PARALLEL) and the endpoint overrides are in the reference.

Compare the two probe methods

The direct read and get_usage read the same figures by different routes. To check that they agree for your logins, run the default order and the claude-only text method one after the other and compare the percentages. /usage prints whole percentages and the direct read can send decimals, so this rounds both to whole numbers before comparing:

q='def whole: if type == "number" then round else . end;
  .[] | {profile, state, session: (.session.used_percentage | whole), week: (.week_all.used_percentage | whole)}'
AMPLIHACK_PROFILE_USAGE_PROBE=text amplihack profile usage --json | jq -c "$q" | sort > ~/usage-text.jsonl
AMPLIHACK_PROFILE_USAGE_PASSIVE_MAX_AGE_SECS=0 amplihack profile usage --json | jq -c "$q" | sort > ~/usage-direct.jsonl
diff ~/usage-text.jsonl ~/usage-direct.jsonl && echo same
same

The second command turns passive readings off, so that every row is read now rather than taken from the readings the first command recorded. Run the two one after the other, not at once, so they do not compete for the host. A percentage can still move between the two runs if a session is working, and a difference of one point can still be rounding, for example 20.5 from a direct read against 20% from /usage. Resets are not compared: they differ in form, an ISO 8601 time against Claude's own words from /usage.

If the figures disagree, or direct reads stop working after a change on Anthropic's side, go back to asking claude:

export AMPLIHACK_PROFILE_USAGE_PROBE=auto

AMPLIHACK_PROFILE_USAGE_PROBE takes direct, auto or text, exactly as written; unset means passive, direct, then claude. auto is the get_usage request with the /usage fallback, and text is /usage alone. Any other value prints a warning and uses the default order. With auto or text, every profile starts claude, so on a busy host also see Probes on a busy host. A running rotator keeps the value it started with; restart it as described in When the host is heavily loaded.

A profile shows live in ~/.claude

If you use a login rotator that moves one account's login into the default ~/.claude directory, such as amplihack profile rotate, that profile's own directory has no login while it is there. profile usage checks that account through ~/.claude instead and marks the row with (live) after the name:

PROFILE      WEEK             W-RESET      SESSION           S-RESET     STATE
team (live)  █████░░░░░  55%  10-22 02:00  ████░░░░░░  40%   10-16 20:00 ok
times: America/Los_Angeles
order: rotator pick (most room in the worse of session and week, then name)

--table shows the same mark as live in ~/.claude in its MARKS column.

The numbers on that row are the account's real usage, and the row is not not_logged_in. In the JSON the row has "live_in": "~/.claude"; every other row has null:

amplihack profile usage --json | jq -r '.[] | select(.live_in != null) | .profile'
team

amplihack finds the profile from a rotator's ledger: <root>/.auto-switch.d/rotate/ledger.json for profile rotate, or <root>/.rotator/ledger.json for an external rotator such as the tmux prototype. If both exist, the one updated more recently decides, so moving from one rotator to the other needs no clean-up. Without a ledger it looks for the one profile with no login whose account matches the account in ~/.claude.json; if you do not use a rotator, there is no ledger and nothing is printed. profile usage only reads the rotators' files and never changes them.

This needs Linux. On macOS Claude keeps the login in the Keychain rather than in ~/.claude/.credentials.json, so no profile is ever shown as live in ~/.claude; on Windows the mark is never shown either.

The live profile's check runs with CLAUDE_CONFIG_DIR unset rather than set to ~/.claude. With the variable set, claude would look for ~/.claude/.claude.json instead of the real ~/.claude.json and could read the wrong account.

When the evidence about which profile is live is unreliable or conflicting, amplihack marks none and prints one warning line, for example:

warning: the login rotator's ledger names a profile that still has its own login; it is not marked live in ~/.claude

That one means the ledger is out of date: the named profile still has its own login, so amplihack checks it through its own directory. The other warnings are listed in Warnings about ~/.claude.

live in ~/.claude is not the same as *: * is the profile amplihack claude uses by default.

If the rotator swaps logins while the check runs, the row's numbers may belong to the new login. amplihack says so on stderr and does not record them for auto-switch. Run the command again for current numbers. This check cannot see a profile that became live after the command started, or a swap away and back again when the ledger has no since time. See Logins in ~/.claude for the exact rules and warnings.

Accounts, organizations and duplicate logins

Which logins count as the same account

One Claude user can belong to several organizations, for example a team organization and a personal one. Each organization has its own subscription and its own usage limits, so a profile per organization is a normal setup.

amplihack reads two values from the oauthAccount block of each .claude.json: accountUuid (the user) and organizationUuid (the organization). Two logins are the same account only when both match:

Login A Login B Same account?
user U, org O1 user U, org O1 yes
user U, org O1 user U, org O2 no
user U, org O1 user U, no org no
user U, no org user U, no org yes
different users (any) no
no user on either side — compared by e-mail address, ignoring case

A missing value never makes two logins look the same. This one rule is used by profile login, profile usage, auto-switch status, auto-switch swaps and the rotator. No credentials file is read to decide it, and the values are never printed.

For example, profiles login-aw and login-ax share a user but have different organizations. They are two accounts, and no command warns about them.

Duplicate logins

Claude's login opens claude.ai in your browser and signs in whichever account the browser is already signed in to. If that account is already in another profile, you get two profiles with the same login.

amplihack profile login checks for this after Claude exits. It compares the new login with every other profile and with the login in ~/.claude. If it matches one, the login is refused:

amplihack profile login login-au
note: holding the previous login of profile 'login-au' in /home/you/.amplihack/claude-profiles/.rejected-logins/.pending-login-au-20261020T171502Z while you log in
...interactive claude session...
note: moving the new login of profile 'login-au' to /home/you/.amplihack/claude-profiles/.rejected-logins/login-au-20261020T171502Z
error: profile 'login-au' was signed in to the same account and organization as profile 'login-ay'. The new login was moved to /home/you/.amplihack/claude-profiles/.rejected-logins/login-au-20261020T171502Z; 'login-au' is back to its previous login.
hint: sign out of claude.ai in your browser (or use a private/incognito window), then run 'amplihack profile login login-au' again.

The command exits with status 1. The profile has the login it had before (or no login, if it had none), and its oauthAccount block is restored. Other .claude.json keys Claude changed during the login stay as Claude left them. The refused login is moved, not deleted.

To fix it, sign out of claude.ai in the browser, or open a private window, and run amplihack profile login login-au again. Sign in to the account this profile is meant for.

If the account is the one in ~/.claude, the holder is named ~/.claude (rotator live profile 'team') when the rotator's live profile is known, otherwise just ~/.claude.

The rotator's live profile cannot be logged in to at all: its login is the one in ~/.claude, and the rotator refuses to swap it back into a profile directory that has a login of its own. login refuses before Claude starts and moves nothing:

error: profile 'team' is the rotator's live profile; its login is ~/.claude. Nothing was moved.
hint: log in with plain 'claude', or stop the rotator first.

When the login is accepted and the profile had a previous login, that login is kept too:

note: the previous login of profile 'work' was moved to /home/you/.amplihack/claude-profiles/.rejected-logins/work-20261020T171502Z-replaced

If Claude exits with an error, or you press Ctrl-C, the previous login is put back, Claude's exit status is kept, and no check is made. A login Claude wrote anyway goes to .rejected-logins/ like a refused one.

What is in .rejected-logins

<root>/.rejected-logins/                         0700
├── .pending-<name>-<time>/                       the previous login and oauthAccount.json while Claude runs
├── <name>-<time>/                                a refused login
│   ├── .credentials.json                         0600, moved, not copied
│   └── oauthAccount.json                         its oauthAccount block, 0600
└── <name>-<time>-replaced/                       a previous login replaced by an accepted one

<time> is UTC, for example 20261020T171502Z. amplihack never deletes anything here. Each login file is in one place only: the profile directory or one of these directories. To use a kept login again, move it back with mv -n into a profile that has no .credentials.json, never cp.

If amplihack itself is killed while Claude runs, the previous login stays in the .pending-… directory, which is printed at the start whenever there was a login file or an oauthAccount block to hold. Ctrl-C is handled, but closing the terminal (SIGHUP) or kill (SIGTERM) ends amplihack before it can restore anything. The previous login is then at <root>/.rejected-logins/.pending-<name>-<time>/.credentials.json, and its oauthAccount block is next to it in oauthAccount.json. If Claude wrote a new login, move that one aside first (or delete it if you do not want it), then move the previous one back into the profile directory with one mv. amplihack also removed the oauthAccount key from the profile's .claude.json before Claude started. If Claude did not write a new one, set that key back to the contents of oauthAccount.json, or the profile names no account until its next login. This example uses the default root; if you chose another root (amplihack profile root prints it), use that path instead:

mv -n ~/.amplihack/claude-profiles/.rejected-logins/.pending-login-au-20261020T171502Z/.credentials.json \
      ~/.amplihack/claude-profiles/login-au/

When the check cannot move the login

  • macOS. Claude keeps the login in the Keychain, not in .credentials.json, and writes only the oauthAccount block in .claude.json. amplihack removes that block before Claude starts, so a block that names an account afterwards is the new login. An empty or malformed block does not count. The new login is checked like a file login:
  • not a duplicate: the login is accepted, a previous .credentials.json moves to <name>-<time>-replaced/, and the account is recorded;
  • a duplicate, with a previous .credentials.json: the previous login and its oauthAccount block are put back and login exits 1:

    error: profile 'work' is signed in to the same account and organization as profile 'personal'; Claude wrote no login file. The previous login file and oauthAccount of 'work' were put back, but the macOS Keychain may still hold the refused account, and Claude may use it until 'work' is logged in again
    
  • a duplicate, with no previous login file: the refusal is printed and login exits 1, but the block is left as Claude wrote it, so .claude.json still matches the login in the Keychain.

A refused login stays in the Keychain. Sign out in the browser and log in again. - No login after a previous one. If the profile had a .credentials.json and Claude exits 0 without writing a new one or a new oauthAccount block, the login did not finish: the previous login and its oauthAccount block are both put back, and login exits 1. - The profiles cannot be read. If the profile root cannot be listed or the auto-switch state cannot be opened, the new login cannot be compared, so it is treated like a refused one: moved to .rejected-logins/, the previous login put back, exit 1. - The rotator swapped the profile in during the login. profile rotate takes no lease. If it made this profile the live one while Claude ran, amplihack stops without moving anything and prints where each login is, and the .pending-… directory that holds the profile's earlier oauthAccount block, even when the profile had no login file. - A login file that is not private. If the new .credentials.json is not a private regular file (for example mode 0644, or a symlink), amplihack does not move it or change its mode. It exits 1, reports the mode, and leaves the previous login in the .pending-… directory, whose path the hint prints. Treat the new login as exposed: log in again. - A session started using the profile during the login. If auto-switch lent the profile's login to a session or the profile now hosts another account, amplihack stops without moving anything and prints where each login is, and the .pending-… directory that holds the earlier oauthAccount block.

/login inside a running session

Running /login inside a Claude session is not checked when it happens. amplihack profile usage and amplihack profile auto-switch status find the duplicate afterwards:

note: profiles 'login-au' and 'login-ay' are signed in to the same account and organization (duplicate login); fix: run 'amplihack profile login login-au' with the browser signed out of claude.ai or in a private window.

Profile names are listed in sorted order. The fix names the profile whose login is not the account recorded for it. amplihack records a profile's account when profile login accepts a login, and in some rotator swaps; see Recorded account. Here login-au was recorded with another account, so it is the one to log in again.

When neither profile has a record, both match their records, or both differ, amplihack cannot tell which login is wrong and says so:

note: profiles 'login-au' and 'login-ay' are signed in to the same account and organization (duplicate login); amplihack cannot tell which of them holds the wrong login; fix: run 'amplihack profile login <name>' for the one that should hold a different account, with the browser signed out of claude.ai or in a private window.

Decide which profile should hold another account, and log that one in again. The accepted login records its account, so the next warning, if any, names a profile.

status prints it as a note: line; usage prints the same text on stderr as a warning: line, after the rows. The login in ~/.claude takes part too, named ~/.claude. It is judged by the record of the rotator's live profile, since that is the account it should hold, and a profile that matches its own record is never named. When ~/.claude is the one off its record, the fix is a /login there rather than profile login:

note: profiles '~/.claude' and 'login-ab' are signed in to the same account and organization (duplicate login); the login in ~/.claude is not the account recorded for profile 'work'; fix: run plain 'claude' and '/login' to the account 'work' is meant for, with the browser signed out of claude.ai or in a private window.

The rotator refuses to swap in the same state, with the same reason. The rotator's live profile is not compared with ~/.claude, since that is where its own login is. See Duplicate-login warning for every form.

A profile can also hold the wrong login without forming a duplicate, for example when a Claude session started with CLAUDE_CONFIG_DIR pointing at that profile's folder signed in to another account. status and usage compare every profile that has a record with its record, the same user in another organization counting as another account, and print one line for each that differs:

warning: profile 'login-ab' holds a login that is not the account recorded for it; fix: run 'amplihack profile login login-ab' with the browser signed out of claude.ai or in a private window.

Switch accounts automatically

When one account is close to its five-hour or seven-day usage limit, auto-switch moves work onto another of your profiles that has quota left. It is off by default. Auto-switch acts on sessions started under a profile; to keep the default ~/.claude login used by plain claude on the account with the most capacity, use profile rotate, which shares this toggle. With it off, and before it has ever been turned on, amplihack behaves exactly as described in the rest of this guide.

Auto-switch does three things:

Where What happens
A running Claude session When the session's account reaches the threshold, the login in that session's configuration directory is swapped for the account with the most quota left. The session keeps running.
Nested launches (recipe agent steps, multitask/orch workstreams) A launch that would inherit an exhausted profile starts under a profile with quota left instead.
A recipe agent step that fails with a usage limit The step is run again under the next profile with quota left instead of ending the run.

amplihack learns how much quota each account has used from the status line Claude Code already computes, and from profile usage when you run it. Auto-switch sends no requests of its own, makes no network calls, and never reads, parses, copies or refreshes a token.

1. Install the usage meter

Claude Code versions that pass rate_limits to the status line give it the account's five_hour and seven_day usage. amplihack wraps your existing status line so it can record those numbers, then runs your original command and prints its output unchanged.

Install the wrapper into every profile. Run it with the same profile root your launches use:

export AMPLIHACK_CLAUDE_PROFILE_ROOT="$HOME/.claude-profiles"   # if your profiles live here
amplihack profile auto-switch install
root: /home/you/.claude-profiles
installed  personal (no previous status line)
unchanged  review
installed  work     (wrapped existing status line)

The command prints the root it acts on. If that root has no profiles, it warns that AMPLIHACK_CLAUDE_PROFILE_ROOT may be unset. Running it again changes nothing: every settings.json stays byte-identical. It covers every profile under the root, including ones you created before auto-switch existed, edits only each profile's own settings.json, and never touches ~/.claude. New profiles do not get the wrapper automatically: run install again after profile add. auto-switch on and status list any profile that is still missing it.

The wrapper calls amplihack by the absolute path of the binary that ran install. If you later move or reinstall amplihack, status shows those profiles as stale, and install reports them as stale without changing them. Fix them with repair:

amplihack profile auto-switch repair
root: /home/you/.claude-profiles
unchanged  personal
repaired   review   (wrapper pointed at a different binary)
unchanged  work
recovery: nothing to do

repair finishes any interrupted swap and returns logins whose session has ended (see Recovery), then does what install does and also rewrites wrappers that are stale, wrapped twice or edited by hand. The last lines say what recovery did, for example recovery: returned the login of personal hosted in work (session ended). install refuses a binary in a directory that other users can write to, and warns if the binary is inside a Cargo target/ directory.

2. Turn it on

amplihack profile auto-switch on
amplihack profile auto-switch status

The setting file is read again on every check, so turning it on or off takes effect in sessions that are already running, from their next status-line update. The exception is a session started with AMPLIHACK_CLAUDE_AUTO_SWITCH set: the variable overrides the file and cannot be changed once the session is running.

The default threshold is 90%: an account counts as exhausted when either its five-hour or its seven-day window is at or above it. To change it, or to stop some profiles from ever being chosen:

amplihack profile auto-switch threshold 80
amplihack profile auto-switch exclude review shared   # never switch *to* these
amplihack profile auto-switch exclude                 # clear the list
amplihack profile auto-switch on --threshold 85 --exclude review

An excluded profile is never chosen as a target, but a session running on it can still be switched away from it.

To force the setting for one shell, which takes precedence over the file:

export AMPLIHACK_CLAUDE_AUTO_SWITCH=0   # off in this shell, whatever the file says
export AMPLIHACK_CLAUDE_AUTO_SWITCH=1   # on in this shell

An empty value means unset. Any other value prints one warning, status notes it, and the file decides.

With auto-switch on, amplihack claude, amplihack launch and amplihack profile run also start the login rotator for ~/.claude if it is not running, and print one line when they do. To keep auto-switch without that, run amplihack profile rotate autostart off.

3. Check what it sees

amplihack profile auto-switch status
root: /home/you/.claude-profiles
switch: on (file)
autostart: on (default)
threshold: 90%
exclude: review
in-session swap: available (Linux)
profile    5h    7d    observed   login   wrapper
personal   12%   40%   1m ago     home    installed
review     -     -     never      home    installed
work       93%   61%   2m ago     home    installed
hosted directories: none
invariant: ok (every login is in exactly one place)

Notes follow the table when they apply, for example:

note: profiles without the wrapper: scratch — run: amplihack profile auto-switch install
note: excluded but missing: shared

While a session in work is using personal's login, work shows parked, personal shows live in work, and the line hosted: work holds the login of personal (swapped 3m ago) replaces hosted directories: none.

5h and 7d are the latest readings. A window whose reset time has passed is shown and treated as 0%. - means no reading yet: the wrapper records nothing while the switch is off, so readings start at the first status-line update after you turn it on. A profile with no reading is treated as having quota left, but is chosen only after every profile with a known reading.

status only reads. It never moves a login or finishes a swap, so looking at the state cannot change it. If a swap was interrupted or a session ended without returning its login, status says so and tells you to run amplihack profile auto-switch repair; the next launch or status-line update fixes it too.

Usage is tracked per profile. If two profiles are signed in to the same account and organization, status prints a duplicate-login note with the fix; see Duplicate logins. Two profiles for the same user in different organizations are separate accounts and get no note.

What happens inside a running session

After each Claude turn, the status-line wrapper records the reading, prints your status line, and then checks the session's account. If another amplihack process holds the state lock for more than 50 ms, the wrapper skips this turn's recording, recovery and check rather than slow your status line; the next turn tries again. If that account is at or above the threshold, the wrapper swaps the login in the session's configuration directory for the eligible account with the lowest usage (or one whose limit has reset). The session continues; Claude picks up the new login on its next request.

Each account's login lives in exactly one place at a time, because Claude rotates refresh tokens and a stored copy would go stale. A swap is therefore a move, never a copy:

  1. The live login, which Claude may have just refreshed, moves back to the account it belongs to.
  2. The chosen account's login moves into the session's directory.
  3. amplihack records which account is now live there and updates the account name Claude shows.

While a login is live in another profile's directory, that account is leased: launching or logging into its own profile directly is refused until the session ends:

error: profile "personal": its login is in use by a session in profile "work"
hint: wait for that session to end, or run `amplihack profile auto-switch status`

While a profile's directory is hosting another account's login, that profile cannot be launched directly either. From a second terminal, amplihack claude --profile work is refused until the session in work ends:

error: profile "work": its directory holds the login of profile "personal" for a running session
hint: wait for that session to end, or run `amplihack profile auto-switch status`

When the session ends, every login goes back to its own profile. A nested launch inside the session (a recipe step, a workstream) shares the session's directory and its current login; it does not trigger a lease refusal. It counts as nested only if it inherited the session's CLAUDE_CONFIG_DIR: exporting AMPLIHACK_CLAUDE_PROFILE=work in a new shell is not enough.

amplihack also updates oauthAccount in the session's .claude.json, the account name /status shows. Claude keeps that file in memory and rewrites it, so /status may keep showing the previous account until Claude next rewrites the file or the session restarts. The login itself has moved: .credentials.json decides which account is used, and the auto-switch status table is the source of truth.

In-session swaps only happen in sessions that show a status line, because the status line is the only place Claude reports usage. Non-interactive claude -p runs are covered by the next section instead.

What happens for nested launches and recipe steps

When the switch is on, a nested launch that inherits a profile whose account is exhausted starts under the eligible profile with the most quota left instead, and prints one line to stderr:

amplihack: profile "work" is at 93% of its five-hour limit; auto-switch is using profile "personal" for this launch

The candidate must hold its own login and must not be hosting another account. Nested launches never move logins. An explicit --profile and the default pointer are never redirected; only an inherited profile is. multitask workstreams make the same choice when their run.sh is written, and again when each nested launch starts.

When a recipe agent step (a nested amplihack claude -p …) fails with a usage limit, and the switch is on, the step is run again under the next eligible profile:

amplihack: profile "work" hit its usage limit; rerunning this step under profile "personal" (auto-switch)

A step counts as having hit its limit when it exits non-zero and the end of its output matches the same usage-limit check the recipe runner uses to end a run (usage limit, session limit, quota exceeded and the like). So a step the runner would stop for is always tried on another profile first. Output that also names a work or environment problem, such as a failed test or permission denied, is not treated as a usage limit and is not rerun. credit balance is too low and disk quota exceeded count as environment problems, so they are not rerun either. Each profile is tried at most once per step. When none is left, the step waits for the limit to reset and runs once more, as described in Waiting for a usage-limit reset. With that wait turned off, the last attempt's output and exit code are passed back, and the recipe run stops with the usual usage-limit message. With the switch off, the wait still applies; with both off, a usage limit ends the run as it did before either existed.

The rerun happens inside the step's own amplihack claude -p launch, not in the recipe runner, so only the failed step runs again; finished steps are not repeated.

While a step is supervised this way, its error output streams as usual but its standard output is held back and printed when the last attempt finishes. The recipe runner's heartbeat therefore reports such a step as idle until it ends; that is expected, and nothing is stopped because of it. A prompt that arrives on standard input is copied to a private file as it arrives, and every attempt reads that copy, so a rerun gets the same prompt as the first attempt. The first attempt is not delayed by the copy: it reads each block as the copier passes it on. Input from a terminal, and standard input of any kind on a launch whose prompt is already in its arguments, is passed through and not copied. The copy starts when the first attempt does, so a supervisor that cannot start at all leaves standard input untouched for the plain launch that follows. If standard input cannot be read to its end, the attempt has been handed less than the prompt that was sent, which it cannot tell from a whole one. amplihack says so on standard error and the step fails, rather than report that attempt's result as the step's. If the caller never closes the pipe, there is no whole copy to replay: amplihack refuses the rerun with a named reason and the step ends with the attempt's own result, rather than waiting on a pipe nobody closes. If the step is stopped (SIGINT, SIGTERM or SIGHUP), it is not rerun: the attempt's output is passed back and amplihack exits with 128 plus the signal number. A rerun starts the step from the beginning, so anything the failed attempt had already done (a push, a comment) may be done again.

When no account has capacity

When every account is at or above the threshold, auto-switch has nowhere to go and stops switching. amplihack then tells you instead of letting Claude go quiet:

  • Status line. A line is added below your usual status line:
⚠ all Claude accounts ≥90% · next reset Oct 22 2am

It reads at limit instead of ≥90% when every account has hit its hard limit. - Claude Code. At session start, or on the next prompt, Claude Code shows the same line followed by — run 'amplihack profile usage'. It is shown once per session for each state, and again if things get worse (from ≥90% to at limit). Claude is also told that capacity is low, so it prefers small sequential steps over large parallel workflows. - amplihack claude. One line on stderr when it starts:

⚠ all Claude accounts ≥90% · next reset Oct 22 2am — run 'amplihack profile usage'
  • amplihack recipe run. One line on stderr before the recipe starts. The recipe still runs; you may know an account is about to reset.
amplihack recipe run: ⚠ all Claude accounts at limit · next reset Oct 22 2am — run 'amplihack profile usage' (continuing anyway)

The reset time is the earliest one across your accounts, in local time. To see every account's numbers:

amplihack profile usage

The notice clears by itself when the first account's window resets. If no reset time is known, it clears 5 hours after it was last confirmed. A profile in the exclusion list does not count, and a profile with no reading yet counts as having capacity, so it never causes a notice.

The state is worked out from readings amplihack already has: the status-line wrapper, amplihack profile usage and the rotator each update it when they record usage. It is kept in <root>/.auto-switch.d/capacity.json, which holds profile names and times, never logins. Nothing is shown, and nothing is written, while auto-switch is off. The file format and exact rules are in the capacity notice reference.

Turn it off

amplihack profile auto-switch off

off keeps your threshold and exclusions. It stops new swaps, substitutions and reruns immediately, including in running sessions, but it does not pull a login out of a session that is running: those logins go back to their own profiles when the session ends. Until then the lease refusals above still apply.

To stop using a version of amplihack that has auto-switch, for example to downgrade:

  1. amplihack profile auto-switch off
  2. End every Claude session started under a profile.
  3. Run amplihack profile auto-switch repair, then amplihack profile auto-switch status, and check that it shows hosted directories: none and invariant: ok.

An older amplihack does not know about parked logins and could launch a profile whose login is elsewhere.

Recovery

amplihack recovers on its own after a crash or a killed session. Every launch, profile login, status-line update and auto-switch repair first finishes or rolls back any interrupted swap, then returns every login whose session has ended. This happens even with the switch off, so turning it off never strands a login. auto-switch status only reports what needs doing.

To recover now rather than at the next launch:

amplihack profile auto-switch repair

If the state files are damaged in a way it cannot interpret, it moves nothing and refuses launches and logins for the profiles involved:

error: auto-switch state is inconsistent: .auto-switch.d/journal.json: unknown version or invalid name
hint: see the Recovery section of docs/howto/claude-profiles.md

To repair it by hand:

  1. End every Claude session started under a profile.
  2. Find each login. Every account's .credentials.json is in exactly one of two places: <root>/<name>/.credentials.json, or <root>/.auto-switch.d/parked/<name>/.credentials.json.
    ls -l "$AMPLIHACK_CLAUDE_PROFILE_ROOT"/*/.credentials.json \
          "$AMPLIHACK_CLAUDE_PROFILE_ROOT"/.auto-switch.d/parked/*/.credentials.json
    
  3. Use <root>/.auto-switch.d/ledger.json to see which account is in which directory. Move each login home with mv -n; never copy it.
  4. Delete ledger.json and journal.json, then run amplihack profile auto-switch repair and amplihack profile auto-switch status, and check that status reports invariant: ok.

After a hand repair, /status may show the wrong account name for a profile until its next launch or amplihack profile login <name>, because the name is kept in .claude.json separately from the login.

If you cannot tell which account a file belongs to, run amplihack profile login <name> for that profile and sign in again.

Check it with two real accounts

The in-session swap relies on two things Claude Code is expected to do, which have not yet been confirmed by a live test: Claude reloads .credentials.json when its modification time changes, and it re-reads the file after taking its own refresh lock (.oauth_refresh.lock). Before relying on in-session swaps, check them once:

  1. Set up two profiles with different logins, run install, and turn the switch on with a low threshold, for example threshold 1.
  2. Start amplihack claude --profile work and send one prompt.
  3. After the reply, auto-switch status shows personal as live in work.
  4. Send another prompt. It succeeds, and /status (after a restart, if needed) names the personal account.
  5. Leave the session idle for more than an hour so Claude refreshes the token, then send another prompt. It still succeeds.
  6. Exit. status shows hosted directories: none, and amplihack profile run personal and amplihack profile run work both work without logging in again.

If any step fails, turn the switch off. Nested substitution and step reruns do not depend on these two behaviours.

Limits of auto-switch

  • In-session swaps need Linux. A session is detected as running by looking for its CLAUDE_CONFIG_DIR in /proc. Without /proc, or when amplihack cannot read /proc/self/environ (for example with hidepid), swaps are disabled and status says so; nested substitution and step reruns still work.
  • A credentials file is required. Logins kept in the macOS Keychain, or profiles without .credentials.json, are never swapped; status notes it.
  • Unix only. On Windows auto-switch on is refused and nothing else happens.
  • Interactive sessions only, for in-session swaps. The trigger is the status line. claude -p runs rely on nested substitution and step reruns.
  • /logout inside a swapped session deletes the borrowed login. The owning profile has to log in again.
  • Helper processes keep a session alive. A login returns home only when no process (including MCP servers Claude started) still has the directory in its environment.
  • Two profiles signed in to the same account and organization are not supported. An account is identified by the profile that owns its login, so they are treated as two accounts with separate readings; status warns about it. See Duplicate logins.
  • /status can lag. It may name the previous account after a swap until Claude rewrites .claude.json; see above.
  • Leases protect against accidents, not attacks. Any process running as you, and root, can read or move these files.
  • Profiles do not isolate accounts from each other. Any process running as you, including an agent following injected instructions, can feed the status-line wrapper a fake usage reading and so pull another profile's login into its session. It could already read that login file directly, so this adds no new exposure.
  • Held-back step output and input are kept on disk briefly. A supervised step's standard output, and its piped standard input, are in private files under <root>/.auto-switch.d/rerun/ until the step finishes. If amplihack is killed first, the next recovery deletes them once that process is gone, and after 24 hours at the latest.
  • A rerun repeats the step. Anything the failed attempt already did may happen twice.
  • File modes are kept. Patching .claude.json or settings.json keeps the file's mode; a settings.json that install creates is 0600.
  • The capacity notice can lag by one reading. It is updated only when the status line, profile usage or the rotator records usage. A step that fails with a usage limit and finds no profile left to rerun on does not update it.
  • Overflow profiles come last and cost money. A profile marked with amplihack profile overflow add is chosen only when no plan profile has capacity (below the rotator's --session-at and --week-at, 85% and 90% by default) and the earliest plan reset is more than the overflow wait away (default 1800 seconds). This is the rule the rotator follows, with the running rotator's own settings. A session or nested launch on an overflow profile moves back to a plan profile as soon as one has capacity. See Auto-switch and overflow profiles.
  • Readings come only from sessions with the wrapper and from profile usage. A profile that has done neither since the switch was turned on has no reading. Run amplihack profile usage to fill them in.

API-key profiles and usage limits

An API-key profile runs Claude Code on a Claude Platform API key instead of a subscription login. It has no session or weekly limit; every token it uses is billed per token. Its login file, .credentials.json, holds {} (an object with no OAuth login), and Claude Code falls back to the Platform credential stored outside the profile directory, in the real home directory. Every profile on the machine shares that credential, so there is one API-key account per home directory. amplihack never reads, prints or copies the key; it decides a profile's kind from key names and file presence only.

A profile with no login file at all is not an API-key profile. It is a subscription profile with no login, and launching it is refused (see below). A missing login file counts as an API key only when the profile names an API-key setting (ANTHROPIC_API_KEY, apiKeyHelper or primaryApiKey); those settings are ignored when the profile has a login file. The full rules are in Kind detection.

amplihack profile kind list shows each profile's kind and why:

$ amplihack profile kind list
api-key   api-key       (detected: login file has no oauth login)
login-av  subscription  (detected: oauth login)
login-ay  subscription  (detected: oauth login)

amplihack profile kind set <name> <subscription|api-key|auto> overrides a wrong detection; auto removes the override. See Kind override.

Allow the API-key profile to be used

An API-key profile is never used automatically until you mark it. Marking is your consent to per-token billing:

$ amplihack profile overflow add api-key
overflow: added api-key (api-key tier, tier 10)
note: api-key is billed per token; it is used only when every plan login is measured and none is below 100% on both windows, no credit profile can be used, the earliest plan reset is more than --overflow-wait away and its login check passes.

overflow list shows whether it is marked:

$ amplihack profile overflow list
login-aw  tier 1  marked
api-key  api-key tier  not marked (not used)

After overflow add api-key the last line reads api-key api-key tier marked. An API-key profile is always tier 10, the last tier, so --tier is refused for it. To stop using it, run amplihack profile overflow remove api-key, which prints overflow: removed api-key.

Before each move onto the API-key profile, the rotator and auto-switch run a login check. It passes when the profile names a key: a non-empty primaryApiKey in the profile's .claude.json, or a non-empty ANTHROPIC_API_KEY under env or apiKeyHelper in its settings.json. A .credentials.json with no OAuth login, {} included, is not enough on its own. The check reads those files only. It makes no request and does not run the helper, so it confirms that a key is configured, not that it works: a revoked or unfunded key still passes. If the check fails, nothing moves, ~/.claude is unchanged and the rotator writes:

key_check_refused api-key: no primaryApiKey, ANTHROPIC_API_KEY or apiKeyHelper setting
ALERT: API key profile api-key failed its login check (no primaryApiKey, ANTHROPIC_API_KEY or apiKeyHelper setting); not moving onto it

The ALERT is written once, not on every cycle.

A key in ~/.claude.json or ~/.claude/settings.json is different: Claude uses it ahead of a plan login, so every session on the host bills per token, marked or not. overflow add warns about it and the rotator logs ALERT: home_key. See API-key login check.

If you upgraded from a release that used API-key profiles without a mark, run amplihack profile overflow add <api-key-profile> to keep that behaviour. Nothing is marked for you. If an unmarked API-key profile is live in ~/.claude at the upgrade, it stays live, billed per token, until a plan login has capacity or is a plan-room target (room below 100% on both windows, week at or below --target-week-max), or a credit profile can take over; rotate status shows it as platform_not_marked meanwhile. To avoid that, mark it or move off it by hand with amplihack profile switch <plan-profile>.

How limits are handled with an API-key profile

When accounts run out of quota, work moves in this order:

  1. another plan (subscription) login with capacity;
  2. another plan login that is past a threshold but still below 100% on both windows, with its week at or below --target-week-max, ranked by the plan-room swap: a login below --session-at first, then the most room;
  3. only when no measured plan login is below 100% on both windows: a marked credit overflow profile, by tier, once the earliest plan reset is further away than the overflow wait;
  4. the marked API-key profile (tier 10), once every plan login is measured, no credit overflow profile can be used, the earliest plan reset is still further away than the wait and its login check passes.

Credit profiles are billed too, so they wait until no measured plan login has room. Only the API key also waits for a plan login that could not be measured (a session on it, or a failed probe), with an ALERT that names it. Earlier releases used them as soon as every plan login had reached its threshold.

Auto-switch and the rotator follow the same order. The rotator moves ~/.claude off the API key on the first cycle after a plan login has capacity, or is a plan-room target again (room below 100% on both windows, week at or below --target-week-max), without waiting for a hold to end. Auto-switch uses the API-key profile only for a new nested launch or a usage-limit rerun and never swaps it into a running session; a session started on the API-key profile keeps it, and its next nested launch or rerun goes back to a plan profile.

profile usage does not probe an API-key profile. Its STATE is api_key and its row reads api-key (billed per token) instead of bars:

$ amplihack profile usage api-key
PROFILE         WEEK             W-RESET      SESSION           S-RESET     STATE
api-key (live)  api-key (billed per token)                                  api_key
live: work is running on the API key (billed per token)
times: Europe/London
order: rotator pick (most room in the worse of session and week, then name)

If the key runs out of funds or is revoked, every API-key profile is blocked with one ALERT until you clear the block. A rate limit blocks it until the time the error gives, or for one hour. While blocked, usage prints blocked: the API key until <time> (<reason>). Fund or replace the key, then clear the block:

$ amplihack profile overflow clear --platform
overflow: cleared the API-key block (key_exhausted)

Subscription profiles with no login are refused

A subscription profile with no OAuth login of its own (never logged in, its login file missing or damaged) would quietly use the API key if launched. profile run, --profile launches and profile switch refuse it, exit 1 and say what to run:

error: profile old-team is a subscription profile with no login of its own; launching it would bill the Claude Platform API key per token. Run 'amplihack profile login old-team', or run 'amplihack profile kind set old-team api-key' if per-token billing is intended.
hint: amplihack profile login <name>, or: amplihack profile kind set <name> api-key

A profile whose login is live in ~/.claude, or lent to a session by auto-switch, is not refused.

Profiles signed in through the macOS Keychain

On macOS, Claude Code keeps a profile's login in the login Keychain and writes no .credentials.json. amplihack recognises such a profile when its .claude.json has an oauthAccount block and the Keychain holds an item for the profile's directory (service Claude Code-credentials-<h>, with <h> the first eight hex digits of the SHA-256 of the directory path in Unicode Normalization Form C, as Claude Code computes it). It only asks whether the item exists; it never reads the secret, and it waits for the answer with no time limit of its own.

$ amplihack profile kind list
work            subscription  (detected: oauth login in the macOS Keychain)

Such a profile launches normally. If the Keychain is locked or cannot be reached, the launch is refused with a different message, and the profile is not treated as an API-key profile:

error: profile work has no login file and the macOS Keychain could not be read (`security` exit status 51); launching it could bill the Claude Platform API key per token. Unlock the login Keychain and run again, or run 'amplihack profile kind set work api-key' if per-token billing is intended.
hint: unlock the login Keychain and run again, or: amplihack profile kind set <name> api-key

Unlock the login Keychain (for example with Keychain Access) and run the command again. Run kind set <name> api-key only if per-token billing is intended. If the profile has no oauthAccount in .claude.json, run amplihack profile login <name> to sign in again. See Keychain logins for the exact rules and their limits.

While the Keychain cannot be read, auto-switch passes the profile over and the capacity file does not count it as overflow. Each place that does so names the Keychain, never a missing login: profile auto-switch status shows keychain unreadable, profile overflow add warns that the Keychain could not be read, and profile usage and the rotate log carry a line that starts auto-switch: profile <name> was passed over. See where an unreadable Keychain is reported.

If every Keychain profile is refused as having no login of its own after a Claude Code upgrade, check the service name first: Claude Code chooses it and may have changed it. The limits give the two commands that test it.

Logging an API-key profile in to a subscription

amplihack profile login api-key works as for any profile and first prints:

note: this profile uses a Claude Platform credential stored outside the profile directory, which amplihack does not manage.

If you complete a subscription login there, the profile has an OAuth login and is detected as a subscription profile from then on, unless a kind override says otherwise.

Waiting for a usage-limit reset

When a recipe agent step fails because the Claude account reached its usage limit, amplihack waits for the limit to reset, or for another login with capacity, and then runs that step once more, instead of ending the recipe run. Steps that already finished are not repeated. The wait is on by default and needs no profiles.

It applies to the amplihack claude -p launch of a recipe step (amplihack recipe run sets AMPLIHACK_NONINTERACTIVE=1), without --profile, --docker or --auto. Interactive sessions and launches typed at a terminal never wait. CI does not turn the wait off: a step under CI=true waits like any other (issue #2911). A failure that is not a usage limit is passed back at once.

What happens

  1. If auto-switch is on and another profile has quota left, the step first runs again under that profile. It does so on every limit, including one met after the step has already waited.
  2. Otherwise amplihack reads the reset time from Claude's own message, such as You've hit your session limit · resets 1pm (America/Los_Angeles), and waits until the earliest of:
  3. the reset plus two minutes;
  4. a different account becoming live for the step's login directory; on ~/.claude, one the rotator records as having room (see A swap onto a full login);
  5. for a step that uses ~/.claude, the login rotator recording a fresh cycle with capacity that left a login with room live;
  6. for a step under an inherited profile with auto-switch on, a usage reading taken during the wait showing that another stored profile has capacity; the step then runs on that profile rather than waiting out the exhausted profile's reset. Only a status line or the login rotator records such readings, so in an unattended run with neither, the wait usually still goes to the reset;
  7. with auto-switch on, the earliest end of a limit block recorded on any other login auto-switch could move the step to, whether or not the step has run there, plus two minutes (bound=earliest_reset+margin); the step then retries on that login without checking it first, so a block end that was wrong about the login costs one attempt (The earliest-reset deadline).

No timer ends a wait. A limit whose message states no usable reset gives the wait no deadline: it waits for a login with room or a login change. 3. The step runs once more with the same arguments and input, and the same environment except for CLAUDE_CONFIG_DIR, which names the other profile when the wait ended on its capacity. If it hits the limit again, on the same login or another, it waits again. A limit never ends the step, and no count or budget bounds the chain. Each wait lasts until its reset or an event, and a capacity or login-change wait writes a waiting_for_capacity line saying why; see Usage-limit waits. Only a stop signal or the session ending stops the chain; the step timeout does not. When the wait ended because something said to try again (the reset arrived, a login had room, or the login changed) and the very first attempt after it hits a limit, the step waits again and logs one reentered line. A usage-limit message whose reset has already passed starts a capacity wait, and the step retries when it ends; see A limit right after a wait.

Both the auto-switch rerun in step 1 and the usage-reading exit in step 2 (logged as end reason=login capacity) can move a step onto another account, so a step pinned to a profile may finish on a different login from the one it started on. That matters if you rely on that profile for billing or data separation. To hold a step on its own login, either turn auto-switch off (amplihack profile auto-switch off), or put the other profiles in the auto-switch exclude list (amplihack profile auto-switch exclude <name>…, which replaces the list, so name every profile you want excluded in one call).

One shared login on the host

Many hosts run every step on one ~/.claude login and let the rotator swap accounts in and out of it at a usage threshold. On such a host a step's limit and the rotator's swap are caused by the same exhausted reading, so the swap often lands while the attempt is still failing.

Three things follow, and all of them apply only to a step that runs on ~/.claude:

  • A swap onto a login with room that has already happened ends the wait before it starts. The supervisor reads which login is live immediately before each attempt and again after the limit. If they differ, and the rotator's ledger says the new login has room, it writes start and end reason=login changed together, then resume, and runs the step again at once on the account now live. Nothing sleeps. If the new login has no room, the step waits as it otherwise would; see A swap onto a full login.
amplihack.recipe.usage_limit_wait start reason=usage_limit harness=claude reset=2026-11-16 13:00:00 +00:00 until=2026-11-16 13:02:00 +00:00 bound=reset+margin
amplihack.recipe.usage_limit_wait end reason=login changed
amplihack.recipe.usage_limit_wait resume attempt=2
  • A new login that is also at its limit gets its own wait. The wait is keyed to the account name the rotator records, which names the login in the log. A step has no count of waits and no mark per login, so a rotator that swaps back to an account the step has already waited on starts a wait like any other.

  • A wait with no stated reset has no deadline. A wait for a stated reset, near or days away, ends at the reset. A wait whose limit stated no usable reset waits for a login with room or a login change, however long that takes. amplihack profile switch <profile> makes that change by hand.

Before this, such a step slept until its own account's reset, however many accounts with room the rotator moved through ~/.claude in the meantime.

An organisation spend limit with no reset also waits on this kind of host. Nothing lifts that limit for the account that hit it, but the next account the rotator brings in may belong to another organisation, so the step waits for the login to change and nothing else. The wait needs no running rotator to start, and it has no deadline. With no rotator running nothing changes the login on its own, so the step waits until you switch the login (amplihack profile switch <profile>) or stop the run.

"And nothing else" is literal. A spend limit is on the organisation's credit, and no reading of session capacity reports credit, so neither the rotator's cycle nor another stored profile's usage reading ends this wait. A rotator cycle that measures the live login and stays on it therefore leaves the step waiting, where on a session or weekly limit the same cycle would end the wait and retry. A cycle that swaps ends it, because the login in ~/.claude has changed, which is the one thing that could put the step on an organisation with credit left. The change is noticed two ways: by watching ~/.claude itself, at the write that makes the swap, and by the login name in the rotator's own records, which is compared against the name read before the attempt started. If the arriving organisation is also spent, the step waits again, keyed to the new login.

A swap onto a full login

A swap is not a reason to run the step again if the login that arrived is nearly spent. A step waiting on a limit ends early when the login in ~/.claude changes and the rotator says the new login has room: its session below the rotator's --session-at and its week below 100%. The rotator records that in its ledger when it records the cycle, and the wait reads the one answer, so there is no threshold to set on the step.

On a host where every login is nearly spent, this is what keeps a step asleep. A swap onto a login at 98% of its session does not end a wait, and neither does stopping the rotator with amplihack profile rotate stop, which records no cycle. A wait ends when the reset arrives, or when a cycle that has capacity records that the login in ~/.claude has room.

Switching the login by hand still wakes a waiting step. amplihack profile switch records the outcome switched with no live_room, which counts as room unless the record states "live_room": false. Use it to unstick a step that you can see is waiting.

Some waits and hosts are not held to this rule, such as a wait for a spend limit and a step that does not use ~/.claude. The reference lists each one with its reason, under What is not gated. To read what the rotator last recorded, and to restart a rotator that predates the field, see Steps that wait on a usage limit.

A limit right after a wait

A wait can end on a signal that turns out to be wrong. The rotator said a login had room, or the reset time passed, and the first attempt after the wait meets a usage limit or a 429 anyway. Before, that attempt ended the step as an indeterminate failure. Now the step waits again and says so once. Its standard error reads, leaving out the sentence written after each until=none line:

amplihack.recipe.usage_limit_wait waiting_for_capacity reason=no_reset harness=claude until=none
amplihack.recipe.usage_limit_wait start reason=usage_limit wait=capacity harness=claude reset=none until=none bound=none
amplihack.recipe.usage_limit_wait end reason=rotator capacity
amplihack.recipe.usage_limit_wait resume attempt=2
amplihack.recipe.usage_limit_wait reentered met=rate_limit
amplihack.recipe.usage_limit_wait waiting_for_capacity reason=no_reset harness=claude until=none
amplihack.recipe.usage_limit_wait start reason=usage_limit wait=capacity harness=claude reset=none until=none bound=none

Neither wait has a deadline, because neither limit stated a reset.

met=usage_limit means the attempt printed a usage-limit message, and met=rate_limit means it ended on a 429 report. A usage-limit message is planned as the first wait was. A message whose stated reset has already passed is waited out as a capacity wait, announced with reason=passed_reset. A retry at 08:32 that meets "resets 8:30am" again is the usual case. The wait has no deadline: it ends when a login has room or the login changes, and the step then retries. See A reset that has already passed. A 429 states no reset, so when it starts a wait at all that wait is a capacity wait with reset=none. A 429 is the one case where the step still asks whether another login could take over before it waits, because a 429 is not a limit message and says nothing about any account's window: with no login that could take over there is nothing to wait out, and the 429 goes back to the recipe runner as the transient fault it is.

A wait that reached its reset is followed by an ordinary retry like any other, and a limit on that retry starts another wait. There is no refusal, no retry count and no budget; the chain is paced by each wait lasting until its reset or an event. A stop signal and the end of the session are different: each of those ends the step. The step timeout does not cut a wait (issue #3037). See What ends a step and what does not.

A 429 counts only when it is the harness's own error line, on standard error or as the last line of the output. The same words inside the model's answer do not start a wait, and everywhere else a 429 is a short-lived fault that the recipe runner retries as before. The reference has the exact phrases and the plan for each kind of limit.

Weekly limits: waiting for another login

A weekly limit, a limit whose message states no reset amplihack can read, a reset that has already passed and credit exhaustion will not lift on a reset the step can use. Each starts a capacity wait. A weekly limit, or any stated reset more than five hours away, is still waited for to that reset; the others have no reset to wait for, so their wait has no deadline. The wait starts whether or not another login has room now, because a login can gain room while it runs:

  • for a step that uses ~/.claude, until the login rotator records a fresh cycle with capacity that left a login with room live, or a different account with room becoming live in ~/.claude (see A swap onto a full login). The rotator cycle needs a rotator running; with none, the wait runs to its reset, or, with no usable reset, until you switch the login;
  • for a step under an inherited profile with auto-switch on, until a usage reading taken during the wait shows that another profile has capacity; the step then runs on that profile, not on the exhausted one. With no rotator, nothing may record a reading during an unattended run, so the wait runs to its reset, or, with no usable reset, until the login changes or you stop the run.

The caveat under What happens applies here too: a step pinned to a profile may finish on another account unless you hold it.

Each capacity wait writes a waiting_for_capacity line that names why it is waiting for capacity. A wait whose limit stated no usable reset reads until=none, and a sentence on standard error says it has no deadline:

amplihack.recipe.usage_limit_wait waiting_for_capacity reason=no_reset harness=claude until=none
amplihack: nothing records when this limit lifts, so this step waits with no deadline until a login has room or the login changes. `amplihack profile switch` ends such a wait for a step on ~/.claude; a stop signal ends the step. See docs/reference/usage-limit-waits.md
amplihack.recipe.usage_limit_wait start reason=usage_limit wait=capacity harness=claude reset=none until=none bound=none
amplihack.recipe.usage_limit_wait progress remaining=none

To see which runs are waiting, search the recipe log:

grep 'usage_limit_wait waiting_for_capacity' "$AMPLIHACK_RECIPE_LOG"

On a host with no rotator and no other login, nothing ends such a wait on its own. To run the step again, switch the login. For a step on ~/.claude:

amplihack profile switch personal

The switch records switched in the rotate ledger, and the wait ends as end reason=rotator capacity. For a step under its own config directory, log that directory in to another account; the wait ends as login changed. A stop signal (Ctrl-C, SIGTERM, SIGHUP) ends the step instead, and the run is recorded as resumable, so the same command launched again resumes at the step. See A wait with no deadline.

A step the wait cannot lift waits until a login has room, the login changes, a stop signal arrives or the session ends; the step timeout does not end it. If you would rather a run end at a limit, set recipe.usage_limit_wait = false. No setting gives a wait a length; see Usage-limit waits. The recipe runner records the failure class as usage_limit when a step does end on one, and auto-drive stops such a loop as USAGE_LIMIT, not STUCK.

The same applies to the loop-health evaluator that auto-drive runs after each round: a limit on its agent step is waited out and the step retried, so the loop gets an ordinary verdict.

When it does not wait

A usage limit always starts a wait. The run ends with no wait only when:

  • the wait is turned off by the operator (recipe.usage_limit_wait = false, or AMPLIHACK_USAGE_LIMIT_WAIT=0). This ending is intended: it is how a job with a timeout of its own asks for the limit result at once. The run is still recorded as resumable with the cause usage_limit. CI is not such a setting and does not turn the wait off;
  • the output carries no limit message in the harness's own shape, so it is not a limit;
  • the prompt came on a pipe and could not be read to its end, so the attempt was given only part of its task and the step fails whether or not it met a limit (auto-switch then does not rerun the step under another profile either). The run learns of the limit from the step's recorded cause, not from its log, and a relaunch resumes the step with its whole prompt.

A piped prompt is copied aside in memory and replayed to every retry, an --input-format channel included, so no step ends on a limit for want of a copy. A prompt still arriving when the retry is due is fed to the retry as it arrives, and the retry starts at once (issue #3036). A step whose copy cannot be set up, which happens only to a process out of file descriptors or threads, is not run.

Model output that merely mentions a usage limit never starts a wait.

The wait stops without a rerun when the run is stopped (Ctrl-C, SIGTERM or SIGHUP) or when the process that started the step exits. The step's timeout does not stop it.

The rerun starts the step from the beginning, so anything the failed attempt already did, such as a push or a comment, may happen again. Keep agent steps safe to run twice.

A wait that ran to its reset while another login had room

A step under a stored profile ends its wait as soon as a usage reading shows another profile with room, so end reason=reset reached on a step that sat beside an idle login means the check found no candidate it could take. Work through these:

  • Nothing recorded a reading while the wait ran. The check reads stored readings and makes no usage probe of its own, and only a reading taken after the wait began counts. Status lines and the login rotator are what write them, so an unattended run with neither has nothing to see and goes to its reset. amplihack profile rotate status says whether the rotator is running.
  • Another session holds that login. A login lent to another directory, or a directory hosting another account, is never a candidate. Both states come from an in-session swap, the only move that writes a ledger entry; a waiting step takes no lease, so other waiting steps are not what put a login into either state. amplihack profile auto-switch status marks the rows leased→<dir> and hosts:<account>.
  • Auto-switch is off. amplihack profile auto-switch status shows it. With it off the step keeps its own login and has no login capacity exit.
  • The other profiles are in the exclude list. The same command lists them. An excluded profile is never read and never counts.
  • The step chose its own login. A step launched with an explicit CLAUDE_CONFIG_DIR is left where it was put. A step on ~/.claude ends on rotator capacity or login changed instead.
  • The other login is not one auto-switch would choose. A spend block, a weekly-limit record, a reading over the auto-switch threshold, a login for another platform, a leased or hosting directory, and an API-key profile that overflow= does not mark all keep a profile out. The rules are in Capacity for a profile step.
  • The limit was an organisation spend limit with no reset. Room on another login never lifts one, so the wait is for the login to change and capacity readings do not end it. With nothing changing the login, the wait has no deadline and goes on until you switch the login or stop the run; it writes waiting_for_capacity reason=spend_limit with until=none so the cause is visible. See When it does not wait.

The observed column of amplihack profile auto-switch status is the quickest check for the first of these: a profile whose last reading is older than the wait showed the wait nothing.

What the log shows

Each line goes to the step's standard error and starts with amplihack.recipe.usage_limit_wait:

amplihack.recipe.usage_limit_wait start reason=usage_limit harness=claude reset=2026-10-18 08:30:00 -07:00 until=2026-10-18 08:32:00 -07:00 bound=reset+margin
amplihack.recipe.usage_limit_wait progress remaining=3540s
amplihack.recipe.usage_limit_wait end reason=rotator capacity
amplihack.recipe.usage_limit_wait resume attempt=2

A wait for a reset that ended instead on a reading showing another stored profile has room looks the same up to its end line. The start line carries no wait=capacity, because the wait was timed by the reset, so end reason=login capacity is what tells you the wait ended early. The line after the resume names the profile the retry runs under:

amplihack.recipe.usage_limit_wait start reason=usage_limit harness=claude reset=2026-10-18 08:30:00 -07:00 until=2026-10-18 08:32:00 -07:00 bound=reset+margin
amplihack.recipe.usage_limit_wait progress remaining=3540s
amplihack.recipe.usage_limit_wait end reason=login capacity
amplihack.recipe.usage_limit_wait resume attempt=2
amplihack: a login has capacity again; rerunning this step under profile "personal" (auto-switch)

The login is picked twice, once to end the wait and once to build the retry. If it was taken in between, the retry runs on the exhausted login the step started with and fails again. What takes it is either an in-session swap on this host, the one move that leases the login it goes to, or a newer reading that disqualifies the login, by putting it back over the threshold or by recording a spend block. That case says so in place of the line above:

amplihack.recipe.usage_limit_wait end reason=login capacity
amplihack.recipe.usage_limit_wait resume attempt=2
amplihack: no login has room now; this step retries under the limited profile (auto-switch)

Seeing it means the step gave up a wait on the strength of a reading and got nothing for it — on a reset wait, a wait that would have run to its reset and succeeded. It appears only after end reason=login capacity, the one exit where room was actually seen and then lost; a wait that ended any other way never had room to lose and says nothing.

A waiting step takes no lease on the login it retries under. When several steps on one machine hit their limits together, they all read the same spare login at the same poll and all move onto it; none of them excludes the others, so the line above is not what contention between waiting steps looks like. What it looks like instead is several steps sharing one login that may not have room for all of them, and a step that meets a second limit there has already spent its one wait for that login. That consequence is tracked in Issue #2733.

A wait for another login has wait=capacity on its start line. A weekly limit is still waited for to its reset, so its until= is that reset plus two minutes; a message with no readable reset reads reset=none until=none bound=none:

amplihack.recipe.usage_limit_wait start reason=usage_limit wait=capacity harness=claude reset=2026-11-05 00:00:00 -07:00 until=2026-11-05 00:02:00 -07:00 bound=reset+margin
amplihack.recipe.usage_limit_wait end reason=rotator capacity
amplihack.recipe.usage_limit_wait resume attempt=2

A wait for the ~/.claude login to change has wait=login_change, and reason=spend_limit, because an organisation spend limit is the only limit that starts one:

amplihack.recipe.usage_limit_wait start reason=spend_limit wait=login_change harness=claude reset=none until=none bound=none
amplihack.recipe.usage_limit_wait progress remaining=none
amplihack.recipe.usage_limit_wait end reason=login changed
amplihack.recipe.usage_limit_wait resume attempt=2

Every other limit reads reason=usage_limit, including a spend limit that states a session reset: there the session limit is what stopped work, and the step takes an ordinary reset wait.

In the run's recipe log

A run started with amplihack recipe run --detach writes its own log, and each wait adds two lines to it:

amplihack.recipe.usage_limit_wait start reason=usage_limit account=work reset=2026-11-16 13:00:00 +00:00 until=2026-11-16 13:02:00 +00:00 bound=reset+margin
amplihack.recipe.usage_limit_wait end reason=login changed

That is the whole of it: a start line saying why the step is waiting, which account it is waiting on and until when (until=none when nothing records when the limit lifts), and an end line saying how the wait ended. When the first attempt after a wait meets a limit and the step waits again, one more line, reentered met=usage_limit or reentered met=rate_limit, comes between the two waits; see A limit right after a wait. The progress lines stay on the step's standard error. Before this, the recipe log showed only the runner's working (Ns elapsed) heartbeat, so a step that slept for hours looked hung and runs were stopped on that reading. To watch for it, use the path recipe run --detach printed as log: when it started the run:

amplihack recipe run smart-orchestrator --detach -w ~/src/myapp
# session: amp-smart-orchestrator-myapp-20261116-101500
# log: /home/alice/.amplihack/recipe-logs/amp-smart-orchestrator-myapp-20261116-101500.log

grep amplihack.recipe.usage_limit_wait \
  /home/alice/.amplihack/recipe-logs/amp-smart-orchestrator-myapp-20261116-101500.log

Do not reconstruct the path from the session name. The directory is recipe.log_dir, which you may have moved, and a session whose name was already taken becomes -2, -3 and so on, so only the printed log: line is reliable.

A login-change wait names itself on the same line, as it does on standard error, and carries the same reason=spend_limit:

amplihack.recipe.usage_limit_wait start reason=spend_limit wait=login_change account=research reset=none until=none bound=none
amplihack.recipe.usage_limit_wait end reason=login changed

The account is the profile name the rotator records, never an e-mail address or an organisation ID, and unknown when no name can be read, which is what you see on a host with no profile store. A top-level foreground amplihack recipe run has no log file of its own, so it writes no such lines; its standard error is already on your terminal. A foreground run or sub-recipe started inside a detached run appends to that run's log, where its output is going anyway.

Both lines arrive whole, so grep finds them however the runner's own output happened to be flushed. The detached run copies the runner's output into the same file a line at a time, holding back any unterminated tail until its line is complete, so a wait line is never spliced into the middle of a working (Ns elapsed) heartbeat. What reaches your terminal is unchanged: only the copy that goes to the log is held to whole lines.

The reference lists every event and reason, the capacity wait section describes the weekly-limit case in full, and the wait in the recipe log covers the two lines above.

Turn it off

For every run, set it in ~/.amplihack/config.toml:

amplihack config set recipe.usage_limit_wait false

For one run or one shell, the variable outranks the file:

export AMPLIHACK_USAGE_LIMIT_WAIT=0

With the wait off, a limit ends the step at once with skipped reason=disabled, and the run is recorded as resumable with the cause usage_limit.

There is no setting for how long a wait lasts. A wait for a stated reset ends at the reset plus two minutes, however far away; a weekly limit is waited for once, to its reset. A wait whose limit stated no usable reset ends when a login has room or the login changes. recipe.usage_limit_max_wait_secs has been removed: a config file that still sets it gets an unknown key warning, and AMPLIHACK_USAGE_LIMIT_MAX_WAIT_SECS is no longer read. Delete both from your files and shell profile. See A wait has no length setting.

The key is listed in the user-config reference and the variable in environment variables.

Limits of the wait

  • Standard output is held back. While the wait is on, a recipe step's standard output is printed when the step ends, even for steps that never hit a limit. Error output still streams.
  • Piped input is replayed from a copy kept in memory. A recipe agent step is given its prompt on stdin, so the supervisor keeps a copy of that prompt in memory as it arrives and gives every attempt the same bytes. A rerun whose caller has not yet closed the pipe waits for the rest of the prompt. Where the copy cannot be set up at all, which happens only to a process out of file descriptors or threads, the step is not run. Where the prompt itself cannot be read to its end, the step fails whether or not it met a limit, with failed reason=prompt_cut_short, and if a limit also stands it says when the limit lifts so the step can be sent again.
  • ~/.amplihack must be private. Held-back output goes under ~/.amplihack/rerun/ (or <root>/.auto-switch.d/rerun/ with auto-switch on). If ~/.amplihack is not owned by you or others can write it, the step writes skipped reason=not_supervised and runs once.
  • Claude Code and Unix only.

Limits

  • run <name> -- args forwards args literally with no shell; -- "; rm -rf ~" is passed to Claude as a single string.
  • Names differing only by case (Work vs work) are rejected on every platform.
  • Profiles apply only to Claude-compatible binaries (claude, rusty, rustyclawd, amplifier). Copilot and Codex launches are unaffected.
  • Docker is unsupported with profiles. profile run, launch --profile, --docker, --auto and env-activated Docker (AMPLIHACK_USE_DOCKER) are all rejected with an error rather than partially applied. A default pointer under env-activated Docker is skipped with a warning. An inherited AMPLIHACK_CLAUDE_PROFILE is rejected the same way, so a Docker or --auto launch started by hand inside a profiled session fails with hint: unset AMPLIHACK_CLAUDE_PROFILE and CLAUDE_CONFIG_DIR to run with --docker/--auto. These modes keep the CLAUDE_CONFIG_DIR they inherit, which inside a profiled session is still the parent's profile, so unset both to run on the default account: env -u AMPLIHACK_CLAUDE_PROFILE -u CLAUDE_CONFIG_DIR amplihack claude --auto. Recipe steps and multitask workstreams never pass these flags, but they do inherit AMPLIHACK_USE_DOCKER. If it is set to a true value in a profiled session and the Docker daemon is running, every nested launch is refused. Unset it before starting the run.
  • Agent steps in amplihack recipe run and recipe-mode amplihack multitask use the inherited CLAUDE_CONFIG_DIR or ~/.claude when no profile is selected. A successful profile switch changes the login in ~/.claude. Classic multitask launches started from a plain shell still read the default pointer when no profile is selected. To select a profile for a run, start it from inside a profiled amplihack claude session or set AMPLIHACK_CLAUDE_PROFILE=<name>.
  • Removing a profile while sessions pinned to it are running makes their later nested launches fail closed with the inherited-profile error.
  • Fleet and remote VM launches do not pass the profile on. An amplihack claude started inside one of them uses the default pointer.
  • Copilot and Codex launches don't set the variables themselves, but they don't remove an inherited value either. A nested amplihack claude started from a Copilot session that inherited AMPLIHACK_CLAUDE_PROFILE uses that profile and checks it again. Without it, the launch uses the pointer.
  • amplihack recipe run refuses context keys in the AMPLIHACK_ namespace (-c amplihack_claude_profile=x is an error), so -c cannot choose the profile. A recipe's own YAML context: defaults and step output: names are not checked yet: the recipe runner exports them to bash steps under their uppercase names, so a recipe that defines amplihack_claude_profile can still change the profile used by an amplihack claude in its bash steps. It can only pick one of your own profiles, and the directory is still checked before spawn.
  • The profile path is re-validated just before spawn. The check is not atomic; a small window remains.
  • On Unix, launches require the profile directory to be owned by the current user with no group/other permission mode bits (mode & 0o077 == 0, so 0700 passes and 0755, 0750 and 0705 are rejected). This checks mode bits; filesystem ACL entries are not inspected. Profiles created by older versions with 0755 need chmod go-rwx <profile-directory>. Only the profile directory is checked, not its parents; the profile root is created 0700. The check is Unix-only.
  • The seeded hooks, statusLine and permissions keys are code-execution configuration: hooks and the status line run commands, and permissions control what Claude may run. Review them before sharing a profile, and treat ~/.claude/settings.json as trusted input.
  • A launch that reads a default pointer naming a deleted profile fails with a hint (amplihack profile switch <name>).
  • profile run <name> with the rotator's live profile still runs in the profile's empty directory; only amplihack claude and amplihack launch redirect to ~/.claude.
  • A redirected launch skips the auto-switch launch checks, as a launch with no profile does.
  • Profiles are not a security boundary against other processes of the same OS user. Anyone able to read your home directory can read the profile. Every profile can read every other profile's sessions through the shared store; see Privacy.
  • Two profiles writing the same session at once behave as two claude processes writing it under ~/.claude without profiles do. Session ids are UUIDs, so separate sessions never collide.
  • Claude Code is expected to follow the projects/ link. If a Claude version replaces the link with a real directory, the next launch merges it back.
  • A first launch that merges a large projects/ held on another filesystem copies every file, so it can take a while. One line is printed when it starts and the results when it finishes; free space is checked before each file, and it happens once.
  • No token vault or token refresh exists by design. Usage is checked only when you run amplihack profile usage, which asks Claude itself. Automatic switching is opt-in and only moves logins between your own profiles; see Switch accounts automatically and the ccswitch review.

Testing without touching real state

export HOME="$(mktemp -d)"
export AMPLIHACK_CLAUDE_PROFILE_ROOT="$HOME/profiles"
amplihack profile add demo
d="$(mktemp -d)"
printf '#!/bin/sh\necho "$CLAUDE_CONFIG_DIR"\n' > "$d/claude" && chmod +x "$d/claude"
PATH="$d:$PATH" amplihack profile run demo

The fake claude prints $CLAUDE_CONFIG_DIR, which should be the demo profile directory. The temporary HOME keeps the saved root ($HOME/.amplihack/profile-root, written by the first add), the seeding source and the shared session store ($HOME/.claude) away from your real files. The temporary $HOME/.claude doesn't exist, so demo gets no links; run mkdir -m 700 "$HOME/.claude" before profile add to see them made.

To see the usage-limit wait without a real login, use a fake claude that fails with Claude's limit message on its first call and succeeds on its second, in a temporary HOME. The message states a reset one minute ahead, as Unix seconds:

export HOME="$(mktemp -d)" AMPLIHACK_CLAUDE_PROFILE_ROOT="$(mktemp -d)"
d="$(mktemp -d)"
cat > "$d/claude" <<'STUB'
#!/bin/sh
echo call >> "$HOME/calls"
if [ "$(wc -l < "$HOME/calls")" -eq 1 ]; then
  echo "Claude AI usage limit reached|$(( $(date +%s) + 60 ))" >&2
  exit 1
fi
cat    # echo the prompt it was given on stdin
STUB
chmod +x "$d/claude"
echo "summarise CHANGELOG.md" > "$HOME/prompt"
PATH="$d:$PATH" AMPLIHACK_NONINTERACTIVE=1 amplihack claude -p < "$HOME/prompt"

The launch writes a reset-wait start line with bound=reset+margin, waits about three minutes (the reset plus 120 seconds), writes end reason=reset reached and resume attempt=2, and then prints summarise CHANGELOG.md: the retry reads the file from the start again.

To see a wait with no deadline, change the stub's message to Claude AI usage limit reached|soon, which states no reset. The launch writes waiting_for_capacity reason=no_reset harness=claude until=none, the sentence saying the step waits with no deadline, and a start line with until=none bound=none, then writes progress remaining=none once a minute. The temporary HOME has no rotator and no other login, so nothing ends the wait on its own; press Ctrl-C to stop it.