Intelligent code understanding and knowledge management for AI agents. Semantic indexing, calibrated confidence, freshness tracking.
TypeScript
1
619 commits
updated Mar 24, 2026
Fast local onboarding. Cited code context. Honest health checks.
Quick Start · CLI · Examples · Docs · Contributing
.-""""-.
.' .--. '.
/ /_ _\ \
| (o)(o) |
| / __ \ | LiBrainian
\ \____/ / codebase brain for agents
'._`--`_.'
/||\
/_||_\
LiBrainian is a codebase intelligence tool for coding agents and developers. It indexes a repository, builds structural and semantic context, and answers questions with ranked files, evidence, and explicit health signals.
Use it when you want a better first pass than grep alone, but still want answers you can inspect and debug.
Core outcomes:
npm install librainian
CLI binaries:
librainian (primary)librarian (compatibility alias)From a GitHub source checkout, build before running the CLI:
npm install
npm run build
| Surface | Maturity | Recommended for |
|---|---|---|
| CLI | Stable | First run, CI, local debugging, fallback path |
| MCP | Stable | Claude Code, Cursor, Windsurf, VS Code, Gemini CLI |
| TypeScript API | Beta | Node-based agents and custom automation |
| Adapter previews (REST / UTCP / A2A / Python) | Source-only | Deferred from the first public release |
If you are new to LiBrainian, start with the CLI first. It is the most direct way to verify that indexing, retrieval, and diagnostics are healthy in your workspace.
18+9+--offline disables remote provider calls--local-only forces fully local behaviorHealthy first-run signs:
quickstart finishes without bootstrap failurequery returns a summary, ranked files, and confidence metadatastatus and doctor agree on workspace stateIf the workspace is stale or partially indexed, prefer fixing that first with librainian doctor or librainian bootstrap --force --mode fast.
This is the recommended first-run path:
# 1) Build an index and repair obvious setup problems
npx librainian quickstart
# 2) Ask a real repo question
npx librainian query "What are the core modules and how do they connect?"
# 3) Inspect readiness and diagnostics
npx librainian status --json
npx librainian doctor --json
Healthy output includes:
status and doctorMore guided onboarding:
For Claude Code, Cursor, Windsurf, VS Code, or Gemini CLI:
npx librainian mcp --print-config
Then follow the client-specific guide in docs/mcp-setup.md.
Recommended MCP flow:
quickstart in the target repo first.status or doctor is healthy.query, get_context_pack, find_symbol, and find_usages as the default tool path.Contributor-only validation, dogfood, and release scripts live in a source checkout. They are not part of the shipped npm package contract.
Use CONTRIBUTING.md for contributor setup, maintainer validation, and release qualification.
import { initializeLibrarian } from 'librainian';
const session = await initializeLibrarian(process.cwd());
const context = await session.query('Add request-id tracing to API handlers');
console.log(context.summary);
console.log(context.relatedFiles);
console.log(context.confidence);
Compatibility API:
import { initializeLibrarian } from 'librainian';
const session = await initializeLibrarian(process.cwd());
const result = await session.query('Explain the deployment pipeline');
Choose the path that matches your runtime:
docs/integrations/mcp.mddocs/integrations/cli.mdlibrainianRecommended integration docs:
Preview adapter notes remain in the GitHub source tree, but they are not part of the shipped npm surface for the first public release.
| Problem | Typical agent flow | LiBrainian flow |
|---|---|---|
| Context assembly | ad-hoc file search | semantic + structural + graph retrieval |
| Confidence handling | implicit certainty | explicit calibrated confidence + uncertainty |
| Architectural reasoning | scattered inferences | linked imports/calls/docs/tests evidence |
| Release discipline | mostly manual | strict evidence-backed qualification |
| Onboarding new repos | repeated setup friction | quickstart with self-healing bootstrap |
query(...)Built-in parsers and extraction paths cover major ecosystems, including:
LiBrainian auto-detects what is present and indexes only what is available in the workspace.
LiBrainian tracks explicit SLA targets for query latency, indexing throughput, and memory budgets.
p50 < 500ms, p95 < 2000ms, p99 < 5000ms10 changed files < 10s< 512MB RSSMaintainer-only performance diagnostics remain available in a source checkout, but they are not part of the first public CLI surface.
SLA reference:
https://github.com/nateschmiedehaus/LiBrainian/blob/main/docs/performance-sla.mdLiBrainian ships an explicit tool-trigger compliance gate for MCP descriptions.
src/mcp/__tests__/tool_triggering_compliance.test.tsCurrent CI pass criteria:
>= 70%>= baseline compliance>= 70% treatment complianceRun locally:
npm test -- --run src/mcp/__tests__/tool_triggering_compliance.test.ts
# Day 0 / onboarding
npx librainian quickstart
npx librainian bootstrap --mode fast
npx librainian uninstall --dry-run
npx librainian doctor --heal
npx librainian check-providers --json
# Day 1 / normal work
npx librainian query "How is auth wired across API and middleware?"
npx librainian status
npx librainian index --force --incremental
npx librainian repo-map --json
If you are working from a source checkout, follow the contributor loop in CONTRIBUTING.md. The shipped package supports runtime usage; contributor validation and release qualification remain source-checkout workflows.
LiBrainian now auto-detects CI/non-interactive runtime when:
CI=true or GITHUB_ACTIONS=true--ci is passed explicitlyIn non-interactive mode, LiBrainian automatically:
--yes behavior)Useful global flags:
npx librainian status --json --ci --quiet
npx librainian bootstrap --mode fast --yes --no-progress --no-color
GitHub Actions example:
- name: Check index freshness (machine-readable)
run: npx librainian status --json --quiet | jq -e '.freshness.staleFiles == 0 and .freshness.missingFiles == 0'
- name: Refresh index non-interactively
run: npx librainian index --force --incremental --yes --quiet
- name: Run health diagnostics
run: npx librainian doctor --json --quiet | jq -e '.summary.status != "ERROR"'
LiBrainian supports staged-file incremental indexing for commit-time freshness:
# index only staged files
npx librainian index --force --staged
# index explicit changed files (lint-staged style)
npx librainian index --force src/api/query.ts src/cli/index.ts
Built-in integration options:
lint-staged (already configured in package.json): runs librainian index --force --staged with staged filenameslefthook (already configured in lefthook.yml): runs librainian index --force --staged {staged_files}pre-commit users: use the repo-level .pre-commit-hooks.yaml hook librainian-update-stagedThese hook integrations are best-effort and non-blocking for known setup failures (for example, repo not bootstrapped yet).
Development and release validation commands are intentionally documented in the source-checkout contributor guide, not as part of the runtime package contract.
Use the first-party composite action to restore cache, run incremental index refresh, and optionally upload index artifacts:
steps:
- uses: actions/checkout@v4
- name: Index codebase with LiBrainian
uses: nateschmiedehaus/LiBrainian/.github/actions/librainian@main
with:
workspace-root: ${{ github.workspace }}
cache-key: librainian-${{ runner.os }}-${{ hashFiles('**/*.ts', '**/*.js', 'package-lock.json') }}
restore-keys: |
librainian-${{ runner.os }}-
upload-artifact: true
artifact-name: librainian-index
The composite action is published as part of the repository contract; maintainer-only release validation for it happens outside the public Actions surface.
Public runtime trust surfaces:
npx librainian status --json includes provenance and readiness summariesnpx librainian doctor --json is the supported public diagnostic surfacePublish provenance checks, tagged releases, and strict qualification remain maintainer-only source-checkout workflows documented in CONTRIBUTING.md.
Examples are GitHub-only source references, not part of the published npm tarball:
https://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/quickstart_programmatic.tshttps://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/agentic_task_loop.tshttps://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/feedback_loop_example.tsdocs/START_HERE.mddocs/README.mddocs/librarian/README.mddocs/librarian/MILESTONE_BRIEF.mddocs/integrations/README.mddocs/mcp-setup.mddocs/mcp-design-principles.mddocs/START_HERE.md, docs/README.md, docs/mcp-setup.md, docs/mcp-design-principles.md, docs/integrations/README.md, docs/integrations/cli.md, docs/integrations/mcp.mdhttps://github.com/nateschmiedehaus/LiBrainian/tree/main/docs/librarianhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/ARCHITECTURE.mdhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/CONTRIBUTING.mdhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/docs/CRASH_DIAGNOSIS.mdMIT License — see LICENSE.
619 commits
TypeScript
97.0%
JavaScript
2.9%
Intelligent code understanding and knowledge management for AI agents. Semantic indexing, calibrated confidence, freshness tracking.
TypeScript
1
619 commits
updated Mar 24, 2026
Fast local onboarding. Cited code context. Honest health checks.
Quick Start · CLI · Examples · Docs · Contributing
.-""""-.
.' .--. '.
/ /_ _\ \
| (o)(o) |
| / __ \ | LiBrainian
\ \____/ / codebase brain for agents
'._`--`_.'
/||\
/_||_\
LiBrainian is a codebase intelligence tool for coding agents and developers. It indexes a repository, builds structural and semantic context, and answers questions with ranked files, evidence, and explicit health signals.
Use it when you want a better first pass than grep alone, but still want answers you can inspect and debug.
Core outcomes:
npm install librainian
CLI binaries:
librainian (primary)librarian (compatibility alias)From a GitHub source checkout, build before running the CLI:
npm install
npm run build
| Surface | Maturity | Recommended for |
|---|---|---|
| CLI | Stable | First run, CI, local debugging, fallback path |
| MCP | Stable | Claude Code, Cursor, Windsurf, VS Code, Gemini CLI |
| TypeScript API | Beta | Node-based agents and custom automation |
| Adapter previews (REST / UTCP / A2A / Python) | Source-only | Deferred from the first public release |
If you are new to LiBrainian, start with the CLI first. It is the most direct way to verify that indexing, retrieval, and diagnostics are healthy in your workspace.
18+9+--offline disables remote provider calls--local-only forces fully local behaviorHealthy first-run signs:
quickstart finishes without bootstrap failurequery returns a summary, ranked files, and confidence metadatastatus and doctor agree on workspace stateIf the workspace is stale or partially indexed, prefer fixing that first with librainian doctor or librainian bootstrap --force --mode fast.
This is the recommended first-run path:
# 1) Build an index and repair obvious setup problems
npx librainian quickstart
# 2) Ask a real repo question
npx librainian query "What are the core modules and how do they connect?"
# 3) Inspect readiness and diagnostics
npx librainian status --json
npx librainian doctor --json
Healthy output includes:
status and doctorMore guided onboarding:
For Claude Code, Cursor, Windsurf, VS Code, or Gemini CLI:
npx librainian mcp --print-config
Then follow the client-specific guide in docs/mcp-setup.md.
Recommended MCP flow:
quickstart in the target repo first.status or doctor is healthy.query, get_context_pack, find_symbol, and find_usages as the default tool path.Contributor-only validation, dogfood, and release scripts live in a source checkout. They are not part of the shipped npm package contract.
Use CONTRIBUTING.md for contributor setup, maintainer validation, and release qualification.
import { initializeLibrarian } from 'librainian';
const session = await initializeLibrarian(process.cwd());
const context = await session.query('Add request-id tracing to API handlers');
console.log(context.summary);
console.log(context.relatedFiles);
console.log(context.confidence);
Compatibility API:
import { initializeLibrarian } from 'librainian';
const session = await initializeLibrarian(process.cwd());
const result = await session.query('Explain the deployment pipeline');
Choose the path that matches your runtime:
docs/integrations/mcp.mddocs/integrations/cli.mdlibrainianRecommended integration docs:
Preview adapter notes remain in the GitHub source tree, but they are not part of the shipped npm surface for the first public release.
| Problem | Typical agent flow | LiBrainian flow |
|---|---|---|
| Context assembly | ad-hoc file search | semantic + structural + graph retrieval |
| Confidence handling | implicit certainty | explicit calibrated confidence + uncertainty |
| Architectural reasoning | scattered inferences | linked imports/calls/docs/tests evidence |
| Release discipline | mostly manual | strict evidence-backed qualification |
| Onboarding new repos | repeated setup friction | quickstart with self-healing bootstrap |
query(...)Built-in parsers and extraction paths cover major ecosystems, including:
LiBrainian auto-detects what is present and indexes only what is available in the workspace.
LiBrainian tracks explicit SLA targets for query latency, indexing throughput, and memory budgets.
p50 < 500ms, p95 < 2000ms, p99 < 5000ms10 changed files < 10s< 512MB RSSMaintainer-only performance diagnostics remain available in a source checkout, but they are not part of the first public CLI surface.
SLA reference:
https://github.com/nateschmiedehaus/LiBrainian/blob/main/docs/performance-sla.mdLiBrainian ships an explicit tool-trigger compliance gate for MCP descriptions.
src/mcp/__tests__/tool_triggering_compliance.test.tsCurrent CI pass criteria:
>= 70%>= baseline compliance>= 70% treatment complianceRun locally:
npm test -- --run src/mcp/__tests__/tool_triggering_compliance.test.ts
# Day 0 / onboarding
npx librainian quickstart
npx librainian bootstrap --mode fast
npx librainian uninstall --dry-run
npx librainian doctor --heal
npx librainian check-providers --json
# Day 1 / normal work
npx librainian query "How is auth wired across API and middleware?"
npx librainian status
npx librainian index --force --incremental
npx librainian repo-map --json
If you are working from a source checkout, follow the contributor loop in CONTRIBUTING.md. The shipped package supports runtime usage; contributor validation and release qualification remain source-checkout workflows.
LiBrainian now auto-detects CI/non-interactive runtime when:
CI=true or GITHUB_ACTIONS=true--ci is passed explicitlyIn non-interactive mode, LiBrainian automatically:
--yes behavior)Useful global flags:
npx librainian status --json --ci --quiet
npx librainian bootstrap --mode fast --yes --no-progress --no-color
GitHub Actions example:
- name: Check index freshness (machine-readable)
run: npx librainian status --json --quiet | jq -e '.freshness.staleFiles == 0 and .freshness.missingFiles == 0'
- name: Refresh index non-interactively
run: npx librainian index --force --incremental --yes --quiet
- name: Run health diagnostics
run: npx librainian doctor --json --quiet | jq -e '.summary.status != "ERROR"'
LiBrainian supports staged-file incremental indexing for commit-time freshness:
# index only staged files
npx librainian index --force --staged
# index explicit changed files (lint-staged style)
npx librainian index --force src/api/query.ts src/cli/index.ts
Built-in integration options:
lint-staged (already configured in package.json): runs librainian index --force --staged with staged filenameslefthook (already configured in lefthook.yml): runs librainian index --force --staged {staged_files}pre-commit users: use the repo-level .pre-commit-hooks.yaml hook librainian-update-stagedThese hook integrations are best-effort and non-blocking for known setup failures (for example, repo not bootstrapped yet).
Development and release validation commands are intentionally documented in the source-checkout contributor guide, not as part of the runtime package contract.
Use the first-party composite action to restore cache, run incremental index refresh, and optionally upload index artifacts:
steps:
- uses: actions/checkout@v4
- name: Index codebase with LiBrainian
uses: nateschmiedehaus/LiBrainian/.github/actions/librainian@main
with:
workspace-root: ${{ github.workspace }}
cache-key: librainian-${{ runner.os }}-${{ hashFiles('**/*.ts', '**/*.js', 'package-lock.json') }}
restore-keys: |
librainian-${{ runner.os }}-
upload-artifact: true
artifact-name: librainian-index
The composite action is published as part of the repository contract; maintainer-only release validation for it happens outside the public Actions surface.
Public runtime trust surfaces:
npx librainian status --json includes provenance and readiness summariesnpx librainian doctor --json is the supported public diagnostic surfacePublish provenance checks, tagged releases, and strict qualification remain maintainer-only source-checkout workflows documented in CONTRIBUTING.md.
Examples are GitHub-only source references, not part of the published npm tarball:
https://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/quickstart_programmatic.tshttps://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/agentic_task_loop.tshttps://github.com/nateschmiedehaus/LiBrainian/blob/main/examples/feedback_loop_example.tsdocs/START_HERE.mddocs/README.mddocs/librarian/README.mddocs/librarian/MILESTONE_BRIEF.mddocs/integrations/README.mddocs/mcp-setup.mddocs/mcp-design-principles.mddocs/START_HERE.md, docs/README.md, docs/mcp-setup.md, docs/mcp-design-principles.md, docs/integrations/README.md, docs/integrations/cli.md, docs/integrations/mcp.mdhttps://github.com/nateschmiedehaus/LiBrainian/tree/main/docs/librarianhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/ARCHITECTURE.mdhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/CONTRIBUTING.mdhttps://github.com/nateschmiedehaus/LiBrainian/blob/main/docs/CRASH_DIAGNOSIS.mdMIT License — see LICENSE.
619 commits
TypeScript
97.0%
JavaScript
2.9%