[FEATURE]: Hierarchical rules triggered by file-related tool calls for progressive disclosure #6867

Closed
opened 2026-02-16 18:05:28 -05:00 by yindo · 2 comments
Owner

Originally created by @bailey-busc on GitHub (Jan 19, 2026).

Originally assigned to: @thdxr on GitHub.

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

Claude Code looks up nested CLAUDE.md files based on what files are being read, allowing for progressive disclosure based on what Claude is working on (docs link). This seems small, but I think this is a killer feature because context bloat is so undesirable and degrades model performance so aggressively.

Implementation:

  • Rules files are matched based on the regex (.+[-_\.])?AGENTS.md, allowing for files such as python.AGENTS.md, backend_AGENTS.md, typescript.AGENTS.md, and the normal AGENTS.md to match
  • Read, edit, grep tools trigger rule lookup + injection
  • When the tool calls that introduced a rule are pruned during compaction, the rules themselves are pruned as well
  • Rules support a paths parameter via YAML frontmatter, which is a list of file globs. If present, the rule will only be loaded if the globs match the file(s) being loaded. This is analogous to Claude Code's path-specific rules feature.

I'm in the process of implementing this, and have a functional prototype with the exception of:

  • Rules that have been loaded are missing from the web UI message interface
  • List of all rules loaded in a session in the context panel in the web UI

Open questions/feedback I'm requesting:

  • Is "hierarchical" the right word to describe this? I'm not really settled on if this is what this should be called.
  • Are rules different conceptually from the current instructions implementation? Should I merge the two concepts somehow?
  • Should the regular expression for rule loading be configurable? In either case, does the default regex (.+[-_\.])?AGENTS.md make sense?
  • The paths frontmatter thinge feels like it possibly should be split off into it's own feature and supported in instructions as well, but I'm not totally sure.
Originally created by @bailey-busc on GitHub (Jan 19, 2026). Originally assigned to: @thdxr on GitHub. ### 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 Claude Code looks up nested `CLAUDE.md` files based on what files are being read, allowing for progressive disclosure based on what Claude is working on ([docs link](https://code.claude.com/docs/en/memory#how-claude-looks-up-memories)). This seems small, but I think this is a killer feature because context bloat is so undesirable and degrades model performance so aggressively. ### Implementation: * Rules files are matched based on the regex `(.+[-_\.])?AGENTS.md`, allowing for files such as `python.AGENTS.md`, `backend_AGENTS.md`, `typescript.AGENTS.md`, and the normal `AGENTS.md` to match * Read, edit, grep tools trigger rule lookup + injection * When the tool calls that introduced a rule are pruned during compaction, the rules themselves are pruned as well * Rules support a `paths` parameter via YAML frontmatter, which is a list of file globs. If present, the rule will only be loaded if the globs match the file(s) being loaded. This is analogous to Claude Code's [path-specific rules feature](https://code.claude.com/docs/en/memory#path-specific-rules). I'm in the process of implementing this, and have a functional prototype with the exception of: * Rules that have been loaded are missing from the web UI message interface * List of all rules loaded in a session in the context panel in the web UI ### Open questions/feedback I'm requesting: * Is "hierarchical" the right word to describe this? I'm not really settled on if this is what this should be called. * Are rules different conceptually from the current instructions implementation? Should I merge the two concepts somehow? * Should the regular expression for rule loading be configurable? In either case, does the default regex `(.+[-_\.])?AGENTS.md` make sense? * The `paths` frontmatter thinge feels like it possibly should be split off into it's own feature and supported in instructions as well, but I'm not totally sure.
yindo added the discussion label 2026-02-16 18:05:28 -05:00
yindo closed this issue 2026-02-16 18:05:28 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 19, 2026):

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

  • #6316: Context Auto-Discovery: Load AGENTS.md from Directories When Accessing Files
  • #7576: Auto-selection of nested AGENTS.md based on file/directory context
  • #7361: Auto-inject subdirectory CLAUDE.md files on read operations
  • #4716: Setting Glob-based rules
  • #9211: Advanced Dual-Scope Memory System for OpenCode

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 19, 2026): This issue might be a duplicate of existing issues. Please check: - #6316: Context Auto-Discovery: Load AGENTS.md from Directories When Accessing Files - #7576: Auto-selection of nested AGENTS.md based on file/directory context - #7361: Auto-inject subdirectory CLAUDE.md files on read operations - #4716: Setting Glob-based rules - #9211: Advanced Dual-Scope Memory System for OpenCode Feel free to ignore if none of these address your specific case.
Author
Owner

@bailey-busc commented on GitHub (Jan 19, 2026):

Github issue search sucks ass, I'll just discuss my implementation in #6316

@bailey-busc commented on GitHub (Jan 19, 2026): Github issue search sucks ass, I'll just discuss my implementation in #6316
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6867