What ai-blackteam defend does

ai-blackteam defend runs every attack twice: once with no defenses (baseline), once with your defenses applied. Then it shows you a side-by-side comparison of what improved, what regressed, and what stayed the same.

How it works

The command runs in three phases: Phase 1: Baseline scan - Runs all selected attacks against the bare model with no system prompt and no guardrails. Records the verdict for each attack. Phase 2: Defended scan - Runs the same attacks against the model with your system prompt and/or guardrails applied. Records the verdict for each attack. Phase 3: Compare - Builds a delta table showing how each attack’s verdict changed between baseline and defended.

All flags

You must provide at least one of --system-prompt, --system-prompt-file, or --guardrail. Otherwise the command exits with an error - there’s nothing to defend with.

Reading the delta table

Delta values

Verdict ranking

The delta uses a ranking system:
If the baseline was BYPASSED (0) and defended is BLOCKED (2), the rank increased so delta = +1. If the baseline was BLOCKED (2) and defended is BYPASSED (0), the rank decreased so delta = -1. The numeric delta is +1 or -1 regardless of how many levels it jumped. BYPASSED to BLOCKED and PARTIAL to BLOCKED both show +1.

Summary stats

Below the table, you get aggregate numbers:
The percentage is calculated as (delta_blocked / total_attacks) * 100. A positive delta means your defense is working. A negative delta means something went wrong.

Combining system prompts + guardrails

You can stack a system prompt with a guardrail preset:
This applies both defenses in the defended phase:
  1. The guardrail’s input filter runs first (might block the prompt before it reaches the model)
  2. If the prompt passes the input filter, the model runs with the system prompt
  3. The guardrail’s output filter checks the model’s response
The label in the output reflects both:

Saving results to JSON

Use --output to save the full comparison as JSON:
The JSON file contains:
Use this for tracking defense effectiveness over time, comparing different system prompts, or feeding into CI pipelines.

Example workflows

Testing a system prompt

Testing guardrail presets

Testing specific attacks

A/B testing system prompts

Run the same attacks with different system prompts and compare the JSON output:
Then compare v1.json and v2.json to see which prompt defends better.

Exit codes

The exit code reflects the defended results, not the baseline. Even if the baseline had 50 bypasses, exit 0 means your defense stopped all of them.