Skip to main content

A local git gatekeeper that blocks AI-generated slop in PR descriptions.

Project description

DiffSniff

Stop AI-generated filler from sneaking into your Git history.

DiffSniff is a local, terminal-based gatekeeper that cross-references your staged Git changes against your Pull Request description. If it detects that the description is generic AI-generated filler that doesn't accurately reflect the code you've written, it blocks the commit.


Why DiffSniff?

Traditional AI detectors focus on writing style, which makes them easy to bypass. You can simply ask a model to "write like a human."

DiffSniff takes a different approach.

Instead of analyzing how text is written, it verifies whether the claims in your PR description actually match the code changes in your diff.

How It Works

Local Heuristics

DiffSniff performs lightweight local analysis to identify low-effort copy-paste descriptions by measuring:

  • Vocabulary overlap
  • Structural variance
  • Content specificity

This catches obvious mismatches instantly without requiring an API call.

Adversarial Q&A

DiffSniff then:

  1. Feeds your Git diff to an LLM.
  2. Generates highly specific technical questions about the code changes.
  3. Checks whether your PR description answers those questions.

If your PR claims one thing while the code does another, DiffSniff flags it.


Installation

Install directly from PyPI:

pip install diffsniff-gatekeeper

Configuration

Bring Your Own Model

DiffSniff uses LiteLLM under the hood, allowing you to use virtually any supported provider, including:

  • Gemini
  • OpenAI
  • Anthropic
  • Local models

Example: Gemini

Export your API key:

export GEMINI_API_KEY="your-google-ai-key"

Optional Configuration

Create a config.json file in your working directory to customize behavior:

{
  "model": "gemini/gemma-4-31b-it",
  "slop_threshold": 55,
  "num_questions": 3
}

Configuration Options

Option Description
model LLM used for adversarial questioning
slop_threshold Minimum score required to pass validation
num_questions Number of generated code-specific questions

Using OpenAI

To switch providers:

{
  "model": "gpt-4o"
}

Then export your API key:

export OPENAI_API_KEY="your-openai-key"

Usage

  1. Stage your code changes:
git add .
  1. Write a draft PR description in a Markdown file.

  2. Run DiffSniff:

diffsniff pr_draft.md

Results

✅ Pass

Your PR description accurately reflects the code changes and you're ready to push.

❌ Fail

Your description doesn't sufficiently explain what the code actually does.

Rewrite the documentation and try again.


Philosophy

DiffSniff doesn't care whether a human or an AI wrote your PR description.

It cares whether the description is true.

If your documentation accurately explains the code, it passes.

If it's generic filler disconnected from reality, it fails.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffsniff_gatekeeper-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffsniff_gatekeeper-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file diffsniff_gatekeeper-0.1.0.tar.gz.

File metadata

  • Download URL: diffsniff_gatekeeper-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for diffsniff_gatekeeper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e99838ee81e1c28f3e1ea21d7cc50d5468698cdd86ee96a19608642d7280dc8f
MD5 3948797df7f12885d023c892c3edc631
BLAKE2b-256 f7c8e1aceda30ecea7cb53190e407d09f4888a911a71c40de9425a12902b96f2

See more details on using hashes here.

File details

Details for the file diffsniff_gatekeeper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for diffsniff_gatekeeper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba7ec74e7b90c3bf7c44ea118f45b22e82abceebf77f397892dcca39bb8c44aa
MD5 ad82a900d03215f0823e14ff9dcfac7b
BLAKE2b-256 283e4e9757c08cd0ab446434523aa9c1f2e2c14da6c7ab8ef50855f20056d054

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page