# diffler

[![crates.io](https://img.shields.io/crates/v/diffler.svg)](https://crates.io/crates/diffler)
[![npm](https://img.shields.io/npm/v/@mattfillipe/diffler.svg)](https://www.npmjs.com/package/@mattfillipe/diffler)
[![IRC](https://img.shields.io/badge/IRC-chat.h4ks.com-blue.svg)](https://chat.h4ks.com)

![diffler reviewing an agent's change: word-level diff highlights, an inline comment, and the agent replying and fixing the code live over MCP](assets/demo.gif)

A tool for taking ownership of agentic code: review what your agent writes,
together with the agent, while it happens. The code that lands is code you
have actually reviewed.

If you know Emacs' [magit](https://magit.vc), diffler is basically a
standalone magit with an MCP server built in: the same fast, keyboard-driven
git UI, no Emacs required. The keys follow the
[Doom Emacs](https://github.com/doomemacs/doomemacs) magit experience, so its
leader-key transients land where your fingers expect them. Launch it in a repo
alongside Claude Code or any MCP-compatible agent: it shows a live diff of what
the agent is doing; you read, comment, stage, and commit; the agent picks your
feedback up over MCP and responds in place. One binary, no browser, no daemon.

## Install

```sh
cargo install diffler
```

<details>
<summary><b>Prebuilt binary</b></summary>

Skips the compile, and needs no Rust toolchain.

```sh
cargo binstall diffler
```

Or download it straight from the
[releases page](https://github.com/matheusfillipe/diffler/releases): macOS,
Linux and Windows, x86_64 and arm64. Any GitHub-release installer (`eget`,
`ubi`, ...) works against it too.

</details>

<details>
<summary><b>Homebrew</b></summary>

macOS and Linux. The tap is this repository.

```sh
brew tap matheusfillipe/diffler https://github.com/matheusfillipe/diffler
brew install diffler
```

</details>

<details>
<summary><b>Scoop</b></summary>

Windows. The bucket is this repository.

```sh
scoop bucket add diffler https://github.com/matheusfillipe/diffler
scoop install diffler
```

</details>

<details>
<summary><b>Arch</b></summary>

`diffler-bin` on the AUR ships the prebuilt binary, so it installs without
building.

```sh
yay -S diffler-bin
```

</details>

<details>
<summary><b>Nix</b></summary>

The flake serves the prebuilt binary. `nix run` tries it without installing
anything, `nix profile install` keeps it.

```sh
nix run github:matheusfillipe/diffler
nix profile install github:matheusfillipe/diffler
```

</details>

<details>
<summary><b>npm</b></summary>

A wrapper that fetches the prebuilt binary. The package name is scoped, the
command it installs is plain `diffler`.

```sh
npx @mattfillipe/diffler
npm install -g @mattfillipe/diffler
```

</details>

## Quickstart

Run `diffler` inside a repository. It starts the TUI and an MCP server on
port 8417. Connect your agent once:

<details>
<summary><b>Claude Code</b></summary>

```sh
claude mcp add --transport http diffler http://127.0.0.1:8417/mcp
# or, over stdio, auto-discovering the port:
claude mcp add diffler -- npx -y diffler-mcp
# or, as a plugin (MCP server plus a /diffler command):
claude plugin marketplace add matheusfillipe/diffler && claude plugin install diffler@diffler
```

Connected, the server's `review` prompt shows up as the `/diffler:review`
command; the plugin adds a bare `/diffler`.

</details>

<details>
<summary><b>opencode</b></summary>

Add the server to `opencode.json` in the project, or globally in
`~/.config/opencode/opencode.json`:

```json
{
  "mcp": {
    "diffler": {
      "type": "local",
      "command": ["npx", "-y", "diffler-mcp"],
      "enabled": true
    }
  }
}
```

And install the `/diffler` command (opencode has no package mechanism for
commands, so this fetches the one maintained in this repo):

```sh
mkdir -p ~/.config/opencode/commands && curl -fsSLo ~/.config/opencode/commands/diffler.md \
  https://raw.githubusercontent.com/matheusfillipe/diffler/main/.opencode/commands/diffler.md
```

</details>

<details>
<summary><b>Any other MCP agent</b></summary>

Point it at `http://127.0.0.1:8417/mcp` (streamable HTTP), or run
`npx -y diffler-mcp` as a stdio proxy that auto-discovers the port from
`.diffler/mcp.json`. The server also ships a `review` prompt that
prompt-aware clients surface as a command.

</details>

The loop: the agent edits files, the diff updates live. You comment lines or
ranges in the diff view and press `Z` to send feedback. The agent picks the
comments up through `wait_for_feedback`, replies or proposes resolutions, and
you confirm in the TUI. `y`/`Y` copy the same feedback as markdown if you would
rather paste it into a prompt.

The same review works against real pull requests: the status screen shows the
branch's PR (and `b` `p` lists all open ones; reviewing never needs a
checkout). PR comments sync in as regular threads, yours stack locally, and
`S` submits them as a single review on the forge. `b` `P` opens a new one from
the current branch, filling the title and body from its commits and pushing
first when the forge has not seen the branch yet. Replies the agent wrote stay
local: what goes out carries your name, so it is what you wrote.

## Keys

Vim-like: `j`/`k`/`gg`/`G` motions, `/` search, and
`<c-d>`/`<c-u>` paging work in every list. The basics:

| Key | Action |
| --- | --- |
| `<c-k>` | command palette: fuzzy-find every action on this screen and its key |
| `<cr>` | open the thing under the cursor |
| `s` / `u` | stage / unstage |
| `cc` | commit |
| `c` | comment the diff line (`V` selects a range first) |
| `v` / `u` / `U` | in the diff view: mark the file viewed and step to the row under it, sorting it to the top of its group (a folder row marks everything under it) / jump to the next unviewed / clear every mark |
| `+` / `-` / `=` | widen / narrow the context around a hunk, or open the whole file |
| `\|` | side-by-side diff |
| `t` | cycle the sidebar: file tree, review buckets (viewed files fold away, come back if they change), kinds (source, tests, docs, config, build, generated, assets) |
| `Z` | send feedback to the agent |
| `C` | comments sidebar: walk every comment, Enter jumps to it in the pane |
| `d` / `D` | delete the comment under the cursor / every local comment of the review |
| `S` | submit stacked PR comments as one review |
| `b` `P` | open a pull request for the current branch |
| `d` | review the working tree against something else: `d` base branch, `c` last commit, `b` a branch, `s` a commit, `w` HEAD |
| `y` / `Y` | copy feedback as markdown (file / all) |
| `y` | on a status or PR-list row, copy what it points at: a pull request as its URL, a commit as its sha |
| `<c-t>` | find any tracked file: Enter opens it, `b` blames it, `e` sends it to `$EDITOR` |
| `B` | blame the file under the cursor, at that line (`b` toggles the column, `<cr>` reviews the commit) |
| `e` | open the file in `$EDITOR` |
| `?` | full keymap for the current screen |
| `q` | back / quit |

Every binding is remappable, see
[docs/config.example.toml](docs/config.example.toml).

The diff view is two panes: a file sidebar and the selected file's diff. `h`
and `l` (or the left/right arrows) focus the sidebar and the diff; `j`/`k`
change the selected file from the sidebar or scroll the diff when focused there;
`J`/`K` or `<c-n>`/`<c-p>` step through files from either; `<tab>` (or `za`)
folds the folder or section under the sidebar cursor.

Diffs are compared on the syntax tree, so a reindented or rewrapped block
highlights only the tokens that actually differ.

The mouse works too (including over tmux): the wheel scrolls the pane under the
pointer, and a left click selects a row. Clicking a section, directory, or
recent-commits header folds it, and clicking a sidebar file opens it. Mouse
capture means the terminal's own text selection needs the usual override
(`Shift`, or `Option` in iTerm2).

## How it compares

Pagers like [delta](https://github.com/dandavison/delta) render diffs
beautifully, and [lazygit](https://github.com/jesseduffield/lazygit) and
[gitui](https://github.com/gitui-org/gitui) are great general git TUIs.
diffler is review-first: comments live on diff lines, an agent reads and
answers them over MCP while you watch, and the same threads work against real
GitHub, GitLab and Forgejo pull requests, including ones whose branch you
never checked out.

You may also want to check [tuicr](https://github.com/agavra/tuicr), the
closest alternative.

## MCP tools

While the TUI is running, diffler serves an MCP server the agent uses to read
your review and respond in place. See [docs/mcp.md](docs/mcp.md).

## Configuration

Layered TOML: defaults, then `~/.config/diffler/config.toml` (XDG respected,
macOS included), then `<repo>/.diffler/config.toml`, then CLI flags. Every
option and key remap, documented with its default, lives in
[docs/config.example.toml](docs/config.example.toml). Inspect the merged
result and where each value came from:

```sh
diffler config --dump
```

## Themes

Switchable live with `T`, or set `ui.theme`. The
[gallery](showcase/THEMES.md) shows each one.

![the review screen in catppuccin-mocha: the file tree, a diff carrying a comment thread with the agent's reply, and the comments sidebar](showcase/img/catppuccin-mocha.png)

## Development

```sh
just ci     # core gate: fmt + clippy + tests
just e2e    # PTY end-to-end suite (needs uv)
```

Requires Rust 1.88+, `just`, `cargo-nextest`. Hooks: `prek install`.

## License

MIT or Apache-2.0, at your option.
