[FEATURE] Rule precedence explainer — show which CLAUDE.md/rule layer won and why
Summary
Claude Code supports layered instruction files — global ~/.claude/CLAUDE.md, project-level CLAUDE.md, language/framework-specific rule files, plugin/skill instructions — but there's no way to ask "which instruction actually took effect just now, and why did it win over the others?" when two layers conflict. Please add a debug command/view that explains rule precedence for a given decision.
Current behavior
With a global CLAUDE.md, a project CLAUDE.md, and several language-specific rule files all potentially addressing the same topic (e.g. commit message format, error handling style, testing requirements) at different specificity levels, there is no way to inspect which one actually governed a given response. If the output doesn't match what you expected, you're left manually diffing multiple files and guessing at precedence rather than being told directly.
Motivation
Layered instruction systems (global → project → language-specific → skill/plugin) are common practice (my own setup: ~/.claude/rules/common/*.md overridden by ~/.claude/rules/<language>/*.md, plus a project CLAUDE.md, plus whatever skills/plugins are active in a given session). When something doesn't behave as instructed, the first debugging question is always "which file's rule actually applied here?" — and today that requires manual archaeology across every layer instead of the tool just saying so.
Proposed behavior
- A command (e.g.
/rulesor/why) that, given a topic or a recent response, lists every instruction source that was loaded (global CLAUDE.md, project CLAUDE.md, active skill/plugin instructions, rule files) and which one's directive on that topic actually took precedence. - Where two loaded sources conflict outright, flag the conflict explicitly rather than silently picking one.
- Should work retroactively on a specific turn ("why did you do X instead of Y") as well as proactively ("show me all currently active instructions on topic Z").
Why it matters
- Turns "why isn't Claude following my rule" from manual file-diffing into a direct answer.
- Makes layered CLAUDE.md/rules setups (increasingly common as teams standardize instructions across many repos) actually debuggable instead of opaque.
- Reduces wasted turns where the user re-explains a rule that was already stated somewhere, but got silently overridden by a more specific (or less specific, depending on the bug) file.
Related issues (adjacent, not duplicates)
- #6235
Feature Request: Support AGENTS.md— adjacent (instruction-file format), different ask (a new file format vs. precedence transparency for existing ones) - #68636
[FEATURE] Exempt CLAUDE.md from compaction— adjacent (CLAUDE.md handling), different concern (compaction vs. precedence)
Notes
- Reviewed for duplicates before filing (searched "CLAUDE.md rules conflict precedence explain which wins") — nothing found describing this specific precedence-explainer ask as of 2026-07-19.