Skip to content

fix(settings-hook): respect CLAUDE_CONFIG_DIR when resolving settings.json#2239

Open
andrefogelman wants to merge 1 commit into
garrytan:mainfrom
andrefogelman:fix/settings-hook-respect-claude-config-dir
Open

fix(settings-hook): respect CLAUDE_CONFIG_DIR when resolving settings.json#2239
andrefogelman wants to merge 1 commit into
garrytan:mainfrom
andrefogelman:fix/settings-hook-respect-claude-config-dir

Conversation

@andrefogelman

Copy link
Copy Markdown

Problem

Claude Code supports alternate profile directories via the CLAUDE_CONFIG_DIR environment variable, but bin/gstack-settings-hook hardcodes $HOME/.claude/settings.json as its default target.

On machines where sessions run with CLAUDE_CONFIG_DIR set (e.g. isolated agent profiles like ~/.claude-agentos), hooks registered by ./setup --plan-tune-hooks land in the wrong profile's settings.json and never execute in the active session.

Fix

One line — fall back to CLAUDE_CONFIG_DIR before $HOME/.claude:

SETTINGS_FILE="${GSTACK_SETTINGS_FILE:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/settings.json}"
  • Behavior unchanged when CLAUDE_CONFIG_DIR is unset (default ~/.claude).
  • Explicit GSTACK_SETTINGS_FILE override still takes precedence.

Tested

On a machine with two profiles (~/.claude and ~/.claude-agentos):

  • CLAUDE_CONFIG_DIR=~/.claude-agentos gstack-settings-hook list-sources → reads/writes the agentos profile (3 registered hooks listed).
  • env -u CLAUDE_CONFIG_DIR gstack-settings-hook list-sources → falls back to ~/.claude/settings.json ("no gstack-tagged hooks").
  • add-event/remove-source round-trip verified against the profile selected by the env var.

🤖 Generated with Claude Code

….json

Claude Code supports alternate profile directories via the
CLAUDE_CONFIG_DIR environment variable, but gstack-settings-hook
hardcoded $HOME/.claude/settings.json as its default target. On
machines where sessions run with CLAUDE_CONFIG_DIR set (e.g. isolated
agent profiles), hooks registered by setup --plan-tune-hooks landed in
the wrong profile's settings.json and never executed.

Fall back to CLAUDE_CONFIG_DIR before $HOME/.claude. Behavior is
unchanged when the variable is unset, and the explicit
GSTACK_SETTINGS_FILE override still takes precedence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Jul 11, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@andrefogelman

Copy link
Copy Markdown
Author

please merge

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