The problem

You wrote a system prompt that says “never help with harmful requests.” Does it work? Against one prompt, sure. Against 1,000 attack techniques designed to bypass safety instructions? That’s what ai-blackteam tests.

Using —system-prompt

Pass your safety instructions directly on the command line:
The system prompt gets injected as the system message in every API call. For single-turn attacks, it’s set once. For multi-turn attacks, it persists across the entire conversation.

Using —system-prompt-file

For longer system prompts, put them in a file:
Both --system-prompt and --system-prompt-file work with run, batch, sweep, and defend.

How system prompts are injected

The system prompt is passed to the provider’s send_prompt or send_in_conversation method via the system_prompt parameter. Each provider passes it to the API in the appropriate format:
  • Anthropic - system parameter in the messages API
  • OpenAI - system role message prepended to the conversation
  • Google - System instruction in the generation config
  • Others - Provider-specific system message handling
The system prompt is separate from the attack prompts. Attack techniques don’t see your system prompt directly (unless the attack specifically targets system prompt leakage).

Tips for writing effective safety instructions

Be specific, not vague

Vague instructions give models wiggle room. Specific instructions are harder to reframe away.

Address common bypass strategies

Attacks use role-play, encoding, fictional framing, and authority claims. Call these out directly:

Use the rule-after-exception pattern

This lets the model be helpful about security topics without crossing into harmful specificity.

Keep it concise

Long system prompts can get lost in context. Models sometimes deprioritize instructions that appear in a wall of text. Keep safety rules short, direct, and early in the prompt.

Example workflow

1. Baseline scan (no system prompt)

Note the exit code and how many attacks get through.

2. Defended scan (with system prompt)

Compare the results. Fewer bypassed attacks = your system prompt is working.

3. Use ai-blackteam defend for side-by-side comparison

The defend command automates this baseline-vs-defended workflow:
This runs every attack twice (once without your prompt, once with it) and shows you a delta table of what improved, what regressed, and what stayed the same.

4. Iterate on the prompt

Look at attacks that still bypassed with your system prompt. Understand their strategy (encoding? role-play? authority?) and add specific countermeasures. Then re-run.
The -v flag shows the full response, so you can see exactly how the model was tricked and adjust your prompt accordingly.