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

推荐订阅源

P
Proofpoint News Feed
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Cisco Blogs
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
T
Tenable Blog
A
Arctic Wolf
小众软件
小众软件
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
PCI Perspectives
PCI Perspectives
博客园 - 司徒正美
The Last Watchdog
The Last Watchdog
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Stack Overflow Blog
Stack Overflow Blog
N
News and Events Feed by Topic
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园 - 【当耐特】
S
Security @ Cisco Blogs
P
Proofpoint News Feed
Cloudbric
Cloudbric
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
月光博客
月光博客
Schneier on Security
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
V
Visual Studio Blog
D
DataBreaches.Net
H
Help Net Security
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Project Zero
Project Zero
阮一峰的网络日志
阮一峰的网络日志
Cyberwarzone
Cyberwarzone
博客园 - Franky
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
N
News and Events Feed by Topic
The Cloudflare Blog
Simon Willison's Weblog
Simon Willison's Weblog
S
SegmentFault 最新的问题
W
WeLiveSecurity
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
I
Intezer
Hugging Face - Blog
Hugging Face - Blog
Attack and Defense Labs
Attack and Defense Labs

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 Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How I Run Multiple Claude Code Accounts From One Terminal
Hariom Sharm · 2026-05-10 · via DEV Community

The first problem sounds simple: you have more than one Claude Code account.

Maybe one is personal and one belongs to your company. Maybe you use Claude Max personally but your org wants work to happen under its own account. Maybe you freelance and each client expects a clean boundary.

You can solve that with shell aliases.

But the better version is quieter: let the folder choose the Claude Code profile.

Once you do that, the trick opens up. It is not only for multiple Claude accounts. The same setup lets you keep different MCP credentials, GitHub orgs, Slack workspaces, Linear teams, Sentry projects, and customer tools separated without thinking about it every time you open a repo.

The small mechanism is direnv plus CLAUDE_CONFIG_DIR.

The bigger idea is that Claude Code should run inside the same trust boundary as the folder you are in.

Key Takeaways

  • Run multiple Claude Code accounts from one terminal without manual login/logout
  • Use one Claude Code profile per trust boundary, not one profile per repo
  • Put .envrc in parent folders like ~/personal, ~/work/company, or ~/clients/acme
  • Every repo under that folder can reuse the right Claude account, MCP auth, history, settings, and tool permissions
  • Split profiles when GitHub, Slack, Linear, Sentry, email, database, or customer credentials should not mix
  • Keep shared MCP server definitions in .mcp.json, but keep private auth in the local profile
  • This does not make untrusted MCP servers safe; it narrows the blast radius when tools go wrong

A notebook diagram showing many project folders flowing into separate reusable Claude Code profiles with isolated tool credentials

Why this is worth caring about

People are already running into the rough edges.

There are Reddit threads about multiple Claude Code accounts on one machine, with people using Docker, shell aliases, and CLAUDE_CONFIG_DIR to keep accounts and config apart.

There are also messier threads where users claim account switching or billing attribution got confusing. Treat that as anecdotal, not a verified platform rule. The useful signal is that manual account switching is fragile, especially when work and personal usage share the same machine.

That is the obvious use case. The less obvious one is MCP.

Someone asked how to handle multiple email accounts through MCP, and the practical answer was basically separate tool auth per account.

Then there are the actual security blunders:

The point is not that direnv magically fixes malicious packages. It does not.

The point is that one global Claude profile turns every connected service into one big pile of keys.

Separate profiles make the boundary visible.

The model: profiles are buckets

Do not create a new Claude profile for every repo by default.

Create a profile for every identity or credential boundary.

~/.claude-profiles/
  personal/
  org/
    company/
  clients/
    acme/
    nova/
  sandbox/

Enter fullscreen mode Exit fullscreen mode

Then use direnv at the folder level where that boundary starts.

~/personal/.envrc
~/personal/blog/
~/personal/open-source-tool/

~/work/company/.envrc
~/work/company/web-app/
~/work/company/api/
~/work/company/mobile/

~/clients/acme/.envrc
~/clients/acme/admin/
~/clients/acme/worker/
~/clients/acme/docs/

Enter fullscreen mode Exit fullscreen mode

The Acme repos all use the Acme profile. The company repos all use the company profile. Your personal repos all use the personal profile.

You only split further when the credentials need to split further.

This works because direnv checks the current directory and parent directories for an authorized .envrc, then loads and unloads those variables as you move around your filesystem.

Claude Code supports CLAUDE_CONFIG_DIR, which changes where Claude stores profile state. Claude's .claude docs also say that when CLAUDE_CONFIG_DIR is set, the normal ~/.claude paths live under that configured directory instead.

That means a folder can choose the Claude Code home directory.

Setup once per boundary

Create the profile directories:

mkdir -p ~/.claude-profiles/personal
mkdir -p ~/.claude-profiles/org/company
mkdir -p ~/.claude-profiles/clients/acme
mkdir -p ~/.claude-profiles/sandbox

Enter fullscreen mode Exit fullscreen mode

Put .envrc in the parent folder, not every child repo:

# ~/clients/acme/.envrc
export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/clients/acme"

Enter fullscreen mode Exit fullscreen mode

Approve it once:

cd ~/clients/acme
direnv allow

Enter fullscreen mode Exit fullscreen mode

Now any repo under ~/clients/acme gets the Acme Claude profile:

cd ~/clients/acme/admin
claude

Enter fullscreen mode Exit fullscreen mode

First run, log in and authenticate the MCP tools for that boundary:

/login
/mcp

Enter fullscreen mode Exit fullscreen mode

After that, the workflow is boring. You cd into a folder and run claude.

Use case 1: personal vs company

A notebook diagram showing personal projects and company projects flowing into two separate Claude Code profiles

This is the cleanest split.

Your personal folder points to your personal profile:

# ~/personal/.envrc
export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/personal"

Enter fullscreen mode Exit fullscreen mode

Your company folder points to your company profile:

# ~/work/company/.envrc
export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/org/company"

Enter fullscreen mode Exit fullscreen mode

Now your side projects can use your personal Claude account, personal GitHub, personal notes, personal MCP tools, and whatever experimental setup you are playing with.

Your company repos can use the org-approved account, org-safe MCP servers, work GitHub, work Slack, work Linear, and company settings.

This is not only about billing.

It is about not letting your personal toolchain become invisible background state inside a work repo.

Use case 2: same Claude account, different service auth

A notebook diagram showing one Claude account using separate MCP credential sets for different services

You may only have one Claude account.

That is fine. This pattern still matters.

The profile does not only isolate Claude login. It also isolates Claude Code settings, history, local config, plugins, and MCP auth state.

Maybe two products use the same Claude subscription but different services:

Product A profile:
  GitHub org A
  Slack workspace A
  Linear team A
  Sentry org A

Product B profile:
  GitHub org B
  Slack workspace B
  Linear team B
  Sentry org B

Enter fullscreen mode Exit fullscreen mode

Those should not be one profile.

The failure mode is simple:

  • "Find the Linear issue" searches the wrong team
  • "Check the deploy thread" reads the wrong Slack
  • "Look at Sentry" opens the wrong org
  • "Create a GitHub issue" writes to the wrong repo

Same Claude account. Different tool identities.

That is enough reason to split.

Use case 3: freelancers with client boundaries

A notebook diagram showing a freelancer routing separate client folders into isolated Claude Code profiles

Freelance and client work is where this stops being a nice trick.

Each client should get its own profile:

~/.claude-profiles/clients/acme
~/.claude-profiles/clients/nova
~/.claude-profiles/clients/orbit

Enter fullscreen mode Exit fullscreen mode

Each client folder gets one .envrc:

# ~/clients/acme/.envrc
export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/clients/acme"

Enter fullscreen mode Exit fullscreen mode

All Acme repos can reuse the Acme profile:

~/clients/acme/admin
~/clients/acme/api
~/clients/acme/worker
~/clients/acme/docs

Enter fullscreen mode Exit fullscreen mode

There is no need to create acme-admin, acme-api, and acme-worker profiles unless those repos genuinely use different service credentials.

This keeps the important stuff separated:

  • client GitHub orgs
  • client Slack workspaces
  • client Linear teams
  • client Sentry orgs
  • customer support tools
  • per-client Claude Code history and permissions

Offboarding is cleaner too. When Acme ends, revoke Acme OAuth access and archive the Acme profile. You are not trying to remember which parts of a global Claude setup belonged to which client.

Use case 4: shared MCP definitions, private credentials

A notebook diagram showing shared MCP definitions and private credentials feeding into one Claude Code profile

Claude Code supports MCP scopes: local, project, and user.

The useful team pattern is:

  • project scope for shared server definitions
  • local or user scope for personal setup
  • profile-specific OAuth through /mcp
  • no real secrets committed to Git

Project-scoped MCP creates or updates .mcp.json, which is meant to be shared with the team.

That file should answer:

Which MCP servers does this repo use?

It should not answer:

Whose Slack, Linear, GitHub, Sentry, database, or email account should Claude use?

That belongs to the developer's profile.

Claude Code's MCP docs also support environment variable expansion in .mcp.json, including URLs, headers, and env values. That is useful for shared structure. It is not permission to commit credentials.

Keep the definition shared. Keep the auth local.

Optional split: sandbox and production

Once you have the pattern, two extra profiles are often useful.

Sandbox:

export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/sandbox"

Enter fullscreen mode Exit fullscreen mode

Use this for trying unknown MCP servers, random plugins, hook experiments, or anything you do not want in your daily profile.

Production or support:

export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/org/company-support"

Enter fullscreen mode Exit fullscreen mode

Use this when the same repo sometimes needs safer, narrower access. For example: read-only Sentry, support Slack, no write-capable deployment tools, no experimental MCP servers.

You do not need this everywhere.

But the safest profile is often the one that simply does not have the dangerous tool installed.

What belongs where?

Layer What it should own
Parent .envrc Select the Claude profile for a folder tree
CLAUDE_CONFIG_DIR Claude Code login, settings, history, plugins, rules, and profile state
.mcp.json Shared MCP server definitions for a repo
/mcp auth OAuth/account connection for the active profile
Git repo config Commit name/email and repo-local Git behavior

The line I care about is the first one.

Put .envrc where the trust boundary starts.

Not necessarily in every repo.

A good default layout

For most people:

~/personal/.envrc
~/work/company/.envrc
~/scratch/.envrc

Enter fullscreen mode Exit fullscreen mode

For freelancers:

~/clients/acme/.envrc
~/clients/nova/.envrc
~/clients/orbit/.envrc

Enter fullscreen mode Exit fullscreen mode

For each .envrc, point at one reusable profile folder:

export CLAUDE_CONFIG_DIR="$HOME/.claude-profiles/clients/acme"

Enter fullscreen mode Exit fullscreen mode

Then stop thinking about it.

If you are in an Acme repo, Claude gets Acme's context.

If you are in your personal repo, Claude gets personal context.

If you are in the company repo, Claude gets company context.

The folder tree chooses the identity.

The whole point

Claude Code is no longer just a code editor with a chat box.

Once you connect MCP, it becomes a tool operator. It can read tickets, inspect errors, search messages, query systems, and sometimes take action.

So the question is not only:

Which model should I use?

It is:

Which identity and tool boundary should this repo run inside?

My answer is simple: let the folder decide.


Originally published at harryy.me