[BUG] Claude Code CLI `paths` handling in `.claude/rules/*.md`

Status Fixed / completed
Reported on v2.1.47
Maintainer reply None cached
Activity 6 comments · opened Feb 19, 2026 · closed Apr 9, 2026

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.json
  • applet/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

  1. Create or edit a rule file under .claude/rules/, for example:
  • .claude/rules/rule-uniapp3-config.md
  1. Configure the paths field with at least two entries, for example:

```yaml
paths:

  • "applet/src/manifest.json"
  • "applet/src/pages.json"

```

  1. 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).
  2. 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.
  3. If you reduce paths to a single entry (e.g. just applet/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 paths should only contain a single entry.
  • The configuration works as expected when paths contains only one entry.
  • I also considered whether using a glob pattern (such as applet/src/*.json or applet/src/{manifest,pages}.json) would be the intended way to support multiple files, but the documentation suggests that paths as an array should be valid and therefore this appears to be a bug in how multiple entries are handled.

View original on GitHub ↗

6 Comments

TrueNine · 6 months ago

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 paths entries. 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.

armandtapia · 6 months ago

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:

  - "**/{UnitTests,IntegrationTests}/**"
  - "**/*Prefix*Test.cs"

This configuration works as expected and the rule is loaded successfully.

However, if I change the second path to:

  - "**/{UnitTests,IntegrationTests}/**"
  - "**/*AnotherPref*Test.cs"

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.

nekketsuuu · 6 months ago

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.

maxjeltes · 5 months ago

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:

# Before (broken):
---
paths:
  - "applet/src/manifest.json"
  - "applet/src/pages.json"
---

# After (working):
---
alwaysApply: false
paths: applet/src/manifest.json, applet/src/pages.json
---

Both alwaysApply: false and the CSV format are required — without alwaysApply: 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

TrueNine · 4 months ago

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.

github-actions[bot] · 4 months ago

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.