[DOCS] Path-scoped rules: `*.md` matches nested files, not only the project root
Documentation Type: Incorrect/outdated documentation
Documentation Location: https://code.claude.com/docs/en/memory#path-specific-rules
Section/Topic: Path-specific rules, the glob pattern table
Current Documentation
The pattern table states:
| Pattern | Matches |
| --- | --- |
| **/*.ts | All TypeScript files in any directory |
| src/**/* | All files under src/ directory |
| *.md | Markdown files in the project root |
| src/components/*.tsx | React components in a specific directory |
What's Wrong or Missing
*.md does not behave as "Markdown files in the project root". It matches Markdown files at any depth, so it behaves like **/*.md.
Reproduced on Claude Code 2.1.277 (macOS), with the InstructionsLoaded hook as the observer.
Setup, in a throwaway project:
.claude/rules/md-only.mdwith frontmatterpaths: ["*.md"].claude/rules/docsdir-only.mdwith frontmatterpaths: ["docs/**"]- A nested Markdown file at
scripts/notes.md, outside the project root and outsidedocs/ - An
InstructionsLoadedhook whose command appends its stdin payload to a log
Run a non-interactive session that reads the nested file:
claude -p "Read the file scripts/notes.md and reply with its title line only." \
--setting-sources project --settings ./settings-probe.json \
--allowedTools "Read" --permission-prompts none
Observed: the rule scoped to *.md loads.
{"hook_event_name":"InstructionsLoaded","file_path":".claude/rules/md-only.md",
"load_reason":"path_glob_match","globs":["*.md"],
"trigger_file_path":"scripts/notes.md"}
Expected from the table: no load, since scripts/notes.md is not in the project root.
The docs/** rule correctly did not load for that same read, so the discrepancy is specific to the leading * pattern rather than to path scoping in general.
Reading .claude/rules/always.md in the same project also loads the *.md rule, which confirms the depth is irrelevant to the match.
Suggested Improvement
Two possibilities, and the documentation should say which one is intended.
If matching at any depth is the intended behavior, correct the table row and add a note, since the current wording leads authors to write a much narrower scope than they get:
| Pattern | Matches |
| --- | --- |
| *.md | Markdown files anywhere in the project, at any depth |
If root-only matching is the intended behavior, then the matcher has the defect and the table is right, and this is a bug report rather than a documentation one.
Either way, the distinction matters for the use case the page recommends path scoping for. A team scoping a documentation rule with *.md to keep it out of the always-on context will find it loading in nearly every session of a Markdown-heavy repository.
Impact
Medium - Makes feature difficult to understand