惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
C
Check Point Blog
雷峰网
雷峰网
小众软件
小众软件
GbyAI
GbyAI
美团技术团队
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
Jina AI
Jina AI
爱范儿
爱范儿
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I built nvm-style account manager for Claude Code
Timur Lolaev · 2026-05-21 · via DEV Community

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)