> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getblame.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automated Pull Request Reviews

Blame automates code reviews on GitHub Pull Requests with the depth of a senior staff engineer. Unlike basic linters or generic LLM prompts that simply summarize text, Blame executes an exhaustive multi-stage review pipeline that evaluates:

* **Edge Cases & Boundary Conditions:** Rigorous checks on null/undefined safety, empty inputs, unhandled promise rejections, and fallback behavior.
* **Broken, Phantom, or Missing Imports:** Cross-references imported symbols against AST module graphs to flag runtime `TypeError` issues before merge.
* **Security & Trust Boundaries:** Analyzes authentication/authorization gates, credential leaks, unvalidated inputs, and injection vectors.
* **Architectural & System Design Trade-offs:** Evaluates coupling, memory footprint, concurrency/race conditions, and project-specific idioms.
* **1-Click GitHub Suggestions:** Produces exact, indented code replacement blocks directly executable via GitHub's "Apply suggestion" button.

***

## How the PR Review Pipeline Works

When a developer opens or updates a Pull Request in a connected repository, Blame processes the event in real-time:

```mermaid theme={null}
flowchart TD
    GH[GitHub PR Webhook] --> Ingest[Webhook Ingestion & Noise Filtering]
    Ingest --> DiffParser[parse-diff AST Annotation]

    subgraph Context Gathering
        DiffParser --> RuleDiscovery[Auto-Discovery: .cursorrules, CLAUDE.md, blame.yaml]
        DiffParser --> RepoMemory[Workspace Memory & Guidelines]
        DiffParser --> GraphRAG[Tree-sitter AST & Voyage Cross-Encoder Rerank]
    end

    subgraph LLM Multi-Pass Engine
        RuleDiscovery --> ReviewAgent[Blame Review Agent]
        RepoMemory --> ReviewAgent
        GraphRAG --> ReviewAgent
        ReviewAgent --> JSONSchema[Structured JSON Output & Schema Validation]
    end

    subgraph Publishing
        JSONSchema --> PRSummary[Post Executive PR Summary & Confidence Score]
        JSONSchema --> InlineComments[Post GitHub Inline Comments with 1-Click Suggestions]
        JSONSchema --> Alerts[Dispatch Slack / Discord / Linear Notifications]
    end
```

***

## 1. Webhook Ingestion & Smart Diff Filtering

Blame intercepts GitHub `pull_request` and `synchronize` webhooks. Before initiating AI evaluation:

* **Noise & Asset Stripping:** Automatically filters out lockfiles (`package-lock.json`, `pnpm-lock.yaml`, `Cargo.lock`), minified bundles, build outputs, and binaries.
* **Diff Line Annotation:** Uses `parse-diff` to attach precise line numbers (`+` added, `-` deleted, unchanged context) ensuring every comment anchors to real diff coordinates.
* **Scale Boundaries:** Analyzes up to 50 modified files and 4,000 diff lines per pull request to optimize review depth without degrading context quality.

***

## 2. Multi-Source Context Gathering

Blame surrounds the pull request diff with three layers of intelligence:

### A. Auto-Discovered Project Rules & Instruction Files

Blame scans the repository root and subdirectories to load team guidelines and coding conventions. It natively detects:

* `.cursorrules` and `.cursor/rules/*.mdc` (including glob-scoped rules)
* `CLAUDE.md` and `.claude/CLAUDE.md`
* `AGENTS.md` and `.agents/AGENTS.md`
* `blame.yaml` / `.blamerc` / `.coderabbit.yaml`
* `.github/copilot-instructions.md`
* `CONTRIBUTING.md` and `docs/architecture.md`

### B. Repository Memory & Custom Team Guidelines

Rules configured in the Blame dashboard under **Repository Settings > Memory** are dynamically injected to enforce team-specific patterns.

### C. GraphRAG Cross-File Analysis

Blame queries the repository's Tree-sitter AST index and runs Voyage AI `rerank-3` to retrieve upstream imports and downstream callers affected by the diff.

***

## 3. Calibrated Confidence Scoring (1 to 5)

Every pull request review receives a calibrated confidence rating with a detailed rationale:

| **Score** | **Rating** | **Criteria** |
| :- | :- | :- |
| **5 / 5** | **Production Ready** | Comprehensive test coverage, all edge cases handled, zero security vulnerabilities or stability risks. |
| **4 / 5** | **High Quality** | Core logic is solid; includes minor suggestions for idiomatic polish, performance tweaks, or non-critical tests. |
| **3 / 5** | **Needs Attention** | Missing key edge-case guards, unhandled async errors, or noticeable test gaps. |
| **2 / 5** | **Significant Concerns** | Contains broken logic paths, contract violations, missing imports, or security anti-patterns. |
| **1 / 5** | **Critical Failures** | Severe bugs that cause runtime crashes, data corruption, memory leaks, or critical vulnerabilities. |

***

## 4. Structured Output & Inline Comments

Blame posts two types of feedback on GitHub:

### Executive PR Summary

A top-level comment structured with clear sections:

* **Executive Overview:** High-level problem statement and core impact.
* **Architectural & Design Evaluation:** Assessment of coupling, modularity, and trade-offs.
* **Edge Cases & Boundary Analysis:** Defensive invariants and runtime pitfalls.
* **Security & Reliability Audit:** Scrutiny of data validation and failure isolation.
* **Recommended Test Coverage:** Concrete unit/integration test cases needed for full confidence.

### Actionable Inline Comments

Every detected issue is anchored to its specific line and tagged with:

* **Severity:** `Critical`, `High`, `Medium`, or `Low`.
* **Category:** `Bug`, `Security`, `Performance`, `Architecture`, `Maintainability`, `Testing`, or `Readability`.
* **1-Click Suggestion:** Pre-formatted diff replacements matching exact file indentation so developers can accept fixes with one click.

***

## Triggering Reviews

Reviews can be triggered in three ways:

1. **Automatic (On PR Open / Sync):** Whenever a PR is opened or new commits are pushed (configurable in **Repo Settings**).
2. **Slash Command:** Comment `/blame review` or `/review` directly on any GitHub PR.
3. **Manual Trigger:** Click **Trigger Review** inside the Blame web dashboard.

***

## Related Guides

* **Graph-Based Codebase Context** — How Blame indexes code and queries symbol graphs.
* **Repository Settings** — Configuring review triggers, automated comments, and file ignore rules.
* **Chat & Codebase Memory** — Interactive multi-repo chats and workspace memory.
