[BUG] Path-scoped rules in `.claude/rules/` not automatically loaded when working with matching files

Open 💬 10 comments Opened Jan 8, 2026 by BlondeLegion

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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/ (no paths: frontmatter) load correctly
  • Path-scoped rules in other subdirectories like .claude/rules/api/, .claude/rules/services/ have paths: 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 responses

Observation:
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.ts should load .claude/rules/api/api-rules.md (matches src/api/**)
  • The /context command 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

  1. Create a project with Claude Code initialized
  1. Create a global rule (works correctly):

``bash
mkdir -p .claude/rules/general
echo "# Global Rules\n\n- Always use TypeScript" > .claude/rules/general/global.md
``

  1. Create a path-scoped rule:

```bash
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
```

  1. Create a matching source file:

``bash
mkdir -p src/api
echo "export function handler() { return 'hello'; }" > src/api/routes.ts
``

  1. Start Claude Code: claude
  1. Run /context - observe that only the global rule appears under "Memory files", not the path-scoped rule
  1. Ask Claude to read the matching file: "Read src/api/routes.ts"
  1. 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.

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗