Here's how I run my personal and work Claude accounts without constantly logging out and losing context. Takes about 5 minutes to set up.
The Problem
You have two accounts:
- Personal (whatever tier you're paying for)
- Work (company's Claude)
Default behavior: everything lives in ~/.claude. Switch accounts = log out = lose your conversation. Sucks when you're mid-task.
The Fix
CLAUDE_CONFIG_DIR environment variable. Point it to a different folder, Claude uses that instead. Simple.
Setup
1. Create folders
mkdir ~/.claude-personal
mkdir ~/.claude-work
2. Add these to your ~/.zshrc
claude-work() {
CLAUDE_CONFIG_DIR=~/.claude-work claude "$@"
}
Then source ~/.zshrc.
3. Log in once
claude-work /login
Do this for each account. Credentials get stored in their respective folders. Default claude keeps using ~/.claude for your personal one.
Usage
| Command | Config |
|---|---|
claude |
~/.claude |
claude-work |
~/.claude-work |
Run both in separate terminal tabs. No logout. Both logged in. Done.
Sharing History (Optional)
Want both accounts to share conversation history? One symlink:
rm -rf ~/.claude-work/projects
ln -sf ~/.claude/projects ~/.claude-work/projects
Now any account can --resume conversations from the other. Credentials still separate.
The Script (If You Want It)
Save as scripts/claude-accounts.sh:
#!/bin/bash
WORK_DIR="$HOME/.claude-work"
case "$1" in
work) CLAUDE_CONFIG_DIR="$WORK_DIR" claude "${@:2}" ;;
*) claude "$@" ;;
esac
Run ./scripts/claude-accounts.sh work.
Or just use the functions in your shell. Either works.
Context Tips (Important)
Shared history helps, but don't rely on it alone. Do this instead:
- CLAUDE.md - Create one in your project root. Claude reads it every session.
# Current
- Adding user auth
- Next: API integration
# Stack
- React + Vite
- TanStack Query
Tell Claude to update memory - Before ending a session: "Update memory with what we did."
End-of-day hand-off - "Summarize progress, update CLAUDE.md."
The Script
Full version with setup and share-history:
#!/bin/bash
PERSONAL_DIR="$HOME/.claude-personal"
WORK_DIR="$HOME/.claude-work"
setup() {
mkdir -p "$PERSONAL_DIR" "$WORK_DIR"
local zshrc="$HOME/.zshrc"
local marker="# Claude Code multi-account"
if ! grep -q "$marker" "$zshrc" 2>/dev/null; then
cat >> "$zshrc" << 'EOF'
# Claude Code multi-account
claude-work() {
CLAUDE_CONFIG_DIR=~/.claude-work claude "$@"
}
EOF
source "$zshrc"
fi
}
share_history() {
[ -d ~/.claude/projects ] && [ ! -L ~/.claude-work/projects ] && {
rm -rf ~/.claude-work/projects
ln -sf ~/.claude/projects ~/.claude-work/projects
}
echo "History linked!"
}
case "$1" in
setup) setup ;;
share-history) share_history ;;
work) CLAUDE_CONFIG_DIR="$WORK_DIR" claude "${@:2}" ;;
*) claude "$@" ;;
esac
Run:
./scripts/claude-accounts.sh setup
./scripts/claude-accounts.sh share-history
./scripts/claude-accounts.sh work
That's It
Two isolated accounts. Optional shared history. Your context preserved via CLAUDE.md.
Works on macOS. Should work on Linux too (same CLAUDE_CONFIG_DIR approach).
Top comments (0)