swarm: Command for Claude Code

.claude/commands/add_metric.md

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

A command for adding a new measurement to the SWARM analysis system. It defines the measurement, adds tests, and connects it to reports and exports.

In plain words
What is it for?
Use it when you need a per-epoch, red-team, boundary, or leakage metric, then include it in the relevant CSV or JSON reporting.
Why use it?
It closes gaps where existing measurements do not capture an important behaviour or failure. The definition and tests also make the result consistent and repeatable.

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/add_metric.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 add_metric

README.md
[![agentmods](https://agentmods.dev/badge/commands/swarm-ai-research/swarm/add_metric/github.svg)](https://agentmods.dev/commands/swarm-ai-research/swarm/add_metric)
Your own site
<a href="https://agentmods.dev/commands/swarm-ai-research/swarm/add_metric"><img src="https://agentmods.dev/badge/commands/swarm-ai-research/swarm/add_metric/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add_metric

Your own site · 80×15
<a href="https://agentmods.dev/commands/swarm-ai-research/swarm/add_metric"><img src="https://agentmods.dev/badge/commands/swarm-ai-research/swarm/add_metric.svg" alt="Reviewed on agentmods" width="80" 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 296 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.00296
Opus 5 $0.00000 $0.00148
Sonnet 5 $0.00000 $0.00059
Haiku 4.5 $0.00000 $0.00030

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

Security

Grade A, and why

add_metric 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 12d 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/add_metric.md · 33 lines

What it actually says

/add_metric

Add a new metric and wire it into SWARM reporting — use when analysis reveals a measurement gap not covered by existing toxicity, quality-gap, or payoff metrics. Distinct from /add_scenario (new parameter config) and /add_domain (new task category with new observables).

Usage

/add_metric <metric_name> [where]

Examples:

  • /add_metric norm_violation_rate
  • /add_metric collusion_entropy swarm/metrics/collusion.py

Behavior

  1. Decide where it belongs:
  • Per-epoch aggregate metric: swarm/metrics/soft_metrics.py or a new module under swarm/metrics/.
  • Red-team metric: swarm/redteam/metrics.py
  • Boundary/leakage metric: swarm/boundaries/*
  1. Implement the metric with:
  • Clear definition (units, range, failure modes)
  • Determinism (given the same event log/history)
  • Minimal coupling (don’t reach into private orchestrator state unless necessary)
  1. Wire it into reporting:
  • Update the relevant reporter (often swarm/metrics/reporters.py) so it is exported consistently.
  • Add/extend tests in tests/ that lock down the definition and basic sanity properties.
  1. Ensure it shows up in:
  • CSV/JSON exports when applicable
  • Any standard plots generated by /plot (if relevant)
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. 12d ago First seen · 33 lines · 0 tokens per session scan A 1232b8df0c5f

Subscribe to this mod's changes

add_metric is a command published in the GitHub repository swarm-ai-research/swarm (42 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 296 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.