Skip to content

CCAR-F · Domain 3: Claude Code Configuration & Workflows · 20% of the exam

Task 3.3: Apply path-specific rules for conditional convention loading

Rules in .claude/rules/ with paths globs that load only when Claude works on matching files, and why they beat subdirectory CLAUDE.md files for conventions spread across the tree.

Study it

  • Path-specific rules with paths globs

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.

Question 1 · choose 1

Database migration files named *.migration.sql live inside each of 25 service folders in your repository. They must follow the same naming and rollback conventions, which matter only when Claude is working on those files. What is the most maintainable way to apply the conventions?

  1. AA reminder in the pull request template asking reviewers to check migration conventions
  2. BA .claude/rules/migrations.md rule file whose YAML frontmatter sets paths to "**/*.migration.sql"
  3. CA migrations section in the root CLAUDE.md, so that Claude always knows the conventions in every session
  4. DA CLAUDE.md file in each of the 25 service folders that repeats the migration conventions
Show the answer and why
  • AA reminder in the pull request template asking reviewers to check migration conventions

    Incorrect

    Review catches problems after the code is written; the conventions should guide Claude while it writes the files.

  • BA .claude/rules/migrations.md rule file whose YAML frontmatter sets paths to "**/*.migration.sql"

    Correct

    A path-scoped rule loads only when Claude works on matching files, wherever they are in the tree.

  • CA migrations section in the root CLAUDE.md, so that Claude always knows the conventions in every session

    Incorrect

    Always-loaded text spends context in every session, including the many that never touch a migration.

  • DA CLAUDE.md file in each of the 25 service folders that repeats the migration conventions

    Incorrect

    Directory-bound files have to be duplicated in every folder and loaded for unrelated work in those folders too.

For conventions that follow a file type across many directories, use a .claude/rules/ file with a paths glob. It loads only when matching files are read or edited, so it costs nothing elsewhere.

Question 2 · choose 2

Your project has .claude/rules/security.md with no frontmatter and .claude/rules/frontend.md whose frontmatter sets paths to "src/web/**/*.tsx". Which TWO statements describe how Claude Code loads them? (Choose TWO.)

  1. Afrontend.md stays off until a developer turns it on for the session with the /memory command
  2. BBoth rule files load only when they are imported from CLAUDE.md with an @path line
  3. Csecurity.md loads at launch in every session, with the same priority as the project's .claude/CLAUDE.md
  4. Dfrontend.md loads once Claude reads, writes or edits a file that matches its glob
  5. EThe paths value is read as a regular expression, so the pattern has to escape the dots in .tsx
Show the answer and why
  • Afrontend.md stays off until a developer turns it on for the session with the /memory command

    Incorrect

    No command switches a path-scoped rule on; matching files trigger it.

  • BBoth rule files load only when they are imported from CLAUDE.md with an @path line

    Incorrect

    Files in .claude/rules/ are discovered automatically; they do not need to be imported.

  • Csecurity.md loads at launch in every session, with the same priority as the project's .claude/CLAUDE.md

    Correct

    Rules without a paths field are loaded unconditionally at the start of the session.

  • Dfrontend.md loads once Claude reads, writes or edits a file that matches its glob

    Correct

    Path-scoped rules load on demand when Claude works with matching files.

  • EThe paths value is read as a regular expression, so the pattern has to escape the dots in .tsx

    Incorrect

    paths takes glob patterns such as **/*.ts, not regular expressions.

Rules in .claude/rules/ are discovered automatically. Without paths they load at launch; with a paths glob they load when Claude reads, writes or edits a matching file.

Question 3 · choose 1

A rule scoped to "**/*.sql" loaded even though Claude never used the Read tool on a SQL file; it had only run cat on one through Bash. A teammate calls this a bug. What is accurate?

  1. AIt is a bug; only the Read tool should ever trigger path rules
  2. BThe rule loaded because .sql rules are always global
  3. CViewing the file with cat counts as a read, so the rule loads
  4. DPath-scoped rules load for any Bash command in the session
Show the answer and why
  • AIt is a bug; only the Read tool should ever trigger path rules

    Incorrect

    The documented behavior includes recognized Bash reads.

  • BThe rule loaded because .sql rules are always global

    Incorrect

    File type does not make a rule global.

  • CViewing the file with cat counts as a read, so the rule loads

    Correct

    Path-scoped rules also load when a single file is viewed with a recognized Bash read command.

  • DPath-scoped rules load for any Bash command in the session

    Incorrect

    Only reads of matching files trigger them.

A single-file Bash read such as cat or head on a matching file counts as a read for path-scoped rules.

Question 4 · choose 1

After running /compact in a long session, a developer notices that Claude no longer seems aware of the conventions in a path-scoped rule for *.graphql files. What happens to such rules after compaction?

  1. AThey reload the next time Claude touches a matching file
  2. BThey become global and load in every later turn
  3. CThey are deleted from the project and must be recreated
  4. DThey load again only after Claude Code is restarted
Show the answer and why
  • AThey reload the next time Claude touches a matching file

    Correct

    Path-scoped rules reload when a matching file is touched again after compaction.

  • BThey become global and load in every later turn

    Incorrect

    Their paths scoping still applies.

  • CThey are deleted from the project and must be recreated

    Incorrect

    Compaction affects context, not files.

  • DThey load again only after Claude Code is restarted

    Incorrect

    A restart is not required.

The project-root CLAUDE.md is re-injected after compaction, while nested CLAUDE.md files and path-scoped rules load again on demand.

Question 5 · choose 1

Your .claude/rules/ folder has grown to 30 files, some with paths frontmatter and some without. You want to group them into frontend/ and backend/ subfolders without changing how any of them load. What happens after the move?

  1. AThey load only once Claude works on files inside .claude/rules/frontend/ or backend/
  2. BThey load only if an index.md in .claude/rules/ imports each subfolder
  3. CThey stop loading, because rules must sit directly in .claude/rules/
  4. DThey load as before: .md files are discovered recursively, and each keeps its own paths frontmatter
Show the answer and why
  • AThey load only once Claude works on files inside .claude/rules/frontend/ or backend/

    Incorrect

    Rule subfolders are just organization; loading still depends on each file's own paths field, not on the folder name.

  • BThey load only if an index.md in .claude/rules/ imports each subfolder

    Incorrect

    No index or import is needed; the folder is searched as a whole.

  • CThey stop loading, because rules must sit directly in .claude/rules/

    Incorrect

    Subdirectories are supported.

  • DThey load as before: .md files are discovered recursively, and each keeps its own paths frontmatter

    Correct

    Rules can be organized into subdirectories, and scoped and unscoped rules behave as they did.

All .md files under .claude/rules/ are discovered recursively, so you can organize rules into subfolders such as frontend/ and backend/. Each file's paths frontmatter, or its absence, still decides when it loads.

Question 6 · choose 1

You symlink a shared company rules directory, stored outside the repository, into .claude/rules/shared. In the next interactive session the shared rules do not take effect at first. What does Claude Code require?

  1. AListing the symlink in .mcp.json
  2. BYour approval of external imports for the project
  3. CCopying the files instead, since symlinks are not supported
  4. DRenaming the files so that they end in .rule
Show the answer and why
  • AListing the symlink in .mcp.json

    Incorrect

    MCP configuration has nothing to do with rules.

  • BYour approval of external imports for the project

    Correct

    Symlinks pointing outside the working directory are treated like external imports and wait for approval.

  • CCopying the files instead, since symlinks are not supported

    Incorrect

    .claude/rules/ supports symlinks.

  • DRenaming the files so that they end in .rule

    Incorrect

    Rules are markdown files.

Shared rules can be symlinked into .claude/rules/; links that resolve outside the working directory need external-import approval before they load.

Question 7 · choose 1

Your Next.js app keeps localized pages under app/[locale]/, and a rule file in .claude/rules/ should load only for them. Its frontmatter has paths: ["app/[locale]/**/*.tsx"], but the rule never loads when Claude edits those pages. What should you change?

  1. AEscape the brackets, as in 'app/\[locale\]/**/*.tsx', so that they match literally
  2. BUse single quotes around the pattern in the YAML instead of double quotes
  3. CWrite the pattern as a regular expression, such as app/\[locale\]/.*\.tsx$
  4. DUse "**/*.tsx" instead, which also covers the localized pages
Show the answer and why
  • AEscape the brackets, as in 'app/\[locale\]/**/*.tsx', so that they match literally

    Correct

    In a glob, [locale] is a bracket expression that matches one character; escaping the brackets matches the folder's literal name.

  • BUse single quotes around the pattern in the YAML instead of double quotes

    Incorrect

    Quoting style changes how YAML reads the string, not how the glob interprets the brackets.

  • CWrite the pattern as a regular expression, such as app/\[locale\]/.*\.tsx$

    Incorrect

    paths takes glob patterns, not regular expressions.

  • DUse "**/*.tsx" instead, which also covers the localized pages

    Incorrect

    That loads the rule for every .tsx file in the project, not only the localized pages.

Glob syntax treats [ as the start of a bracket expression, so a folder named [locale] does not match itself. Escape the bracket to match it literally; an invalid bracket pattern matches nothing while the rule's other patterns keep working.

Practise domain 3 →Practise all domains →