Skip to content

installer: honor CLAUDE_CONFIG_DIR for global Claude Code installs#1029

Open
borfast wants to merge 1 commit into
colbymchenry:mainfrom
borfast:installer-honor-claude-config-dir
Open

installer: honor CLAUDE_CONFIG_DIR for global Claude Code installs#1029
borfast wants to merge 1 commit into
colbymchenry:mainfrom
borfast:installer-honor-claude-config-dir

Conversation

@borfast

@borfast borfast commented Jun 27, 2026

Copy link
Copy Markdown

Problem

The Claude Code installer target hardcodes ~/.claude and ~/.claude.json, so codegraph install --location global always writes to the default profile — even when the user runs Claude Code against a custom profile via the CLAUDE_CONFIG_DIR env var (e.g. ~/.claude-gc).

The result: the MCP server entry, permissions, and CLAUDE.md instructions all land in a directory Claude Code never reads, so codegraph silently never loads for users on a non-default profile.

Fix

Resolve the global config dir from CLAUDE_CONFIG_DIR when set, falling back to ~/.claude. The .claude.json MCP file follows Claude Code's own placement rule:

  • default profile~/.claude.json (in $HOME, beside ~/.claude)
  • CLAUDE_CONFIG_DIR set$CLAUDE_CONFIG_DIR/.claude.json (inside the profile dir)

settings.json and CLAUDE.md move with the profile dir. Project-local installs are unaffected.

Tests

  • Added a test asserting that with CLAUDE_CONFIG_DIR set, a global install writes .claude.json, settings.json, and CLAUDE.md into the custom profile and leaves ~/.claude untouched. Verified it fails on main and passes with this change.
  • Hardened the installer-targets harness to clear CLAUDE_CONFIG_DIR in setHome, so a custom profile in the real environment can't leak into the existing default-profile tests.

All 152 tests in installer-targets.test.ts pass; tsc --noEmit is clean.

🤖 Generated with Claude Code

The Claude Code target hardcoded `~/.claude` and `~/.claude.json`, so
`codegraph install --location global` always wrote to the default
profile even when the user runs Claude Code against a custom profile via
the `CLAUDE_CONFIG_DIR` env var (e.g. `~/.claude-gc`). The MCP server,
permissions, and instructions all landed in a profile Claude Code never
reads, so codegraph silently never loaded.

Resolve the global config dir from `CLAUDE_CONFIG_DIR` when set, falling
back to `~/.claude`. The `.claude.json` MCP file follows Claude Code's
own rule: it lives *inside* the profile dir when `CLAUDE_CONFIG_DIR` is
set, but beside `~/.claude` (in `$HOME`) for the default profile.
Project-local installs are unaffected.

Also clear `CLAUDE_CONFIG_DIR` in the installer-targets test harness so a
custom profile in the real environment can't leak into tests that assume
the default profile, and add a test covering the new behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

1 participant