Skip to content

Honor CLAUDE_CONFIG_DIR in get_claude_config_path - #4

Open
jesseclark wants to merge 2 commits into
dr5hn:mainfrom
jesseclark:fix/claude-config-dir-support
Open

Honor CLAUDE_CONFIG_DIR in get_claude_config_path#4
jesseclark wants to merge 2 commits into
dr5hn:mainfrom
jesseclark:fix/claude-config-dir-support

Conversation

@jesseclark

@jesseclark jesseclark commented Jun 24, 2026

Copy link
Copy Markdown

Closes #3

Problem

Users who manage multiple Claude accounts via non-standard config directories (pointed to by the CLAUDE_CONFIG_DIR environment variable) cannot add their second account with ccm add. The command always reports the account as "already being managed" because get_claude_config_path ignores CLAUDE_CONFIG_DIR and always reads from ~/.claude/.claude.json or ~/.claude.json.

Example setup that breaks today:

# ~/.zshrc
alias claude-home='CLAUDE_CONFIG_DIR=$HOME/.claude-home claude'
alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work claude'

With two separate config dirs — ~/.claude-home (personal account) and ~/.claude-work (work account) — ccm add always reads ~/.claude.json, which contains only one of the accounts, so the second account can never be added.

Fix

Check CLAUDE_CONFIG_DIR first in get_claude_config_path. If the env var is set and the corresponding .claude.json exists, use it. Otherwise fall through to the existing primary/fallback logic unchanged.

Usage with this fix:

CLAUDE_CONFIG_DIR=~/.claude-work  ccm add   # adds work account
CLAUDE_CONFIG_DIR=~/.claude-home  ccm add   # adds personal account

All other ccm commands (use, switch, status, etc.) also benefit automatically — they will read/write the correct config when CLAUDE_CONFIG_DIR is set.

Changes

  • ccm.sh — add CLAUDE_CONFIG_DIR check at the top of get_claude_config_path; no other logic changed
  • tests/get_claude_config_path.bats — five bats tests covering the new path and the original primary/fallback behaviour
  • .github/workflows/test.yml — CI matrix running bats on ubuntu-latest and macos-latest for every push/PR
  • package.json — adds "test": "bats tests/" script

jesseclark and others added 2 commits June 25, 2026 07:42
Users who run multiple Claude accounts via non-standard config
directories (set with CLAUDE_CONFIG_DIR) can't add their second
account because get_claude_config_path always reads ~/.claude.json
or ~/.claude/.claude.json, regardless of which account is active.

With this change, if CLAUDE_CONFIG_DIR is set, CCM reads
$CLAUDE_CONFIG_DIR/.claude.json first. This lets users prepend
the env var to any ccm command to target the right account:

  CLAUDE_CONFIG_DIR=~/.claude-work  ccm add
  CLAUDE_CONFIG_DIR=~/.claude-home  ccm add

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds five tests covering:
- CLAUDE_CONFIG_DIR respected when .claude.json exists
- CLAUDE_CONFIG_DIR falls through when .claude.json is absent
- Original primary (~/.claude/.claude.json) and fallback (~/.claude.json) paths

Wires up a GitHub Actions matrix (ubuntu-latest, macos-latest) and a
`npm test` script so the suite runs automatically on every PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trouble adding second account

1 participant