Skip to content

fix: prefer CLAUDE_CONFIG_DIR for plugin detection to avoid wrong-profile selection#6

Open
jcasimir wants to merge 1 commit intomainfrom
fix/profile-aware-plugin-detection
Open

fix: prefer CLAUDE_CONFIG_DIR for plugin detection to avoid wrong-profile selection#6
jcasimir wants to merge 1 commit intomainfrom
fix/profile-aware-plugin-detection

Conversation

@jcasimir
Copy link
Copy Markdown
Member

Problem

When multiple Claude profiles are installed (e.g., ~/.claude and ~/.claude-jsl), the plugin detection logic:

PLUGIN_DIR=$(find "$HOME/.claude" "$HOME/.claude-"* -path "*/compound-engineering/*/agents/review" -type d 2>/dev/null | head -1 | sed 's|/agents/review$||')

always resolves to ~/.claude alphabetically because find lists it first and head -1 takes that. Users running from a non-default profile (e.g., ~/.claude-jsl) end up with the wrong PLUGIN_DIR, pointing at the default profile's plugin installation instead of their active one.

Fix

Claude Code exposes CLAUDE_CONFIG_DIR as an environment variable pointing to the active profile directory. The fix checks that variable first:

# Prefer the active Claude profile ($CLAUDE_CONFIG_DIR) over a global search
if [ -n "$CLAUDE_CONFIG_DIR" ]; then
  PLUGIN_DIR=$(find "$CLAUDE_CONFIG_DIR" -path "*/compound-engineering/*/agents/review" -type d 2>/dev/null | head -1 | sed 's|/agents/review$||')
fi
# Fall back to searching all Claude profiles if not found via CLAUDE_CONFIG_DIR
if [ -z "$PLUGIN_DIR" ]; then
  PLUGIN_DIR=$(find "$HOME/.claude" "$HOME/.claude-"* -path "*/compound-engineering/*/agents/review" -type d 2>/dev/null | head -1 | sed 's|/agents/review$||')
fi

The fallback preserves backward compatibility with:

  • The default ~/.claude profile (where CLAUDE_CONFIG_DIR may equal ~/.claude or be unset)
  • Older Claude Code versions that don't set CLAUDE_CONFIG_DIR
  • Running from source repo (which falls through to plugins/compound-engineering relative path)

Files changed

  • skills/refresh/SKILL.md — Step 1: Locate plugin (searches for agents/review)
  • skills/ce-run/SKILL.md — Step 2: Locate plugin (searches for orchestrators)
  • skills/ce-user-scenarios/SKILL.md — Step 2: Locate plugin (searches for agents/user)

Test plan

  • Running /ce:refresh from the JSL profile resolves PLUGIN_DIR to ~/.claude-jsl/plugins/... instead of ~/.claude/plugins/...
  • Running from the default profile still resolves correctly (fallback path)
  • Running without CLAUDE_CONFIG_DIR set falls back to the find pattern unchanged

🤖 Generated with Claude Code

…file selection

When multiple Claude profiles are installed (e.g., ~/.claude and
~/.claude-jsl), the previous `find "$HOME/.claude" "$HOME/.claude-"*`
pattern with `head -1` always resolved to ~/.claude alphabetically,
even when running from the JSL profile.

Claude Code exposes CLAUDE_CONFIG_DIR pointing to the active profile.
The fix checks that env var first and falls back to the broad find
pattern only when CLAUDE_CONFIG_DIR is unset or the plugin isn't found
under it. This preserves backward compatibility with the default
profile and older Claude Code versions.

Affects: ce:refresh (Step 1), ce:run (Step 2), ce:user-scenarios (Step 2)

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.

1 participant