Writing a context rule's constraint operand
A context rule's file pattern decides which files it applies to. Its constraints decide what is checked in those files, and each constraint names one thing: the operand.
An operand is matched literally against your source, as text. So an operand only works if it is something that actually appears in code.
| Constraint | Operand | Fires when |
|---|---|---|
forbidden | mustNotUse | the text is present |
required | mustUse | the text is absent |
allowOnlyIn | element | the text is present outside the allowed paths |
Write code, not a description
These are operands, because each one occurs in a file:
bg-gradient-to-, a utility class prefixCard, a component name@legacy/ui, an import path[data-theme], a CSS attribute selectorwindow.alert
These are descriptions, and cannot be operands:
visible labelseverity orderingplaceholder-only labelhardcoded agency hex
The difference is not style. No file contains the characters visible label in that order, so the check has nothing to find, and what happens next depends on the constraint type. A forbidden rule written this way never fires, which looks exactly like a rule that passes. A required rule written this way can never be satisfied, so every file the pattern selects reports a violation.
Either way the rule is not doing what its author intended, and nothing in the result says so.
Say it in the description instead
A requirement that cannot be reduced to a string in code is still worth recording. Put it in the rule's description, which is shown to coding agents along with the rule and carries the rule's file pattern with it. A rule can have a description and no constraints: it then guides without gating, which is honest about what it can enforce.
What a rule will not accept
Saving a rule is refused when an operand:
- contains a space or any other whitespace, which is the usual sign that a description was written where code was meant
- is empty, or only whitespace
- is not text, for example a number or a list where a single value belongs
- contains
*,?,{or}
It is also refused when the constraint's type is not one of the four in the table above. suggested used to be a fifth and no longer is, so a rule that still names it is refused with "is not a constraint type any decoder handles".
The last one catches a path scope written in the wrong place. --nys-color-theme-* tokens looks like it would match a family of tokens, but an operand is not a pattern, so it matches nothing. A path scope belongs in the rule's file pattern, where wildcards do work. See Writing a context rule's file pattern.
Punctuation that occurs in real code is accepted, so [data-theme], @legacy/ui and bg-gradient-to- all save normally.
When a rule is refused, the message names every operand at fault and why, so one correction fixes the whole rule rather than meeting the next problem on the next attempt. Generating rules from your patterns follows the same check: a generated rule whose operand cannot be read is withheld and listed as omitted, rather than saved in a state that cannot work.
Changed in October 2026
Operands used to be accepted as written, including descriptions, so a rule could be saved in a state where it could never fire or could never pass. They are now checked when a rule is created, edited, duplicated or accepted from a generated batch.
suggested was retired as a constraint type. It required a component the way required does, and differed only in reporting a warning instead of an error, so nothing enforced it and no design system was using it. If you have a rule that still names it, the rule keeps working and its other constraints keep firing; the suggested constraint reports nothing, and editing that rule will ask you to remove or change it. To keep a recommendation without enforcing it, write it as required and set the rule's enforcement to advisory, which reports it without asking anyone to change code.
Ten existing constraints that were written as descriptions were retired at the same time, across four rules. Their rules remain, with their file patterns, suggested presets and descriptions intact, so the guidance is still carried to agents. Three of those rules now have no constraints and gate nothing, which is what they were doing before, now stated plainly rather than implied.