[BUG] CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 does not load .claude/rules/*.md from --add-dir paths
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (closest prior art: #25562 — related but distinct; that issue is about
~/.claude/rules/scoping, this one is about--add-dir+ env-var behavior) - [x] This is a single bug report
- [x] I am using the latest version of Claude Code (2.1.137)
What's Wrong?
The Memory documentation states:
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared-configThis loadsCLAUDE.md,.claude/CLAUDE.md,.claude/rules/*.md, andCLAUDE.local.mdfrom the additional directory.
Empirically, with both the env var set AND --add-dir pointing at a directory containing .claude/rules/*.md files with paths: frontmatter, only CLAUDE.md (top-level) loads. The .claude/rules/*.md files do NOT register with the path-scoped auto-loader; reading a file whose path matches the rule's paths: glob does not fire path_glob_match for the rule.
What Should Happen?
Per the documented behavior, .claude/rules/*.md from the --add-dir directory should register with the auto-loader. Reading a file that matches the rule's paths: glob should fire an InstructionsLoaded event with load_reason: path_glob_match for the additional-directory rule.
Error Message/Logs
No error — silent non-load. Verified via InstructionsLoaded hook logging.
Log excerpt from a controlled probe (only the env-var-bypass test event shown):
[2026-05-09T19:36:13Z] reason=session_start memory=Project file=/private/tmp/loadprobe/CLAUDE.md
[2026-05-09T19:36:13Z] reason=session_start memory=Project file=/Users/work/.claude/plugins/cache/cascadian-local/cascadian/0.2.0/CLAUDE.md
[2026-05-09T19:36:17Z] reason=path_glob_match memory=Project file=/private/tmp/loadprobe/.claude/rules/local-test.md trigger=/private/tmp/loadprobe/bin/example.sh globs=bin/**/*.sh
CLAUDE.md from the additional directory loaded (cache CLAUDE.md, line 2). The PROJECT-LOCAL rule fired (line 3). The ADDITIONAL-DIRECTORY rule (.claude/rules/*.md from the --add-dir path with matching paths: glob) did NOT fire — no event emitted for it despite a matching read.
Steps to Reproduce
- Create an "additional" directory with a
.claude/rules/rule:
```bash
mkdir -p /tmp/additional/.claude/rules
cat > /tmp/additional/.claude/rules/test-rule.md << 'INNER_EOF'
---
paths:
- "bin/**/*.sh"
---
# Test rule body — should fire path_glob_match when bin/*.sh is read.
INNER_EOF
```
- Create a separate project directory with a matching path and an
InstructionsLoadedhook:
``bash``
mkdir -p /tmp/probe/.claude /tmp/probe/bin
echo '#!/bin/bash' > /tmp/probe/bin/example.sh
touch /tmp/probe/CLAUDE.md
cat > /tmp/probe/.claude/log.sh << 'INNER_EOF'
#!/usr/bin/env bash
input=$(cat)
echo "[$(date -u +%FT%TZ)] $(printf '%s' "$input" | jq -c '{file_path, load_reason, memory_type, trigger_file_path}')" >> /tmp/probe-loads.log
exit 0
INNER_EOF
chmod +x /tmp/probe/.claude/log.sh
cat > /tmp/probe/.claude/settings.json << 'INNER_EOF'
{
"hooks": {
"InstructionsLoaded": [
{ "hooks": [{ "type": "command", "command": "/tmp/probe/.claude/log.sh" }] }
]
}
}
INNER_EOF
- From
/tmp/probe, run:
``bash``
: > /tmp/probe-loads.log
cd /tmp/probe && CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 \
claude --add-dir /tmp/additional \
-p "Read bin/example.sh and tell me its first line."
- Inspect
/tmp/probe-loads.log. Observed: onlysession_startevents forCLAUDE.mdfiles. Nopath_glob_matchevent for the additional-directory rule despitebin/example.shbeing read.
Claude Model
None — this is platform/CLI behavior, model-independent.
Is this a regression?
Don't know — haven't bisected. The documented behavior may have never worked for .claude/rules/*.md, or may have regressed at some point. The doc claim is current as of 2026-05-09.
Last Working Version
N/A (see above)
Claude Code Version
2.1.137
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS) — zsh
Additional Information
Suggested resolution: either clarify the doc to specify which file types actually load from --add-dir paths under the env var (CLAUDE.md only?), or fix the mechanism so .claude/rules/*.md from --add-dir paths register with the path-scoped auto-loader.
Discovered while building a plugin framework that needed to understand which discovery surfaces propagate from a plugin's cache directory to consumer sessions. The behavior gap shaped architectural decisions around whether to rely on --add-dir for cache reads vs. explicit settings-based permission grants.
Related prior art: #25562 (closed-stale) describes a related scoping issue with ~/.claude/rules/. Not a duplicate — that issue concerns user-level rules matching files outside the primary working directory; this issue concerns --add-dir directories' rules not loading at all under the documented env-var bypass.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗