herdr-reviewr
AGENTS.md832 starsChanged 5 months agoMITView on GitHub
AGENTS.md is the primary file. CLAUDE.md is a symlink to it. herdr-reviewr is a Rust TUI (ratatui) code-review pane: it runs in a herdr pane beside a coding agent, shows the agent's diff, takes line comments, and sends them back to the agent's input. One binary, one git worktree per pane. It also runs standalone (cargo run in any repo). New behavior is designed with /brainstorming and sequenced with /planning in the conversation; the repo keeps no spec tree. The…
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. AGENTS.md is the primary file. CLAUDE.md is a symlink to it.
herdr-reviewr is a Rust TUI (ratatui) code-review pane: it runs in a herdr pane beside a coding agent, shows the agent's diff, takes line comments, and sends them back to the agent's input. One binary, one git worktree per pane. It also runs standalone (cargo run in any repo).
Commands
just test— full test suite, with the herdr environment stripped so no test can reach a live agent pane. Inside herdr, run a single test the same way:env -u HERDR_WORKSPACE_ID -u HERDR_PANE_ID HERDR_BIN_PATH=false cargo test <name>(unit tests live beside the code, integration tests intests/:cargo test --test app_flow <name>).just lint— clippy with warnings as errors.just fmt/just fmt-check— rustfmt.just ci— exactly what CI runs (fmt-check, lint, test, release build).just qa-install— put a local build into the user's real herdr panes. See "QA install" below before using it.just smoke-edit— PTY smoke test of the editor path (e) against a real release binary. Unit tests stop at the argv; everything after it is terminal state, so run this after any change torun_editor, the terminal mode stack, or the editor dialects. Not part ofjust ci: it drives a pty and takes about a minute.cargo run --example snapshot -- <out-dir>— paints every theme's real frames, scene by scene, as HTML fragments for a side-by-side color review. Ad-hoc tooling for theme and color work, not a gate; run it with the herdr environment stripped.python3 scripts/bench_tui.py --binary target/release/herdr-reviewr --fixture— perceived-latency benchmark (keypress → painted frame, via PTY). Ad-hoc tooling, not a gate: run it when a change might feel slower.cargo run --release --example bench_latency -- <repo>attributes a slow number to its component calls. The one committed baseline isscripts/bench-results/baseline.json— replace it when a change moves the numbers, never add per-round runs. For an A/B, rebuild the old binary to a second target dir and interleave runs under the same system load — absolute numbers drift with background load.
Invariants
New behavior is designed with /brainstorming and sequenced with /planning in the conversation; the repo keeps no spec tree. The commit message and the changelog carry the decisions.
Load-bearing invariants. Cite them by name:
- No writes: reviewr never mutates the worktree, index, or branches. Its only git writes are private refs under
refs/worktree/reviewr/: the turn baseline and the base pick. - Comments survive: comments are never lost to a refresh or the agent's edits, and leave only by explicit export. The comment store is in-memory by design — do not propose persisting it.
- Continuity: place state (cursor, scroll, tab, scope, folds, selection, layout) moves only under the user's own input. World events (polls, refreshes, fetch results) may only reconcile it: match by identity first (path, comment author+anchor — never row index), fall back to the nearest surviving target, clamp last. Derived state on screen may be stale, never wrong: blank a view only when its identity changed, never because the same thing gained newer content.
Architecture
The runtime is a single-threaded frame loop (event_loop in src/lib.rs): draw → wait for input or poll deadline → mutate App → draw. Clipboard, agent-send, and per-file diff builds run synchronously between frames, and a terminal editor holds the loop for its whole session by design (policies/ux-responsiveness.md). Five things run on worker threads: the world worker (src/world.rs — the refresh build and turn tracking), the search worker (src/search.rs — the fff-search engine, which runs its own scan, watch, and content-index threads), the PR input probe, the PR forge fetch (gh/glab/az), and config recovery. World results land through land_world_completion: input-tagged, latest-wins, reconciled only while the view still matches (see Continuity above).
src/app.rs— theAppstate machine. Tabs (Changes/AllFiles/Pr), scopes (Uncommitted/Branch/LastTurn),Focus(files vs diff pane),Mode(Normal, theComposing/Listoverlays, and the body-replacingSearchscreen).reconcile_world()is the one place a world snapshot touches place state;reload()is the synchronous build+reconcile pair used at startup, first tab visits, and scope switches. Each file tab stashes its full place state on switch-away (swap_active_with_stash). While composing, the open diff is frozen (reconcile skips it) so a draft's anchor can't move. A markdown file shows asRow::Renderedrows, each carrying its block's source range.src/world.rs— the world worker: the pure snapshot build (WorldInput→WorldSnapshot), the request/completion channels (latest-wins by generation), andTurnHost(the turn tracker, worktree snapshots, and the baseline ref write, all worker-side).src/git.rs— every git subprocess.changed_files(scope changesets),all_files(tracked + untracked + ignored vials-files— never usegit status --ignored, it walks inside ignored trees and costs seconds),snapshot_worktree(temp-indexadd -A+write-treefor turn baselines), baseline refs.src/diff.rs—FileDiffbuild (syntect highlight both sides, similar-line pairing, word emphasis, folds) andDiffCache, keyed by path and gated by content hash. Cleared on scope switch and theme change.src/markdown.rs— the markdown renderer. Every rendered line maps to its block's source range, andsilentlists the source lines nothing renders.src/rendered.rs— a file tab'sRenderedView(choice, content, render, marks) and theRenderedIndexover its rows: unit runs, lead rows, and the one landing rule for a source line.src/marks.rs— rendered change marks. An inserted line belongs to its new block, a deleted line to its block in the old document (the old side renders too), and markers stand for the rest.src/roles.rs— the color roles. A theme's primitives derive every fill (a layer under text, stacked inLAYERS) and every ink (a text or glyph color), each resolved per fill so it reads there. Components paint roles, never a hue;legible/readablekeep content colors (syntax, markdown headings) readable on any fill, hue kept.src/theme.rs— the theme catalog: each built-in theme's primitives, syntax pairing, and the official fills it sets itself.src/ui.rs— all rendering. Row heights and wrapping recompute per frame across the visible diff, so render cost scales with open-file size.src/forge.rs+ thePrRefresh/PrCoordinatorstate machines inlib.rs— the PR snapshot. Fetches are tagged with the input (repository identity, pinned HEAD and base, the branch's published heads and pin) that produced them, and a result paints only if a fresh probe proves the input still matches. This generation/input-tag pattern is the template for moving other derived state off-thread.src/gitlab.rs/src/azure_devops.rs— theglabandazproviders behind the forge boundary inforge.rs, each mapping its CLI's payloads onto the onePrSnapshotshape.src/turn.rs— the pure turn state machine: a resting→working edge starts a turn, and a pending candidate promotes to thelast-turnbaseline once the worktree diverges from it. The world worker'sTurnHostdrives it;src/herdr.rsholds the herdr CLI calls.src/model.rs—CommentStore(in-memory), comment anchoring (diff_anchoreddistinguishes diff comments from All-files content comments — each renders only in its own view).src/editor.rs— the editor command: a name-keyed dialect table (how each editor takes a line, and whether it draws in the pane), quote-aware splitting, and theeditorkey's{file}/{line}template. Pure argv resolution, spawning nowhere.run_editorinlib.rsowns the spawn, and hands the pane over for a terminal editor, blocking the frame loop for that editor's whole session.src/export.rs— comment export: format all, send viaherdr agent sendor clipboard, consume-on-success only.src/config.rs— plugin config: the whole file validates before every frame/action. An invalid config blocks all review work until recovery, which carries authored state.herdr-plugin.toml+herdr/pane.sh— plugin packaging: pane, toggle/open/close actions, and worktree workspace-birth auto-open.
QA install — putting a local build into the user's herdr panes
The user tests builds in real herdr panes. The panes run the GitHub-installed plugin's binary at ~/.config/herdr/plugins/github/persiyanov.reviewr-<hash>/bin/herdr-reviewr, NOT anything in this worktree. Full procedure: docs/qa-install.md. Short form:
just qa-installThen tell the user to close and reopen their reviewr panes with the toggle keybinding. Done.
Three rules. Each one has already burned a session:
- Never overwrite that binary in place.
cponto the existing file keeps the inode and macOS SIGKILLs the binary at every launch (exit 137, blank panes, no log). Replace through a fresh inode and re-sign — which is exactly whatjust qa-installdoes. Do not improvise the swap by hand. - Swapping the file does not restart running panes. They keep the old binary image until closed and reopened. Refresh inside reviewr does nothing for this.
- Never script pane opens. The plugin's
open/toggleactions act on the currently focused workspace and ignoreHERDR_WORKSPACE_ID. Automating reopens stacks panes into whatever space the user is looking at. Closing viaherdr/pane.sh closeis safe. Reopening is the user's keystroke, always.
Rollback: bin/herdr-reviewr.release-backup sits beside the installed binary, swap it back the same fresh-inode way (or herdr plugin install to restore the release).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

