Skip to content

Let a project switch off a globally installed pack #465

Open

Description

@breferrari

Problem

A pack installed with mcs sync --global reaches every project, and there is no way to switch it off in just one. The workaround is project-scoped installs everywhere else, which flips the default: every new repo starts without the pack until someone remembers to add it.

Packs can't solve this themselves without each inventing its own marker (see mcs-cli/memory#49, closed in favour of this), and a pack only controls its hooks. Its MCP servers, skills, plugins and CLAUDE.md section are installed by mcs, so mcs is the one place that can switch all of them off together.

Proposal

State. A project records which global packs are off in .mcs-project: disabledGlobalPacks: ["memory"]. Nothing changes in ~/.mcs/global-state.json or in global files other than the hook guard below.

UX. The project picker already lists global packs under "Already installed globally" and skips them. That section becomes a toggle: on here (default) or off here. For scripts: mcs sync --disable <id> / --enable <id>, and a disable: list in mcs.yaml for mcs bootstrap.

Applying it. Project sync derives the overrides from the global pack's current manifest on every run and writes them into files it already owns. Nothing is stored per artifact, so a pack that gains a skill or server is covered on the next mcs update --all-projects.

Artifact Off switch Written to
Hooks env.MCS_DISABLED_PACKS, read by a guard on global hook commands settings.local.json
MCP servers the server name in disabledMcpServers (the list /mcp → disable writes); the server never starts ~/.claude.json → projects[<path>]
Skills skillOverrides: { "<skill>": "off" } settings.local.json
Plugins enabledPlugins: { "<plugin>": false } settings.local.json
Templates see open question 1 CLAUDE.local.md or settings.local.json
Pack settings out of scope: mcs can't know a key's "off" value; documented as staying in effect —

The hook guard. ComponentDefinition.hookCommand(pathPrefix:) wraps global-scope commands only:

case " $MCS_DISABLED_PACKS " in *" memory "*) ;; *) node ~/.claude/hooks/memory/kb-gate.mts ;; esac
  • With the variable unset the hook runs exactly as today; stdin and the exit code pass through.
  • No runtime dependency on the mcs binary.
  • Doctor and global cleanup keep matching, since both derive from hookCommand and cleanup keys on the path token.
  • It follows the session's project, not the hook's cwd, so a cd mid-session doesn't flip it.
  • Existing global installs pick up the guard on their next global sync; until then they behave as today.

Doctor. In a project with a disabled pack, skip that pack's checks and add one check that its overrides are present.

Verified on Claude Code 2.1.312

Throwaway project, headless sessions, overrides only in the project's settings.local.json:

  • env reaches hook commands on SessionStart, UserPromptSubmit and PreToolUse; the guard silenced only the disabled pack's hooks.
  • skillOverrides: "off" removes a ~/.claude/skills/ skill from both the model's skill list and slash commands.
  • A project enabledPlugins: false overrides a user true.
  • claudeMdExcludes excludes an @imported file.
  • Not run: disabledMcpServers (it would mean editing a real ~/.claude.json). It is documented for user-scoped servers and the projects[<path>] shape is what Claude Code writes today.

Alternatives considered

  • Wrapper binary (mcs hook run <pack> -- <cmd>): cleaner command and logic testable in Swift, but every global hook would depend on mcs being on the hook's PATH and pay a process start. The shell guard has neither cost.
  • Marker file per pack (what memory#49 did): agent-writable, and resolves against the hook's cwd. settings.local.json is Claude Code's own per-project config and already composed by mcs.
  • Removing the hook entry per project: not possible; Claude Code merges hooks across scopes and has no per-hook override, only disableAllHooks.

Open questions

  1. Templates. (a) Write a CLAUDE.local.md section saying the pack is off here: no change to the global layout, but the global section still loads. (b) Write each global pack's template to its own file imported from ~/.claude/CLAUDE.md, and add that file to the project's claudeMdExcludes: a real exclusion, but it changes every user's global CLAUDE.md layout and needs a migration. I'd start with (a).
  2. Protective hooks. Disabling a pack disables all its hooks, including safety ones such as the memory pack's write gate. Since it's an explicit mcs action stored in Claude Code settings, I think that's acceptable, but a pack could opt out of being disableable if you'd rather.
  3. Relation to Let packs declare supported scopes and enforce them on sync #457. Complementary: Let packs declare supported scopes and enforce them on sync #457 is the author limiting where a pack may be installed; this is the user switching a global one off locally. A pack with scopes: [project] never appears as disableable.

Acceptance

  • Integration: disabling a global pack in a project writes each override above, and re-enabling removes exactly those entries.
  • Integration: a project without disabled packs gets byte-identical settings.local.json and CLAUDE.local.md.
  • Unit: hookCommand wraps global-scope commands only; doctor's hook check still matches guarded commands.
  • Integration: a pack that gains a skill after being disabled has it switched off on the next project sync.

Docs

  • docs/cli.md: the picker toggle, --disable / --enable, mcs.yaml disable:.
  • docs/architecture.md: the guard in hookCommand and the per-artifact table.
  • docs/troubleshooting.md: pack settings keys stay in effect when a pack is disabled.

Activity

  1. bguidolim commented on Oct 28, 2026

    @bguidolim
    Collaborator

    Thanks for writing this up, and for testing the mechanisms on a real Claude Code build. I didn't know about the env guard or skillOverrides before reading this.

    I'd like to hold this one, though. mcs already supports per-project installs, and adding a third state ("installed globally, off here") costs a lot for what it buys. Every global hook command gets a guard, mcs starts writing ~/.claude.json directly, and a real template exclusion means changing the layout of every user's global CLAUDE.md. Even after all that, the pack's settings keys stay in effect. So far memory-loop is the only pack asking for this.

    memory-loop can also tell on its own when it has nothing to do: a project without .claude/memories has no KB, so its hooks can exit early there. Unlike the marker in #49, nothing new gets created. The hook only checks the pack's own precondition.

    I do agree about the default. If you want a pack in most repos, per-project installs mean remembering it in every new one. I'd rather fix that directly:

    • Default project packs (mcs config set default-packs memory), pre-selected in the picker for a project that has never been synced, plus mcs sync --defaults to apply them without prompts.
    • A line from the SessionStart hook (mcs check-updates --hook already runs there) when a repo has never been synced and default packs are set, or when its mcs.yaml hasn't been applied.
    • mcs sync --pack <id> --all-projects to add a pack to every tracked project, reusing the loop mcs update --all-projects already has.
    • mcs.yaml with mcs bootstrap for teams, which ISSUE-411: Route mcs.yaml packs to project or global scope #461 is extending.

    If another pack runs into the same need, I'm happy to reopen this. Some parts of the proposal would need changing then:

    • HookInterpreter.interpreter(ofRegisteredCommand:) expects the hook path to be the last token. A guarded command ends in ;; esac, so doctor would fall back to bash and stop checking that node or python is installed for global hooks.
    • Plugins should go through claude plugin disable <id> -s local. Since Plugin enablement is written under a key Claude Code ignores, and project syncs install plugins globally #450 the CLI owns enabledPlugins, and mcs doesn't write it.
    • disabledMcpServers would be mcs's first direct write to ~/.claude.json, which running sessions rewrite all the time.
    • If overrides are derived from the current manifest and never recorded, a skill the pack drops while disabled leaves a stale entry behind, and re-enabling could remove overrides the user set themselves.
    • For templates I'd pick (b). With (a), Claude still sees an instruction to use a pack that's switched off in that project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions