From 75a98849da3e7d80b05745f7452957478409012d Mon Sep 17 00:00:00 2001 From: Jeff Casimir Date: Mon, 13 Apr 2026 12:10:35 -0600 Subject: [PATCH] fix: prefer CLAUDE_CONFIG_DIR for plugin detection to avoid wrong-profile 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 --- plugins/compound-engineering/skills/ce-run/SKILL.md | 9 ++++++++- .../skills/ce-user-scenarios/SKILL.md | 9 ++++++++- plugins/compound-engineering/skills/refresh/SKILL.md | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/compound-engineering/skills/ce-run/SKILL.md b/plugins/compound-engineering/skills/ce-run/SKILL.md index e12d2802e..066b92d47 100644 --- a/plugins/compound-engineering/skills/ce-run/SKILL.md +++ b/plugins/compound-engineering/skills/ce-run/SKILL.md @@ -21,7 +21,14 @@ If no orchestrator name is provided, list available orchestrators and ask which Find the plugin's install location: ```bash -PLUGIN_DIR=$(find "$HOME/.claude" "$HOME/.claude-"* -path "*/compound-engineering/*/orchestrators" -type d 2>/dev/null | head -1 | sed 's|/orchestrators$||') +# 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/*/orchestrators" -type d 2>/dev/null | head -1 | sed 's|/orchestrators$||') +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/*/orchestrators" -type d 2>/dev/null | head -1 | sed 's|/orchestrators$||') +fi ``` Fall back to relative path if not found: diff --git a/plugins/compound-engineering/skills/ce-user-scenarios/SKILL.md b/plugins/compound-engineering/skills/ce-user-scenarios/SKILL.md index f8899e236..cce600c0b 100644 --- a/plugins/compound-engineering/skills/ce-user-scenarios/SKILL.md +++ b/plugins/compound-engineering/skills/ce-user-scenarios/SKILL.md @@ -28,7 +28,14 @@ If no stage is specified, use these heuristics: Find the plugin's install location: ```bash -PLUGIN_DIR=$(find "$HOME/.claude" "$HOME/.claude-"* -path "*/compound-engineering/*/agents/user" -type d 2>/dev/null | head -1 | sed 's|/agents/user$||') +# 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/user" -type d 2>/dev/null | head -1 | sed 's|/agents/user$||') +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/user" -type d 2>/dev/null | head -1 | sed 's|/agents/user$||') +fi ``` Fall back to relative path if not found: diff --git a/plugins/compound-engineering/skills/refresh/SKILL.md b/plugins/compound-engineering/skills/refresh/SKILL.md index 1aab87837..1da13a825 100644 --- a/plugins/compound-engineering/skills/refresh/SKILL.md +++ b/plugins/compound-engineering/skills/refresh/SKILL.md @@ -12,7 +12,14 @@ Syncs reviewer persona files, orchestrator definitions, and user persona files f Find the plugin's install location in the Claude plugin cache: ```bash -PLUGIN_DIR=$(find "$HOME/.claude" "$HOME/.claude-"* -path "*/compound-engineering/*/agents/review" -type d 2>/dev/null | head -1 | sed 's|/agents/review$||') +# 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 ``` Fall back to relative path if not found (e.g., running from source repo):