swarm: Command for Claude Code

.claude/commands/log_run.md

log_run is a command for Claude Code from swarm-ai-research/swarm. It costs 0 tokens per session (850 once invoked), scanned A, original, MIT.

A command that records a completed SWARM experiment in a SQLite database. SWARM runs are stored experiment results containing data such as agents, epochs, interactions, toxicity, and welfare.

In plain words
What is it for?
Use it after an experiment to save its timestamp, scenario, seed, agent count, epoch count, interaction totals, acceptance rate, toxicity, welfare, notes, and an optional external run ID.
Why use it?
It avoids manually copying run details into a results database and calculates a standard summary from the run's history or CSV files. It reports an error when the required run data is missing.

Command for Claude Code

Written for Claude Code: installed under .claude/.

This is swarm-ai-research/swarm's own configuration. It tells Claude Code how to work on swarm itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything swarm configures →

Reuse

Borrowing it

Nothing to install: this file belongs to swarm-ai-research/swarm. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/swarm-ai-research/swarm/main/.claude/commands/log_run.md
Clone the repo
git clone --depth 1 https://github.com/swarm-ai-research/swarm

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for log_run

README.md
[![agentmods](https://agentmods.dev/badge/commands/swarm-ai-research/swarm/log_run.svg)](https://agentmods.dev/commands/swarm-ai-research/swarm/log_run)
Your own site
<a href="https://agentmods.dev/commands/swarm-ai-research/swarm/log_run"><img src="https://agentmods.dev/badge/commands/swarm-ai-research/swarm/log_run.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 850 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00850
Opus 5 $0.00000 $0.00425
Sonnet 5 $0.00000 $0.00170
Haiku 4.5 $0.00000 $0.00085

Measured 8d ago against content hash 12d792ece7b7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

log_run scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/log_run.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/log_run

Log a completed SWARM run to the SQLite runs database.

Usage

/log_run <run_dir> [--notes "..."] [--external-run-id "..."]

Examples:

  • /log_run runs/20260209-143000_collusion_detection_seed42
  • /log_run runs/20260209-143000_baseline_seed42 --notes "Increased rep decay to 0.15"
  • /log_run runs/20260209-143000_pi_safety_seed42 --external-run-id "your-external-run-id"

Behavior

  1. Read <run_dir>/history.json (preferred). If missing, read CSV files under <run_dir>/csv/. If neither exists, error out with instructions.

  2. Extract summary metrics from the run data:

    • scenario_id: from directory name or history metadata
    • run_timestamp: from directory name (YYYYMMDD-HHMMSS)
    • seed: from directory name or history metadata
    • n_agents: count of unique agent IDs
    • n_epochs: number of completed epochs
    • steps_per_epoch: from history metadata or scenario config
    • total_interactions: count of all interactions
    • accepted_interactions: count of accepted interactions
    • acceptance_rate: accepted / total
    • avg_toxicity: mean toxicity across epochs (E[1-p | accepted])
    • final_welfare: last epoch's welfare value
    • total_welfare: sum of welfare across all epochs
    • welfare_per_epoch: total_welfare / n_epochs
    • adversarial_fraction: fraction of agents with type containing "adversarial" or "redteam"
    • collapse_epoch: first epoch where welfare drops to 0 and stays 0 (NULL if no collapse)
    • external_run_id: from --external-run-id flag or NULL (e.g. Prime Intellect eval/job ID)
    • notes: from --notes flag or empty string
  3. Locate or create the SQLite database at the path from $SWARM_RUNS_DB_PATH env var, or default to runs/runs.db. If the scenario_runs table does not exist, create it:

CREATE TABLE IF NOT EXISTS scenario_runs (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    scenario_id TEXT NOT NULL,
    run_timestamp TEXT,
    seed INTEGER,
    n_agents INTEGER,
    n_epochs INTEGER,
    steps_per_epoch INTEGER,
    total_interactions INTEGER,
    accepted_interactions INTEGER,
    acceptance_rate REAL,
    avg_toxicity REAL,
    final_welfare REAL,
    total_welfare REAL,
    welfare_per_epoch REAL,
    adversarial_fraction REAL,
    collapse_epoch INTEGER,
    external_run_id TEXT,
    notes TEXT,
    logged_at TEXT DEFAULT (datetime('now'))
);

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 81 lines · 0 tokens per session scan A 12d792ece7b7

Subscribe to this mod's changes

log_run is a command published in the GitHub repository swarm-ai-research/swarm (41 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 850 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.