DEV Community

Cover image for I built nvm-style account manager for Claude Code
Timur Lolaev
Timur Lolaev

Posted on • Originally published at Medium

I built nvm-style account manager for Claude Code

If you use Claude Code with more than one account – personal and work, or one per client – you know the dance. claude opens, you realize you're under the wrong account, you /logout, /login, sit through the OAuth browser flow, then forget which account you're in by the time you switch projects again.

I built claudenv to make this stop happening.

claudenv use work
claude   # automatically under your work account

cd ~/projects/clientA
# auto-switches if you opted in, or:
claudenv use personal
Enter fullscreen mode Exit fullscreen mode

That's it. The same claude binary, just pointed at different config directories via the official CLAUDE_CONFIG_DIR environment variable. No symlinks, no patching files in place, no daemons.

How it works

Claude Code reads its config from ~/.claude by default, but respects CLAUDE_CONFIG_DIR if set. claudenv keeps one directory per account under ~/.claudenv/accounts/<name>/ and points the env var at the right one. Each account has its own OAuth state, settings, MCP servers, the whole thing.

There are three layers of state, exactly like nvm:

  • Global default – what you set with claudenv use work, persists across shells
  • Per-project override – a .claudenvrc file in your repo, picked up via walk-up resolution like .nvmrc
  • Shell-session override.claudenvrc auto-switches on cd if you enable the hook Set a default, override per-project, forget about it.

Why not just claude-switch or claudectx?

There are other tools in this space – I want to be upfront about that.

claude-switch uses the same CLAUDE_CONFIG_DIR mechanism, but the workflow is per-launch: claude-switch work runs Claude under that profile, every time you start a session. If you prefer being explicit on every invocation, use it – it's a fine tool.

claudectx and a few others go a different route entirely, symlinking or patching ~/.claude.json in place. That works too, but it's stateful in a way I didn't want. If the symlink breaks or a patch fails halfway, you end up in a weird state that's hard to debug.

claudenv is for people who switch accounts more than once a day and don't want to type the profile name every time. If your projects are clearly tied to specific accounts, .claudenvrc + auto-switch means you basically never think about it again.

Install

curl -fsSL https://raw.githubusercontent.com/bodasooqa/claudenv/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Or with wget, or download and inspect first – instructions are in the README.

Bash or zsh, that's the only requirement. No Node, no Python, no Homebrew, no extra dependencies. Twenty lines into ~/.zshrc, you're done.

What's next

A few things on the roadmap: a claudenv self-update command, a Homebrew tap once there's a real release cadence, and a wrapper that makes GUI-launched IDEs (Cursor, VS Code from the Dock or Spotlight) pick up the active profile – currently that's a known limitation with launchd not reading shell rc files, documented in the README.

If it solves your problem, a star helps me prioritize what to build next. Issues and PRs welcome.

GitHub logo bodasooqa / claudenv

nvm-style account manager for Claude Code. Switch profiles via CLAUDE_CONFIG_DIR, with per-project .claudenvrc and auto-switch on cd.

claudenv

ShellCheck License: MIT macOS Linux

An nvm-style account manager for Claude Code. Set a default account, override per-project with .claudenvrc, optionally auto-switch on cd. Zero dependencies.

claudenv import default       # save current ~/.claude as 'default' (auto-activated — first profile)
claudenv add work             # create new empty slot
claudenv use work             # switch this shell + set as global default
claude                        # /login here, isolated from 'default'
Enter fullscreen mode Exit fullscreen mode

When accounts/ is empty, the first import or add auto-activates the new profile so you don't have to follow with claudenv use. Subsequent ones don't change the active profile.

Is this for you?

Claude Code already supports CLAUDE_CONFIG_DIR for account isolation. Several tools wrap this — pick the one that fits how you work:

claudenv claude-switch
Mental model Set a default, work normally Specify account on every launch
Typical command claude (after claudenv use work) claude-switch work
Per-project config .claudenvrc (walk-up resolution)

Top comments (0)