Agent Tool Reference

All 16 Agent Tools, one MCP reference.

Every tool is an MCP call over stdio. Pick a tool on the left to read its registry-owned description, modes, runtime defaults, safety behavior, returns, limitations, errors, staleness semantics, parameters, and a real example invocation.

Discovery

bb_search

readrequires indexsearch

Unified lexical, content, exact-symbol, and file retrieval.

Unified indexed retrieval for symbol lists, content, exact symbol source, or files. This is retrieval, not natural-language explanation or code analysis. Symbol/content/file modes carry a freshness block ({ fresh, stale, missing, staleRatio, mode, remediation }) stating whether results reflect the current files; rows may carry stale=true. Remediation names the exact reindex command. When a read finds stale/missing files within budget, the handler auto-refreshes exactly those files (reindexFilesParallel) before answering and declares it in an autoRefresh field; refresh=false opts out and answers from existing data with the staleness block.

Best used for

Unified lexical, content, exact-symbol, and file retrieval.

Safety behavior

Read-only. It does not refresh the index or modify source files.

Modes (4)

  • symbols
  • content
  • symbol
  • file

Runtime defaults

  • mode · symbols
  • limit · 15
  • includeContent · false
  • exact · false
  • caseSensitive · false
  • regex · false
  • offset · 0

Returns

  • Indexed matches with file and line provenance
  • Exact symbol or bounded file source in retrieval modes
  • Freshness state where available

Errors

  • Missing mode-specific query, symbolName, or filePath
  • Invalid regular expression
  • Unknown or mode-irrelevant option

Limitations

  • Results reflect the current index and may be stale
  • Content search is lexical; use bb_ask for semantic discovery

Relationship to other tools

For lexical/exact retrieval use this tool. For natural-language questions over the codebase use `bb_ask` (semantic, cited answers).

Evidence semantics

Paths, line ranges, symbol kinds, and source snippets are indexed evidence; stale flags qualify that evidence.

Pagination and result limits bound retrieval; exact indexed lookup is preferred over content scanning.

Staleness

Freshness modes (registered as freshnessModes): symbol, content, file. Staleness surfaces as: per-row stale flags + freshness block ({ fresh, stale, missing, staleRatio, mode, remediation }). When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
caseSensitivebooleanOptionalcase-sensitive matching (default false)
exactbooleanOptionalonly exact name matches (default false)
filePathstringOptionalfile target or symbol disambiguation
includeContentbooleanOptionalinclude a code snippet per result (default false)
languagestringOptionalfilter by language (e.g. typescript, python, go)
limitnumberOptionalmax results (default 15)
modestringOptionalretrieval mode (default symbols)
offsetnumberOptionalpagination offset (default 0)
querystringOptionalsymbol/content query; also accepted as the exact symbol name
refreshbooleanOptionalfalse opts out of the inline auto-refresh of stale files (default: auto-refresh within budget before answering)
regexbooleanOptionaltreat query as a regex against symbol names (default false)
symbolKindstringOptionalfilter by symbol kind (function, class, variable, interface, enum, ...)
symbolNamestringOptionalexact symbol name for symbol mode

Example tool input

{
  "mode": "symbols",
  "query": "handleRequest",
  "limit": 5
}

Reference: docs/tools/bb_search.md

Discovery

bb_ask

readrequires indexsearch

Natural-language answers and semantic matches.

Answer a question about the codebase using semantic search over the index. Returns matched symbols with similarity scores.

Best used for

Natural-language answers and semantic matches.

Safety behavior

Read-only. It does not write source or silently rebuild embeddings.

Modes (1)

  • answer

Planned (roadmap, not executable today): explainfeature

Runtime defaults

  • limit · 5

Returns

  • Natural-language answer
  • Ranked semantic matches
  • Similarity and source provenance

Errors

  • Empty query
  • Unavailable index or embedding state
  • Unknown option

Limitations

  • Semantic similarity discovers candidates but does not independently prove a claim
  • Local word vectors provide lexical-quality fallback rather than model-quality semantics

Relationship to other tools

For exact symbol/content/file retrieval use `bb_search`; this tool answers natural-language questions with citations.

Evidence semantics

Treat matched symbols and resolvable source locations as evidence; treat generated explanation as interpretation.

The limit bounds returned semantic matches; embedding coverage and model choice affect ranking quality.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
querystringRequirednatural-language question
limitnumberOptionalmax results (default 5)

Example tool input

{
  "query": "how does request handling work?"
}

Reference: docs/tools/bb_ask.md

Diagnostics

bb_health

readno index requiredlifecycle

Unified index, schema, freshness, embeddings, runtime, integrity, and analysis history.

Unified index health: file/symbol/relationship/imports counts, embedding model + coverage, schema version, runtime, and file freshness. Use verbose=true for per-language breakdown and stale-file names, refresh=true to reindex before reporting, force=true to force a full in-place reindex before reporting, integrity=true for the 12-point index health check, complete=true for full (not sampled) freshness, includeAnalysisRuns=true for persisted run/finding totals, history=true for persisted analysis history.

Best used for

Unified index, schema, freshness, embeddings, runtime, integrity, and analysis history.

Safety behavior

Status is read-only. refresh=true explicitly mutates only index data; force=true performs a full in-place reindex.

Modes (2)

  • status
  • refresh

Runtime defaults

  • verbose · false
  • history · false
  • limit · 20
  • refresh · false
  • force · false
  • wait · true
  • freshness · sampled
  • sampleSize · 200
  • integrity · false
  • includeAnalysisRuns · false

Returns

  • Index, schema, runtime, freshness, and embedding health
  • Optional integrity and analysis-history summaries
  • Typed warnings and refresh outcome

Errors

  • Invalid freshness or sample settings
  • Refresh/index failure
  • Unknown option

Limitations

  • Sampled freshness is not a complete filesystem proof
  • Embedding coverage reports stored state, not semantic quality

Relationship to other tools

For index size/counts use `bb index status` (CLI) or the stats surface; this tool reports index health and integrity.

Evidence semantics

Counts and versions come from the brain database; freshness compares indexed metadata with the filesystem.

Sampled freshness is the default; complete freshness and integrity checks intentionally cost more.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
forcebooleanOptionalforce a full in-place reindex before reporting
freshnessstringOptionalfreshness mode (default sampled)
historybooleanOptionalreturn persisted analysis history (default false)
includeAnalysisRunsbooleanOptionalinclude persisted analysis run/finding totals
integritybooleanOptionalrun the 12-point index integrity check
limitnumberOptionalhistory run limit (default 20)
refreshbooleanOptionalreindex the project before reporting
sampleSizenumberOptionalfreshness sample count (default 200)
verbosebooleanOptionalinclude stale/missing file names (default false)
waitbooleanOptionalwait for refresh to finish (default true)

Example tool input

{
  "verbose": true
}

Reference: docs/tools/bb_health.md

Analysis

bb_patterns

readrequires indexanalysis

Pattern/orphan analysis with optional persisted run history.

Detect orphaned code, framework patterns, and anti-patterns, with staleness markers when a finding's file changed after indexing. Use scope=orphaned for dead code; scope=all (default) for the full pattern scan with the optional pattern/confidence filters. Architecture and code-quality analysis are planned, not yet executable.

Best used for

Pattern/orphan analysis with optional persisted run history.

Safety behavior

Source is read-only. recordRun writes only analysis-history records in the brain database.

Modes (2)

  • orphaned
  • all

Planned (roadmap, not executable today): qualityarchitecture

Runtime defaults

  • scope · all
  • limit · 20
  • includeOrphaned · true
  • includeFramework · true
  • includeAntiPatterns · true
  • confidenceThreshold · 0.6
  • history · false
  • recordRun · false

Returns

  • Pattern findings with confidence and locations
  • Orphan, framework, and anti-pattern classifications
  • Optional persisted run history

Errors

  • Invalid scope or confidence threshold
  • Unavailable index
  • Unknown option

Limitations

  • Orphan status is static incoming-reference evidence, not proof that code is unused
  • Framework and anti-pattern detection is heuristic and confidence-qualified
  • Candidates are derived from analyzer-extracted symbols and relationships; the same graph gaps (dynamic/reflection wiring, unresolved cross-file references) that limit the analyzers also constrain these detections

Relationship to other tools

For security-specific taint findings use `bb_security`; this tool covers orphans, framework patterns, and anti-patterns.

Evidence semantics

Every finding is confidence-qualified and tied to indexed files, symbols, or relationships.

The result limit and confidence threshold bound reporting; history access is separately limited.

Staleness

Freshness applies to the tool's read output (no registered per-mode split). Staleness surfaces as: per-finding [stale] markers + counts footer naming the remediation; silent when all fresh. When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
confidenceThresholdnumberOptionalminimum confidence 0..1 (default 0.6)
historybooleanOptionalreturn persisted pattern history
includeAntiPatternsbooleanOptionalinclude anti-patterns (default true)
includeFrameworkbooleanOptionalinclude framework patterns (default true)
includeOrphanedbooleanOptionalinclude orphaned-code patterns in an all scan (default true)
limitnumberOptionalmax results (default 20)
recordRunbooleanOptionalpersist this scan as an analysis run
scopestringOptionalorphaned only, or all pattern classes (default all)

Example tool input

{
  "scope": "orphaned"
}

Reference: docs/tools/bb_patterns.md

Diagnostics

bb_security

readrequires indexanalysis

Cross-language findings with optional persisted run history.

Cross-language security scan: SQL injection, XSS, command injection, hardcoded secrets, weak crypto. Findings whose underlying file changed after indexing carry a staleness marker.

Best used for

Cross-language findings with optional persisted run history.

Safety behavior

Source is read-only. recordRun writes only analysis-history records in the brain database.

Modes (1)

  • findings

Planned (roadmap, not executable today): flowsummaryhotspots

Runtime defaults

  • history · false
  • recordRun · false
  • limit · 20

Returns

  • Normalized security findings
  • Cross-language source-to-sink flow evidence
  • Optional persisted run history

Errors

  • Unavailable index
  • Invalid history limit
  • Unknown option

Limitations

  • Static taint analysis can produce false positives and false negatives
  • It is not runtime testing or a penetration test

Relationship to other tools

For general code-quality patterns use `bb_patterns`; this tool focuses on taint flows and security findings.

Evidence semantics

A finding is supported by indexed source/sink locations and relationship paths; severity does not imply exploitability.

Indexed flow analysis and output/history limits bound work and response size.

Staleness

Freshness applies to the tool's read output (no registered per-mode split). Staleness surfaces as: per-finding [stale] markers + counts footer naming the remediation; silent when all fresh. When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
historybooleanOptionalreturn persisted security history
limitnumberOptionalhistory run limit (default 20)
recordRunbooleanOptionalpersist this scan as an analysis run

Example tool input

{}

Reference: docs/tools/bb_security.md

Diagnostics

bb_visualize

readrequires indexanalysis

Scoped canonical dependency graphs with explicit truncation and provenance.

Scoped dependency and architecture visualization over the canonical graph engine, with explicit filters, provenance, truncation, machine-readable JSON, and self-contained HTML. Every node and link carries a stale flag (file changed since index); links inherit worst-of-endpoints; a freshness envelope rides the JSON output. Same owner-cascade semantics as bb_graph: member-level relationships are attributed to the owner class.

Best used for

Scoped canonical dependency graphs with explicit truncation and provenance.

Safety behavior

Read-only. HTML output contains the same bounded graph as JSON and does not mutate the project.

Modes (5)

  • project
  • file
  • module
  • symbol
  • feature

Runtime defaults

  • scope · project
  • maxNodes · 200
  • maxLinks · 5000
  • format · text

Returns

  • Canonical nodes and links
  • Text, JSON, or self-contained HTML projection
  • Provenance and explicit truncation metadata

Errors

  • Missing target for a scoped graph
  • Unsupported scope or format
  • Unavailable index

Limitations

  • The graph reflects static indexed relationships
  • Nodes and links beyond configured budgets are omitted and reported
  • Owner-cascade attribution: member-level relationships are attributed to the owner class, same as bb_graph

Relationship to other tools

For raw graph data use `bb_graph`; this tool renders diagrams with truncation metadata.

Evidence semantics

Nodes and links resolve to canonical indexed entities; links with omitted endpoints are not emitted.

maxNodes, maxLinks, scope, relationshipTypes, and languages constrain graph construction.

Staleness

Freshness applies to the tool's read output (no registered per-mode split). Staleness surfaces as: per-node and per-link stale flags (links inherit worst-of-endpoints) + freshness envelope ({ fresh, stale, missing, staleRatio, mode, remediation }) on JSON; truncation composes with staleness. When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
formatstringOptionaloutput format (default text)
languagesarrayOptionallanguage filter
maxLinksnumberOptionalmax links (default 5000)
maxNodesnumberOptionalmax nodes (default 200)
relationshipTypesarrayOptionalrelationship type filter
scopestringOptionalgraph scope (default project)
targetstringOptionalfile, module, symbol, or feature target

Example tool input

{
  "scope": "symbol",
  "target": "handleRequest",
  "format": "json"
}

Reference: docs/tools/bb_visualize.md

Analysis

bb_migrate

readrequires indexanalysis

Batch cross-language migration plans with ordering, methodology, and unsupported mappings.

Read-only single or batch migration planning with dependency order, explicit effort methodology, library mappings, risks, truncation, and unsupported cases. Plans whose source file changed since the last index are flagged stale up front — a plan is a claim about current code; JSON output carries the freshness block.

Best used for

Batch cross-language migration plans with ordering, methodology, and unsupported mappings.

Safety behavior

Read-only. It does not generate, replace, or compile target-language source.

Modes (1)

  • plan

Runtime defaults

  • format · text

Returns

  • Dependency-ordered migration plans
  • Effort methodology, library mappings, and risks
  • Explicit unsupported and truncation results

Errors

  • Missing targetLanguage
  • No symbolName or symbolNames
  • Unknown option

Limitations

  • Plans are estimates, not translated source
  • Library mappings are advisory and unsupported routes remain explicit
  • Dependency ordering and mapping depend on the analyzer-extracted symbol and relationship graph; edge cases that the analyzers cannot resolve (reflection, dynamic dispatch, or cross-file relations the grammar does not model) limit the completeness of the resulting plan

Relationship to other tools

For dependency structure use `bb_graph`; this tool produces migration plans with declared limitations.

Evidence semantics

Dependency ordering comes from indexed relationships; effort and mappings are labeled methodology-driven estimates.

Requests are capped at 100 symbols and dependency traversal is bounded.

Staleness

Freshness modes (registered as freshnessModes): plan. Staleness surfaces as: per-plan sourceFile + stale flags with an up-front stale-plan notice + freshness envelope ({ fresh, stale, missing, staleRatio, mode, remediation }) on JSON. When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
targetLanguagestringRequirede.g. rust, go, python
formatstringOptionaloutput format (default text)
symbolNamestringOptionallegacy single symbol alias
symbolNamesarrayOptionalone or more symbols to migrate

Example tool input

{
  "symbolName": "handleRequest",
  "targetLanguage": "go"
}

Reference: docs/tools/bb_migrate.md

Analysis

bb_analyze

readrequires indexanalysis

One typed analysis surface replacing standalone relationship and test intelligence names.

Unified evidence-backed analysis over graph relationships, dependencies, statistics, complexity, impact, and test intelligence. Select exactly one mode. Every read mode carries a freshness block (fresh/stale/missing counts + remediation) resolved against the live working tree; graph nodes and report rows carry a stale flag when their file changed after indexing. Callers/callees/trace/impact modes share the graph engine's owner-cascade semantics: a relationship stored against a class member is attributed to the owner class. Per-mode parameters: target applies to callers, callees, trace, complexity, impact, and test_impact; filePath scopes dependencies only; stats, test_mapping, test_gaps, and test_quality are project-wide and ignore both.

Best used for

One typed analysis surface replacing standalone relationship and test intelligence names.

Safety behavior

Read-only. Analysis never creates tests or edits source.

Modes (11)

  • callers
  • callees
  • trace
  • dependencies
  • stats
  • complexity
  • impact
  • test_mapping
  • test_gaps
  • test_impact
  • test_quality

Runtime defaults

  • limit · 20

Returns

  • Mode-specific typed analysis
  • Graph, dependency, complexity, impact, or test evidence
  • Explicit unavailable and truncation states

Errors

  • Missing required mode
  • Missing target for a target-based mode
  • Option irrelevant to the selected mode

Limitations

  • Static relationships cannot establish runtime behavior
  • Test results describe indexed static evidence, not executed coverage
  • Callers/callees/trace/impact modes share the graph engine's owner-cascade semantics: a relationship stored against a class member is attributed to the owner class

Relationship to other tools

For the plain per-symbol call graph use `bb_graph` (same engine, evidence tiers). For bounded impact-with-files use mode `impact` (numbers identical to `bb_impact`).

Evidence semantics

Findings derive from brain_* symbols, files, relationships, complexity, and test-file classifications.

Mode-specific limits and graph traversal bounds prevent unbounded output.

Staleness

Freshness modes (registered as freshnessModes): callers, callees, trace, dependencies, stats, complexity, impact, test_mapping, test_gaps, test_impact, test_quality. Staleness surfaces as: freshness block ({ fresh, stale, missing, staleRatio, mode, remediation }); graph nodes and report rows carry stale flags (project-wide modes sample or resolve visible rows only — the block names its coverage mode). When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
modestringRequiredanalysis mode
filePathstringOptionalfile scope for file-based analysis
limitnumberOptionalresult limit
targetstringOptionalsymbol or analysis target

Example tool input

{
  "mode": "callers",
  "target": "handleRequest"
}

Reference: docs/tools/bb_analyze.md

Analysis

bb_doc

readrequires indexanalysis

Cited Markdown or JSON documentation over indexed source and relationships.

Generate read-only, evidence-backed documentation with resolvable citations and a freshness block over the cited files. Supports symbol, file, module, feature, API, project, and documentation-coverage modes in Markdown or JSON.

Best used for

Cited Markdown or JSON documentation over indexed source and relationships.

Safety behavior

Read-only. It never refreshes implicitly, writes source, or invokes bb_edit.

Modes (7)

  • symbol
  • file
  • module
  • feature
  • api
  • project
  • coverage

Runtime defaults

  • format · markdown
  • audience · developer
  • detail · standard
  • includeExamples · false
  • includeDiagrams · false
  • includeTests · false
  • limit · 20
  • maxTokens · 4000

Returns

  • Markdown or structured JSON documentation
  • Resolvable citations and evidence classifications
  • Quality and website reference metadata

Errors

  • Missing target for target-based mode
  • Unsupported format or mode
  • Unavailable indexed evidence

Limitations

  • Unknown facts remain explicit rather than inferred without support
  • Stale evidence is qualified and cannot silently become current

Relationship to other tools

For raw symbol metadata use `bb_search` mode `symbol`; this tool composes documented, cited explanations.

Evidence semantics

Claims are classified as extracted, inferred, generated, or unknown and carry resolvable citations where applicable.

Evidence count and maxTokens impose explicit response budgets.

Staleness

Freshness applies to the tool's read output (no registered per-mode split). Staleness surfaces as: freshness envelope ({ fresh, stale, missing, staleRatio, mode, remediation }) on JSON + footer naming the remediation; per-citation (stale) in Sources; silent when all fresh. When something is stale/missing, the remediation names the registered reindex interfaces: project scope → reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only); file scope → reads auto-refresh this file within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index "<file>" (or the bb_index tool with that file path). Nothing is stale → silence (no remediation text). Detection uses a mtime+size fast path with a content-hash fallback: an edit that leaves both size and mtime unchanged is reported fresh without hashing (same trade-off as git's index stat-cache; accepted, documented in src/brain/freshness.ts).

Parameters

ParameterTypeRequiredDescription
modestringRequireddocumentation mode
audiencestringOptionaldocumentation audience
detailstringOptionaldetail level
formatstringOptionaloutput format (default markdown)
includeDiagramsbooleanOptionalinclude cited diagrams when available
includeExamplesbooleanOptionalinclude only source-backed examples
includeTestsbooleanOptionalinclude indexed test evidence
limitnumberOptionalmaximum evidence items
maxTokensnumberOptionaloutput token budget
targetstringOptionalsymbol, file, module, feature, or API target; optional for project and coverage

Example tool input

{
  "mode": "symbol",
  "target": "handleRequest"
}

Reference: docs/tools/bb_doc.md

Operations

bb_edit

writerequires indexoperations

Unified safe source editing with preview, validation, rollback, and reindex.

Unified, validated source mutation. Discriminated by mode: write, update, insert, delete, or refactor. Supports dry-run previews, separator/symlink-safe paths, AST byte bounds, caller protection, rollback on validation failure, formatting, and reindexing.

Best used for

Unified safe source editing with preview, validation, rollback, and reindex.

Safety behavior

Write-capable. Uses project-root path checks, atomic writes, snapshots, validation, and rollback; use dryRun before risky edits.

Modes (5)

  • write
  • update
  • insert
  • delete
  • refactor

Runtime defaults

  • dryRun · false
  • format · true
  • force · false

Returns

  • Structured mutation result or dry-run preview
  • Validation, formatting, rollback, and reindex status
  • Affected paths and caller protection outcomes

Errors

  • Path escape or symlink escape
  • Stale or ambiguous indexed symbol bounds
  • Caller protection, parse, formatting, or reindex failure

Limitations

  • Named symbol edits require a fresh index
  • Refactoring is identifier-aware static rewriting, not a full language-server proof

Relationship to other tools

To attach human-visible notes to symbols use `bb_annotate`; this tool mutates source files.

Evidence semantics

Mutation bounds come from indexed AST bytes; validation and reindex state report whether post-edit evidence is current.

Only affected files are written, formatted, validated, and reindexed.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
modestringRequiredEdit kind: write (create or overwrite a file), update (replace a symbol body), insert (add code relative to a symbol), delete (remove a symbol), or refactor (identifier-aware rename)
contentstringOptionalFull file content for write mode; also accepted in place of newContent for update and insert
dryRunbooleanOptionalPreview the planned changes without writing any file (default false)
filePathstringOptionalwrite: project-relative target file to create or overwrite. Other modes: disambiguates symbolName when it appears in multiple files
forcebooleanOptionaldelete: allow removal when indexed callers or live references survive; leftovers are reported as warnings (default false)
formatbooleanOptionalRun the project formatter on written files after the edit (default true)
lineStartnumberOptionalDeclaration line of the target symbol, used with symbolName/filePath to disambiguate repeated names
newContentstringOptionalReplacement source: update swaps the symbol body for this text; insert adds this text relative to targetSymbolName
newNamestringOptionalrefactor: the valid identifier the symbol is renamed to
positionstringOptionalinsert anchor relative to targetSymbolName (default after)
symbolNamestringOptionalName of the symbol to update, delete, or refactor (named-symbol edits require a fresh index)
targetSymbolNamestringOptionalinsert: symbol whose body or boundary receives the new code (required for insert)

Example tool input

{
  "mode": "update",
  "symbolName": "helper",
  "newContent": "export function helper() { return 2 }"
}

Reference: docs/tools/bb_edit.md

Operations

bb_index

writeno index requiredoperations

Immediately refresh the index for a just-written/edited file or directory; mode=post re-derives relationships/taints/health without re-parsing.

Reindex a file or directory so the index reflects edits immediately (agent-fresh). Accepts a path (file or dir); a file reindexes only that file, a dir runs an incremental index of that dir (changed files only). mode=post re-runs the heavy derived-data phases (relationships/enrichment/gravity/taints/health) WITHOUT re-parsing — the remediation after edits on incremental paths. Returns indexed/deleted/error counts, or the per-phase post-processing report.

Best used for

Immediately refresh the index for a just-written/edited file or directory; mode=post re-derives relationships/taints/health without re-parsing.

Safety behavior

Write-capable against index data only. It never modifies source files.

Modes (4)

  • auto
  • file
  • dir
  • post

Runtime defaults

  • mode · auto

Returns

  • Indexed, deleted, and error counts for the refreshed path
  • Mode actually applied (auto resolved, file, or dir)
  • Per-file error names for any file that failed to reindex

Errors

  • Missing path
  • Path outside the project root
  • Parse or store failure for an individual file

Limitations

  • A file reindex updates only that file's evidence; cross-file relationships refresh on the next full or incremental dir index
  • Dir mode reuses the incremental indexer: unchanged files are skipped by design

Relationship to other tools

The CLI twin is `bb index` (same semantics; see docs/MCP_CLI_INDEXER_GUIDE.md). Refresh changed files after agent edits with mode `dir`/`file` or the CLI `--changed`.

Evidence semantics

Counts come from the real parse/store pipeline; errors name the file that failed rather than swallowing it.

A single file reindex is bounded by that file's parse cost; dir mode is bounded by the changed-file set.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
pathstringRequiredProject-relative file (reindex only that file) or directory (incremental index of changed files); for mode=post, the project whose derived phases should be re-run
modestringOptionalauto (default) infers file vs dir from path; file reindexes one file; dir runs an incremental directory index; post re-runs derived phases (relationships/taints/health) without re-parsing

Example tool input

{
  "path": "src/new-file.ts"
}

Reference: docs/tools/bb_index.md

Analysis

bb_graph

readrequires indexgraph

Per-symbol graph with per-edge evidence tiers — the agent view of the editor's graph panel.

Per-symbol dependency graph over the canonical graph engine: callers, callees, per-edge evidence tier (structural/import_based/usage_contextual/reference_qualified/inferred), confidence, and cross-language edge count. Same engine and tier rules the editor graph panel uses; truncated traversals are declared with a reason, never silent. Traversal semantics: a relationship stored against any member of a class (a method call, an inherited behavior) is attributed to the owner class, so caller/callee sets include the owner-family level — every edge still traces to a stored relationship row.

Best used for

Per-symbol graph with per-edge evidence tiers — the agent view of the editor's graph panel.

Safety behavior

Read-only. It does not modify source files or index data.

Modes (1)

  • graph

Runtime defaults

  • maxDepth · 3

Returns

  • Per-symbol dependency graph: callers and callees
  • Per-edge evidence tier (structural/import_based/usage_contextual/reference_qualified/inferred) with confidence
  • Declared truncation with a reason when the traversal is bounded

Errors

  • Missing symbol
  • maxDepth outside the declared 1-10 range
  • Symbol not found in the index

Limitations

  • Edges reflect indexed static evidence with declared tiers; inferred edges are labeled, not proven
  • The graph reflects the index as of the last index run
  • Owner-cascade attribution: a relationship stored against a class member (e.g. a call to a method) is reported toward the owner class, so caller/callee sets are a superset of exact-symbol-only matches — every edge still traces to a stored relationship row

Relationship to other tools

For richer analysis (dependencies, complexity, tests, impact aggregation) use `bb_analyze`; for plain callers/callees with evidence tiers this is the tool.

Evidence semantics

Nodes and edges come from the canonical graph engine over brain_symbol and brain_relationship rows; each edge carries its evidence tier and confidence.

maxDepth (default 3, max 10) bounds traversal; per-edge evidence resolution is bounded by the returned subgraph.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
symbolstringRequiredsymbol name to root the graph at
maxDepthnumberOptionaltraversal depth bound (default 3)

Example tool input

{
  "symbol": "handleRequest"
}

Reference: docs/tools/bb_graph.md

Analysis

bb_impact

readrequires indexgraph

Bounded impact with declared truncation — identical numbers to the editor's impact mode.

Bounded reverse-dependency impact for one symbol via the same component the editor graph panel uses: declared node budget (200) and depth (5), truncation as a first-class field with reason, and an independently declared total when computable. Unknown symbols are loud declared errors — an empty impact set is never invented. Owner-cascade applies: impact includes dependents attributed at class level, not only exact-symbol rows.

Best used for

Bounded impact with declared truncation — identical numbers to the editor's impact mode.

Safety behavior

Read-only. It does not modify source files or index data.

Modes (1)

  • impact

Runtime defaults

No declared defaults — every option is explicit.

Returns

  • Downstream dependents of the symbol with per-edge evidence tiers and confidence
  • Declared-absent result when the symbol is unknown — never an empty guess

Errors

  • Missing symbol
  • Symbol not found in the index

Limitations

  • Static impact analysis cannot establish runtime behavior
  • Reflects the index as of the last index run
  • Owner-cascade attribution applies: dependents through class-member relationships are attributed to the owner class

Relationship to other tools

This is the bounded-impact specialist; `bb_analyze` mode `impact` aggregates the same canonical walk with file-level risk — the numbers are identical by gate.

Evidence semantics

Impact derives from brain_relationship rows via the same engine the editor impact panel uses.

Traversal bounds match the canonical graph engine limits; output scales with the dependents subgraph.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
symbolstringRequiredsymbol name to compute impact for

Example tool input

{
  "symbol": "handleRequest"
}

Reference: docs/tools/bb_impact.md

Analysis

bb_cross_language

readrequires indexgraph

Stored cross-language pairs with declared absence — the agent view of the hover section.

Cross-language facts for one symbol from stored brain_relationship rows only (is_cross_language = 1), per-pair with bridge mechanism and evidence tier. Pairs with no stored rows are declared absent — this tool never infers, guesses, or aspires. Identical semantics to the editor's cross-language hover section.

Best used for

Stored cross-language pairs with declared absence — the agent view of the hover section.

Safety behavior

Read-only. It does not modify source files or index data.

Modes (1)

  • cross-language

Runtime defaults

No declared defaults — every option is explicit.

Returns

  • Cross-language relationship pairs for the symbol with bridge mechanism and evidence tier
  • Declared-absent result when no stored cross-language rows exist

Errors

  • Missing symbol
  • Symbol not found in the index (declared, not an empty set)

Limitations

  • Reads stored is_cross_language=1 relationship rows only; never infers cross-language facts
  • Coverage depends on the analyzers that produced cross-language rows

Relationship to other tools

For same-language callers/callees use `bb_graph`; this tool reports cross-language pairs and bridges (declared absent when none).

Evidence semantics

Only brain_relationship rows with is_cross_language=1; identical semantics to the editor cross-language hover section.

Bounded by the stored cross-language rows for the symbol; no graph traversal.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
symbolstringRequiredsymbol name to fetch cross-language facts for

Example tool input

{
  "symbol": "Warehouse"
}

Reference: docs/tools/bb_cross_language.md

Analysis

bb_annotate

writeno index requiredannotations

Agent note with enforced provenance, stored where the human reads.

Attach an agent-authored annotation to a symbol in the shared index. Provenance is enforced: the row records author class 'agent' (never spoofable), the calling tool identity, and timestamps. Re-annotating the same symbol+path updates the note in place — one note per author per location. Annotations are opinions layered on evidence, never index facts, and surface in the editor where the human reads (hover + graph). To change source code use bb_edit; to read notes back use bb_annotations.

Best used for

Agent note with enforced provenance, stored where the human reads.

Safety behavior

Write-capable against the annotation store only. It never modifies source files.

Modes (1)

  • annotate

Runtime defaults

No declared defaults — every option is explicit.

Returns

  • Stored annotation id and provenance (tool identity, timestamp)
  • Declared refusals for missing symbol, empty body, or over-limit body

Errors

  • Missing or unknown symbol
  • Empty body (a refusal, not a silent no-op)
  • Body exceeds the declared 2000-char limit

Limitations

  • Annotations are opinions layered on index evidence, never index truth
  • Annotation store semantics are owned by the M28 workstream

Relationship to other tools

To change source code use `bb_edit`; this tool stores provenance-enforced notes on symbols.

Evidence semantics

Annotations carry provenance (toolIdentity, time) and are stored in brain_annotation.

Constant-time store write bounded by the 2000-char body limit.

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
bodystringRequiredannotation text (max 2000 chars)
symbolstringRequiredsymbol name to annotate
pathstringOptionaloptional file path to disambiguate same-named symbols
toolIdentitystringOptionaloptional name of the calling agent/tool (recorded verbatim)

Example tool input

{
  "symbol": "handleRequest",
  "body": "Legacy auth path — scheduled for removal in Q3."
}

Reference: docs/tools/bb_annotate.md

Analysis

bb_annotations

readno index requiredannotations

Annotations with full provenance; absence declared.

Read annotations for a symbol (or all annotations up to the declared limit) with full provenance on every row: author class, tool identity, and timestamps. No annotations is a declared absence, never an error. To write a note use bb_annotate.

Best used for

Annotations with full provenance; absence declared.

Safety behavior

Read-only. It does not modify source files, index data, or annotations.

Modes (1)

  • annotate

Runtime defaults

  • limit · 50

Returns

  • Typed annotations for a symbol or the whole project, with full provenance (author class, tool identity, timestamps)
  • Declared-absent result when none exist — absence is never an error

Errors

  • limit outside the declared 1-200 range

Limitations

  • Reads only stored annotations; absence is declared, not inferred
  • Annotation store semantics are owned by the M28 workstream

Relationship to other tools

To write a note use `bb_annotate`; this tool reads stored annotations and declares absence.

Evidence semantics

Rows come from brain_annotation with provenance fields preserved.

Indexed lookup by project and symbol (brain_annotation_project_symbol_idx).

Staleness

This tool does not report per-file index staleness and does not auto-refresh. Output reflects the index as of the last index run; when files changed after indexing, refresh first (project scope: reads auto-refresh stale files within budget when enabled — disable with BB_NO_AUTO_REFRESH=1 or refresh=false; manual repair: run: bb index --changed (or the bb_index tool with the project path — incremental, changed files only)).

Parameters

ParameterTypeRequiredDescription
limitnumberOptionalmax rows returned (default 50, cap 200)
symbolstringOptionalsymbol name (omit to list all annotations)

Example tool input

{
  "symbol": "handleRequest"
}

Reference: docs/tools/bb_annotations.md

Every word above is generated from the same tool manifest the MCP server and CLI expose and from the shipped reference pages under docs/tools/. If a tool behaves differently than documented here, that is a bug worth reporting.

Agent tools in the guide

Wiring the server: bb mcp · one call per tool over stdio.