swarm: Skill for Claude Code

.skills/kb-query/SKILL.md

kb-query is a skill for Claude Code from swarm-ai-research/swarm. It costs 76 tokens per session (1,097 once invoked), scanned A, original, MIT.

A knowledge-graph search tool for a research project. A knowledge graph maps connections between documents, scenarios, commands, agents, and code references.

In plain words
What is it for?
Use it to find pages, inspect backlinks and outgoing links, discover related items, trace paths between items, and locate unused or broken references.
Why use it?
It answers relationship questions that ordinary text search may miss, such as what links to a page or how two concepts are connected.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. 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 python scripts/kb_graph_query.py <subcommand> <args>.

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/.skills/kb-query/SKILL.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 kb-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/swarm-ai-research/swarm/kb-query/github.svg)](https://agentmods.dev/skills/swarm-ai-research/swarm/kb-query)
Your own site
<a href="https://agentmods.dev/skills/swarm-ai-research/swarm/kb-query"><img src="https://agentmods.dev/badge/skills/swarm-ai-research/swarm/kb-query/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 kb-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/swarm-ai-research/swarm/kb-query"><img src="https://agentmods.dev/badge/skills/swarm-ai-research/swarm/kb-query.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,097 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00076 $0.01097
Opus 5 $0.00038 $0.00549
Sonnet 5 $0.00015 $0.00219
Haiku 4.5 $0.00008 $0.00110

Measured 6d ago against content hash 1e72b43f8195, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

kb-query 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 6d 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.

.skills/kb-query/SKILL.md · 101 lines

How it starts

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

EXECUTE NOW

Query: $ARGUMENTS

Parse the query type and run the matching subcommand. The script lives at scripts/kb_graph_query.py and reads docs/assets/kb_graph.json (it will rebuild the graph automatically if the JSON is missing).

Query shape Subcommand Example
"find X", "search X" find <terms> find soft labels
"info on X", "describe X" info <id-or-title> info concepts/soft-labels.md
"what links to X", "who uses X" backlinks <X> backlinks concepts/governance.md
"what does X link to" outbound <X> outbound cmd/ship
"X is related to what" related <X> related agent/auditor
"how does X reach Y", "connect X and Y" path <X> <Y> path concepts/soft-labels.md papers/delegation_games.md
"what's dead/unused/disconnected" orphans [--kind K] orphans --kind command
"key/central pages", "where do I start", "what's load-bearing" central [--kind K] [-n N] central -n 10
"broken/stale links", "dead code refs" stale stale

For free-text questions ("what is X about", "what's similar to X"), prefer info followed by related — info gives the description, related gives the neighborhood across all edge kinds including TF-IDF semantic suggestions.


Execution

Run the relevant subcommand as a single Bash invocation and return its output verbatim. Do not synthesize or summarize unless the user asked you to — the caller usually wants the raw structure.

python scripts/kb_graph_query.py <subcommand> <args>

If the user gave a free-text query ("tell me about delegation games"):

python scripts/kb_graph_query.py info delegation_games
python scripts/kb_graph_query.py related delegation_games

If the query is ambiguous (multiple title matches), the script prints the candidates and exits non-zero. Ask the user which one they meant, or pick the clearest exact match by id.


When to use this skill (and when not to)

Use kb-query when:

  • You need to know what links to a doc/scenario/command/agent before renaming or deleting it.
  • You want the shortest conceptual path between two ideas (introductions, related-work sections, onboarding paths).
  • You're looking for semantically related pages that aren't explicitly linked yet (densification candidates, duplicate-content candidates).
  • You want orphan pages for triage — by kind, by section.
  • You want to navigate the corpus structurally instead of by full-text grep.

Read the full file on GitHub · 101 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. 6d ago First seen · 101 lines · 76 tokens per session scan A 1e72b43f8195

Subscribe to this mod's changes

kb-query is a skill published in the GitHub repository swarm-ai-research/swarm (42 stars, last pushed today), licensed MIT. It adds 76 tokens to every session and 1,097 once invoked, about $0.0004 per session on Opus 5. 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-09-03.