SpecMatter field notes

Claude Code / project instruction field notes

Claude Code Rules: CLAUDE.md, path scopes, and conflicts

Short answer: put repository-wide instructions in a project CLAUDE.md or .claude/CLAUDE.md. Split focused guidance into Markdown files under .claude/rules/. A rule without paths applies broadly; a rule with paths is documented to load when Claude reads a matching file. Keep rules concrete, non-contradictory, and small enough to audit. Do not claim a rule was applied unless a session shows it.

We created an isolated rule with marker RULES-LOCAL-9274 and path scope src/**/*.js. The file exists and the CLI reached the authentication boundary, but no InstructionsLoaded event was recorded and no model response was produced. Rule discovery and application are therefore marked untested, not inferred from the file structure.

A repository tree routes matching project rule documents to source files and records the matches in an audit log
Path-scoped rules should follow matching files. This mechanism is documented; the isolated fixture did not authenticate far enough to verify it locally.

Fixture: Windows 11, Claude Code 2.1.283, 2026-09-27. No login, no API key, zero model tokens, zero cost.

Choose the instruction surface by scope

SurfaceBest useLoading boundary
Project CLAUDE.mdRepository-wide commands, architecture facts, and safety rulesLoaded as project instructions for the session
.claude/rules/*.md without pathsModular guidance that applies across the projectDocumented to load at launch with project instructions
.claude/rules/*.md with pathsLanguage, package, or directory-specific guidanceDocumented to load when matching files are read
Nested CLAUDE.mdGuidance local to a subtreeLoaded when Claude works in or reads through that subtree
~/.claude/CLAUDE.md and ~/.claude/rules/Personal preferences across projectsUser scope; keep project facts out of it

A path-scoped rule

---
paths:
  - "src/**/*.js"
---

# Evidence boundary

Marker: RULES-LOCAL-9274

Never describe documentation-derived behavior as a local
runtime result. If a model-backed step was not run, label it untested.

The marker is deliberately not repeated in the prompt. If an authenticated session later quotes it after reading src/example.js, the output can help show that the matching rule entered context. Even then, quoting a marker proves discovery more directly than it proves faithful execution of every rule.

Official documentation warns that invalid YAML frontmatter causes Claude Code to treat a rule as if it had no paths field. A typo can therefore broaden a rule rather than merely disabling it. Use debug output and an InstructionsLoaded hook when auditing path-specific behavior.

What the local attempt actually returned

The session command targeted project settings and asked Claude to read src/example.js. It stopped before model processing:

"terminal_reason":"api_error"
"result":"Not logged in · Please run /login"
"total_cost_usd":0
"input_tokens":0
"output_tokens":0

The configured InstructionsLoaded hook did not create instruction-events.jsonl. That absence does not prove the rule is invalid; it proves only that this unauthenticated attempt produced no captured loading event.

Download the rules test observations (CSV)

What was tested, and what remains untested

ClaimVerdictEvidence
The rule fixture exists at the documented project pathTestedLocal file inspection found .claude/rules/evidence-boundary.md and its unique marker.
The session attempted to start with project settingsTestedThe CLI produced a structured result and stopped at login.
The path-scoped rule loadedUntestedNo InstructionsLoaded record was created.
The model followed the ruleUntestedNo model response occurred.
A conflicting rule resolved in a predictable orderUntestedNo conflict experiment was run.
Do not confuse three layers: a file can exist, be loaded, and still not be followed. Test and report those claims separately.

A conflict audit that can be run later

  1. Put one unique marker and one harmless formatting instruction in the root CLAUDE.md.
  2. Put a different marker and the opposite formatting instruction in a path-scoped rule.
  3. Start a fresh authenticated session and read one matching file and one nonmatching file.
  4. Capture InstructionsLoaded events, the model's stated active instructions, and the produced edit separately.
  5. Repeat after /compact, because root instructions and lazily loaded rules have different reload timing.

Do not put marker values in the prompt, and do not use a production repository for deliberate conflicts. A disposable fixture keeps the result reversible.

FAQ

Are Claude Code rules the same as skills?

No. Rules are persistent project instructions. Skills are reusable task packages invoked when their description or name matches the work.

Does a valid paths glob prove the rule was loaded?

No. The glob describes intended scope. Verify loading with session evidence such as an InstructionsLoaded record and then verify behavior separately.

Why not upgrade just to complete this test?

The owner chose not to purchase a Claude subscription or add an API key. The missing model-backed steps are therefore labeled untested rather than filled with assumptions.

Sources and related field notes

Official documentation checked 2026-09-27. The local fixture and observation CSV are original test records. SpecMatter is not affiliated with Anthropic.