swarm: Command for Claude Code

.claude/commands/load_keys.md

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

A command that reads API keys from shell startup files such as .zshrc or .bashrc and exports them into the current shell session. It supports selecting a provider or loading all recognized keys.

In plain words
What is it for?
Use it before commands or programs that need keys for providers such as OpenRouter, Anthropic, OpenAI, Groq, Together, DeepSeek, or Google.
Why use it?
It avoids manually searching for and exporting provider keys every time a new terminal session needs them.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/swarm-ai-research/swarm/load_keys.svg)](https://agentmods.dev/commands/swarm-ai-research/swarm/load_keys)
Your own site
<a href="https://agentmods.dev/commands/swarm-ai-research/swarm/load_keys"><img src="https://agentmods.dev/badge/commands/swarm-ai-research/swarm/load_keys.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 680 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.00680
Opus 5 $0.00000 $0.00340
Sonnet 5 $0.00000 $0.00136
Haiku 4.5 $0.00000 $0.00068

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

Security

Grade A, and why

load_keys 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 7d 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/load_keys.md · 66 lines

How it starts

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

/load_keys

Load API keys from ~/.zshrc (or ~/.bashrc) into the current shell environment. Eliminates the need to manually grep and export keys each session.

Usage

/load_keys [provider]

Examples:

  • /load_keys (load all available keys)
  • /load_keys openrouter (load only OpenRouter key)

Behavior

  1. Detect shell config file: Check for ~/.zshrc first, then ~/.bashrc, then ~/.bash_profile.

  2. Extract keys: For each known provider, grep the shell config for the key variable and export it. The known key variables are:

    Variable Provider
    OPENROUTER_API_KEY OpenRouter
    ANTHROPIC_API_KEY Anthropic
    OPENAI_API_KEY OpenAI
    GROQ_API_KEY Groq
    TOGETHER_API_KEY Together
    DEEPSEEK_API_KEY DeepSeek
    GOOGLE_API_KEY Google

    Extraction command per key (handles export VAR="val", export VAR='val', export VAR=val):

    grep '^export KEY_NAME=' ~/.zshrc | tail -1 | sed 's/^export //' | cut -d= -f2- | tr -d '"' | tr -d "'"
    
  3. Export into current environment: For each key found, run:

    export KEY_NAME="<extracted_value>"
    
  4. Report: Print which keys were loaded and their character count (NOT the actual values):

    API Keys Loaded
      OPENROUTER_API_KEY:  set (73 chars)
      ANTHROPIC_API_KEY:   not found
      OPENAI_API_KEY:      not found
      GROQ_API_KEY:        not found
      TOGETHER_API_KEY:    not found
      DEEPSEEK_API_KEY:    not found
      GOOGLE_API_KEY:      not found
    
  5. If a [provider] argument is given, only load that provider's key. Map provider names to variables:

    • openrouterOPENROUTER_API_KEY
    • anthropicANTHROPIC_API_KEY
    • openaiOPENAI_API_KEY
    • groqGROQ_API_KEY
    • togetherTOGETHER_API_KEY
    • deepseekDEEPSEEK_API_KEY
    • googleGOOGLE_API_KEY

Constraints

  • Never print the actual key values — only confirm presence and length.
  • If the shell config file doesn't exist, say so and stop.
  • If a key is already set in the environment AND matches what's in the config file, skip it and note "already set".
  • If a key is already set but DIFFERS from the config file, load the config file version and note "updated from ~/.zshrc".

Read the full file on GitHub · 66 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. 7d ago First seen · 66 lines · 0 tokens per session scan A c5accb6871a6

Subscribe to this mod's changes

load_keys 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 680 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.