Skip to main content

Writing a context rule's file pattern

A context rule applies only to files whose path matches its file pattern. The same pattern decides where the build gate checks the rule, where coding agents are told about it, and which reviewer signals list it for a file, so a pattern selects the same files in all three places.

Paths are matched relative to the root of your repository, for example apps/web/src/pages/settings.tsx.

Syntax

WriteMatchesExample
**any run of characters, across foldersapps/web/** matches every file under apps/web
*any run of characters inside one folder or file name**/*Modal.tsx matches components/credits/BuyCreditsModal.tsx
?exactly one character inside a name**/v?.ts matches api/v1.ts
{a,b}either alternative**/{components/studio/**,pages/*-studio.tsx} matches both locations

Everything else is matched literally, including ., (, ), [ and ], so Next.js route groups such as app/(admin)/** and dynamic segments such as pages/[slug].tsx work as written. Matching is case-sensitive.

Alternatives can nest ({a,{b,c}}), and one can be empty: **/Button{,Group}.tsx matches both Button.tsx and ButtonGroup.tsx. A brace pair with no comma, such as {a}, is literal. A pattern that expands to more than 1,024 alternatives is rejected and matches nothing.

The pattern must match the whole path

A pattern has to match the entire path from the repository root, not a piece of it. In a monorepo, src/components/** does not match apps/web/src/components/Button.tsx, because that path starts with apps/. Start the pattern with **/ to match at any depth: **/src/components/**.

**/ needs at least one folder in front of what follows it. **/studio/** matches apps/web/src/components/studio/Tabs.tsx but not a top-level studio/Tabs.tsx. Use ** on its own to match every file.

Common mistakes

  • Guessing folder names. **/forms/** matches nothing if your forms live in components/settings/. Check your repository layout before you write the pattern. A rule whose pattern matches no files never produces a finding, which looks exactly like a rule that passes.
  • Starting from src/ in a monorepo. See the section above.
  • Expecting a name wildcard to cover a folder's contents. **/*alert* matches files whose own name contains alert, not every file inside an alert folder. For that, write **/*alert*/**.

Changed in September 2026

Agent guidance used to match file patterns more loosely than the build gate, so an agent could be told about a rule for a file the gate never checked it against. Both now use the same matcher. If a rule stops appearing in agent guidance for a file, that file was never covered by the rule at the gate either. Brace alternatives ({a,b}) and ? also became available at the same time.

Reviewer signals (get_reviewer_signals_for_file) followed with the same rules. They used to let **/ match zero folders, so a pattern such as **/* listed its rule for top-level files like README.md that the gate never checks. Those files no longer receive it. Brace alternatives and route groups such as app/(admin)/** now select the same files in reviewer signals as at the gate.

Was this page helpful?

Last reviewed by @jschuyler
All systems operationalDocsDevelopersPlatformPricing
PrivacyTerms© 2026 fndd, LLC