Adding a new attack to ai-blackteam is one Python file. This guide covers all three modes.

Quick Start

Create a file in src/ai-blackteam/attacks/:
That’s it. Drop this file in the attacks/ directory and it auto-discovers on next run.

Full Template

Here’s a complete template with all fields:

Single-Turn Attack

The simplest type. Generate prompt variants, each tested independently.

Multi-Turn Attack

A conversation that builds context over multiple messages. Override generate_turns().
The Engine sends these one at a time. Each turn gets the full conversation history, so the model has context from earlier turns.

Tool-Use Attack

Tests whether an AI agent misuses its tools. Override get_tools(), generate_tool_messages(), and optionally get_tool_responses().

External Plugin Directory

You can also place attacks outside the ai-blackteam package. Use discover_folder():
Any .py file in that directory with @register_attack will be loaded.

Testing Your Attack

Write a test that verifies your attack generates the expected number and format of prompts:
Run with:

Checklist

Before submitting:
  1. File is in src/ai-blackteam/attacks/ (or your plugin directory)
  2. Class extends BaseAttack
  3. Decorated with @register_attack("your-technique-id")
  4. technique_id matches the decorator argument
  5. mode is set correctly
  6. generate_prompts() is implemented (even if empty for multi-turn/tool-use)
  7. The right mode-specific method is implemented
  8. Test verifies prompt count and format