Apache-2.0 · 100% Local & Deterministic · Zero API Keys

Catch the cross-stack bugs tsc & pyright miss in <2s.

Single-language typecheckers stop at the HTTP boundary. Cloud AI PR reviewers are slow and probabilistic. ProjectBrain is a local Tree-sitter CST & Python AST contract firewall, PR SARIF gate, and optional MCP coordinate router for FastAPI/Pydantic ↔ React/TS repos.

$ uvx --from projectbrain-mcp projectbrain audit --profile fullstack
Zero dotfiles written on trial · 0 PB011 false positives across 43 OSS repos · SARIF v2.1.0 + GitHub Actions ready · Python 3.10+
mongodb-labs/full-stack-fastapi-mongodb — real catch in 210 ms zero-write
$ uvx --from projectbrain-mcp projectbrain audit --profile fullstack Indexed 100 files · 21 HTTP routes · 50 Pydantic schemas · 0 dotfiles written (210 ms) ERROR [PB011] http_payload_casing_mismatch (proven) frontend/app/components/moderation/CreateUser.tsx:29 → backend/app/app/schemas/user.py:22 POST /users/create sends 'fullName', but UserCreate expects 'full_name' Why compilers missed it: ✓ tsc passed (IUserProfileCreate declared fullName) ✓ pyright passed (UserBase declared full_name: str = "") ✓ HTTP 200 OK (Pydantic extra="ignore" silently saved full_name="" into MongoDB)
Verified In The Wild

43 Open-Source Python + React/TS Repos Audited

We ran projectbrain audit --profile fullstack zero-write across 43 active starred repositories (20,604 source files) and manually verified every headline bug.

43
OSS repos audited
20,604
Source files scanned
5,392
HTTP routes indexed
0 FP
PB011 cross-stack FPs
291
Automated tests passing
mongodb-labs/full-stack-fastapi-mongodb
PB011 Official Template

Frontend sends fullName to POST /users/create and PUT /users/ while FastAPI's UserBase expects full_name. Returns 200 OK and silently persists empty names to MongoDB. Caught in 210 ms.

CreateUser.tsx ↔ schemas/user.py PR #77 →
open-webui/open-webui
PB011 159k ★

processWebSearch sends { query, collection_name } to POST /api/v1/retrieval/process/web/search while backend SearchForm expects queries: list[str] (guaranteed 422; drifted client helper still exported & imported).

apis/retrieval/index.ts ↔ routers/retrieval.py Verified schema drift
khoj-ai/khoj
PB012 38k ★

FilesMenuCommandBox defined inside FilesMenu() remounts <CommandInput> and wipes search text on every file toggle; uncancelled useEffect fetches on [pageNumber] and [selectedFile] overwrite active file previews.

allConversations.tsx · search/page.tsx PR #1476 →
aws-samples/bedrock-chat
PB012 AWS Samples

ToolResultDocument defined inside ToolCard() remounts stateful <JSONTree /> and collapses expanded nodes on parent renders; uncancelled getMyBot(botId) overwrites 15+ form fields on rapid navigation.

ToolCard.tsx · BotKbEditPage.tsx PR #1193 →
Zero-Friction Setup

Try in 10 Seconds — Keep What Fits Your Workflow

Works standalone as a CLI or CI PR gate without writing dotfiles or wiring MCP. Enable hooks or the lean 5-tool MCP server only when you want them.

# Non-overlapping profile alongside ruff / pyright / tsc / eslint (writes zero dotfiles):
uvx --from projectbrain-mcp projectbrain audit --profile fullstack

# Satellite Coordinate Router: exact file:Lstart-Lend spans + callers + covering tests (~500 tokens):
uvx --from projectbrain-mcp projectbrain route "how are invoices validated and settled"

# Day-1 architecture & boundary learning (optional):
uvx --from projectbrain-mcp projectbrain learn

# Permanent install via uv or pip:
uv tool install projectbrain-mcp
name: ProjectBrain Cross-Stack & Architecture Gate
on: [pull_request]
jobs:
  guardrail:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v4
      - name: Cross-stack schema, React lifecycle & architecture check
        run: |
          uvx --from projectbrain-mcp projectbrain check --base main --profile fullstack --ci --format sarif
          # Or sticky Mermaid PR summary: projectbrain check --base main --format pr-comment
# .projectbrain.toml (or [tool.projectbrain] in pyproject.toml)
profile = "fullstack"          # all | fullstack | governance
ignore  = ["PB010"]
exclude = ["generated/*", "migrations/*"]

# Code-native business invariants (automatically surfaced & AST-hash locked):
# @pb-invariant: Must remain idempotent on duplicate invoice_id
@router.patch("/invoices/{invoice_id}")
def patch_invoice(invoice_id: str, payload: InvoicePatch):
    data = payload.model_dump(exclude_unset=True)  # safe partial update

# Inline escape hatch for intentional exceptions:
# pb:ignore PB013 -- deliberate full reset
{
  "mcpServers": {
    "projectbrain": {
      "command": "uvx",
      "args": ["--from", "projectbrain-mcp", "projectbrain-mcp", "--lean", "/path/to/your/repo"]
    }
  }
}
Deterministic Pillars

What ProjectBrain Verifies Locally (0 LLM Tokens)

Built on bundled Tree-sitter C grammars (6 languages), Python AST dataflow, and a Salsa early-cutoff SQLite WAL code graph.

PB011

Cross-Stack HTTP Schema Solver

Verifies fetch, axios, and 1–2 hop client wrappers against FastAPI/Pydantic v1/v2, SQLModel, TypedDict, and @dataclass schemas — catching 422 missing fields, camelCase ↔ snake_case drift, response shape bugs, and HTTP verb mismatches.

PB012

React Lifecycle & Async Race Verifier

Uses Tree-sitter CST to prove inline nested component remounts, post-mount loading early-returns unmounting stateful children, and uncancelled useEffect([dep]) async setState races.

PB013

Pydantic Partial-Update & I/O Guard

Flow-sensitively catches .model_dump() / .dict() without exclude_unset=True clobbering columns in PATCH/update sinks (respecting exclude={...}) and silent except: pass around .commit() or outbound HTTP mutations.

PB002 · PB007 · PB008

Governance Tamper Lock

Enforces --forbid architectural boundaries, tracks code-native @pb-invariant: AST hashes, and blocks AI agents from deleting or weakening .projectbrain.toml / governance rules in PRs.

ROUTE · SLICE

Satellite Coordinate Router

Returns exact file:Lstart-Lend GPS coordinates, 1-hop callers/callees, HTTP route peers, covering tests, and invariants in ~500 tokens — letting agents use native read_file/edit_file without truncated dumps.

SARIF · CI

Sub-2s PR Merge-Base Gate

Diffs multi-commit PRs cleanly against git merge-base and outputs text, JSON, GitHub annotations, sticky Mermaid PR impact summaries, or OASIS SARIF v2.1.0 with zero cloud code egress.

Native Rust Rewrite · Apache-2.0

ProjectBrain Rust Engine (pb)

Need multi-repo contract linking, polyglot support beyond Python/TS, or sub-100 ms warm incremental checks? The core contract graph and Satellite MCP engine are also built as a 5-crate native Rust workspace.

<100 ms warm checks ~15–60 ms warm MCP 5 Rust crates (~39k LOC) 74 / 74 CI tests passing
  • pb-parser — Parallel rayon + blake3 + tree-sitter AST extractors across TypeScript/TSX/JS, Python, Go, Rust, Kotlin, Protobuf (.proto), OpenAPI, Prisma, and SQL.
  • pb-graph — Incremental rusqlite WAL index (.pb/index.db), multi-repo pb.workspace.toml linker, Ochiai co-change graph, and brownfield baseline ratchet.
  • pb-bundles & pb-reporters — Multiplex PPR Satellite Locator (pb_locate) with secret-redacting config fallback, <7,800-char inline MCP, Mermaid PR comments, and SARIF.
  • pb-cli — Single stripped native binary (pb) with local CLI, editor hooks, GitHub Action, and stdio MCP server.
Explore projectbrain-rs on GitHub →
# Clone & build the native Rust binary (`pb`)
git clone https://github.com/Johanabhishek/projectbrain-rs
cd projectbrain-rs
cargo build --release --bin pb
cargo test --workspace

# Index single repo or multi-repo workspace (pb.workspace.toml)
pb index

# Deterministic cross-stack & org contract PR gate
pb check --ci --base origin/main --new-only --format pr-comment

# Sub-60ms warm Satellite Locator over local graph
pb locate "invoice checkout route and schema"
Stack Fit & Honest Tradeoffs

Pairs With Your Compilers — Never Replaces Them

Layer What It Catches Blind Spot ProjectBrain's Slot (--profile fullstack)
ruff / pyright / tsc / eslint Single-language syntax, static types, lints Blind across Python ↔ TS HTTP boundaries & repo invariants Cross-stack schema solver (PB011), React races (PB012), Pydantic clobbers (PB013)
Cloud AI PR Reviewers High-level logic & prose review 30–90s latency, probabilistic noise, cloud code egress <2s deterministic local/CI SARIF gate, zero API keys, Apache-2.0
Coding Agents & Swarms Fast rg, parallel edits, multi-file refactors Break uninspected callers, drift past invariants, tamper with configs Post-edit hooks, tamper-locked rules (PB007), shared ~500-token coordinate routing

Where ProjectBrain Shines

  • Monorepos pairing FastAPI / Pydantic / SQLModel backends with hand-written React / TypeScript fetch or axios clients.
  • Teams reviewing high-volume AI-generated PRs who want deterministic, zero-token CI gates for layer rules and business invariants.
  • Sub-second incremental local checks (~515ms body edits on 3,051-file Django repos via SQLite WAL + Salsa early-cutoff).

Honest Boundaries Today

  • Monorepo required for PB011: Split frontend/backend repos and generated OpenAPI SDKs (where tsc already checks generated types) don't need PB011.
  • Express routes: Currently verifies HTTP verbs and path matching, not Zod/Joi request/response body schemas.
  • Dynamic runtime dispatch: Static analysis cannot prove calls through runtime-resolved adapters; verify honestly returns UNKNOWN.