You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Always-on hook misses the flag file when CLAUDE_CODE_SUBPROCESS_ENV_SCRUB removes CLAUDE_CONFIG_DIR #255
I keep my Claude Code config in ~/.config/claude with CLAUDE_CONFIG_DIR exported from my shell, and the flag file is at $CLAUDE_CONFIG_DIR/.i-have-adhd-always. The always-on SessionStart hook runs and exits 0 but prints nothing, so ADHD mode never loads.
I also set CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 in the env block of settings.json. With that set, Claude Code leaves CLAUDE_CONFIG_DIR out of the hook's environment. always-on.mjs then falls back to ~/.claude/.i-have-adhd-always, doesn't find it there and exits quietly.
Steps to reproduce
Export CLAUDE_CONFIG_DIR pointing anywhere other than ~/.claude.
Add "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1" to env in $CLAUDE_CONFIG_DIR/settings.json.
Install the plugin and run touch "$CLAUDE_CONFIG_DIR/.i-have-adhd-always".
Start a session with claude -p "ok" --debug-file hook.log --include-hook-events --output-format stream-json --verbose.
The debug log shows that the hook ran:
Hooks: SessionStart:startup [node -e "..."] (plugin i-have-adhd@i-have-adhd) finished with status 0 (238ms)
Its hook_response event has "stdout": "" though. When I run the same command with --settings '{"env":{"CLAUDE_CODE_SUBPROCESS_ENV_SCRUB":"0"}}', CLAUDE_CONFIG_DIR shows up in the hook environment and the ruleset loads.
I saw this on Claude Code 2.1.296 on macOS with plugin 0.4.1. main still has the same lookup in always-on.mjs, always-on.sh and always-on.ps1.
Possible fix
I'm not sure what the cleanest fix is, so here is one idea. Installed plugins are copied to <config dir>/plugins/cache/..., so when CLAUDE_CONFIG_DIR is missing the hook could work out the config dir from its own install path before it falls back to ~/.claude:
This depends on how Claude Code lays out its plugin cache, which could change, and it doesn't help plugins loaded with --plugin-dir. CLAUDE_PLUGIN_DATA also survives the scrub and sits under the config dir, but using it depends on the layout in the same way. You may know of a better signal than either of these. Whichever way you go, the .sh and .ps1 fallbacks would need the same change.
This is the same kind of quiet failure as #129, where a missing environment variable makes the hook exit 0 with no output.
Activity
fix(hooks): resolve config dir from script path when CLAUDE_CONFIG_DI…