Skip to content

Colors9527/diffpack

Repository files navigation

diffpack

Pack only the changed code in a Git repository into an LLM-ready review file.

diffpack is a tiny local CLI for AI-assisted code review. It collects your Git diff, the current contents of changed files, basic repository status, estimated token usage, and best-effort secret redaction into one Markdown file you can paste into ChatGPT, Claude, Gemini, Codex, Cursor, Aider, or another coding tool.

It does not call any API. Your code stays on your machine.


Why this exists

Full-repo context is useful, but most day-to-day AI coding tasks are about the current change:

  • review this PR;
  • explain this diff;
  • find the bug in my staged changes;
  • write a commit message;
  • suggest tests for files I touched.

diffpack gives you one command:

diffpack . -o REVIEW.md

Then paste REVIEW.md into your AI coding tool.


Features

  • Diff-focused: includes Git status, patch diff, and changed file contents.
  • Local-first: no network calls, no account, no telemetry.
  • Token-aware: estimates token usage and stops before your budget.
  • Secret redaction: masks likely API keys, private keys, passwords, and tokens.
  • Untracked files: includes new files by default.
  • Branch review: compare against main, origin/main, or any ref.
  • Zero runtime dependencies: standard-library Python only.

Install

From source:

git clone https://github.com/Colors9527/diffpack.git
cd diffpack
python -m pip install -e .

After publishing to PyPI:

pip install diffpack

Usage

Pack current unstaged and staged changes

diffpack . -o REVIEW.md

Review a branch against main

diffpack . --base main -o REVIEW.md

Use a smaller context budget

diffpack . --max-tokens 40000 -o REVIEW.md

Exclude untracked files

diffpack . --no-untracked -o REVIEW.md

Preview without writing

diffpack . --dry-run

Recommended prompt

Paste the generated file into your AI tool with this instruction:

You are reviewing the following Git diff and changed file context. Identify correctness bugs, security risks, missing tests, and unclear code. Be specific and cite file paths.

CLI reference

usage: diffpack [path] [-o OUTPUT] [--base BASE] [--max-tokens N]
                [--max-file-size BYTES] [--max-diff-chars CHARS]
                [--no-untracked] [--no-redact] [--dry-run]

Important options:

  • --base REF: compare committed changes against a Git ref. Default: HEAD.
  • --max-tokens N: approximate context budget. Default: 80000.
  • --max-file-size BYTES: skip changed files larger than this. Default: 250000.
  • --max-diff-chars CHARS: truncate very large patch text. Default: 200000.
  • --no-untracked: skip untracked files.
  • --no-redact: disable best-effort secret redaction.

Safety notes

diffpack makes a best effort to redact secrets, but it is not a formal security scanner. Always skim the generated file before pasting it into a third-party service.


Related

  • ctxpack: pack a whole repository into an LLM-ready context file.

License

MIT

About

Pack changed code into an LLM-ready review file for AI coding tools.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages