Skip to content

Guardrail Rule Builder

Write block, flag, redact and require rules in a one-line-each syntax, run them against your own sample text, and export the JavaScript and Python that enforces them.

Samples blocked
2 of 4

1 flagged, 1 allowed through. A rule set is only as good as the sample it disagrees with you about, so put the awkward cases in the box above.

Rules parsed
6
Rules refused as unsafe to run
0
Lines that did not parse
0
Samples with something redacted
2
Samples tested
4
Every sample, and what fired on it:
  • 1. ALLOWED — "Your refund is on its way. Sources: order #4821." — no rule fired
  • 2. BLOCKED — "Sure — the key is sk-ABCDEFGHIJKLMNOPQRSTUVWX and the accoun…" — block at character 18 (line 2: looks like a leaked API key); redact at character 65 (line 3: a nine-digit id in the answer)
  • 3. BLOCKED — "As an AI language model, I cannot help with that." — flag at character 0 (line 5: the boilerplate refusal opening); require at character 0 (line 7: every answer must cite its sources)
  • 4. FLAGGED — "Email [email protected] if it has not arrived. Sources…" — redact at character 6 (line 4: an email address in the answer)
What this assumes: every rule is tested against the ORIGINAL text and the redactions are applied to a separate copy, so one rule cannot hide a later rule's evidence by rewriting the thing it was looking for. A regex whose shape can backtrack catastrophically is refused rather than run: your filter executes on your own request path, so a pattern that takes a second on a hostile string is an outage you wrote yourself. require fires when its matcher does NOT match. Matching is done by JavaScript's regex engine here and Python's in the generated code, and the two differ on lookbehind and named groups. Everything on this page runs in your browser. Nothing you paste is uploaded, logged or sent anywhere.

Guardrails fail in two directions and only one of them is visible. A rule that misses something reaches you as an incident; a rule that fires on ordinary text reaches you as nothing at all, because the user whose legitimate question was blocked does not file a ticket, they leave. That asymmetry is why the sample box above matters more than the rule box: the interesting text is the text you expect to pass, and a rule set you have only tested on the thing you were trying to catch has been tested in one direction.

Where each rule belongs

Input rules are free and fast — they run before you spend anything, so a request that was never going to be acceptable costs nothing. Output rules are the ones that catch what the model produced, and they run after you have already paid for the tokens. Length is nearly always an input rule. Leaked-credential patterns are nearly always output rules. Anything expensive belongs on whichever side has fewer calls.

Why a pattern gets refused here

A filter runs on your request path, synchronously, while other work waits behind it. A regular expression with a repeat inside a repeat can take exponential time on a string a user chooses, which turns your safety rule into a way of taking your service down. The check above is structural — it names the shape and the offset rather than timing anything — and a rule it refuses is reported rather than quietly skipped, because a rule you believe is protecting you and is not is worse than no rule.

Guardrail Rule Builder · Multigrid