Cursor .cursor/rules/*.mdc Globs Not Matching — paths: vs globs: & Pattern Pitfalls
Symptom: Your .cursor/rules/*.mdc rule sits in the repo but never activates when editing target files.
Cursor .mdc rules fail to match for four reasons: using Claude Code's paths: key instead of globs:, prefixing globs with a leading slash (/src/**), setting alwaysApply: false without a description or valid glob, or forgetting to quote globs starting with * in YAML frontmatter.
Broken vs. Fixed Configuration
--- paths: /src/api/*.ts alwaysApply: false --- # API Rules Use Zod for request validation.
---
description: Backend API route conventions and Zod request validation
globs: ["src/api/**/*.{ts,tsx}", "!src/api/**/*.test.ts"]
alwaysApply: false
---
# API Rules
Validate every incoming body with Zod in src/api/schemas/.Why This Happens
YAML parses an unquoted leading asterisk (globs: *.tsx) as an alias syntax error, and cross-tool teams frequently copy .claude/rules/*.md files (which use paths:) straight into .cursor/rules/*.mdc where Cursor ignores paths: completely.
Step-by-Step Fix
- 01Use globs: (never paths:) in Cursor .mdc frontmatter
Rename paths: to globs: and verify the file ends with .mdc inside .cursor/rules/.
- 02Remove leading slashes and quote wildcard patterns
Write globs: ["src/api/**/*.{ts,tsx}", "!src/api/**/*.test.ts"] instead of /src/api/*.ts.
- 03Always include description when alwaysApply is false
A clear description lets Cursor attach the rule in Agent-Requested mode even when no file tab is currently focused.
- 04Verify matches against real repository paths
Paste your frontmatter and real file paths into AgentLint's Cursor .mdc Glob Tester to confirm green matches before committing.
Automated AgentLint Checks That Catch This
Frequently Asked Questions
Can Cursor .mdc globs exclude test files with negation (!)?
Yes. Pair a positive glob with a negated glob like ["src/**/*.ts", "!src/**/*.test.ts"] and test the exact path list in AgentLint's Glob Tester.
When should I set alwaysApply: true instead of globs?
Reserve alwaysApply: true for one compact repo-wide rule file (or an AGENTS.md bridge); scope framework and folder rules with globs to keep context lean.