CLAUDE ENGINEERING · LESSON 193 OF 278

Instruction Hierarchy, Imports, and .claude/rules

Understand user, project, local, nested, and path-scoped Claude instructions and how large repositories should organize them.

What you will learn

Understand user, project, local, nested, and path-scoped Claude instructions and how large repositories should organize them.

In simple words

Claude Code can load instructions at organization, user, project, local, and nested scopes. Imports reduce duplication, while .claude/rules can keep domain-specific guidance modular and conditionally relevant.

Visual explanation: Instruction Hierarchy, Imports, and .claude/rules

Trace how Broad rules becomes Relevant guidance through scoped instructions.

WATCH THE IDEA

Instruction Hierarchy, Imports, and .claude/rules

Playing
Broad rulesScoped instructionsRelevant guidance
  1. 1Observe: Broad rules
  2. 2Transformation: Scoped instructions
  3. 3Outcome: Relevant guidance

Observe: Broad rules. Trace how Broad rules becomes Relevant guidance through scoped instructions.

The diagram highlights Broad rules, Scoped instructions, Relevant guidance. Use the labels to trace the main relationship from left to right.

Real-world example: Operational AI decision

A team applies instruction hierarchy, imports, and .claude/rules to a real business workflow.

What the team decides: Instruction scope should match code scope so context stays precise instead of noisy.

Risk to avoid: A strong technical concept still needs measurement, safeguards, and ownership in production.

Technical explanation

Claude Code can load instructions at organization, user, project, local, and nested scopes. Imports reduce duplication, while .claude/rules can keep domain-specific guidance modular and conditionally relevant.

Python and implementation examples

Use these examples to connect the concept to working code. Package-based examples assume the named library is installed in your own environment.

Path-scoped rule concept

text
---
paths:
  - "src/api/**/*.ts"
---

# API rules
- Validate every request body.
- Keep authorization checks on the server.
- Never return secrets or raw internal errors.

Scoped rules reduce context noise by loading specialized guidance only for relevant files.

Common misconception

This concept is not a guarantee of a correct outcome by itself. Its value depends on suitable evidence, careful implementation, and evaluation against the real task.

QUICK QUIZ

Why use path-scoped rules?

Practical application

Instruction scope should match code scope so context stays precise instead of noisy.

Key takeaway

Instruction scope should match code scope so context stays precise instead of noisy.

Next concept

Continue with CLAUDE.md and AGENTS.md Interoperability.

Engineering view

Instruction scope should match code scope so context stays precise instead of noisy.

Internals view

Understand user, project, local, nested, and path-scoped Claude instructions and how large repositories should organize them. Claude Code can load instructions at organization, user, project, local, and nested scopes. Imports reduce duplication, while .claude/rules can keep domain-specific guidance modular and conditionally relevant.

Architecture view

Consider the Broad rules → Scoped instructions → Relevant guidance flow, and make the system's inputs, checks, and outcomes explicit.

Was this lesson helpful?

Lesson discussion

Comments are reviewed before publication. Keep discussion focused on learning and do not post private information.

Loading discussion…

Your quiz answer and current lesson are saved on this device. Sign in to explore account-backed learning features.

Content version 1 · Last reviewed 2026-10-16