DOCUMENTATION

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:

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

CLI Commands

CommandPurpose
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 watchWatches 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):

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"