Skip to content

Add --profile flag for per-account state isolation - #58

Open
guimou wants to merge 1 commit into
mainfrom
profile-support
Open

guimou wants to merge 1 commit into
mainfrom
profile-support

Conversation

@guimou

@guimou guimou commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

When using ccbox with multiple accounts (e.g. one on Vertex AI, one on Anthropic), a single shared ~/.claude directory blends credentials, session history, and /usage statistics across accounts — /usage is computed locally from session transcripts and the stats cache, so both accounts accumulate into one pool.

This PR adds a --profile <name> flag that keeps each account fully separate:

  • Isolated per profile (under ~/.claude-profiles/<name>/): .credentials.json, .claude.json, statsig/, stats-cache.json, caches (file-history, paste-cache, cache, backups), and per-project data (ccbox-projects/ — session transcripts, history, todos, plans, tasks, plugins). This is everything /usage reads, so each profile gets independent usage statistics.
  • Shared across profiles (still from ~/.claude): settings, keybindings, CLAUDE.md, hooks, commands, skills, agents, rules, themes, workflows — no duplication of customizations, no symlinks needed since ccbox mounts item-by-item.
CLAUDE_CODE_USE_VERTEX=1 ANTHROPIC_VERTEX_PROJECT_ID="my-project" ccbox --profile vertex
ccbox --profile anthropic
ccbox   # no flag = unchanged default behavior, shared ~/.claude

Details

  • Container names become ccbox-{project}-{hash}-{profile}-{session-id}, so --list-sessions (unchanged, prefix-based) shows which profile each session belongs to.
  • Profile names are validated: lowercase letters, digits, dashes, underscores.
  • A new profile starts unauthenticated (run /login or use provider env vars) and re-runs first-time onboarding once, since its .claude.json starts empty.
  • ensure_global_config is split into shared vs account-specific (ensure_account_config) halves; without --profile both run against ~/.claude, producing identical behavior to before.
  • Docs updated: README (new "Account Profiles" section, architecture diagram, "Where Data Lives" table) and CLAUDE.md.

Testing

  • ShellCheck: no new findings (the two pre-existing info/warning findings on main remain).
  • Smoke tests with a stubbed podman and isolated $HOME:
    • --profile vertex: profile tree created, all account-specific mounts sourced from ~/.claude-profiles/vertex/, container name includes the profile.
    • No flag: generated podman run mounts identical to current behavior.
    • Invalid names (--profile "Bad Name") rejected with a clear error.
    • --list-sessions still works and matches profile-suffixed containers.

When using ccbox with multiple accounts (e.g. one on Vertex AI, one on
Anthropic), a single shared ~/.claude directory blends credentials,
session history, and /usage statistics across accounts.

The new --profile <name> flag stores account-specific state under
~/.claude-profiles/<name>/ instead: .credentials.json, .claude.json,
statsig/, stats-cache.json, caches, and the per-project data that
/usage reads (session transcripts, history). Customizations (settings,
keybindings, CLAUDE.md, hooks, commands, skills, agents, rules, themes,
workflows) remain shared across profiles.

Container names include the profile (ccbox-{project}-{hash}-{profile}-
{session-id}) so concurrent sessions from different profiles are
distinguishable; --list-sessions still matches all of them. Without
--profile, behavior is unchanged.

---
Signed-off-by: Guillaume Moutier <guimou@users.noreply.github.com>
Co-authored-by: Claude <claude@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant