Build KB Command /build-kb¶
Overview¶
/build-kb is a thin shortcut that asks the active chat agent to follow the
bundled build-kb skill and build the project's vector-indexed
knowledge base — semantic_models, metrics, and reference_sql (the
LanceDB-backed stores). It is the heavy companion to the lightweight
/init: where /init writes the AGENTS.md inventory
plus the cheap file-based stores (knowledge / memory), /build-kb runs
the expensive generation and then refreshes the AGENTS.md KB index.
The skill walks the agent through:
- Resolving the scope from any free-text hints you pass — specific
files (globs/paths), tables, datasources, or business domains. With no
hints it covers the whole project. If
AGENTS.mdalready exists, it reuses that inventory instead of re-scanning the whole tree. - Scanning and classifying the in-scope files plus database metadata
into business domains. A validated-query corpus is enumerated pair by
pair (never sampled) so every
(question, SQL)example is indexed. - Exploring each domain in parallel with read-only
exploresubagents (at most 3 at a time). - Presenting a Generation Manifest — the resolved scope and one row per artifact to generate — then stopping for your confirmation. Reply to confirm, or correct the scope / any row.
- After you confirm, routing every artifact to its store via the
storage-classifyskill: semantic models, metrics, and reference SQL, each generated by its matching subagent (onegen_sql_summarycall per SQL). Each(question, SQL)pair is dual-routed — toreference_sql(the example) and toextract-knowledge(the rule behind it). - Refreshing the
AGENTS.mdKB index — updating## Semantic Models/## Metrics/## Reference SQLwith counts + retrieval tools, and appending any newly mined## Knowledgeentries. It does not rewrite the inventory sections/initowns. IfAGENTS.mdis missing, it writes the full file.
Because /build-kb runs through the standard chat pipeline, you get the
usual UX — streamed ActionHistory events, Ctrl+O to expand trace
details, ESC to interrupt, and multi-turn refinement.
The skill source lives at datus/resources/skills/build-kb/SKILL.md and is
loaded directly from the installed package. Override it at
./.datus/skills/build-kb/SKILL.md (project-local, takes precedence) or
~/.datus/skills/build-kb/SKILL.md (user-global).
Basic Usage¶
> /build-kb
> /build-kb orders + order_items tables and queries/*.sql, sales domain only
> /build-kb only the analytics datasource
/build-kb accepts an optional free-text scope. Anything after the command
is forwarded verbatim to the skill, which parses it into in-scope files /
tables / datasources / domains. With no arguments it covers the whole
project, scoped to the currently active datasource — when several are
configured it builds only that one unless your hints name others. Switch
with /datasource <name> first to target a different datasource.
When the agent runs, you'll see: load_skill, scoped filesystem and
database scans, parallel task calls for the explore subagents, a pause
at the Generation Manifest, then — after you confirm — batched generation
task calls (gen_semantic_model, gen_metrics, gen_sql_summary,
extract-knowledge) and a final edit_file on AGENTS.md.
Prerequisites¶
- A configured LLM. Run
/modelfirst if no model is active. - A non-empty
~/.datus/conf/agent.ymlwith datasources configured via/datasource. - Recommended: run
/initfirst soAGENTS.mdand the initial knowledge/memory exist;/build-kbthen reuses that inventory and only adds the vector stores. It also works standalone (it will createAGENTS.mdif missing).
Relationship to /init and /bootstrap¶
- vs
/init—/initis the lightweight, confirmation-free pass (inventory + file-based knowledge/memory)./build-kbis the heavy, confirmation-gated pass that builds the retrieval-backed stores. Typical flow:/init, then/build-kb(optionally scoped). - vs
/bootstrap—/bootstrapis a separate deterministic, Python TUI flow for bootstrapping the KB (schema / sql / semantic / metrics / knowledge)./build-kbis the agentic, skill-driven equivalent that understands free-text scope hints and routes throughstorage-classify. Use/bootstrapwhen you want the guided TUI; use/build-kbwhen you want the agent to scope and reason about what to generate.
Customizing Output¶
The skill is the single source of truth. To change behavior, edit:
- Project-local override:
./.datus/skills/build-kb/SKILL.md - User-global override:
~/.datus/skills/build-kb/SKILL.md - Built-in fallback:
datus/resources/skills/build-kb/SKILL.md
Project-local skills shadow user-global skills, which shadow the packaged built-in.
See also: /init, /model, /datasource (in the slash command reference), Skills Integration.