swarm: Command for Claude Code

.claude/commands/preflight.md

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

A pre-commit check command for staged files. Pre-commit checks run automated quality and security tests before code is committed.

In plain words
What is it for?
Use it to check staged Python files, optionally auto-fix Ruff and isort issues, or scan a repository, directory, or file for exposed secrets.
Why use it?
It gathers issues in one run so you can fix several problems without stopping at the first failure.

Command for Claude Code

Written for Claude Code: installed under .claude/. Also seen: reads .claude/ paths.

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 →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is bash .claude/hooks/scan_secrets.sh [path].

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/swarm-ai-research/swarm/preflight.svg)](https://agentmods.dev/commands/swarm-ai-research/swarm/preflight)
Your own site
<a href="https://agentmods.dev/commands/swarm-ai-research/swarm/preflight"><img src="https://agentmods.dev/badge/commands/swarm-ai-research/swarm/preflight.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 1,402 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.01402
Opus 5 $0.00000 $0.00701
Sonnet 5 $0.00000 $0.00280
Haiku 4.5 $0.00000 $0.00140

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

Security

Grade A, and why

preflight 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/preflight.md · 115 lines

How it starts

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

/preflight

Run all pre-commit checks on staged files without committing. Shows all issues at once and optionally auto-fixes what it can.

Use --secrets [path] to run the secrets scanner standalone (replaces the former /scan_secrets command).

Usage

/preflight [--fix]
/preflight --secrets [path]

Examples:

  • /preflight — check only, report all issues
  • /preflight --fix — auto-fix ruff/isort issues, then report remaining
  • /preflight --secrets — scan all tracked + untracked files for secrets
  • /preflight --secrets swarm/bridges/ — scan a specific directory
  • /preflight --secrets swarm/bridges/gastown/bridge.py — scan a single file

Argument parsing

  • --fix: Auto-fix ruff/isort issues before reporting.
  • --secrets [path]: Run secrets scanner only (skip all other checks). If no path given, scans the whole repo. Equivalent to bash .claude/hooks/scan_secrets.sh [path].

Behavior

  1. Get the list of staged Python files:
git diff --cached --name-only --diff-filter=ACM | grep '\.py$'

If no staged .py files, report "No staged Python files to check" and exit.

  1. Run all checks, collecting results before reporting (do NOT stop on first failure):

    a) Syntax check — for each staged .py file, run python -m py_compile <file>. This catches IndentationError, SyntaxError, and other parse-level errors that concurrent sessions may introduce. Report any failures immediately — these block everything else.

    for f in $staged_py_files; do
        python -m py_compile "$f" 2>&1 || echo "SYNTAX ERROR: $f"
    done
    

    b) Secrets scan — run the same secret-pattern check from .claude/hooks/pre-commit on the staged diff. Report any matches.

    c) Ruff lintruff check <staged_files>. If --fix flag was given, first run ruff check --fix <staged_files>, then re-stage the fixed files with git add, then re-check to report remaining unfixable issues.

    d) Mypy type check — only for staged files under swarm/: mypy --follow-imports=skip <swarm_files>. Report type errors (cannot auto-fix).

Read the full file on GitHub · 115 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 · 115 lines · 0 tokens per session scan A d5461386811c

Subscribe to this mod's changes

preflight 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 1,402 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.