Skip to content

fix: respect CLAUDE_CONFIG_DIR in hooks for multi-profile setups#290

Open
gjaya79 wants to merge 2 commits intomksglu:nextfrom
gjaya79:fix/respect-claude-config-dir
Open

fix: respect CLAUDE_CONFIG_DIR in hooks for multi-profile setups#290
gjaya79 wants to merge 2 commits intomksglu:nextfrom
gjaya79:fix/respect-claude-config-dir

Conversation

@gjaya79
Copy link
Copy Markdown

@gjaya79 gjaya79 commented Apr 15, 2026

Summary

Fixes #289

Hooks hardcoded ~/.claude paths via join(homedir(), ".claude", ...), ignoring the CLAUDE_CONFIG_DIR environment variable. This broke multi-profile setups where users launch Claude Code with different config directories:

alias cc="CLAUDE_CONFIG_DIR=~/.claude-personal claude"
alias ccw="CLAUDE_CONFIG_DIR=~/.claude-work claude"

All path resolution now checks process.env.CLAUDE_CONFIG_DIR first, falling back to ~/.claude when unset. No behavior change for single-profile users.

Changes

  • session-helpers.mjs: Added getClaudeConfigDir() helper. Updated getSessionDBPath(), getSessionEventsPath(), getCleanupFlagPath() to use it for Claude opts.
  • pretooluse.mjs: Self-heal block now resolves configBase from env var for settings.json and installed_plugins.json paths.
  • sessionstart.mjs: CLAUDE.md discovery and debug log path respect the env var.
  • precompact.mjs: Debug log path respects the env var.

Test plan

  • Set CLAUDE_CONFIG_DIR=~/.claude-test and verify session DB is created under ~/.claude-test/context-mode/sessions/
  • Verify default behavior (no env var set) still uses ~/.claude/
  • Verify self-heal in pretooluse reads correct settings.json and installed_plugins.json
  • Verify CLAUDE.md is read from the correct config directory on session start

github-actions bot and others added 2 commits April 15, 2026 18:22
Hooks hardcoded ~/.claude paths, ignoring the CLAUDE_CONFIG_DIR
environment variable. This broke setups where users run multiple
Claude Code profiles with separate config directories (e.g.,
CLAUDE_CONFIG_DIR=~/.claude-personal vs ~/.claude-work).

All path resolution now checks process.env.CLAUDE_CONFIG_DIR first,
falling back to ~/.claude when unset. Affected files:
- session-helpers.mjs: added getClaudeConfigDir(), used in
  getSessionDBPath, getSessionEventsPath, getCleanupFlagPath
- pretooluse.mjs: self-heal block (settings.json, installed_plugins)
- sessionstart.mjs: CLAUDE.md paths, debug log path
- precompact.mjs: debug log path

Fixes mksglu#289
@mksglu mksglu changed the base branch from main to next April 16, 2026 14:42
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.

Hooks ignore CLAUDE_CONFIG_DIR — hardcode ~/.claude paths

2 participants