[FEATURE] Lazy plugin activation based on project file markers
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Plugins that ship MCP servers add measurable startup latency to every session, even when the plugin has nothing to do with the current project. I confirmed this with -debug -- MCP server init from plugins is one of the biggest contributors to a ~17s cold start on a simple claude -p "hello".
The current scoping model (user/project/local) means I either install globally and pay the cost everywhere, or install per-repo and carry the mental burden of remembering which plugins each project needs.
Proposed Solution
Allow plugins to declare activation rules based on file presence in the project root. When Claude Code starts, it evaluates these rules and only initializes plugins whose conditions are met.
Example in the plugin manifest:
activation:
when:
- glob: "playwright.config.*"
Same idea as .nvmrc or .tool-versions -- if the marker file is there, the plugin loads. If not, it's skipped. Plugins without activation rules would keep current behavior.
Plugin authors could ship sensible defaults, so most users wouldn't need to configure anything.
Alternative Solutions
- Manually installing plugins at local scope in each repo that needs them. Works, but doesn't scale across dozens of repos and requires remembering what each project needs.
- Using
enabledPlugins/disabledMcpjsonServersin global settings and overriding per-project. Functional, but high maintenance -- every new project needs configuration. - A SessionStart hook that checks for marker files and prints reminders. Crude workaround that still doesn't prevent the plugins from loading.
Priority
High - Significant impact on productivity
Feature Category
MCP server integration
Use Case Example
I have the Playwright plugin installed. I use it in 2-3 projects out of dozens. Today, its MCP server initializes on every claude invocation regardless of project. With declarative activation, the plugin would only load when playwright.config.* exists in the project root -- zero startup cost everywhere else, zero manual configuration per repo.
Additional Context
Related to #21545, which addresses context window overhead from loaded plugin schemas. This issue focuses on the startup latency side -- preventing irrelevant plugins from initializing at all based on project markers. Both problems are complementary and could be solved independently.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗