-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- I am using the latest version of Claude Code
What's Wrong?
Rules with paths: frontmatter in .claude/rules/ subdirectories are never automatically loaded into context when reading or editing files that match the specified glob patterns.
Setup:
- Global rules in
.claude/rules/general/(nopaths:frontmatter) load correctly - Path-scoped rules in other subdirectories like
.claude/rules/api/,.claude/rules/services/havepaths:frontmatter but never load
Example rule file at .claude/rules/api/api-rules.md:
---
paths: src/api/**, lib/api/**
---
# API Rules
- Always validate request parameters
- Use structured error responsesObservation:
When running /context, only the general rules appear under "Memory files":
Memory files
└ .claude/CLAUDE.md: 3.8k tokens
└ .claude/rules/general/architecture.md: 2.5k tokens
└ .claude/rules/general/coding-standards.md: 535 tokens
The path-scoped rules (e.g., .claude/rules/api/api-rules.md) don't appear at all - not even as "available but not loaded."
When I then read a file that matches the path pattern (e.g., src/api/routes.ts), the path-scoped rule is still not injected into context.
What Should Happen?
When I read or edit a file matching a rule's paths: glob pattern, that rule should automatically be loaded into context. For example:
- Reading
src/api/routes.tsshould load.claude/rules/api/api-rules.md(matchessrc/api/**) - The
/contextcommand should show path-scoped rules as available (perhaps with their path patterns)
Error Messages/Logs
No error messages. The rules are silently not loaded.Steps to Reproduce
-
Create a project with Claude Code initialized
-
Create a global rule (works correctly):
mkdir -p .claude/rules/general echo "# Global Rules\n\n- Always use TypeScript" > .claude/rules/general/global.md
-
Create a path-scoped rule:
mkdir -p .claude/rules/api cat > .claude/rules/api/api-rules.md << 'EOF' --- paths: src/api/** --- # API Rules - Always validate input parameters - Return structured JSON errors EOF
-
Create a matching source file:
mkdir -p src/api echo "export function handler() { return 'hello'; }" > src/api/routes.ts
-
Start Claude Code:
claude -
Run
/context- observe that only the global rule appears under "Memory files", not the path-scoped rule -
Ask Claude to read the matching file: "Read src/api/routes.ts"
-
Expected: The api-rules.md content should now be in context
Actual: The rule is still not loaded; Claude has no awareness of the API rules
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
No response
Claude Code Version
v2.1.1
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
This also does not work in the standard macOS terminal.