Skip to main content

Operator Reference

Each operator defines how a field value is compared against a pattern string.

String operators

CONTAINS

Substring match. Case-sensitive.

IF command CONTAINS "rm -rf"

Matches: sudo rm -rf /tmp, rm -rf ., echo rm -rf

EQUALS

Exact string match.

IF tool EQUALS "Bash"

Matches only the exact string Bash.

STARTS_WITH

Prefix match.

IF command STARTS_WITH "git "

Matches: git status, git push. Does not match: echo git.

ENDS_WITH

Suffix match.

IF path ENDS_WITH ".env"

Matches: .env, src/.env. Does not match: .env.local.

Pattern operators

GLOB

Shell-style glob patterns.

IF path GLOB "src/**/*.test.ts"
  • * — matches any characters except /
  • ** — matches any characters including /
  • ? — matches a single character

REGEX

Regular expression (JavaScript syntax).

IF command REGEX "npm install\\s+\\S+@\\^"

Safety limits:

  • Max pattern length: 500 characters
  • Nested quantifiers blocked (ReDoS prevention)
  • Invalid patterns fail-secure (match, triggering the rule)

WORD

Word-boundary match without regex overhead. O(n) linear scan.

IF command WORD "rm"

Matches rm -rf and sudo rm file but not format or inform.

Line-aware operators

These operators process the field value line-by-line and strip // comments before matching. Useful for code content analysis.

LINE_CONTAINS

Per-line substring match after stripping // comments.

IF content LINE_CONTAINS "console.log"

Matches console.log("hello") but not // console.log("debug").

LINE_REGEX

Per-line regex match after stripping // comments.

IF content LINE_REGEX "@ts-ignore"

Matches // @ts-ignore only if @ts-ignore appears in the non-comment portion. Strips // comments first, so // @ts-ignore as a standalone comment would be stripped to empty.

Numeric size operators

These operators compare the size of a field value against an integer threshold. The right-hand side must be a quoted decimal integer. A non-numeric value never matches (fail-open: no spurious block).

Size is measured as the UTF-8 byte length of the field string. The TOKENS variants divide that byte count by 4 (a deterministic approximation of roughly 4 characters per token), so the threshold is expressed in estimated tokens rather than bytes.

LENGTH_GT

Matches when the field's UTF-8 byte length is strictly greater than N.

IF content LENGTH_GT "10000"

Useful for blocking or logging unexpectedly large file writes.

LENGTH_LT

Matches when the field's UTF-8 byte length is strictly less than N.

IF content LENGTH_LT "1"

TOKENS_GT

Matches when the estimated token count (byte-length / 4) is strictly greater than N.

IF content TOKENS_GT "2000"

Useful for capping how much content an agent pastes into a single write.

TOKENS_LT

Matches when the estimated token count (byte-length / 4) is strictly less than N.

IF content TOKENS_LT "1"

Notes for numeric operators:

  • The threshold value must be a decimal integer with no surrounding whitespace inside the quotes, or leading/trailing spaces are trimmed automatically. Non-numeric values (e.g. "15000x") never match.
  • Size operators do not route through the regex NFA engine, so the REGEX pattern-length cap and nested-quantifier guard do not apply.
  • NOT LENGTH_GT "N" is equivalent to LENGTH_LT "N+1" but more readable for allowlist rules.

NOT modifier

All operators support negation:

IF command NOT CONTAINS "echo"
IF path NOT GLOB "*.test.ts"
IF tool NOT EQUALS "Read"

NOT inverts the match result. Useful for allowlists:

rule only-allow-echo {
enabled true
DENY execution
IF command NOT STARTS_WITH "echo"
MESSAGE "Only echo commands allowed."
}