講座 › 分野3 Claude Codeの設定とワークフロー
3.3 パス固有ルール
配点 3.3%Path-specific rules
ルールにパスの条件を付けると、該当するファイルを扱うときだけ読み込まれる。文脈を無駄にしない。
未読
ルールに、対象のファイルを書く 読了

.claude/rules/ の各ファイルの先頭に、paths という項目を書くと、そのパターンに合うファイルを扱うときだけ、ルールが効きます。パスの指定がないルールは、起動時に毎回読み込まれます。
出典:How Claude remembers your project
Rules can be scoped to specific files using YAML frontmatter with the paths field. These conditional rules only apply when Claude is working with files matching the specified patterns.https://code.claude.com/docs/en/memory.md(取得 2026-11-20)
出典:How Claude remembers your project
Rules without paths frontmatter are loaded at launch with the same priority as .claude/CLAUDE.md.https://code.claude.com/docs/en/memory.md(取得 2026-11-20)
いつ読み込まれるか 読了

パスの条件つきのルールは、該当するファイルを読む・書く・編集するときに読み込まれます。関係のない作業の間は文脈に入らないので、トークンの節約になります。
出典:How Claude remembers your project
A path-scoped rule loads when Claude uses the Read, Write, or Edit tool on a matching file.https://code.claude.com/docs/en/memory.md(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
How path-scoped rules load only when editing matching files, reducing irrelevant context and token usagehttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
グロブのパターンの書き方 読了

拡張子、ディレクトリ、またはその組み合わせで、対象を指定できます。たとえば **/*.test.tsx と書けば、置き場所にかかわらず、すべてのテストファイルが対象です。
出典:How Claude remembers your project
Use glob patterns in the paths field to match files by extension, directory, or any combinationhttps://code.claude.com/docs/en/memory.md(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Using glob patterns in path-specific rules to apply conventions to files by type regardless of directory location (e.g., **/*.test.tsx for all test files)https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
フォルダー別の CLAUDE.md との違い 読了

テストのファイルがあちこちのフォルダーに散らばっていると、フォルダーごとの CLAUDE.md では、全部に同じ文を置くことになります。パターンで指定するルールなら、散らばったファイルにまとめて適用できます。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The advantage of glob-pattern rules over directory-level CLAUDE.md files for conventions that span multiple directories (e.g., test files spread throughout a codebase)https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Choosing path-specific rules over subdirectory CLAUDE.md files when conventions must apply to files spread across the codebasehttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
一部にだけ要る指示は、パスつきのルールへ 読了

コードベースの一部にしか関係しない指示は、常に読み込まれる CLAUDE.md から、パスつきのルールに移します。全体の文脈が軽くなります。
出典:How Claude remembers your project
Move instructions that matter for only part of the codebase into path-scoped rules, which load only when Claude works with matching files.https://code.claude.com/docs/en/memory.md(取得 2026-11-20)
試験のポイント
- paths にグロブを書くと、該当するファイルを扱うときだけ読み込まれる。
出典:How Claude remembers your project
Rules can be scoped to specific files using YAML frontmatter with the paths field. These conditional rules only apply when Claude is working with files matching the specified patterns.
https://code.claude.com/docs/en/memory.md(取得 2026-11-20) - 散らばったファイルの規約は、フォルダー別の CLAUDE.md ではなくパス指定のルール。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Choosing path-specific rules over subdirectory CLAUDE.md files when conventions must apply to files spread across the codebase
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - 一部にしか要らない指示は、全体の CLAUDE.md から外す。
出典:How Claude remembers your project
Move instructions that matter for only part of the codebase into path-scoped rules, which load only when Claude works with matching files.
https://code.claude.com/docs/en/memory.md(取得 2026-11-20)