WhyBase Reference & Usage Guide
Requirements: Node.js 20.0.0+ and Git. Everything runs 100% locally with zero cloud API keys.
Quickstart
Initialize WhyBase inside any single repository or multi-repo parent workspace without installing globally:
cd your-project npx whybase init --all --sync-rules
Or install globally once to use whybase across every project:
npm install -g whybase cd your-project whybase init --all --sync-rules whybase ui
Running whybase init indexes Git history (including nested child Git repos), parses AST dependencies, writes .ai-context/, configures MCP targets for detected editors, and installs a non-blocking post-commit Git sync hook. Add --ollama to generate local LLM hotspot summaries via Ollama.
Using WhyBase in AI Editors
whybase init --all automatically writes MCP configurations for:
- Claude Code / Universal:
.mcp.json - Cursor:
.cursor/mcp.json - VS Code Copilot:
.vscode/mcp.json - Windsurf:
.windsurf/mcp.json - Continue:
~/.continue/config.yaml(updated if present)
Reopen or reload your project window, then ask your AI assistant questions such as:
"Why does this lock exist and what breaks if I edit src/billing/webhook.ts?" "Check fragile zones in this repo before refactoring." "Record a decision that we must keep LOCK_MS for duplicate Stripe retries."
Visual Knowledge Graph Dashboard
Launch the local browser dashboard with live file-watcher updates:
npx whybase ui
- Explorer & Blast Radius: Interactive SVG flow diagram showing imports, target file, expandable direct callers, symbol-level caller filters, co-changed files, and recent commits.
- Click-to-Open in Running IDE: Clicking any caller/dependency pill or Open in IDE opens the file in your active window (
Antigravity,Cursor,VS Code,VS Code Insiders, orVSCodium) using--reuse-window, verifying that the matching project is already open. - Dependency Graph: Interactive force-directed codebase graph with module filtering, node dragging, zoom/pan, search highlighting, and 2-hop focus mode.
- Fragile Zones & Guardrails CRUD: Time-weighted risk distribution chart plus create, edit, delete, and search controls for decisions and rules.
CLI Commands
| Command | Purpose |
|---|---|
| whybase init [--all] [--local] [--ollama] [--no-hook] [--sync-rules] | Initializes .ai-context/, builds Git + AST graph, writes IDE MCP configs, and installs the non-blocking post-commit hook. |
| whybase ui [--port 4173] [--no-open] [--no-watch] | Starts local web dashboard at 127.0.0.1:4173 with live SSE refresh via file watcher. |
| whybase watch | Watches source files and keeps .ai-context/.cache/graph.json incrementally updated on save. |
| whybase sync [--ollama] | Incrementally re-scans Git history and AST dependencies using cached mtimeMs entries. |
| whybase inspect <file> [--symbol name] | Prints Git stats, fragile score, direct callers, symbol callers, and matching guardrails in terminal. |
| whybase decide "<title>" --rule "..." --context "..." [--paths "..."] | Creates a numbered ADR Markdown file under .ai-context/decisions/. |
| whybase rules-sync [--targets cursor,claude,continue,agents] | Mirrors rules.yaml and ADRs into .cursorrules, CLAUDE.md, .continuerules, and AGENTS.md. |
| whybase hook <install|remove> [--local] | Installs or removes the non-blocking Git post-commit auto-sync hook across root or nested repos. |
| whybase pr-check [--base main] [--markdown] [--fail-on-score N] [--max-impact N] | Evaluates changed files in a branch or PR for blast radius and fragile zone CI gates. |
| whybase serve [-r path] | Starts the WhyBase MCP server over stdio (invoked automatically by AI editors). |
| whybase doctor [-r path] | Verifies .ai-context/, graph cache, IDE MCP configs, rules files, Git hooks, and Ollama status. |
MCP Tools & Resources
Exposed over @modelcontextprotocol/sdk (stdio):
get_architecture_map({ focus?, limit? })— Module directories, exports, dependencies, and detected HTTP routes.why_this_exists({ path, symbol? })— Git commits, bug-fix history, symbol history, symbol callers, AI summaries, co-changed files, and ADRs.get_blast_radius({ path, symbol?, maxDepth? })— Direct, symbol-level, and transitive dependents plus impacted tests and routes.get_fragile_zones({ limit? })— Time-weighted bug-fix and revert hotspots with AI summaries and co-changed peers.get_guardrails({ path?, query? })— Glob-scoped rules and decisions with optional keyword search.record_decision({ title, context, rule, paths? })— Saves permanent architectural decisions mid-chat into.ai-context/decisions/.
Exposed MCP Resources: whybase://overview, whybase://guardrails, and whybase://hotspots.
Team Workflow & .ai-context/ Layout
Commit shared team rules and decisions to Git so every teammate gets context immediately on clone; .ai-context/.cache/ is git-ignored automatically.
your-repo/
└── .ai-context/
├── config.yaml # Ignore paths, maxGitCommits, Ollama settings (commit)
├── rules.yaml # Global and glob-scoped guardrails (commit)
├── decisions/ # Numbered Markdown ADRs (commit)
├── summaries.json # Compact hotspot & project snapshot (commit)
└── .cache/ # Local graph.json cache (git-ignored automatically)
GitHub Actions PR Gate
Run whybase pr-check in CI to generate a Markdown blast-radius summary and optionally block high-risk PRs:
- name: WhyBase PR Check
run: npx whybase pr-check --base origin/${{ github.base_ref }} --markdown --fail-on-score 12 --max-impact 25 >> "$GITHUB_STEP_SUMMARY"