From 6218839e468abe83ca36451a59e5f3e0bfb6ed1b Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 8 Sep 2026 15:45:05 -0500 Subject: [PATCH] Add Use Claude Code From Multiple Accounts as a Claude Code TIL --- README.md | 3 +- .../use-claude-code-from-multiple-accounts.md | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 claude-code/use-claude-code-from-multiple-accounts.md diff --git a/README.md b/README.md index e509839..614e8c4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1878 TILs and counting..._ +_1879 TILs and counting..._ See some of the other learning resources I work on: @@ -174,6 +174,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Resume Specific Session](claude-code/resume-specific-session.md) - [Set Permission Mode When Starting Session](claude-code/set-permission-mode-when-starting-session.md) - [Stash The Current Prompt To Send Another First](claude-code/stash-the-current-prompt-to-send-another-first.md) +- [Use Claude Code From Multiple Accounts](claude-code/use-claude-code-from-multiple-accounts.md) ### Clojure diff --git a/claude-code/use-claude-code-from-multiple-accounts.md b/claude-code/use-claude-code-from-multiple-accounts.md new file mode 100644 index 0000000..eae8049 --- /dev/null +++ b/claude-code/use-claude-code-from-multiple-accounts.md @@ -0,0 +1,52 @@ +# Use Claude Code From Multiple Accounts + +When I first start using Claude Code (`claude`) from the CLI, it will by default +use the `~/.claude` directory for settings, authentication, memory, sessions, +etc. This works fine as long as I'm working from a single, personal Claude +subscription. If I am juggling multiple subscriptions, there is not an obvious +way to switch between them. + +A client I work with recently invited me to their Claude Team subscription via a +company email. I needed a way to access `claude` both from my existing +subscription, for other projects and work, while also doing stuff specific to +this client from the team account. Constantly logging in and out sure doesn't +feel like a sustainable solution. + +The solution was to make use of the `CLAUDE_CONFIG_DIR` environment variable. + +I first make a new config directory for Claude that is specific to this client. + +```bash +❯ mkdir -p ~/.claude-client-x +``` + +Then, from the project directory for this client (e.g. +`~/dev/clients/client-x/codebase`), I start a `claude` session pointing at this +new, empty directory. + +```bash +❯ CLAUDE_CONFIG_DIR="~/.claude-client-x" claude +``` + +I'm prompted with a couple settings and config questions since this is a blank +slate `claude` session. Then I need to do a fresh authentication with `/login`. +For me, this involved authenticating in a separate Chrome profile where this +secondary Claude Team subscription was already active. + +Lastly, I need to make sure that I use the correct "credentials" +whenever I'm starting a `claude` session. That means pointing `claude` to the +correct _config dir_. I tend to use `mise` or `direnv` across all my projects. +For any projects that pertain to _Client X_, I add the following to my +environment (i.e. `mise.local.toml`): + +``` +[env] +CLAUDE_CONFIG_DIR = "~/.claude-client-x" +``` + +Now, whenever I run `claude` from that project, it will use that specific config +in `~/.claude-client-x`. + +Pretty much everywhere else on my machine that I'm using `claude`, I want to use +the account that is already signed in at the default config dir, so no other +change is needed there.