claude-account: Manage Multiple Claude Code Profiles on Linux

Overview

claude-account is a community-developed profile switcher for Claude Code on Linux. It enables users to maintain multiple isolated accounts (e.g., work and personal) by providing each account with its own CLAUDE_CONFIG_DIR, allowing users to switch between identities without repeating the login process.

Core Functionality

claude-account acts as a shim that transparently forwards commands to the official Claude executable while managing the environment for different profiles.

Account Management Commands

  • Adding Accounts: claude account add <name> triggers the official Claude Code login flow. The first profile added becomes the active one. Users can specify emails or use flags like --sso or --console for specific login types.
  • Switching Accounts: claude account use <name> changes the active profile for newly launched Claude processes. Existing sessions remain tied to the account they were started with.
  • Inspection: claude account list shows all configured profiles, and claude account current returns the active profile name (suitable for scripting).
  • Removal: claude account remove <name> runs the official auth logout within that profile. Using the --purge flag permanently deletes all settings, sessions, plugins, and history associated with that profile.

Security and Isolation

To ensure the selected profile is used, the wrapper removes the following environment variables from the child Claude process:

  • ANTHROPIC_API_KEY
  • ANTHROPIC_AUTH_TOKEN
  • CLAUDE_CODE_OAUTH_TOKEN

Users can override this behavior by setting CLAUDE_ACCOUNT_PRESERVE_AUTH_ENV=1.

Installation and Requirements

System Requirements

  • Operating System: Linux
  • Prerequisites: A working installation of Claude Code
  • Build Requirements: Rust 1.85 or later (if building from source)

Installation Steps

  1. Release Installation: Download the latest release (e.g., claude-account-v0.1.1-x86_64-unknown-linux-gnu.tar.gz) and its SHA256 checksum. After verifying the checksum, extract the archive and run ./claude-account install.
  2. Path Configuration: The installer provides an export PATH=... line that must be added to the user's ~/.bashrc to ensure the shim takes precedence over the official Claude executable.
  3. Source Build: Clone the repository, run cargo build --locked --release, and execute ./target/release/claude-account install.

Storage Architecture

claude-account respects XDG_CONFIG_HOME and XDG_DATA_HOME. By default, it uses the following paths:

  • State File: ~/.config/claude-account/state.json (stores profile names and paths; does not store tokens).
  • Profile Data: ~/.local/share/claude-account/profiles/<name>/
  • Binaries: ~/.local/share/claude-account/bin/claude and ~/.local/share/claude-account/libexec/claude-account.

Users can consolidate all data under one directory by setting the CLAUDE_ACCOUNT_HOME environment variable.

Community Perspectives and Alternatives

While claude-account provides a structured management system, the Hacker News community highlighted several alternative methods for achieving account isolation:

  • Environment Variable Aliases: Some users employ simple shell aliases or scripts to set CLAUDE_CONFIG_DIR per account.
  • Directory-Based Switching: Users of the mise tool can automate account switching by defining CLAUDE_CONFIG_DIR in a mise.toml file within specific project directories.
  • Usage-Based Rotation: Tools like omp.sh are used by some to rotate accounts automatically when usage limits are reached.
  • Hybrid Usage: Some users avoid the need for a switcher by using the Claude Code desktop app for one account and the CLI for another.

Discussion on Risks

Community members raised concerns regarding the safety of frequent account switching and the potential for account bans. However, the project documentation emphasizes that claude-account does not read or copy credential contents, as Claude Code itself handles all authentication, token refresh, and storage.

Sources