Claude Code: load rules by file path and MCP servers per project
How to stop Claude Code loading every rule and MCP server in every session: put stack rules in ~/.claude/rules/ with paths: globs, add MCP servers at local scope, and keep them disabled until a task needs them. For anyone using Claude Code across several stacks.
- Issue
- #6
- Published
- Reading time
- 3 min
- Stack
- Claude Code, MCP, Nuxt, Nuxt UI
The story
I use Claude Code across about a dozen projects: Nuxt apps, a Chrome extension, an Expo app, a Windows tool. Two things followed me into every session, whether they fit or not.
The first was my coding rules: one shared file with Nuxt, Supabase, Chrome-extension and Expo rules side by side, so a session in the extension repo could read Vue advice.
The second was a tool. MCP servers are add-ons Claude can call; I use the Nuxt UI docs server so Claude checks a component's real options instead of guessing. A checklist told me to add it at user scope, which starts it in every session.
Same problem twice: context loaded for every task instead of the task at hand.

Why I'm sharing this
If you work across stacks, everything loaded "just in case" costs tokens on every turn. Rules from another stack can also clash with the project's own, and the model has to pick a side.
The fix
Rules. Claude Code reads personal rule files from ~/.claude/rules/. A file without paths: loads in every session; a file with paths: loads once Claude reads a matching file. I split mine into one file per stack:
---
paths:
- "**/nuxt.config.*"
- "**/app/**/*.vue"
---
# Nuxt
- ...

One catch: globs match file names, not dependencies. My Nuxt file's app/**/*.ts also matched a Next.js repo, because Next.js keeps its code in an app/ folder too, and **/*.vue matches Vue repos without Nuxt UI. Test each glob against your other repos; where a glob can't tell, start the file with a line saying when it applies.
Tools. Add each server only to the projects that use it, then switch it off with /mcp:
claude mcp add --scope local --transport http nuxt-ui https://ui.nuxt.com/mcp
The two meet: opening a .vue file loads the Nuxt UI rules, which send Claude to the docs tool, and I turn it on for that session.

To check: start a new session and run /memory; only the always-on file should be listed. Then read one matching file and ask Claude which rule files it has.

Use it in your workflow
Audit what you load in every session.
1. Read my instruction files (CLAUDE.md, AGENTS.md, ~/.claude/rules/). Split stack-specific rules into one file per stack in ~/.claude/rules/, each with a `paths:` block; keep rules for every stack in general.md without `paths:`.
2. Check each glob against <my other repos> for accidental matches, and list rules that contradict each other.
3. List my MCP servers by scope. Move each user-scope server to local scope in the projects that use it, disabled, and add a line to the matching rule file saying when to enable it with /mcp.
Show the plan before changing anything, then tell me how to verify with /memory and `claude mcp list`.