Skip to content

[FEATURE]: Auto-inject subdirectory CLAUDE.md files on read operations #7361

Closed

Description

@allisoneer

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

In Claude Code, CLAUDE.md files located in subdirectories are auto-injected into context when a read tool is called anywhere along that path. Specifically, additional read tool calls are injected for each CLAUDE.md found in the path hierarchy.

Example Directory Structure

CLAUDE.md
dir_1/
├── CLAUDE.md
├── src/
│   ├── CLAUDE.md
│   └── project2/
│       └── other_file.txt
└── other_dir/
    └── example_file.txt
dir_2/
├── CLAUDE.md
└── path/
    └── to/
        └── deeply/
            ├── CLAUDE.md
            └── nested/
                └── dir/

Current Behavior (Claude Code)

By default, the root CLAUDE.md is injected into the system prompt.

When a read tool call is made, Claude Code walks up from that file's directory and injects additional read tool calls for any CLAUDE.md files found along the path.


Example 1: Reading a file in dir_1/other_dir/

read(dir_1/other_dir/example_file.txt)  # original call
read(dir_1/CLAUDE.md)                   # injected

Example 2: Subsequently reading a file in dir_1/src/project2/

read(dir_1/src/project2/other_file.txt)  # original call
read(dir_1/src/CLAUDE.md)                # injected
# dir_1/CLAUDE.md is NOT injected (already read this session)

Example 3: Reading a deeply nested file in dir_2/

read(dir_2/path/to/deeply/nested/dir/somefile.txt)  # original call
read(dir_2/path/to/deeply/CLAUDE.md)                # injected
read(dir_2/CLAUDE.md)                               # injected

Additional Note

I believe you also traverse backwards up the filesystem outside the working directory. Claude Code does not do this.

For example, if the above structure lived at /home/allison/git/repo_1/example/, and repo_1/ (the git root) contained a CLAUDE.md, Claude Code would not inject a read for /home/allison/git/repo_1/CLAUDE.md—but I think your implementation would.

I don't personally need that behavior, but I'd really like subdirectory CLAUDE.md injection support.

Reference Implementation

I emulated the full complexity of this CLAUDE.md injection behavior here, which you can optionally use as a reference:

https://github.com/allisoneer/agentic_auxilary/blob/e8a053d09fca0f0d8e1106baf734c73d3771e003/gpt5_reasoner/src/engine/memory.rs#L27-L154


Does that make the tool-call injection clearer? I can also add explicit comments like # injected tool call if you want to hammer it home even more.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 8, 2026
  2. github-actions commented on Jan 8, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if your specific use case isn't addressed by these issues.

  3. allisoneer commented on Feb 5, 2026

    @allisoneer
    Author

    You guys did this, thanks big dawgs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions