agentleFS
kaiketsu-labskaiketsu-labs/diffguide/AGENTS.md

diffguide

AGENTS.md1 starsChanged yesterdayMITView on GitHub

DiffGuide is a VS Code extension for reviewing code with Claude on one review page, for local changes and for GitHub pull requests. Editing and navigation stay in VS Code's editor. Keep the workflow simple and preserve existing behavior. src/ has five layers. test/layers.test.ts fails when a file imports a layer it may not.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

13 rules. About 1 is common, 9 are distinctive, and 3 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use strict TypeScript with noUncheckedIndexedAccess and exactOptionalPropertyTypes.

    line 33
  2. Distinctive:

    Keep persisted review data independent of the transport.

    line 35
  3. Distinctive:

    Add doc comments for exported behavior.

    line 36
  4. Distinctive:

    Update the page right away for the user's own toggles (Viewed, read marks) and let the extension's next state confirm them.

    line 45
  5. Distinctive:

    Use clear system sans-serif fonts for extension UI and monospace fonts for code.

    line 54
  6. Distinctive:

    Keep UI copy short, in English, and actions self-explanatory.

    line 55
  7. Distinctive:

    Before building a new or rearranged surface, sketch it as a rendered HTML mock in the user's theme colors, not ASCII in chat, and confirm …

    line 58
  8. Distinctive:

    Keep conversations anchored to their code.

    line 67
  9. Distinctive:

    Only the human can resolve a thread.

    line 70
  10. Distinctive:

    Do not silently attach uncertain comments or read marks to another line of code.

    line 73
  11. Common:

    Keep connection credentials outside the repository and preserve existing Claude configuration.

    line 75
  12. Very specific:

    Use Python through uv run if a supporting media task requires it.

    line 84
  13. Very specific:

    Commit messages use <type>(<scope>): <lowercase subject> with !

    line 99

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Project instructions

DiffGuide is a VS Code extension for reviewing code with Claude on one review page, for local changes and for GitHub pull requests. Editing and navigation stay in VS Code's editor. Keep the workflow simple and preserve existing behavior.

Code map

src/ has five layers. test/layers.test.ts fails when a file imports a layer it may not.

LayerHoldsMay import
core/Domain: review store and contracts, anchors, diffs, review marks, guide model, git and worktrees. forge.ts and agent.ts define the Forge and agent interfaces; events.ts and host.ts replace VS Code's events and storage.core
page/The review page, host-neutral: protocol.ts (both message directions and their validation), html.ts (HTML and CSS), overviewState.ts (state the page shows), page actions, previews, pullRequest/ (the PR page controller) and webview/ (the browser script).core
forges/github/Forge for GitHub: provider.ts (GitHubApiProvider), parse.ts (API responses), githubApi.ts (requests; sign-in through the GitHubHost port).core
agents/claude/Claude Code: claudeRunner.ts (AgentRunner), reviewRunner.ts (AgentCodeReview), prAnalysisRunner.ts (AgentGuideAnalysis), bridge, channel and hooks.core
hosts/vscode/The VS Code extension: extension.ts wires everything, reviewPanel.ts hosts the page, pullRequestPage.ts gives the PR page controller its PageHost, sidebars, settings, terminals, and the GitHubHost implementation.everything
  • New domain logic goes in core, new page features in page. Code that names GitHub or Claude goes in forges/github or agents/claude, behind the interface in core. Only hosts/vscode imports vscode.
  • Hosts construct concrete forges and agents (GitHubApiProvider, ClaudeRunner) and pass them on as Forge, AgentRunner, AgentCodeReview and AgentGuideAnalysis. GitLab, other agents and a standalone host each add a folder under their layer.
  • Core types use neutral names (ChangeRequestSummary, AgentActivity). Wire formats, persisted values and UI copy keep their existing names, such as 'github' thread sources.
  • core/unifiedDiff.ts parses git diff into highlighted hunks. core/anchors.ts captures and relocates code by content. core/reviewedFiles.ts stores Viewed files and read line ranges. hosts/vscode/localReview.ts feeds the page in local mode.
  • hosts/vscode/textMateHighlighter.ts colors code with VS Code's grammars and the user's theme. highlightPool.ts runs it on worker threads from highlightWorker.ts (bundled to dist/highlight-worker.cjs), so these three files must not import vscode.
  • page/pullRequest/controller.ts composes a PR page from RemoteData (GitHub reads), DiffView (the Files tab), pageState.ts and one action group per area (threads, GitHub, suggestions, Claude, worktree, files, linked changes). Anything that needs VS Code goes through PageHost in context.ts.

Page script (src/page/webview/)

  • main.ts is the entry (bundled to dist/overview.js) and holds all control wiring in page order. messages.ts handles extension messages. render.ts draws the page from state.
  • state.ts holds the shared state: prefs persists through save(), received mirrors what the extension sent, ui is transient. State one module uses stays in that module.
  • Feature folders: header/ (PR state, merge, reviewers, connect menu), claude/ (Claude's header chip and its menu), conversation/, files/ (render, diff table, nav, filters, previews, marks, selection), threads/, guide/, review/. Shared helpers: dom.ts, menus.ts, status.ts, transport.ts (the only use of acquireVsCodeApi).
  • dom.ts and transport.ts import no page module, so they load first.

Code

  • Use strict TypeScript with noUncheckedIndexedAccess and exactOptionalPropertyTypes.
  • Reuse existing helpers. Anchor anything that must follow code across edits with anchors.ts, so it lapses instead of moving to unrelated lines.
  • Keep persisted review data independent of the transport. Treat transport and webview messages as unknown until validated.
  • Add doc comments for exported behavior. Do not number implementation steps in comments.

Review page webview

  • Type both directions of the page protocol with PageMessage and ExtensionMessage. The extension still validates every page message.
  • frameMain runs inside the HTML preview frame from its source text, so it must not use anything outside its own body.
  • The CSS lives in a template string in page/html.ts: no backticks or ${ in it. Its rules sit on long lines; change them with Edit on a unique selector, not scripted rewrites.
  • Redraw only what changed. renderFiles([paths]) rebuilds those files' boxes; renderFiles('state') rebuilds files whose state changed. A full renderFiles() is for global changes such as layout, and costs about 100 ms on a 40-file PR.
  • The page shows before GitHub answers and files show before their colors. Once shown, files must not tick Viewed or hide, so they wait for GitHub's file list. Keep every file's lines in the DOM so find-in-page reaches them; draw them over frames, not on scroll.
  • Update the page right away for the user's own toggles (Viewed, read marks) and let the extension's next state confirm them. A round trip waits for a 150 ms debounce and a state re-read.

UI

  • Webview colors, type sizes, spacing and corners come from src/page/designTokens.ts as CSS custom properties (--brand, --ink, --radius-md). UI text sizes use --text-* and the heights of boxes holding a line of text use --line-*, so diffGuide.fontSize scales them; icons, spacing and the diff's code stay fixed. Use only those properties in webview CSS; change a value there, not at the use site. src/page/webviewStyles.ts holds the shared buttons (primary, agent, quiet, small), inputs, key caps and chips.
  • Color names who is involved: brand is you and stays neutral (the theme's text color), agent jade is the coding agent and its Diff pair, github blue is GitHub. Everything else follows the VS Code theme.
  • Page controls use the page's own menus (.picker, as on Labels and the Files filter) for choices, not native <select> or VS Code quick picks. Text fields keep the shared thin inset focus line from webviewStyles.
  • Use our own page widgets wherever a page can host them: confirm in place (askInline row, or askInMenu under a button with no row), edit text in an inline form, pick from a .picker menu, report results in the page notice. A button that opens a form becomes that form's confirm button, as Merge does. Use VS Code modals, input boxes, quick picks and toasts only where no page is open, such as the sidebar, editor commands and setup, and for errors that must reach a closed page.
  • Draw every new icon ourselves in src/page/icons.ts, following docs/ICONS.md: 1.25 px line icons, filled shapes only for the Diff pair and the DiffGuide mark. Don't copy codicons or other icon sets. Native surfaces use the font npm run icons builds from the same file.
  • Use clear system sans-serif fonts for extension UI and monospace fonts for code.
  • Keep UI copy short, in English, and actions self-explanatory. Leave existing German strings until asked.
  • Name controls after existing ones that do the same thing; a checkbox that marks lines reviewed is "Viewed", like the file's.
  • Give each action a distinct weight: one filled button per row (agent when it sends to the agent, primary otherwise), secondary buttons, text-only Cancel. Don't show hints for standard shortcuts such as ⌘/Ctrl+Enter. Put status text left and buttons right, Cancel first and the filled button last. Align controls on one row height.
  • Before building a new or rearranged surface, sketch it as a rendered HTML mock in the user's theme colors, not ASCII in chat, and confirm terms with the user; "checkbox", "button" and "window" have been misread before.
  • Repository illustrations use a neutral, clean style focused on reviewing code and collaborating with an agent, with concrete code and review examples.

Product invariants

  • Submitted comments are delivered automatically. Unsent keystrokes are not agent instructions.
  • Comments are written on the review page, for local changes and PRs, and sent with Ask or Implement. There is no editor command or native editor comment.
  • Explain automatic feedback delivery in plain language. Keep transport names in optional technical details; the hook-based default supports the terminal/gateway workflow while Channels remains an experimental opt-in.
  • Voice input uses the user's existing macOS Dictation. Do not add an audio recorder or transcription service unless requested separately.
  • Keep conversations anchored to their code. Replies must not silently change targets.
  • ask and summarize request discussion without edits; implement requests scoped code changes.
  • Publishing a PR's Local thread to GitHub is a separate preview-and-publish action.
  • Only the human can resolve a thread. An agent response is not human acceptance.
  • Preserve immutable event IDs and original code context across edits and restarts.
  • A transport connection is not a delivery acknowledgment.
  • Do not silently attach uncertain comments or read marks to another line of code.
  • Reply Markdown stays untrusted. Model-provided paths or command arguments cannot select navigation targets, except path:line references the page itself matches against the files it shows; those only scroll the page.
  • Keep connection credentials outside the repository and preserve existing Claude configuration.

Commands

  • npm ci --ignore-scripts installs dependencies, npm run build bundles, and npm run package builds the installable VSIX.
  • npm run typecheck (under a second) and npm test (about 12 s) check types and run the tests. Run them without asking. npm test -- anchors review runs only the test files whose names contain anchors or review; run the full suite before handing over. A project Stop hook runs the type check when a turn changed TypeScript.
  • npm run bench times the review page and sidebar on fixed fixtures (the bench skill).
  • npm run render screenshots the review page in the user's theme, scenes in parallel (--jobs N, --jobs 1 for one at a time; the render skill). make install packages and installs the VSIX (the install skill). make demo opens an isolated demo window (see below).
  • The demo PR is one typed data file, src/forges/demo/fixture.ts, served by the fake forge in src/forges/demo/fakeForge.ts (writes stay in memory). demo/sample-repo/ holds the plain files of its git history and src/forges/demo/sampleRepo.ts builds it with fixed names and dates, so commit ids are the same everywhere. When you change either, test/demoForge.test.ts tells you the new ids for the fixture. scripts/e2e.mjs runs against the same repo and PR.
  • Use Python through uv run if a supporting media task requires it.

Verification

  • Every bug fix and feature ships with a test that fails without the change; undo the change once to see it fail. Use the cheapest layer that sees the behavior: a unit test (npm test) for core and page logic and for host message handling against test/fakes/vscode.ts; a render scene with expect, text and absent checks (and send for host replies) for what the page shows and does; an scripts/e2e.mjs scenario for flows that need real VS Code, such as commands, tabs, reloads and the sidebar. Only real GitHub and authenticated Claude stay manual; list those checks as pending in the PR.
  • The user tries changes in a make demo window: an isolated VS Code on this worktree's build with a fixed sample PR, so nothing is installed into their main VS Code and several worktrees run side by side. When a change the user should see is finished, write the change summary, then ask with the question tool whether to run make demo, and run it in the worktree only on yes (a new window takes focus, so the user decides when). It rebuilds first. If that worktree's demo window is already open, it only rebuilds: tell the user to reload that window. Never close a demo window; the user may be using it. For release-like checks use make install: it needs npm run package and code --install-extension diffguide-<version>.vsix --force, and an install swaps dist/overview.js under open windows, so pages opened before a reload pair old HTML with the new script and break; after every install, tell the user to reload all windows.
  • While iterating on a webview change, render only the scenes for the area you touched (npm run render -- <names>). Before pushing or handing over, run the full npm run render once, and look at the screenshots of the exact build you install. Add a scene to test/render/fixtures.ts when none shows the change; a failed check fails the run like a script error. Default colors hide border and contrast problems; the screenshot also catches script errors.
  • Measure latency claims with npm run bench (the bench skill), before and after, instead of estimating.
  • A change that shows something before a read finishes can race that read. Run npm run e2e:docker several times; one passing run proves nothing.
  • Verify user-facing flows with end-to-end clicks in VS Code and controlled agent simulation, including the actual failure scenario. npm run e2e:docker runs scripts/e2e.mjs in headless VS Code: local review page, comment with Ask, a simulated agent answer through the bridge, Resolve, a mock PR page with Refresh, and a window reload that must bring both pages back. npm run e2e runs it in a visible window; agents use npm run e2e:docker only, starting Docker Desktop (open -a Docker) when the daemon is down. Extend that script for new flows. PR flows against GitHub and authenticated Claude stay manual.
  • Distinguish automated logic, process simulation, observed native UI and authenticated Claude evidence. Keep unverified flows pending; do not claim completion from unit tests or a simulated walkthrough alone.

Tracking

  • Record user-visible changes as lines under ## Unreleased in CHANGELOG.md. The release workflow moves them into the release as ### Notes. Keep installation, publishing, review findings and known limitations current in README.md and docs/. CHANGELOG.md is large; read only its top.
  • Commit messages use <type>(<scope>): <lowercase subject> with ! before the colon for breaking changes.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.