See what a code change does: its architecture, data flows and design decisions, in one page.
A visual, architecture-first explanation of a branch or pull request: where the change sits, how data flows through it and why it is built this way. Generated by a deterministic CLI; narrated by your coding agent.
Live examples · Quick start · How it works · Configure · Concepts · Limitations
A real pull request of the maybe Rails app. Click it to explore the report.
Code review tools show lines. explain-change shows the design: which components a change touches, which dependencies it adds or breaks, the flows it changes and the decisions behind it. Read it before the diff and the diff makes sense.
| 🗺️ Architecture first | Your layers as lanes, components as boxes, dependencies as arrows. Rule-breaking arrows turn red. |
| 🎬 A guided story | 2–8 steps walk through the change: each moves the map to what changed and shows the code. |
| 📖 Explains, never reviews | Short, present-tense sentences in the style of Simplified Technical English, checked before the page renders. No bug hunting or style opinions: that is your reviewer's job. |
| 📦 One offline file | A single HTML page, light and dark mode, carrying only the code it shows. |
| 🎯 Deterministic and cheap | The CLI computes every fact: the same change gives a byte-identical page. The agent reads a digest of about 5–7k tokens for a real PR (less for a small change), never the full diff. |
1. Install the CLI (Node ≥ 20), then the agent skills:
npm install -g explain-change
explain-change install # the skills, in ~/.agents/skills and ~/.claude/skills2. Configure your repository once. Ask your agent:
configure explain-change for this repo
3. Ask for an explanation, in your own words:
explain my changes
The report opens in your browser when it is ready.
| You ask your agent | It runs |
|---|---|
| "explain PR 1234", or paste the PR URL | explain-change pr 1234 |
| "explain this PR", on the PR's branch | explain-change pr (finds the branch's active PR) |
| "explain my changes", "what does this branch do" | explain-change local |
| the same, with work not committed yet | explain-change local --include-uncommitted |
Azure DevOps and GitHub PRs are read directly. GitLab PRs work through their branch: check it out, then "explain my changes".
The page reads from what to where to why:
| Section | What you get |
|---|---|
| What and why | The title, the goal of the change and a TL;DR. |
| Map and story | A map you can pan and zoom: the architecture as lanes, the data flows in call order and the data model. Click a component for what it now does, its files and its dependencies. |
| Design decisions | What was chosen and why, each labelled with where its why comes from: the PR description, the spec, the code, or inferred from the change. |
| SDD · OpenSpec | For spec-driven changes: the pipeline from proposal to archive, and each requirement traced to the code and tests that implement it. |
| Changes by component | Each changed component with what it now does and its files. |
| Since your review | For a PR you explained before at another head: what changed since, in a few words, ringed on the map and marked in the changes and the story. A rebase or a merge of the target adds no noise. The story keeps the steps you read (✓). |
Reading the map: 🟩 added · 🟦 changed · ⬜ removed · 🟥 a dependency that breaks one of your [rules].
Components the change does not touch stay hidden unless it alters their link to it; the rest is one click away
(Context). For a PR, each file links to the file on the PR page.
The CLI does all the structural work. The agent writes only the prose, in a draft the CLI prepares and validates.
flowchart LR
A["explain-change local / pr"] -->|facts.json · digest.md · draft| B["Your agent<br/>fills the draft"]
B --> C["explain-change render"]
C -->|issues to fix| B
C -->|valid| D["Report<br/>(one HTML file)"]
- Collect: the CLI reads the diff, maps files to components, resolves dependencies, checks your rules and
outlines the story. It writes
facts.jsonand a budgeteddigest.mdthat ends with the explanation's draft. - Explain: the agent reads the digest and writes
explanation.json: the draft with each"<…>"replaced. - Render: the CLI validates the explanation (exit 1 with precise
{path, code, message}issues until it is valid) and writes the page.
Every command takes --json and names the agent's next action (configure, write-explanation, fix-explanation,
collect-change, done). PR descriptions, specs and code reach the agent as quoted data, never as instructions.
Every sentence the agent writes follows the parts of ASD-STE100 Simplified Technical English that suit a design document: the aerospace standard for text that cannot be misread. Its restricted dictionary is left out on purpose: in a code change, the technical names are the content.
| Rule | How it is applied |
|---|---|
| One idea per sentence, at most 25 words | Enforced: render rejects longer sentences and asks to split them. |
| Present tense: what the code does now | Enforced: will, would, could, might, should (and won't…) are refused. |
| The effect, not a judgement | Enforced: better, cleaner, elegant… are refused; say what changes instead. |
| No marketing words, no filler | Enforced: leverage, utilize, seamless… in every form (leveraged, utilizing) and basically, simply, just… are refused. |
| Numbers as digits | Applied: the page writes two, three… as 2, 3 (a refusal only cost the agent a round of fixes). A single thing takes a (a ZIP file, not 1 ZIP file): guidance. |
| Code names exactly as in the code | Enforced: a snake_case, CamelCase, Module::Name or obj.method() that does not exist at the head of the change is rejected. Code names are exempt from the word rules: ensure_admin is not the word ensure. |
| Active voice | Enforced for the passive with its agent: is called by the job is refused; write the job calls it. By for a manner (sorted by date, off by default) passes. |
| Simple verbs (adds, sends, stores, calls, checks), one word per thing, no idioms | Guidance: written in the digest the agent reads. |
Each rejection names the field, the words and what to write instead, so the agent fixes only that field. The refused
words live in one list, src/explanation/prose/en.json: a trailing * refuses every
form of a word, and the digest prints the list exactly as the validator applies it. Reports are written in English.
Without a config, layers and components are guessed from folder names, and the CLI and the page say so.
Ask your agent to "configure explain-change for this repo". The configure skill drafts the file with
explain-change init, reads your docs and existing dependency rules, names layers and components the way your team
talks about the app (bounded contexts in the domain's words, not framework artifacts) and tries the result on recent
PRs.
explain-change check measures how the config fits the code: each lane with its components, their files and the
commits that change them, the files no component covers, the dependencies that break [rules] today, components
that depend on each other, components that change together in the git history, and the hints that keep the config
small: components that rarely change and components that list single files instead of folders and name globs.
.explain-change.toml reference
The config lives at the repository root. Example: examples/explain-change.toml.
Schema: schemas/config.schema.json. Unknown keys are errors, so typos never pass
silently.
| Key | Purpose |
|---|---|
project.name |
Shown in the report. Default: the repository folder name. |
project.direction |
One or two sentences on the intended architecture: context for the story and the decisions. |
project.lang |
Report language: en, the default and, for now, the only one. |
project.base |
Default base for local. |
project.names |
Product and library names written like code (FastAPI, NestJS) that the prose may use: the validator does not look for them in the change. |
project.budget |
Digest size in characters (2000–100000, default 12000). The task always fits; the overview gets shorter (fewer symbols, files by component) until the key hunks have 35% of the budget, so a large change goes past it by the task and the shortest overview: about 20–27k characters (5–7k tokens) on real PRs. --budget overrides it. |
project.host |
Where the PRs live: azure-devops or github (default: the host of the remotes, else Azure DevOps). --host overrides it; a PR URL names its own. |
[[layers]] |
Map lanes, top to bottom in the listed order (entry points first, core last). The order does not decide what may depend on what: [rules] does. |
[rules] allow |
Allowed dependency directions ("a -> b", layer or component ids). When present, any other edge between layers is a violation. |
[rules] forbid |
Always a violation, even when allow matches. |
[rules] same_layer |
Allow dependencies inside a layer (default true). |
[[components]] |
id, layer, paths (globs: * stays inside a folder, ** crosses folders; the most specific match wins). Optional name, desc, and imports (Python, TypeScript), namespaces (C#), constants (Ruby) for code owned outside paths (their * matches anything, . and :: included). |
[[flows]] |
Reference runtime flows ("compA -> compB : message"). An explained flow with the same id is compared with it. |
[glossary] |
The team's ubiquitous language: term = "one-line definition". The agent writes every explanation with these terms. |
[ignore] paths / tests |
Generated or vendored files, and test patterns. Each list replaces its default (explain-change init writes the defaults out). |
| Stack | Dependencies resolved from |
|---|---|
| Ruby on Rails | Zeitwerk constants (with inflect.acronym), lexical nesting, associations, ERB, routes |
| Python / Django | Imports, string model references, include(), import_string, celery tasks, URL routes |
| TypeScript / JavaScript | Relative imports, tsconfig paths and baseUrl |
| C# / .NET | using, namespaces, .csproj project references, public types and methods, ASP.NET endpoints ([HttpGet], [Route]…); EF Core Migrations/ and generated files (*.g.cs, *.Designer.cs, obj/) set apart |
| OpenSpec | Proposal, design decisions, tasks and requirement deltas (ADDED, MODIFIED, REMOVED, RENAMED) with their scenarios, from openspec/changes/<id>/ and openspec/specs/<capability>/spec.md |
Without a config, Rails and Django layouts are recognized (an app per component, big Rails namespaces split by concept); other layouts get one component per top-level folder.
explain-change pr explains a PR without checking it out, on Azure DevOps (through the az CLI with the
azure-devops extension) or GitHub (through gh). The host comes from the first of:
- the PR URL, when you paste one;
--host azure-devops|github;hostunder[project]in.explain-change.toml;- the repository's remotes (Azure DevOps first);
- Azure DevOps.
Login, code and metadata
- Login: when
azhas no session or it expired, it runsaz loginonce, in the browser.ghnever logs in on its own: rungh auth loginonce. git uses your own credentials first (SSH key or credential manager) and, on an HTTPS remote, the CLI's token next, passed through the environment and never stored. Nothing else ever prompts. - Code comes from git:
refs/pull/<id>/merge, the PR applied to its target, the change the PR page shows. A PR without one (merge conflicts, completed, abandoned) is explained as its own commits against the merge base with its target, and the CLI says so. On GitHub these come fromrefs/pull/<id>/head, so PRs from forks need no extra remote. - Title, description and file links come from
az repos pr showorgh pr view. If az does not detect the organization from the remote, runaz devops configure --defaults organization=https://dev.azure.com/<org> project=<project>. Without the CLI, the page still renders from git alone, and the CLI says what is missing. - Fetched refs live under
refs/explain-change/, away from your branches. Every call has a timeout. - GitHub Enterprise Server is not supported yet: github.com only.
The npm package is one bundled file for Node ≥ 20, with no dependencies. It carries the agent skills:
explain-change install writes them where agents look for them (~/.agents/skills and ~/.claude/skills), and
replaces only folders it wrote itself. It needs git.
- Update:
explain-change update(it runsnpm install -g explain-change@latest, then refreshes the skills). - Uninstall:
explain-change uninstallremoves the skills, thennpm uninstall -g explain-change. - Claude Code plugin:
/plugin marketplace add denjamio/explain-change, then/plugin install explain-change@explain-change. The plugin brings the skills, so skipexplain-change install; it still needs the CLI. - Other agents: reference
~/.agents/skills/explain-change/PROMPT.mdfrom yourAGENTS.md.
explain-change local [--base REF] [--include-uncommitted] # the current branch against its base
explain-change pr [ID|URL] [--host HOST] # an Azure DevOps or GitHub PR (no id: the branch's)
explain-change render # validate explanation.json and write the page
explain-change status # the explanation's state and the next step
explain-change init | check # draft and verify .explain-change.toml
explain-change schema config|facts|explanation # the JSON Schemas
explain-change install | update | uninstall | --version # the skills and the CLI itselfOptions and defaults
localandpralso take--spec <id>(an OpenSpec change the code implements without touching it),--host <azure-devops|github>,--budget <chars>,--out <path>,--no-openand--json.- Reports go to
.explain-change/out/<branch>.html. The work folder is added to.git/info/exclude, so it never shows ingit status. - The base is
--base, elseproject.base, else the first that exists oforigin/HEAD,origin/main,origin/master,main,master,origin/developanddevelop. - The report opens in the browser once the explanation is valid (from WSL, in the Windows one); never with
--no-open, in CI or withEXPLAIN_CHANGE_NO_OPEN=1. - Without an agent, the page still renders the map with an automatic story built from the facts.
- Exit codes: 0 done, 1 the explanation is not valid yet (
render,status), 2 usage or config error.
git clone git@github.com:denjamio/explain-change.git && cd explain-change
bun install
bun run check # typecheck, lint and the tests
bun run dev -- local # the CLI from source (any command)
bun run install:dev # this checkout as `explain-change` in ~/.local/bin, skills linked to skills/
bun run examples -- --real # rebuild the 11 real pull requests in examples/ (`explain-change pr <url>`: network and gh)
bun run smoke # build the npm bundle and run it on Node, on a temporary repository
bun run eval # a real agent (haiku) explains the train PRs by their URL; graders score it (costs tokens)
bun scripts/example-work.ts open <example> <dir> # rewrite an example's explanation with the current tool, then: saveRead docs/ARCHITECTURE.md first; the vocabulary is in docs/CONCEPTS.md.
Versions, evals and releases
- Toolchain: Bun runs the build and the tests; the published CLI is the npm bundle, on Node ≥ 20.
- Examples follow the tool: after any change to the analysis, the outline, the draft or the rules, rewrite the
examples' explanations with the current tool (
scripts/example-work.ts open, fill the draft,save) and rebuild them withbun run examples -- --real. They are what the current version produces, and the eval's references. - Examples are real: every published example and every eval run is a real pull request of an open-source product,
asked for by its URL. The scenarios in
examples/scenarios/are offline test fixtures (determinism, reference resolution, an inferred config, OpenSpec parsing), never published or evaluated unless named. - Evals (
bun run eval): a real agent (haiku) explains each real PR by its URL, and pass/fail graders score what it wrote: structure against the facts, content against each PR's independentassertions.json, a prose rubric and whether each decision's why is grounded in its source. Splits, the improvement loop, the meta-eval and every option: docs/EVALS.md. - Versions: bump
ANALYSIS_VERSION(src/core/constants.ts) when the analysis can produce different facts for the same diff, andCONTRACT_VERSIONwhenfacts.jsonorexplanation.jsonchange shape. Changes go in CHANGELOG.md. - Release: set the version in
package.jsonand.claude-plugin/plugin.json(a test checks they match the CHANGELOG), move the CHANGELOG's notes under the new version, then push the tagvX.Y.Zfrommain. The release workflow runs the checks, attaches the 5 binaries to a GitHub release with those notes, and publishes the npm package when the repository has anNPM_TOKENsecret (it skips npm without it). - Screenshot:
docs/report.pngis the maybe example at 1440×900, light theme, on its first story step with Fit pressed (the whole map); retake it when the report's look or that example's story changes.