[Bug]: A project-scope Claude plugin install enables context-mode globally (start.mjs writes enabledPlugins and a SessionStart hook to user settings)

Author: sgaabdu4Created Sep 28, 2026Updated Sep 28, 2026

Version: context-mode 1.0.169 (same code on main: scripts/heal-installed-plugins.mjs healSettingsEnabledPlugins, start.mjs "Self-heal Layer 4") Platform: macOS, Claude Code 2.1.282

Problem

A project that enables context-mode only in its own .claude/settings.json (project-scope install) turns it on for every project on the machine. On each MCP boot, start.mjs calls healSettingsEnabledPlugins on $CLAUDE_CONFIG_DIR/settings.json (user settings) and sets enabledPlugins["context-mode@context-mode"] = true unless the key is already false. Layer 4 also registers the context-mode-cache-heal.mjs SessionStart hook in user settings.

So claude plugin uninstall context-mode@context-mode --scope user, or deleting the user entry, is undone the next time Claude Code starts in any project that enables the plugin.

Reproduction

Isolated config directory with only a project-scope install:

bash
export HOME=/tmp/cm-repro CLAUDE_CONFIG_DIR=/tmp/cm-repro/cfg
P=$CLAUDE_CONFIG_DIR/plugins/cache/context-mode/context-mode/1.0.169
mkdir -p "$(dirname "$P")" /tmp/cm-repro/proj
cp -R <an installed 1.0.169 plugin directory> "$P"
echo '{}' > $CLAUDE_CONFIG_DIR/settings.json
printf '{"version":2,"plugins":{"context-mode@context-mode":[{"scope":"project","projectPath":"/tmp/cm-repro/proj","installPath":"%s","version":"1.0.169"}]}}' "$P" \
  > $CLAUDE_CONFIG_DIR/plugins/installed_plugins.json
cd /tmp/cm-repro/proj
CLAUDE_PROJECT_DIR=$PWD node "$P/start.mjs" </dev/null & sleep 4; kill $!
cat $CLAUDE_CONFIG_DIR/settings.json

User settings go from {} to:

json
{
  "enabledPlugins": { "context-mode@context-mode": true },
  "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "\"/tmp/cm-repro/cfg/hooks/context-mode-cache-heal.mjs\"" } ] } ] }
}

The same happens in a real setup. After the user-scope install was removed and its enabledPlugins entry was gone, one claude mcp list in a project that enables the plugin put true back in ~/.claude/settings.json. context-mode then loaded in unrelated projects as well.

Controls

  • "context-mode@context-mode": false in user settings: the heal skips (explicit-opt-out). Projects that enable the plugin still load it, and other projects stay off. The SessionStart hook is still re-registered on every boot.

Expected

A project-scope install changes only that project. User settings are written only when the user installed the plugin at user scope.

Suggestion

Run healSettingsEnabledPlugins and the Layer 4 hook registration only when installed_plugins.json has a scope: "user" entry for context-mode@context-mode.

Related: #1058 (uninstall leaves the SessionStart hook behind).