Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

cld bash command

A bash wrapper around the claude CLI that automatically switches Claude profiles based on your current working directory. Useful when you have multiple Claude accounts (e.g. personal and work clients).

How It Works

cld reads a list of profile names and symlinks ~/.claude and ~/.claude.json to the matching profile's data before launching Claude. The active profile is selected by matching profile names against your current directory path — the last match wins, with the first profile in the list as the default.

Installation

1. Clone or copy claude.bash somewhere permanent:

git clone https://github.com/canshield-digital/cld.git ~/tools/cld

2. Source it in your shell config (~/.bashrc or ~/.zshrc):

source ~/tools/cld/claude.bash

3. Create the profile list:

mkdir -p ~/.config/claude-profiles
cat > ~/.config/claude-profiles/list <<EOF
personal
client-a
client-b
EOF

The first entry (personal) is the default when no directory match is found.

4. First run:

If ~/.claude and ~/.claude.json already exist (from a prior claude install), cld will prompt you to migrate them into the default profile on first run:

** ~/.claude or ~/.claude.json exist as real files — looks like first run **
** Move them to profile 'personal' in ~/.config/claude-profiles? [y/N]

Enter y to migrate automatically, then log in to the remaining profiles separately.

Usage

Use cld exactly as you would use claude:

cld                  # launches Claude with the auto-selected profile
cld "explain this"   # passes arguments through to claude

Profile Selection Examples

Given the profile list:

personal
client-a
client-b
Working directory Selected profile
~/personal/notes personal
~/work/client-a/project client-a
~/work/client-b/site client-b
~/other/random/dir personal (default)

Logging In to Each Profile

Switch into a directory matching each profile and run cld to authenticate:

cd ~/work/client-a && cld   # logs in as client-a
cd ~/work/client-b && cld   # logs in as client-b
cd ~/myproject     && cld   # logs in as personal (default)

Profile Data Layout

~/.config/claude-profiles/
├── list                        # one profile name per line
├── .claude-personal/           # Claude config dir for 'personal'
├── .claude-personal.json       # Claude credentials for 'personal'
├── .claude-client-a/
├── .claude-client-a.json
├── .claude-client-b/
└── .claude-client-b.json

About

Claude code command wrapper with automatic profile selection

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages