fix(llms): narrow LLM rule globs to router-specific files#7064
fix(llms): narrow LLM rule globs to router-specific files#7064mixelburg wants to merge 1 commit intoTanStack:mainfrom
Conversation
The previous globs (src/**/*.ts, src/**/*.tsx) matched every TypeScript file in the project, causing Cursor to load all five LLM rules (~25-40k tokens) whenever any source file was in context - even unrelated files. Replace with targeted globs: - Route rules (api, guide, routing): src/routes/**/*.ts, src/routes/**/*.tsx, routeTree.gen.ts, __root.tsx - files where router context is actually useful - Setup rules (installation, setup-and-architecture): package.json, vite.config.ts, tsconfig.json, app.config.ts - config files only Rules will no longer auto-load when editing arbitrary source files. Fixes TanStack#6935
📝 WalkthroughWalkthroughModified glob patterns in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/llms-generate.mjs (1)
26-31: Consider centralizing repeated glob lists to avoid drift.
routeandsetupglob sets are repeated across entries. Extracting them into constants would make future updates safer and keep behavior consistent.♻️ Suggested refactor
+const ROUTE_RULE_GLOBS = [ + 'src/routes/**/*.ts', + 'src/routes/**/*.tsx', + '**/routeTree.gen.ts', + '**/__root.tsx', +] + +const SETUP_RULE_GLOBS = [ + 'package.json', + 'vite.config.ts', + 'tsconfig.json', + 'app.config.ts', +] + const packages = { 'react-router': [ { paths: [`${DOCS_DIR}/router/api/router`], description: 'TanStack Router: API', name: 'api', - globs: [ - 'src/routes/**/*.ts', - 'src/routes/**/*.tsx', - '**/routeTree.gen.ts', - '**/__root.tsx', - ], + globs: ROUTE_RULE_GLOBS, }, { paths: [`${DOCS_DIR}/router/guide`], description: 'TanStack Router: Guide', name: 'guide', - globs: [ - 'src/routes/**/*.ts', - 'src/routes/**/*.tsx', - '**/routeTree.gen.ts', - '**/__root.tsx', - ], + globs: ROUTE_RULE_GLOBS, }, { paths: [`${DOCS_DIR}/router/routing`], description: 'TanStack Router: Routing', name: 'routing', - globs: [ - 'src/routes/**/*.ts', - 'src/routes/**/*.tsx', - '**/routeTree.gen.ts', - '**/__root.tsx', - ], + globs: ROUTE_RULE_GLOBS, }, { paths: [`${DOCS_DIR}/router/installation`], description: 'TanStack Router: Installation', name: 'installation', - globs: [ - 'package.json', - 'vite.config.ts', - 'tsconfig.json', - 'app.config.ts', - ], + globs: SETUP_RULE_GLOBS, }, { // ... - globs: [ - 'package.json', - 'vite.config.ts', - 'tsconfig.json', - 'app.config.ts', - ], + globs: SETUP_RULE_GLOBS, }, ], }Also applies to: 37-42, 48-53, 59-64, 76-81
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/llms-generate.mjs` around lines 26 - 31, The repeated glob arrays used in multiple "globs" properties should be centralized: define shared constants (e.g., ROUTE_GLOBS and SETUP_GLOBS) at the top of the module and replace each inline globs: [...] occurrence with the appropriate constant reference; update every occurrence that currently uses the route and setup lists (the objects that currently have globs: ['src/routes/**/*.ts', 'src/routes/**/*.tsx', '**/routeTree.gen.ts', '**/__root.tsx'] and similar blocks at the other entries) so all entries consume the same constants to prevent drift and simplify future changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@scripts/llms-generate.mjs`:
- Around line 26-31: The repeated glob arrays used in multiple "globs"
properties should be centralized: define shared constants (e.g., ROUTE_GLOBS and
SETUP_GLOBS) at the top of the module and replace each inline globs: [...]
occurrence with the appropriate constant reference; update every occurrence that
currently uses the route and setup lists (the objects that currently have globs:
['src/routes/**/*.ts', 'src/routes/**/*.tsx', '**/routeTree.gen.ts',
'**/__root.tsx'] and similar blocks at the other entries) so all entries consume
the same constants to prevent drift and simplify future changes.
Fixes #6935
Problem
The LLM rules use
src/**/*.tsandsrc/**/*.tsxas globs. Per Cursor's docs, whenalwaysApply: falserules have globs set, they auto-load whenever any matching file is in context. These broad globs match every TypeScript file in the project, so all five rules (~25-40k tokens combined) load whenever you open any source file in Cursor.Fix
Narrow the globs to files where router context is actually useful:
src/routes/**/*.ts,src/routes/**/*.tsx,**/routeTree.gen.ts,**/__root.tsxpackage.json,vite.config.ts,tsconfig.json,app.config.tsNow router rules only load when you're actually working with route files or config files, not when editing every file in the project.
Summary by CodeRabbit