What If Pull Requests Had an Explain Command? PR Explain, an AI-assisted service that turns a GitHub Pull Request into an evidence-backed explanation, performs deterministic code analysis to build a structured change graph, collect evidence, and determine potential impact before an AI model narrates the findings. The service analyzes changed files, symbols, imports, call and symbol relationships, line-level evidence, and revision-to-revision changes, then posts the explanation back to the Pull Request as a GitHub comment. Its pipeline runs from a GitHub App webhook through a FastAPI API to a background worker that fetches the repository snapshot, analyzes the diff, parses symbols, builds the change graph, collects evidence, analyzes impact, and persists claims into an explanation packet. PR Explain is an AI-assisted Pull Request explanation service that turns a GitHub Pull Request into an evidence-backed explanation of what changed, why it changed, and what parts of the codebase may be affected. The core idea is simple: PR Explain is like SQL EXPLAIN for Pull Requests. Instead of asking an AI model to blindly read a Pull Request and guess what happened, PR Explain first performs deterministic code analysis, builds a structured change graph, collects evidence, and determines potential impact. The AI model then turns those facts into a human-readable explanation. If you've used EXPLAIN or EXPLAIN ANALYZE in SQL, the easiest way to understand PR Explain is to think of it as the same concept applied to code changes. For example: EXPLAIN SELECT FROM users WHERE email = 'alice@example.com'; The database doesn't ask an AI model to guess what the query does. Instead, the database analyzes the query and produces a structured execution plan describing things such as: - Which tables are accessed - Which indexes may be used - How operations are connected - The expected execution strategy - Potentially expensive operations PR Explain applies the same philosophy to Pull Requests. SQL Query │ ▼ Query Planner │ ▼ Execution Plan │ ▼ Human Understanding Pull Request │ ▼ Code Change Analyzer │ ▼ Change Graph + Evidence + Impact │ ▼ AI Explanation │ ▼ Human Understanding The important distinction is: The AI is not the analyzer. The deterministic analysis pipeline is responsible for discovering what actually changed. The AI model is responsible for explaining those discovered facts. A generic AI code-review system might look like: Pull Request │ ▼ LLM │ ▼ "Here's what I think changed..." PR Explain instead follows: Pull Request │ ▼ Deterministic Analysis │ ├── Changed files ├── Changed symbols ├── Imports ├── Calls ├── Relationships ├── Evidence └── Impact │ ▼ Explanation Packet │ ▼ AI Model │ ▼ Human-readable explanation This makes the AI model primarily a narrator , rather than the source of truth. For example, if a Pull Request changes: PaymentService.process payment │ ├── PaymentRepository.create │ └── EventPublisher.publish PR Explain first determines those relationships from the repository and Pull Request. The AI then receives the resulting evidence and can explain: This change modifies payment processing and affects both persistence and event publishing. The new behavior therefore has potential impact on the payment data path as well as downstream consumers of the payment event. The model is explaining relationships that the analysis pipeline has already established rather than inventing them. PR Explain analyzes Pull Requests and produces an explanation based on the actual repository contents and changes. The analysis includes: - Changed files - Changed symbols - Functions and classes - Imports - Call relationships - Symbol relationships - Relevant files outside the diff - Line-level evidence - Potential impact - Claims about the change - Revision-to-revision changes The resulting explanation can be viewed in the web application and posted back to the Pull Request as a GitHub comment. A Pull Request moves through the following pipeline: GitHub Pull Request │ ▼ GitHub App Webhook │ ▼ FastAPI API │ ▼ Background Job │ ▼ Worker │ ├── Fetch repository snapshot ├── Analyze diff ├── Parse symbols ├── Build change graph ├── Collect evidence ├── Analyze impact └── Persist claims │ ▼ Explanation Packet │ ▼ AI Provider │ ├───────────────┐ │ │ ▼ ▼ Ollama OpenAI Local Production │ │ └───────┬───────┘ ▼ Explanation │ ▼ PostgreSQL / \ / \ ▼ ▼ React UI GitHub API │ ▼ PR Comment PR Explain follows: Deterministic analysis first. AI narration second. The deterministic pipeline creates a structured representation of the change. The AI receives a bounded explanation packet containing those facts. This separation provides several benefits: - Better grounding - Lower risk of hallucinated files or functions - Repeatable analysis - Inspectable evidence - Local/private AI inference - Ability to change AI providers without changing the analysis pipeline - AI failures do not destroy deterministic analysis The GitHub App is the entry point into PR Explain. It receives Pull Request webhook events and gives PR Explain permission to read repository contents and update Pull Request comments. | Permission | Access | Purpose | |---|---|---| | Metadata | Read | Repository and installation metadata | | Contents | Read | Read repository contents | | Pull requests | Write | Create/update PR explanation comments | PR Explain does not require GitHub Checks permissions and does not submit a Pull Request review score. You need to create a GitHub App before PR Explain can receive Pull Request events. GitHub's official documentation: GitHub Apps Quickstart Go to: GitHub → Settings → Developer settings → GitHub Apps → New GitHub App For an organization-owned application: Organization → Settings → Developer settings → GitHub Apps → New GitHub App Use: GitHub App name: PR Explain Configure the homepage URL to point to your deployed application or repository. Enable: Active: Yes Set the webhook URL to: https://