[BUG] Claude Code CLI `paths` handling in `.claude/rules/*.md`
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?
When I configure a rule file under .claude/rules/*.md with multiple entries in the paths array, Claude Code CLI does not handle them correctly.
It appears that only one path is honored; adding a second (or more) path entries causes the rule to not be applied as expected to all files.
Concretely, I have a rule like:
paths:
- "applet/src/manifest.json"
- "applet/src/pages.json"
In practice, only one of these files behaves as if the rule is applied; the other one is effectively ignored (no rule behavior is triggered there).
What Should Happen?
Claude Code should support multiple entries in the paths array for .claude/rules/*.md rule files.
With the configuration above, the same rule should be applied consistently to both:
applet/src/manifest.jsonapplet/src/pages.json
without needing any workaround like splitting into multiple rule files.
Error Messages/Logs
There is no explicit CLI error or stack trace in this case.
The CLI runs normally; the bug is in the behavior: only one of the configured `paths` is actually affected by the rule, while the other path behaves as if the rule were not present.
Steps to Reproduce
- Create or edit a rule file under
.claude/rules/, for example:
.claude/rules/rule-uniapp3-config.md
- Configure the
pathsfield with at least two entries, for example:
```yaml
paths:
- "applet/src/manifest.json"
- "applet/src/pages.json"
```
- Run Claude Code CLI in this repository and trigger behavior that should apply this rule (for example, commands that read/apply rules for these files).
- Observe that only one of the files behaves as if the rule is applied; the other file does not appear to be affected by the rule at all.
- If you reduce
pathsto a single entry (e.g. justapplet/src/manifest.json), the rule behaves as expected for that one file.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.47
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
- I have read the official documentation, and I did not find any statement that
pathsshould only contain a single entry. - The configuration works as expected when
pathscontains only one entry. - I also considered whether using a glob pattern (such as
applet/src/*.jsonorapplet/src/{manifest,pages}.json) would be the intended way to support multiple files, but the documentation suggests thatpathsas an array should be valid and therefore this appears to be a bug in how multiple entries are handled.
6 Comments
In addition, I have explicitly confirmed that when there is only a single pattern in
paths, the rule is loaded and works correctly.However, the official documentation shows examples with multiple
pathsentries. In my environment, such multiple-path configurations cannot be loaded or applied correctly, which is why I believe this is a bug rather than a misuse of the documented API.I’m seeing the same behavior. After testing this multiple times, it appears that the paths section is evaluated as a nested AND condition rather than independent matches.
For example I want to work with a file PrefixUnitTest.cs.
In my case, I have the following path pattern:
This configuration works as expected and the rule is loaded successfully.
However, if I change the second path to:
The rule is no longer triggered, even though PrefixUnitTest.cs is located under the UnitTests folder.
It looks like it works in a way that the first path pattern must match, and then within that matched scope, the second pattern must also match. In this scenario, while the directory condition (UnitTests) is satisfied, the filename pattern does not match, so the overall rule is not applied.
This bug may be related to https://github.com/anthropics/claude-code/issues/17204#issuecomment-3927617282. It appears that this is a bug of Claude Code. I can reproduce this with Claude Code v2.1.59.
Workaround confirmed
This is the same underlying bug as #17204 and #16299 — the
paths:YAML array format is broken because the internal CSV parser (_9A()) receives a JS Array and iterates elements incorrectly instead of parsing a string.Fix
Switch from YAML array format to a single unquoted CSV line, and add
alwaysApply: false:Both
alwaysApply: falseand the CSV format are required — withoutalwaysApply: false, rules load eagerly at session start regardless of path matching.See my detailed test results at https://github.com/anthropics/claude-code/issues/17204#issuecomment-4098639043
Thank you all for your support. I’ve confirmed that this issue has been resolved in Claude Code 2.1.97. Everything is now working normally on my side. Thanks again for your help.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.