Skip to content
Claude Certified Architect – Foundations (CCAR-F) Exam Prep

Lesson 15 of 30 · 6 min

x
15/30

Path-Specific Rules

Video lesson: CCAR-F 15/30: Path-Specific Rules

The mechanism

Put one-topic Markdown files in .claude/rules/ (discovered recursively, so subfolders like frontend/ work). A rule without a paths field loads unconditionally. A rule with paths is conditional:

1---2paths:3  - "src/api/**/*.ts"4---5# API Development Rules6- All API endpoints must include input validation

It loads when Claude uses Read, Write or Edit on a matching file (also when a Bash command counts as a read).

Glob patterns

PatternMatches
**/*.tsAll TypeScript files anywhere
src/**/*Everything under src/
*.mdMarkdown files in the project root
src/components/*.tsxComponents in one directory
src/**/*.{ts,tsx}Brace expansion for several extensions

paths takes a YAML list or a comma-separated string. paths is the only frontmatter field Claude Code reads on a rule; others are ignored. Invalid YAML makes it load as if it had no paths (check with claude --debug).

Related locations

  • User-level rules: ~/.claude/rules/ apply to every project.
  • Shared rules: symlinks into .claude/rules/ are supported (approval is asked once per project).

When to use which mechanism (design guidance)

SituationUse
Applies to the whole repoRoot CLAUDE.md
Applies to one directory and its teamA CLAUDE.md in that directory (loads on demand)
Applies to a file type scattered across directories (all tests, all *.tsx).claude/rules/ with paths globs
A multi-step procedureA skill

Path-scoped rules shine when conventions follow file type, not folder: a directory CLAUDE.md cannot express "all *.test.ts files wherever they live".

Exam traps

  • A directory CLAUDE.md for conventions that span many directories.
  • Expecting a path rule to load at launch. It loads when matching files are touched.
  • Unquoted or malformed globs.
  • Assuming extra frontmatter fields do something.

References

  1. How Claude remembers your project — checked Oct 16, 2026

Check your understanding

  • Test conventions for **/*.test.ts across the whole monorepo. Mechanism?Show answer

    Answer

    .claude/rules/testing.md with paths: ["**/*.test.ts"].
  • Does a path rule load at session start?Show answer

    Answer

    No, when Claude reads, writes or edits a matching file.
  • Brace expansion for .ts and .tsx?Show answer

    Answer

    src/**/*.{ts,tsx}.
Previous

Progress is saved in this browser.

Next Lesson