Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
alwaysApply: true rules are respected but if I have alwaysApply: false with glob patterns, these rules never get applied unless I explicitly ask about them.
How can I ensure that rules when editing specific file types, for example, are always applied when working on that file type?
I don’t want to just set alwaysApply: true and take up context for file types that are not relevant.
Steps to Reproduce
Create rule in .cursor/rules/my-rule.mdc
example rule:
---
description: >-
TypeScript/React codegen: DRY, JSDoc on utils, reuse types and utils,
no any/unknown, avoid as casts (including as unknown as), prefer const
function expressions over function declarations, except generator functions;
neutral comment voice, Use when editing.ts/.tsx.
globs:
- "**/*.ts"
- "**/*.tsx"
alwaysApply: false
---
# TypeScript code generation
Follow these rules when adding or changing TypeScript or TSX.
... instructions here
Expected Behavior
If the agent does any edits on ts/tsx files, I expect these rules to be applied. However, they only ever seem to get applied when I ask the agent to apply my rules.
Operating System
MacOS
Version Information
Version: 3.3.27 (Universal)
VSCode Version: 1.105.1
Commit: 80b138a7a0a948e1a798e9ed7867d76a1ba9a310
Date: 2026-05-08T02:26:22.498Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.4.0
For AI issues: which model did you use?
Composer 2
Does this stop you from using Cursor
No - Cursor works, but with this issue
The issue is the glob syntax in your frontmatter. The YAML list format with quoted strings (- "**/*.ts") isn’t recognized by the parser — the quotes and list syntax end up as part of the pattern itself, so it never matches.
Change your frontmatter to use a plain comma-separated string (no quotes, no list):
---
description: >-
TypeScript/React codegen: DRY, JSDoc on utils, reuse types and utils,
no any/unknown, avoid as casts, prefer const function expressions.
globs: **/*.ts, **/*.tsx
alwaysApply: false
---
With the correct syntax, the rule will auto-attach whenever the agent reads a matching .ts/.tsx file during its work. Note that glob rules fire on file reads, not pre-loaded at conversation start — so the rule injects when the agent accesses a matching file, which happens naturally in most agent workflows.
Docs reference: Rules (see “Glob pattern examples” and “Auto-attached by file pattern”).
I get an error in the .mdc file when using that syntax.
The editor marks the comma as invalid because YAML never treats that line as “two globs.” After globs: it expects one YAML value (one string or a list). An unquoted value that starts with ** is also bad: in YAML a leading * is special (aliases), so the parser gets confused on the first * and then flags the comma as junk.
So the red underline lands on the comma, but the real issue is unquoted *-leading globs + comma in a plain scalar.
Fix — use an explicit string or a list:
globs: “**/*.ts”, “**/*.tsx”
or:
globs:
- “**/*.ts”
- “**/*.tsx”
Correction to my earlier reply — the YAML list format you originally used does work. I was wrong to say it isn’t recognized.
The cleanest options that avoid editor lint warnings:
YAML list:
globs:
- "**/*.ts"
- "**/*.tsx"
Single string with commas inside the quotes:
globs: "**/*.ts, **/*.tsx"
One thing to watch out for: globs: "**/*.ts", "**/*.tsx" (two separately quoted values on one line) won’t match correctly. Stick with one of the two formats above.
On the original question: glob-scoped rules with alwaysApply: false activate when the agent reads a matching file during its work, not at conversation start. They fire naturally in most agent workflows when a .ts/.tsx file is accessed.