Skip to main content
Auto-apply rules automatically scan user messages and apply labels with extracted values. Configure regex patterns on any label to trigger automatic tagging — no manual work needed. For example, paste a Linear issue URL and the session gets auto-tagged with the issue key. Mention a dollar amount and a budget label appears.

Configuration

Add autoRules to any label in your labels/config.json:

Rule Properties

PropertyTypeRequiredDescription
patternstringYesRegex with capture groups. Uses JavaScript regex syntax.
flagsstringNoRegex flags (default: gi — global, case-insensitive). g is always enforced.
valueTemplatestringNoTemplate using $1, $2 for capture group substitution. If omitted, uses first capture group.
descriptionstringNoHuman-readable description of what this rule matches.

Regex Patterns

Rules use JavaScript regular expressions with capture groups:
  • Capture groups: $1, $2, etc. are replaced with matched groups in valueTemplate
  • Global matching: The g flag is always enforced, so all occurrences in a message are found
  • Multiple matches: "CRA-1 and CRA-2" produces two label entries on the same label

Evaluation Behavior

Rules run when a user message is sent (both fresh messages and queued messages). Only user messages are scanned — assistant output and tool results are not.
Content inside fenced code blocks (```) and inline code (`) is stripped before evaluation. This prevents false matches on code examples.
The same label+value combination won’t be added twice to a session. If "linear-issue::CRA-123" already exists, mentioning CRA-123 again is a no-op.
Maximum 10 matches per message to prevent label explosion from pasted data (e.g., a log file with hundreds of issue keys).
All rules on a label are evaluated. All matches across all rules are collected and applied.
Invalid regex patterns are skipped at runtime and logged as warnings. Patterns are also validated at config-save time.

Value Normalization

Extracted values are normalized based on the label’s valueType:
valueTypeRaw CaptureNormalized
stringCRA-123CRA-123 (pass-through)
number$45,00045000 (strip symbol + commas)
number1.5M1500000 (expand suffix)
number50k50000 (expand suffix)
date2026-01-302026-01-30 (pass-through)

Full Example

A workspace that auto-tags Linear issues, deadlines, contacts, and budgets:
With this config:
  • Pasting https://linear.app/team/issue/CRA-456 adds linear-issue::CRA-456
  • Typing deadline is 2026-03-15 adds deadline::2026-03-15
  • Mentioning reach out to alice@example.com adds contact::alice@example.com
  • Writing budget is $50k adds budget::50000

Validation

Always validate after creating or editing auto-rules. Invalid regex patterns (including ReDoS-vulnerable patterns) are rejected at save time.