prompt-siren
CLAUDE.md62 starsChanged 9 months agoMITView on GitHub
This is a workbench designed for security research to test attacks against large language models and prompt injection defenses. The project uses pydantic-ai as its core AI framework and supports multiple environments for testing. It features a Hydra-based configuration system for flexible experiment orchestration with parameter sweeps and overrides. Note: Integration tests require Docker to be running. CI/CD pipelines skip integration tests by default for speed. Note: Dataset and attack can be specified either via command-line overrides (+dataset=..., +attack=...) or…
- Installs packages
In this repositoryOne other file it gives its agents.
- docs/plugins/agents.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 74
Always use modern 3.10+ type hints:
- Distinctive: line 77
Always write meaningful tests for new features.
- Distinctive: line 78
Always lint and type check.
- Very specific: line 79
Avoid using type: ignore, unless the issue is the result of a deliberate choice (e.g., in tests).
- Distinctive: line 81
Only use module-level imports instead of local imports, unless it's to import optional dependencies or to handle circular imports.
- Distinctive: line 196
Read configuration from environment variables (no Pydantic config classes)
- Distinctive: line 264
Async-first: All core operations are asynchronous
- Very specific: line 274
Test files mirror source structure under tests/
- Distinctive: line 325
Check out these pages before going to a specific page.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a workbench designed for security research to test attacks against large language models and prompt injection defenses. The project uses pydantic-ai as its core AI framework and supports multiple environments for testing. It features a Hydra-based configuration system for flexible experiment orchestration with parameter sweeps and overrides.
Development Commands
Linting and Type Checking
uv run ruff check --fix
uv run ruff format
uv run ty checkTesting
# Run all tests (unit + integration)
uv run pytest -vx
# Run unit tests only (fast, no Docker needed - CI/CD default)
uv run pytest -vx -m "not docker_integration"
# Run integration tests only (requires Docker)
uv run pytest -vx -m docker_integrationNote: Integration tests require Docker to be running. CI/CD pipelines skip integration tests by default for speed.
Running Experiments
# Export default configuration (first time setup)
uv run prompt-siren config export
# Run benign-only evaluation
uv run prompt-siren run benign +dataset=agentdojo-workspace
# Run attack evaluation
uv run prompt-siren run attack +dataset=agentdojo-workspace +attack=template_string
# Run SWE-bench evaluation
uv run prompt-siren run benign +dataset=swebench
# Override parameters
uv run prompt-siren run benign +dataset=agentdojo-workspace agent.config.model=azure:gpt-5 execution.concurrency=4
# Parameter sweep (use hydra.mode=MULTIRUN for sweeping over multiple values)
uv run prompt-siren run benign --multirun +dataset=agentdojo-workspace agent.config.model=azure:gpt-5,azure:gpt-5-nano
# Parameter sweep with multiple parameters
uv run prompt-siren run benign --multirun +dataset=agentdojo-workspace agent.config.model=azure:gpt-5,azure:gpt-5-nano execution.concurrency=1,4
# Parameter sweep with attacks
uv run prompt-siren run attack --multirun +dataset=agentdojo-workspace +attack=template_string,mini-goat
# Validate configuration
uv run prompt-siren config validate +dataset=agentdojo-workspace +attack=template_string
# Run with config file that includes dataset/attack (no overrides needed)
uv run prompt-siren run attack --config-dir=./my_configNote: Dataset and attack can be specified either via command-line overrides (+dataset=..., +attack=...) or by including them in your config file's defaults list. See docs/configuration.md for details.
Platform Requirements:
- Linux or macOS only (Windows not supported)
- Docker required for SWE-bench
- Base Docker images must have
/bin/bashavailable
Development guidelines
- Always use modern 3.10+ type hints:
list,dict,setinstead of importing fromtyping.|instead ofUnionandOptional.
- Always write meaningful tests for new features. Avoid tests that are obvious.
- Always lint and type check.
- Avoid using
type: ignore, unless the issue is the result of a deliberate choice (e.g., in tests). - Avoid using
cast. - Only use module-level imports instead of local imports, unless it's to import optional dependencies or to handle circular imports.
Architecture
Core Components
- Agent System (
src/prompt_siren/agents/)abstract.py- Defines theAbstractAgentprotocol for agent interfacesplain.py- Implements the main agent logic for running tasks with pydantic-ai_utils.py- Helper utilities for agent operationsregistry.py- Agent plugin registration system- Supports tool execution with injection attack capabilities
- Dataset System (
src/prompt_siren/datasets/)abstract.py- DefinesAbstractDatasetprotocol for dataset interfacesagentdojo_dataset.py- AgentDojo dataset implementationswebench_dataset/- SWE-bench dataset for code editing benchmarks- Uses multi-stage Docker builds (base/env/instance) with caching
- Jinja2 template system for prompts
- Official SWE-bench test harness for evaluation
registry.py- Dataset plugin registration system- Datasets provide:
- Collections of tasks (benign, malicious, and task couples)
- Specification of which environment type to use
- Environment configuration for that environment
- Separates task data from execution context (environments)
- Allows multiple datasets to share the same environment type
- Environment System (
src/prompt_siren/environments/)abstract.py- BaseEnvironmentclass provides the interface for different execution environments- Environment states (
env_state) are managed per-task and passed separately from environment - Two-level context management for resource lifecycle:
create_batch_context()- Batch-level setup for expensive resources (browsers, servers)create_task_context()- Per-task context with fresh environment state
- Environments handle rendering of outputs and injection vector detection
registry.py- Environment plugin registration system- Key environments:
agentdojo/- AgentDojo environment integrationplaywright.py- Playwright-based web automation environment
- Attack System (
src/prompt_siren/attacks/)abstract.py- Base attack abstractionsInjectionAttacktype defines attack payloads (intypes.py)registry.py- Attack plugin registration system- Attack implementations:
nanogcg/gcg.py- GCG (Greedy Coordinate Gradient) attacktemplate_string_attack.py- Template string-based attacksdict_attack.py- Dictionary-based attacks from config or filesmini_goat_attack.py- Mini-GOAT attack implementationtarget_string_attack.py- Target string-based attacks
attack_utils.pyprovides common utilities
- Configuration System (
src/prompt_siren/config/)experiment_config.py- Pydantic-based configuration schema defining ExperimentConfigexport.py- Configuration export functionalityexceptions.py- Configuration-specific exceptionsregistry_bridge.py- Bridge between Hydra config and plugin systemsdefault/- Default Hydra configuration files- Integrates with Hydra for powerful experiment orchestration
- Task System (
src/prompt_siren/tasks.py)Task- Defines individual tasks with evaluatorsTaskCouple- Pairs benign and malicious tasks for evaluationTaskResult- Contains execution results and environment stateTaskEvaluator- Protocol for task evaluation functionsEvaluationResult- Stores evaluation scores from evaluators
- Task Runner (
src/prompt_siren/run.py)run_tasksorchestrates concurrent task execution- Manages batch and task context lifecycle using two-level context management
- Manages concurrency limits and result collection
- Integrates agents, datasets, environments, and attacks
- Handles task evaluation and result aggregation
- CLI Interface (
src/prompt_siren/cli.pyandsrc/prompt_siren/hydra_app.py)cli.py- Click-based CLI with structured subcommands (config, jobs, run, results)hydra_app.py- Hydra integration for configuration management- Entry point:
prompt_sirencommand - Subcommands:
config export,config validate- Configuration managementjobs start [benign|attack]- Start a new jobjobs resume- Resume an existing job with optional retry flagsrun [benign|attack]- Alias forjobs startresults- Aggregate and display results
- Execution mode (benign vs attack) determined by CLI command, not config
- Supports parameter overrides and multi-run sweeps via
--multirun - Job-based experiment tracking with resume/retry capabilities
- Telemetry System (
src/prompt_siren/telemetry/)- OpenTelemetry instrumentation for observability
- Conversation logging capabilities
formatted_span.py- Span formatting utilitiesworkbench_spans.py- Workbench-specific span managementpydantic_ai_processor/- PydanticAI telemetry integration
- Type System (
src/prompt_siren/types.py)
- Core type definitions for the workbench
InjectionAttackand related attack typesInjectableUserPromptPart,InjectableModelRequestfor injection modelingAttackConfig,AttackMetadatafor attack configuration- Content types:
StrContentAttack,BinaryContentAttack
- Plugin System (
src/prompt_siren/registry_base.py)- Base registry functionality for plugin management
- Supports dynamic component registration via entry points
- Each subsystem (agents, attacks, datasets, providers) has its own registry
- Flexible design allows components with or without config classes
- Provider System (
src/prompt_siren/providers/)abstract.py- DefinesAbstractProviderprotocol for model providersregistry.py- Provider registry andinfer_modelfunction- Provider implementations:
bedrock.py- AWS Bedrock provider for Anthropic modelsllama.py- Llama API provider
- Providers handle model creation for specific prefixes (e.g., "bedrock:", "llama:")
- Read configuration from environment variables (no Pydantic config classes)
- Automatically integrated via
infer_modelin agent configuration - Factory functions take no parameters (unlike other components)
- Job System (
src/prompt_siren/job/)models.py- Job data models (JobConfig, TaskResult, RunIndexEntry, etc.)job.py- Job class for creating, running, and resuming jobspersistence.py- Per-task persistence (save/load results)naming.py- Job naming utilities (sanitize, generate job names)- Jobs are stored in
jobs/<job_name>/with per-task directories
- Supporting Modules
tools_utils.py- Utilities for tool handling
Task Selection
Task selection is configured via the task_ids field in ExperimentConfig:
task_ids: null(default) - Run all tasks appropriate for the execution mode:- Benign mode: all unique benign tasks
- Attack mode: all task couples
task_ids: ["task1", "task2"]- Run specific tasks by ID- Task IDs with
:are treated as couple IDs (e.g.,"benign_id:malicious_id") - Task IDs without
:are treated as individual task IDs
- Task IDs with
- Task selection logic is handled by
get_selected_tasks()inhydra_app.py - Execution mode (benign vs attack) is determined by CLI command, not stored in config
Plugin System
The workbench uses Python entry points for extensibility. Components are registered in pyproject.toml:
- Agent plugins:
prompt_siren.agentsentry pointplain- Plain agent implementation
- Attack plugins:
prompt_siren.attacksentry pointtemplate_string- Template string attacksagentdojo- Alias for template_string (backwards compatibility)dict- Dictionary-based attacks from configfile- Dictionary-based attacks from filemini-goat- Mini-GOAT attacks
- Dataset plugins:
prompt_siren.datasetsentry pointagentdojo-workspace- AgentDojo workspace datasetswebench- SWE-bench dataset for code editing benchmarks
- Provider plugins:
prompt_siren.providersentry pointbedrock- AWS Bedrock provider for Anthropic modelsllama- Llama API provider- Note: Providers don't use config classes; they read from environment variables
Plugins can be added by implementing the appropriate protocol and registering via entry points.
Available Environment Implementations
Environments are not registered as plugins; instead, datasets directly instantiate and own their environment instances:
- AgentDojoEnv (
src/prompt_siren/environments/agentdojo_env.py) - For AgentDojo benchmark suites- Used by: AgentDojo datasets
- Features: Snapshottable environment state, placeholder injection, AgentDojo tool integration
- PlaywrightEnv (
src/prompt_siren/environments/playwright.py) - For web automation tasks- Features: Non-snapshottable (uses tool replay), browser automation, webpage interaction
Datasets specify which environment implementation to use and configure it during initialization.
Key Design Patterns
- Dependency Injection: Uses generic types for flexible dependency management
- Protocol-based Design: Uses Python protocols for extensibility
- Async-first: All core operations are asynchronous
- Two-level Context Management: Environments use a two-tier context system:
- Batch context for expensive resource setup shared across tasks
- Task context for per-task execution with fresh environment state
- Plugin Architecture: Entry points system for component registration
Testing Structure
- Uses
pytestwithanyiofor async testing conftest.pyprovides mock environments and fixtures- Test files mirror source structure under
tests/
Dependencies
Core Dependencies (always installed)
pydantic-ai-slim[anthropic,bedrock,openai]- AI framework with model integrationsclick- CLI framework for structured subcommandshydra-core- Configuration management and experiment orchestrationhydra-submitit-launcher- Submitit launcher for Hydralogfire- Logging and observabilityopentelemetry-api,opentelemetry-sdk,opentelemetry-exporter-otlp- Telemetryomegaconf- Configuration managementpyyaml- YAML parsingaiohttp- Async HTTP clientfilelock- File locking utilitiespandas- Data analysis for results aggregation
Optional Dependencies
Install optional features with: pip install 'prompt-siren[feature]'
| Group | Dependencies | Purpose |
[agentdojo] | agentdojo>=0.1.35 | AgentDojo dataset, environment, and attacks |
[swebench] | swebench, jinja2>=3.1.6 | SWE-bench dataset for code editing benchmarks |
[docker] | aiodocker>=0.24.0 | Docker sandbox manager |
[playwright] | playwright>=1.54.0 | Web automation environment |
[all] | All optional deps | Full installation with all features |
Examples:
# Minimal install (core only)
pip install prompt-siren
# AgentDojo support
pip install 'prompt-siren[agentdojo]'
# SWE-bench with Docker sandbox manager
pip install 'prompt-siren[swebench,docker]'
# Everything
pip install 'prompt-siren[all]'Requirements
- Python: Requires Python 3.10+
- Package Manager: Uses
uvfor dependency management - Platform: Linux and macOS only (Windows not supported due to sandbox architecture)
Useful documentation links
Check out these pages before going to a specific page. Navigate the .md links as they are more LLM-friendly.
- PydanticAI: https://ai.pydantic.dev/llms.txt
- Pydantic: https://docs.pydantic.dev/latest/llms.txt
- Hydra: https://hydra.cc/docs/intro/
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

