[BUG] nested_memory injects a directory's .claude/rules/* but skips that directory's CLAUDE.md

Status Open
Reported on v2.1.270
Maintainer reply None cached
Activity 0 comments · opened Sep 17, 2026

Preflight Checklist

  • [x] I have searched existing issues. Closest are #78697 / #87020 (imports not expanded on non-cwd CLAUDE.md) and #94463 (same loader, double load); this is a different symptom of the same loader — the file is not loaded at all.

What's Wrong?

The nested_memory loader injects a directory's .claude/rules/*.md while skipping that same directory's CLAUDE.md.

Setup: sessions start in a parent directory holding ~40 sibling repo clones. The parent is not a repo, so every repo's CLAUDE.md is nested below the cwd. One repo, kube-addons, has:

  • CLAUDE.md — 91 lines, no @import lines, plain content
  • .claude/rules/openspec.md, .claude/rules/security.md — no paths: frontmatter, i.e. unconditional
  • .claude/rules/argo-manifests.md, .claude/rules/helm-values.md — glob-scoped via paths:

Three sessions, same directory, same files on disk, different subsets injected:

| date | CLI | injected for kube-addons |
|---|---|---|
| 2026-09-14 | 2.1.270 | CLAUDE.md + openspec.md + security.md + argo-manifests.md (complete, twice) |
| 2026-09-16 | 2.1.273 | openspec.md + security.md + argo-manifests.md — no CLAUDE.md |
| 2026-09-17 | 2.1.274 | security.md only — no CLAUDE.md, and no openspec.md despite it being unconditional too |

The 2026-09-17 session ran 100 minutes, had 414 records with cwd inside that repo, made 137 Bash tool calls there and created a merge request in it. The repo's CLAUDE.md never entered context; the agent happened to cat it once by hand in its second tool call and worked from that. The 2026-09-16 session shows both behaviors at once: no CLAUDE.md for kube-addons at 10:28, then CLAUDE.md plus three rules for a different repo at 10:47.

Across this machine's transcripts: 93 (session, repo) pairs where the shell cwd was inside a repo that has a CLAUDE.md; in 75 of them that CLAUDE.md was never injected.

What Should Happen?

If the loader decides a directory's memory applies — which it demonstrates by injecting that directory's .claude/rules/*.md — the directory's CLAUDE.md should come with it. Failing that, the omission should be visible somewhere, rather than leaving the agent to infer that a repo has no project instructions.

Error Messages/Logs

Attachment records from the 2026-09-17 session (2.1.274), the only nested_memory event in 100 minutes of work in that repo:

nested_memory 2026-09-17T07:52:55  .../kube-addons/.claude/rules/security.md   (cwd: .../kube-addons)

Compare 2026-09-14 (2.1.270), same directory:

nested_memory 2026-09-14T11:44:40  .../kube-addons/CLAUDE.md
nested_memory 2026-09-14T11:44:40  .../kube-addons/.claude/rules/openspec.md
nested_memory 2026-09-14T11:44:40  .../kube-addons/.claude/rules/security.md
nested_memory 2026-09-14T11:44:40  .../kube-addons/.claude/rules/argo-manifests.md

Reproduce the count on any machine:

grep -rh '"type":"nested_memory"' ~/.claude/projects --include='*.jsonl' \
 | python3 -c 'import json,sys
for l in sys.stdin: print(json.loads(l)["attachment"]["path"])' | sort | uniq -c

Steps to Reproduce

  1. Make a directory that is not a repo and put two or more repo clones inside it, each with its own CLAUDE.md and a .claude/rules/*.md with no paths: frontmatter.
  2. Start Claude Code in the parent.
  3. Work in one repo for a while — cd into it, run shell commands, edit files.
  4. Inspect the session transcript for "type":"nested_memory" records and compare the injected set against what is on disk.

Claude Code Version

2.1.274 (also seen on 2.1.273; 2.1.270 injected the complete set)

Platform / OS / Terminal

CLI, macOS 15 (Darwin 25.6.0), zsh

Additional Information

I am not claiming a clean version regression from three data points — the injected subset may depend on what the session touched. What I do want to flag is that the subset is not observable from inside the session: an agent cannot distinguish "this repo has no CLAUDE.md" from "this repo's CLAUDE.md was not injected", and in a multi-repo parent directory the second case is the common one.

View original on GitHub ↗