diffctx: pack git changes for LLM review

작성자

카테고리:

← 피드로
DEV Community · SybilGambleyyu · 2026-07-21 개발(SW)

SybilGambleyyu

TL;DR: I shipped diffctx, a small CLI that turns a git change set into clean, token-aware markdown you can paste into an LLM or coding agent.

The problem

When you want a model to review a PR or fix what just broke, the useful context is almost never “the whole repository.” It’s:

  1. What commits landed
  2. Which files moved
  3. The unified diff
  4. Enough surrounding file content to understand the change
  5. Nearby tests

People still solve this by hand: copy a git diff, open a few files, forget the test, and occasionally paste a secret. Whole-repo packers (repomix and friends) are excellent for “explain this codebase,” but they are the wrong default for “look at this change.”

What diffctx does

# Uncommitted work
diffctx

# Everything since main, ready for review
diffctx main --template review --out pack.md

# Stay inside a rough context budget
diffctx main --budget 12000 --stats 2>stats.json >pack.md

Enter fullscreen mode Exit fullscreen mode

The pack includes a short meta table, commit subjects, the file list, a fenced unified diff, full contents of changed files, and heuristically related tests (foo_test.go, foo.test.ts, test_foo.py, …).

Optional prompt wrappers (review, fix, summarize) put a short instruction block above the pack so the first paste is already a usable prompt.

Design choices

Local only. No model API keys, no network. It shells out to git and reads the working tree.

Redact by default. Common PAT/cloud-key/private-key/JWT shapes are replaced with [REDACTED:…] markers before output. This is best-effort pattern matching, not a full secret scanner — but it catches the worst paste mistakes.

Budget with priorities. If you set --budget, lower-priority sections (related tests, full files) drop first. Meta and the diff stay as long as possible.

Approximate tokens. Counts use chars÷4. Good enough to stay inside a context window; not for billing.

Install

go install github.com/SybilGambleyyu/diffctx/cmd/[email protected]

Enter fullscreen mode Exit fullscreen mode

Source and docs: github.com/SybilGambleyyu/diffctx.

What it is not

  • Not a code-review agent — it only prepares context
  • Not a whole-repo packer — use repomix when you need the project
  • Not a replacement for reading the diff yourself

What’s next

I want to deepen this rather than spawn clones: better related-file discovery, PR fetch via gh, and a “failure pack” mode that folds test output into the same document. If you try it and something is wrong or missing, open an issue on the repo.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다