Packs and rules
Choose a guardrail rule pack, add your own pinned by digest, validate it, and change single rules, suppressions and sensitive tools with guardrail.rules.
Three settings decide which rules the guardrail enforces. Use the lightest one that does the job:
| You want to | Use | Key |
|---|---|---|
| Run a different shipped pack | Choose a pack | guardrail.rule_pack |
| Add your own rules, or replace a shipped category | Add your own pack, pinned by digest | guardrail.custom_packs and guardrail.rule_pack |
| Turn a rule off, change its severity, add a suppression or turn on a protection pack | Change the pack you use | guardrail.rules |
All three work at four scopes (global, one connector, one profile, one connector inside a profile). The running gateway applies them on its next reload, with no restart. The levels that go with a pack are on Block and alert levels.
The demo follows one tool call from the hook event to its action: a rule match, the suppression check, the optional judge, then severity and the action the pack gives it.
Guided example · Synthetic runtime event
Trace a runtime verdict from event to action
Follow normalization, a bundled rule match, suppressions, severity, and the default pack mapping.
# ~/.defenseclaw/config.yaml (excerpt)guardrail: mode: action # observe mode never blocks judge: enabled: false # the optional LLM judge is off by default # No block_at is set, so the default pack decides: # CRITICAL blocks, HIGH and MEDIUM alert, LOW allows.# ~/.defenseclaw/config.yaml (excerpt)guardrail: mode: action # observe mode never blocks judge: enabled: false # the optional LLM judge is off by default # No block_at is set, so the default pack decides: # CRITICAL blocks, HIGH and MEDIUM alert, LOW allows.
HIGH maps to alert under the default pack
Emit decision record
What DefenseClaw did — and did not do
What it did
- Show the ordered stages that assemble a runtime verdict
- Distinguish the optional judge from deterministic rules
What it did not do
- Evaluate Rego or scanner output in the browser
- Reuse runtime actions as skill or MCP admission actions
Choose a rule pack
guardrail.rule_pack is a shipped pack (default, strict, permissive) or a key of guardrail.custom_packs.
defenseclaw guardrail use-pack strict # every connector
defenseclaw guardrail use-pack strict --connector codex # one connector
defenseclaw guardrail use-pack --clear --connector codex # back to the global pack
defenseclaw guardrail list-packs # who enforces whichuse-packvalidates the pack first and writes nothing if it is invalid.- A global
use-packremoves per-connectorrule_packentries, and dropsenable,disableandseverity_overridesIDs the new pack does not have. It names each one. This is also the way out when a pack folder was deleted:defenseclaw guardrail use-pack default. - Profiles have no
use-packoption:defenseclaw config set guardrail.profiles.contractors.rule_pack strict. - Pack names are lower case letters, digits,
-and_, at most 64 characters. A folder name with other characters is normalized to this form.
Known limit. An upgrade does not refresh a shipped pack (default, strict or permissive) whose files you edited: the whole edited pack stays, with its older rules. To get the new rules, move the edited folder aside and run defenseclaw init, which seeds the pack again.
The admission preset for skills, MCP servers and plugins is separate: defenseclaw policy activate strict (Presets and packs).
Add your own pack
A custom pack is a folder of rule files you review and pin. config.yaml records its path and content digest, and the gateway refuses to load the pack if the folder no longer hashes to that digest. A rule change reaches enforcement only through a deliberate config change. How to write a rule: Custom rules with CEL.
Copy a pack and edit it
cp -r ~/.defenseclaw/policies/guardrail/default ~/.defenseclaw/policies/guardrail/acme-rulesAdd a rules file with its own category, or edit one.
Validate it
defenseclaw guardrail validate-pack ~/.defenseclaw/policies/guardrail/acme-rulesRule pack valid: "/home/alice/.defenseclaw/policies/guardrail/acme-rules"
rules: 283/287 enabled across 7 files
components: judges=4 judge_categories=23 local_patterns=11 suppressions=9 sensitive_tools=6
digest: 3c6157f8ce099f79ebfa475c3631f8e9334ce929a310630ed2ce66a0fbaa3759
files digest: 8e97ebd6c9627892aa238c7fabc1e7b31f2ae7ab7ceaace892d051efc4fb7bf7 (the guardrail.custom_packs pin)Add --json for CI. See Validate a pack.
Pin it and switch to it
defenseclaw guardrail use-pack acme-rulesguardrail:
rule_pack: acme-rules
custom_packs:
acme-rules:
path: /home/alice/.defenseclaw/policies/guardrail/acme-rules
digest: sha256:<files digest>use-pack takes a pack name under ~/.defenseclaw/policies/guardrail/ or a folder path (./NAME for the current folder). Add --connector X for one connector.
Check it worked
defenseclaw guardrail list-packs
defenseclaw doctordoctor validates the pack each connector uses and shows a Rule pack row per connector.
To undo, defenseclaw guardrail use-pack default; it also removes the pin when no other scope still selects the pack.
A pattern-only rule can block matching prompts and content, but a regex match on a tool call is detection only and never blocks, whatever block_at is. For a tool-call block, write a CEL expression.
On a managed host the Python CLI is not installed. Validate with /opt/defenseclaw/bin/defenseclaw-gateway rulepack validate --dir PACK (/opt/cisco/defenseclaw/bin/defenseclaw-gateway on macOS), which prints the digest to pin, and set rule_pack and custom_packs in the admin config (custom rule packs).
Validate a pack
defenseclaw guardrail validate-pack PATH # or a pack name
defenseclaw guardrail validate-pack PATH --json--json prints one line:
{"kind":"validation","summary":{"alert_only_rule_count":0,"digest":"3c6157f8…","enabled_rule_count":283,"files_digest":"8e97ebd6…","judge_category_count":23,"judge_count":4,"local_pattern_count":11,"rule_count":287,"rule_file_count":7,"sensitive_tool_count":6,"stale_rule_count":0,"suppression_count":9},"valid":true,"wire_version":1}| Exit | Meaning |
|---|---|
0 | The pack is valid. |
1 | The pack is invalid. The output names the file, error code and reason. |
2 | Validation is unavailable (gateway binary missing, untrusted, timed out or incompatible). This does not say whether the pack is valid. |
- All or nothing. If a recognized file is present, the whole file must parse: a malformed rule, an invalid Go regular expression or an unsupported schema version fails the pack. DefenseClaw does not silently discard the bad file or keep only the entries that parsed.
- Unknown files fail. A file the loader does not recognize fails the pack; the reason names it (or the folder, for a copy of another pack inside this one) and says to move it out.
- CEL. Every
expressionis compiled, disabled rules included (CEL engine). - Partial packs. A pack folder is an overlay on the built-in baseline. A missing
suppressions.yaml,sensitive-tools.yaml, judge file orrules/local-patterns.yamlkeeps the baseline. Any otherrules/*.yamladds or replaces one category. judges=4counts the built-in exfiltration judge and the three judge files.
Rule pack invalid: "/home/alice/.defenseclaw/policies/guardrail/bad"
inventory_unexpected at correlation-patterns.yaml: unexpected YAML component: move correlation-patterns.yaml out of the rule-pack folder or remove it, then run the command or installer againThe digest pin
| Line | What it is |
|---|---|
digest: | The loaded pack after compilation, including built-in defaults. It can change between builds. |
files digest: | The pin in guardrail.custom_packs.NAME.digest: a byte-for-byte hash of the pack files. Comments, key order, line endings and a BOM change it. Write it as sha256: and the 64 hex characters. |
The pinned digest also covers the optional defenseclaw-pack.json posture file. Adding or editing that file changes the digest, so validate the pack again and pin the new digest, as for a rule file (pack posture).
A guardrail.custom_packs entry is a config error when its path is empty, unreadable or holds no valid pack, or when its digest is missing or does not match. A relative path is read against the folder of config.yaml; ~ is not expanded. While an entry has an error, a setting that selects it runs the built-in pack of that name (default for any other name), status and doctor name the error, and the hook outage mode follows the strict tier. config set guardrail.custom_packs.NAME saves such an entry but prints is registered but will not load.
Change a pinned pack
If you edit a pinned pack in place, the digest no longer matches and the gateway rejects the change. The previous policy keeps running, so nothing weakens:
defenseclaw doctorfails the Config validation and Rule pack rows (with theconfig setcommand that pins the new digest) and skips Policy:live state was not checked while config.yaml is invalid./healthshows the same text inpolicy.last_reload_error, anddefenseclaw config validatefails with it.
Apply an edit on purpose in one of two ways:
# A: a new copy, switched to when ready
cp -r ~/.defenseclaw/policies/guardrail/acme-rules ~/.defenseclaw/policies/guardrail/acme-rules-2
defenseclaw guardrail validate-pack ~/.defenseclaw/policies/guardrail/acme-rules-2
defenseclaw guardrail use-pack acme-rules-2
# B: re-pin the edited folder in place
defenseclaw guardrail use-pack acme-rules --repin--repin validates the folder, shows the old and new digest, names every other scope that selects the same pin (they get the edited pack too), and asks before it writes. If config.yaml changed meanwhile it saves nothing and says config changed, run again. Scripts pass --yes; --json without --yes refuses.
Customise a pack with guardrail.rules
guardrail.rules changes the pack you already use, in memory, without copying it.
guardrail:
rules:
protections: [database-destruction-protection]
disable: [CMD-REVSHELL-NC]
enable: [ENT-PASSPORT-US]
severity_overrides:
ACME-INTERNAL-DUMP: CRITICAL
suppressions:
- id: ACME-SUPP-BUILD-EMAIL
finding_pattern: JUDGE-PII-EMAIL
entity_pattern: '@build[.]acme[.]example$'
reason: Build bot addresses are not personal data
sensitive_tools:
- name: acme_crm_lookup
result_inspection: true
min_entities_for_alert: 3| Key | What it does | Command |
|---|---|---|
protections | Turns on opt-in protection packs. Their rules replace base rules with the same ID and add the rest. | guardrail protection enable NAME / disable NAME |
enable | Turns on rules the pack ships off. | guardrail rule enable ID |
disable | Turns off rules. | guardrail rule disable ID |
severity_overrides | Sets a rule's severity. | guardrail rule severity ID high (default removes it) |
suppressions | Drops LLM judge findings (Suppressions). | guardrail suppress add / remove |
sensitive_tools | Adds or changes a sensitive tool. With result_inspection: true, a result with at least min_entities_for_alert distinct sensitive values (default 1) raises a tool-result-pii-alert. judge_result also sends the result to the PII judge. | config set or config.yaml |
Some self-protection rules, such as tamper.detector_state_write, cannot be turned off or lowered: rule disable and rule severity do not change them.
Every command takes --connector X and --profile P (both together for a profile connector). rule disable also removes the ID from enable in the same scope, and the reverse, so a disable followed by an enable leaves the config as it was.
defenseclaw guardrail rule disable CMD-REVSHELL-NC
defenseclaw guardrail rule severity CMD-REVSHELL-BASH high --connector codex
defenseclaw guardrail protection enable kubernetes-production-protection --profile contractors --connector codexThe writers and the gateway refuse a layer that names a rule ID the pack does not have, lists a rule under both enable and disable, repeats a suppression ID, or names an unknown protection pack. protection enable also refuses a combination the gateway could not load, such as one over the CEL cost limit. The protection packs are listed on Deterministic detection.
Scopes and layering
Layers apply broadest first, each on the result of the one before, so a narrower scope wins:
- Global:
guardrail.rules - Connector:
guardrail.connectors.<connector>.rules - Profile:
guardrail.profiles.<profile>.rules - Profile connector:
guardrail.profiles.<profile>.connectors.<connector>.rules
A connector with no profile gets layers 1 and 2. A layer applies to the pack its scope selected, and every rule ID it names must exist in that pack: a global layer that names a rule only acme-rules has makes a connector on strict fail with unknown rule ACME-INTERNAL-DUMP. defenseclaw-gateway policy digest lists one rule_pack: component per scope.
When something is wrong
| Situation | What happens |
|---|---|
| A pinned pack's digest does not match | The reload is rejected; the previous policy keeps running (Change a pinned pack). |
An unknown rule ID, or a rule under both enable and disable | The writer refuses; a hand edit makes the gateway reject the reload. |
rule_pack names an unknown pack | Refused with config rule pack "nosuchpack" is neither built in (default, strict, permissive) nor a guardrail.custom_packs entry. |
| A pack file is invalid | validate-pack exits 1; use-pack changes nothing. |
| A profile's rules cannot be applied | The gateway logs the profile and the reason; its subjects get the base rule set. |
On a managed device the writers refuse; the pack and rules belong in the admin config.
Suppressions
Suppressions tune the optional LLM judge. They never silence a regex or CEL rule finding (such as SEC-AWS-KEY), and never redact what is sent to the model. To quiet a rule, use guardrail rule disable or rule severity.
| List | What it does | Where it lives |
|---|---|---|
pre_judge_strips | Removes text from the judge's input, for judges in applies_to (all when empty) | The pack's suppressions.yaml |
finding_suppressions | Drops one judge finding when its ID and the matched text both match | The pack, or guardrail.rules.suppressions |
tool_suppressions | Drops listed PII findings for tools whose name matches | The pack's suppressions.yaml |
Don't blanket-match
Never use .*, .+ or ^.*$ as a suppression pattern. It silences everything the list would report.
Add a finding suppression without copying a pack:
defenseclaw guardrail suppress add ACME-SUPP-BUILD-EMAIL \
--finding JUDGE-PII-EMAIL --entity '@build[.]acme[.]example$' \
--reason "Build bot addresses are not personal data"
defenseclaw config get guardrail.rules.suppressions # check
defenseclaw guardrail suppress remove ACME-SUPP-BUILD-EMAIL # undo--findingis matched against the whole finding ID, soJUDGE-PII-.*matches every PII finding.--entityis matched against the reported text; left out, it matches every value.--reasonis required, and the ID must be new.- If
--findingis exactly a rule ID in the active pack, the entry is still saved, with a warning that names the commands that change the rule. - The command takes no
condition; use a pack-level suppression foris_epochoris_platform_id.
Pack entries the default pack ships, for reference:
pre_judge_strips:
- id: STRIP-SYSTEM-SENDER
pattern: '\b(cli|system|bot|admin)\b'
context: "System sender metadata injected by agent framework"
applies_to: [pii]
tool_suppressions:
- tool_pattern: '^(graph_auth_status|session_status|get_status)$'
suppress_findings: [JUDGE-PII-USER]
reason: "Status check tools return expected system metadata"A strip does not hide a secret: the SEC-* rules still match it. Scope tool_pattern to exact tool names. The recipe catalog lists more shipped entries.
Tier table (Preview)
Preview. A custom pack may carry a tiers.yaml next to defenseclaw-pack.json. It names the pack's tier and sets, for each kind of finding (a row), the least action it gets and how its severity counts, per-user and managed. The shipped packs have none and use the built-in table.
version: 1
tier: strict
rows:
- id: tiered-strict
per_user: {floor: block}
managed: {floor: block}| Key | Meaning |
|---|---|
version | Always 1. |
tier | default, permissive or strict. |
rows[].id | A row name (list below). A row you leave out keeps its built-in cells; list each row once. |
rows[].per_user, rows[].managed | The cell for a per-user install and a managed computer. |
cell floor | allow, alert, confirm or block: the least action. |
cell ceiling | alert or record (optional): the most it can raise. record needs floor allow. |
cell levels | true (default) or false. false keeps the finding out of block_at/alert_at; with floor allow it is refused. |
cell severity | Optional; must equal the built-in row's severity. |
Rows: effect-unknown, effect-content-decided, effect-own-key-write, effect-link, effect-read, record, advisory, ask-ticket-request, evaluation-fault, unverified-path, truncated, state-write, shell-protected-file, read-ssh-private-key, read-credential, read-other-home-ssh-private-key, read-other-home-git-credential, read-other-home-credential, tiered-strict, tiered-managed.
The loader refuses the whole pack, naming the row, when a column changes a row's severity, lowers a protected row (evaluation-fault, state-write, truncated, unverified-path, shell-protected-file can only be raised), or turns record-only on or off for a row. validate-pack prints the same message.
See also
- Block and alert levels:
block_at,alert_atand the pack's posture. - Presets and packs: what each shipped pack and admission preset contains;
defenseclaw policy activate defaultputs admission back to the default preset. - Deterministic detection: the shipped rules and protection packs.
- Configuration reference: every key.
DefenseClaw compared with other guardrails
Compare DefenseClaw with LlamaFirewall, LLM Guard, NeMo Guardrails, Guardrails AI, Invariant, CodeShield and guard models, with links to benchmark results.
Block and alert levels
Set the guardrail block_at and alert_at levels: where to set them, which scope wins, what the rule pack supplies by default, and how to change them.