Skip to content

[BUG] paths: frontmatter in user-level rules (~/.claude/rules/) is ignored #21858

@ucuc

Description

@ucuc

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 placed in user-level rules directory (~/.claude/rules/) are never loaded, even when working with files that match the specified glob patterns.

Setup:

  • User-level rule file: ~/.claude/rules/csharp-dotnet.md with paths: ["**/*.cs"] frontmatter
  • Project has .cs files

Observation:

  • When editing .cs files, the user-level rule with paths: is NOT loaded
  • The same rule file works correctly when placed in project-level rules (./.claude/rules/)
  • The same rule file also works when symlinked from user-level to project-level rules
  • Rules without paths: frontmatter in ~/.claude/rules/ load correctly (unconditionally)

Verified behavior:

Location paths: frontmatter Result
~/.claude/rules/ With paths ❌ Not loaded
./.claude/rules/ With paths ✅ Loaded
./.claude/rules/ Symlink to user-level ✅ Loaded

What Should Happen?

User-level rules with paths: frontmatter should be loaded when working with files that match the specified glob patterns, just like project-level rules.

According to the documentation:

User-level rules: You can create personal rules that apply to all your projects in ~/.claude/rules/

The paths: frontmatter should work consistently regardless of whether the rule is placed in user-level or project-level rules directory.

Error Messages/Logs

No error messages. The rules are silently not loaded. Running `/memory` shows the user-level rule with `paths:` is not listed in the loaded memory files.

Steps to Reproduce

  1. Create a user-level rule file with paths: frontmatter:

    mkdir -p ~/.claude/rules
    cat > ~/.claude/rules/csharp-rules.md << 'EOF'
    ---
    paths:
      - "**/*.cs"
    ---
    
    # C# Rules
    
    - Follow C# naming conventions
    EOF
  2. Create a project with a .cs file:

    mkdir test-project && cd test-project
    echo 'public class Test { }' > Test.cs
  3. Start Claude Code: claude

  4. Run /memory - observe that csharp-rules.md is NOT listed

  5. Edit the .cs file: ask Claude to "Read Test.cs"

  6. Run /memory again - the rule is still NOT loaded

  7. Workaround test: Copy the same rule to project-level:

    mkdir -p .claude/rules
    cp ~/.claude/rules/csharp-rules.md .claude/rules/
  8. Restart Claude Code and edit the .cs file

  9. Run /memory - now the rule IS loaded

This confirms paths: works in project-level rules but not in user-level rules.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.25

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

Workaround:
Using symlinks from project-level rules to user-level rules works:

# In project directory
mkdir -p .claude/rules
# On Windows (requires admin):
mklink ".claude\rules\csharp-rules.md" "C:\Users\username\.claude\rules\csharp-rules.md"
# On macOS/Linux:
ln -s ~/.claude/rules/csharp-rules.md .claude/rules/

Related issues:

This issue is different from the above as it specifically affects user-level rules (~/.claude/rules/), not project-level rules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsmemoryplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions