[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"lab-entry-load-rules-and-tools-where-needed":3},{"entry":4,"newer":27,"older":32},{"slug":5,"tag":6,"issueNumber":7,"publishedAt":8,"title":9,"excerpt":10,"readingTimeMinutes":11,"updatedAt":12,"bodyHtml":13,"cover":14,"videoUrl":14,"links":15,"stack":22,"nextStep":14},"load-rules-and-tools-where-needed","Lesson",6,"2026-11-23T09:06:38.249092+00:00","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 ~\u002F.claude\u002Frules\u002F 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.",3,"2026-11-23T13:37:52.869641+00:00","\u003Ch3>The story\u003C\u002Fh3>\n\u003Cp>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.\u003C\u002Fp>\n\u003Cp>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.\u003C\u002Fp>\n\u003Cp>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.\u003C\u002Fp>\n\u003Cp>Same problem twice: context loaded for every task instead of the task at hand.\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fmedia\u002Flab\u002Fad1ed2cf-7fa8-46b4-88ff-5995a93137cd-1600x900.webp\" alt=\"Before: every stack's rules and both docs tools in every session. After: one general rule file at launch, stack rules loaded when Claude opens a matching file, docs tools added per project and off by default.\" width=\"1600\" height=\"900\" loading=\"lazy\" decoding=\"async\">\u003C\u002Fp>\n\u003Ch3>Why I'm sharing this\u003C\u002Fh3>\n\u003Cp>If you work across stacks, everything loaded &quot;just in case&quot; 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.\u003C\u002Fp>\n\u003Ch3>The fix\u003C\u002Fh3>\n\u003Cp>\u003Cstrong>Rules.\u003C\u002Fstrong> Claude Code reads personal rule files from \u003Ccode>~\u002F.claude\u002Frules\u002F\u003C\u002Fcode>. A file without \u003Ccode>paths:\u003C\u002Fcode> loads in every session; a file with \u003Ccode>paths:\u003C\u002Fcode> loads once Claude reads a matching file. I split mine into one file per stack:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-markdown\">---\npaths:\n  - &quot;**\u002Fnuxt.config.*&quot;\n  - &quot;**\u002Fapp\u002F**\u002F*.vue&quot;\n---\n# Nuxt\n- ...\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Cimg src=\"\u002Fmedia\u002Flab\u002Fa32af2f4-e569-421f-897a-84b1b9e4878e-920x152.webp\" alt=\"Claude Code output after reading a file: Loaded rules\u002Fnuxt.md and Loaded rules\u002Ftypescript.md\" width=\"920\" height=\"152\" loading=\"lazy\" decoding=\"async\">\u003C\u002Fp>\n\u003Cp>One catch: globs match file names, not dependencies. My Nuxt file's \u003Ccode>app\u002F**\u002F*.ts\u003C\u002Fcode> also matched a Next.js repo, because Next.js keeps its code in an \u003Ccode>app\u002F\u003C\u002Fcode> folder too, and \u003Ccode>**\u002F*.vue\u003C\u002Fcode> 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.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Tools.\u003C\u002Fstrong> Add each server only to the projects that use it, then switch it off with \u003Ccode>\u002Fmcp\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre>\u003Ccode>claude mcp add --scope local --transport http nuxt-ui https:\u002F\u002Fui.nuxt.com\u002Fmcp\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The two meet: opening a \u003Ccode>.vue\u003C\u002Fcode> file loads the Nuxt UI rules, which send Claude to the docs tool, and I turn it on for that session.\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fmedia\u002Flab\u002F07537cfb-9b00-4aee-8caa-d13473aa7f24-1182x236.webp\" alt=\"Claude Code's \u002Fmcp screen in a Nuxt UI project: nuxt and nuxt-ui listed under Local MCPs with an empty circle, added to this project and switched off\" width=\"1182\" height=\"236\" loading=\"lazy\" decoding=\"async\">\u003C\u002Fp>\n\u003Cp>To check: start a new session and run \u003Ccode>\u002Fmemory\u003C\u002Fcode>; only the always-on file should be listed. Then read one matching file and ask Claude which rule files it has.\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fmedia\u002Flab\u002Fe39a954b-2be9-479f-ae48-1500afd99e8d-1027x412.webp\" alt=\"Claude Code's \u002Fmemory screen at launch: general.md is the only rule file listed, no stack rules yet\" width=\"1027\" height=\"412\" loading=\"lazy\" decoding=\"async\">\u003C\u002Fp>\n\u003Ch3>Use it in your workflow\u003C\u002Fh3>\n\u003Cpre>\u003Ccode class=\"language-text\">Audit what you load in every session. \n1. Read my instruction files (CLAUDE.md, AGENTS.md, ~\u002F.claude\u002Frules\u002F). Split stack-specific rules into one file per stack in ~\u002F.claude\u002Frules\u002F, each with a `paths:` block; keep rules for every stack in general.md without `paths:`.\n\n2. Check each glob against &lt;my other repos&gt; for accidental matches, and list rules that contradict each other.\n\n3. 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 \u002Fmcp. \n\nShow the plan before changing anything, then tell me how to verify with \u002Fmemory and `claude mcp list`.\n\u003C\u002Fcode>\u003C\u002Fpre>\n",null,[16,19],{"label":17,"url":18},"Claude Code docs: memory and rules","https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fmemory",{"label":20,"url":21},"Claude Code docs: MCP","https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fmcp",[23,24,25,26],"Claude Code","MCP","Nuxt","Nuxt UI",{"slug":28,"tag":6,"issueNumber":29,"publishedAt":30,"title":31},"azure-tts-timings-fail-silently",8,"2026-11-27T05:39:28.188557+00:00","Azure text-to-speech timings fail silently, so check word and bookmark events against your script",{"slug":33,"tag":34,"issueNumber":35,"publishedAt":36,"title":37},"agent-test-rerun-button-hidden-copy","Experiment",5,"2026-10-28T07:32:46.682425+00:00","Rerunning the AI agent test: a real button, and a hidden copy of it"]