build-kb

A command that analyzes a codebase and builds a searchable knowledge base describing its data, workflows, relationships, and overall architecture.

In plain words
What is it for?
Use it to extract models and data structures, map function call flows, inspect important internal logic, discover architecture, and optionally create a semantic search index.
Why use it?
It gives coding agents structured context about a project while reanalyzing only changed files during updates.

Command

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.

agentmods
npx agentmods add commands/jingnanzhou/fellow/build-kb
Clone the repo
git clone --depth 1 https://github.com/jingnanzhou/fellow
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 12,849 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00035 $0.12849
Opus 5 $0.00017 $0.06424
Sonnet 5 $0.00007 $0.02570
Haiku 4.5 $0.00003 $0.01285

Measured yesterday against content hash a075f8e16ee7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

build-kb 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 yesterday.

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.

commands/build-kb.md · 1,368 lines

How it starts

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

Build Knowledge Base

Extract comprehensive semantic knowledge from a codebase to enable intelligent coding context, architectural guardrails, and constraint enforcement.

Supports Incremental Updates: Only re-analyzes changed files for fast updates during active development.

Objective

Analyze a target project and extract comprehensive semantic knowledge:

  1. Factual Knowledge (Phase 1 - AST-enhanced by default)

    • What entities, models, and data structures exist
    • 90% token reduction via AST parsing
  2. Procedural Knowledge (Phase 2+4 - Unified by default) ⭐ DEFAULT

    • How workflows and execution flows work
    • Inter-function: Call graphs (100% coverage)
    • Intra-function: CFG/DFG/PDG for critical functions (selective 8-10%)
    • 54% token reduction vs traditional
  3. Conceptual Knowledge (Phase 3 - Architecture-enhanced by default) ⭐ DEFAULT

    • What the overall architecture and design patterns are
    • 77% token reduction via generic architecture discovery
    • Disable with --no-architecture flag (for debugging only)
  4. Semantic Index (Phase 5 - Optional)

    • Searchable embeddings for efficient context retrieval
    • 99.5% token reduction for context retrieval
    • Enable with --index flag

Store this knowledge in the target project's .fellow-data/semantic/ directory for use by coding assistants.


Arguments

  • Project Path (optional): Path to target project

    • If empty: Use current working directory
    • If provided: Use specified path
  • Mode Flags (optional):

    • --full: Force complete re-extraction (ignore existing KB)
    • --update: Force incremental update (default if KB exists)
    • No flag: Auto-detect (full if no KB, incremental if KB exists)
  • Optimization Flags (optional):

    • --no-ast: Disable AST-enhanced extraction (use traditional full-file reading)
      • AST extraction is enabled by default
      • Uses AST parsing for Python, JavaScript/TypeScript, Java
      • 90% token reduction for supported languages
      • 10x faster extraction
      • Falls back to traditional reading for other languages
      • Use --no-ast only for debugging or comparison purposes

Read the full file on GitHub · 1,368 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. yesterday First seen · 1,368 lines · 0 tokens per session scan A a075f8e16ee7

Subscribe to this mod's changes

build-kb is a command published in the GitHub repository jingnanzhou/fellow (4 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 35 tokens to every session and 12,849 once invoked, about $0.0002 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-08-31.