kb-search

kb-search is a command for Claude Code from mathiasbourgoin/roster. It costs 17 tokens per session (798 once invoked), scanned A, original, MIT.

A search tool for a project's knowledge base, which is a collection of project notes and reference files. It combines meaning-based matching with exact-word matching and returns ranked passages with their source and status.

In plain words
What is it for?
It is for finding relevant project documentation, specifications, decisions, and constraints when the knowledge-base search index already exists.
Why use it?
It avoids loading every knowledge-base file when you need a specific fact, term, or constraint. It can also exclude historical or superseded information by default.

Command for Claude Code

Written for Claude Code: when-to-use in frontmatter.

Part of the roster plugin — 40 commands, 8 agents shipped together

Good fit It is for finding relevant project documentation, specifications, decisions, and constraints when the knowledge-base search index already exists.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/mathiasbourgoin/roster/kb-search
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/mathiasbourgoin/roster

Made for: Claude Code.

Or install roster, the plugin that ships this one along with the rest of its 40 commands, 8 agents.

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-search

README.md
[![agentmods](https://agentmods.dev/badge/commands/mathiasbourgoin/roster/kb-search/github.svg)](https://agentmods.dev/commands/mathiasbourgoin/roster/kb-search)
Your own site
<a href="https://agentmods.dev/commands/mathiasbourgoin/roster/kb-search"><img src="https://agentmods.dev/badge/commands/mathiasbourgoin/roster/kb-search/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-search

Your own site · 80×15
<a href="https://agentmods.dev/commands/mathiasbourgoin/roster/kb-search"><img src="https://agentmods.dev/badge/commands/mathiasbourgoin/roster/kb-search.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 798 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.00017 $0.00798
Opus 5.5 $0.00007 $0.00319
Sonnet 5.5 $0.00003 $0.00160
Haiku 4.5 $0.00002 $0.00080

Measured 1mo ago against content hash a52b5358882b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

kb-search 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 1mo 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/kb-search.md · 83 lines

How it starts

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

You perform hybrid semantic and keyword search over the project KB's LanceDB index. Use this skill instead of loading all KB files when searching for a specific concept, term, or constraint.

Prerequisite: kb/.index/ must exist. Run /kb-reindex first if not.

Steps

Step 1 — Pre-condition check

[ -d kb/.index ] && echo "index: present" || echo "index: absent"

If absent:

⛔ No KB index found at kb/.index/. Run /kb-reindex to build the index first.


Step 2 — Execute hybrid search

Accept:

  • query (string): the search query
  • top_k (int, default: 5): number of results to return
  • include_all_statuses (bool, default: false): if false, filter out historical and superseded chunks

Hybrid search algorithm:

  1. Vector search: embed query with the same model used for indexing. Compute cosine similarity against all chunks in kb_chunks. Retrieve top top_k * 3 candidates.

  2. Keyword search: tokenize query. Score each candidate with BM25 against its content field.

  3. Score fusion: combine vector score (weight 0.7) and BM25 score (weight 0.3). Re-rank by fused score.

  4. Status filter: if include_all_statuses = false, remove chunks where status is historical or superseded. Apply this as a pre-filter on the vector query (not post-fusion) so that top_k * 3 candidates are drawn only from live-doctrine and derived chunks, ensuring top_k results are always available when they exist.

  5. Return top top_k results.


Step 3 — Format results

Return a ranked list:

KB Search Results for: "<query>"
Showing top N results (historical/superseded filtered)

1. [score: 0.92] kb/properties.md § "Invariants"
   > "All database writes must be wrapped in explicit transactions..."
   Status: live-doctrine

2. [score: 0.87] kb/spec.md § "API Contract"
   > "The API must return errors in the format {error: string, code: int}..."
   Status: live-doctrine

3. [score: 0.61] kb/architecture.md § "Storage Layer"
   > "PostgreSQL is the primary storage backend..."
   Status: live-doctrine

Read the full file on GitHub · 83 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. 1mo ago Changed · -1 lines · -9 tokens per session a52b5358882b
  2. 1mo ago First seen · 84 lines · 26 tokens per session scan A 0e199b9595b1

Subscribe to this mod's changes

kb-search is a command published in the GitHub repository mathiasbourgoin/roster (2 stars, last pushed 2d ago), licensed MIT. It adds 17 tokens to every session and 798 once invoked, about $0.0001 per session on Opus 5.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-07.