Skip to main content

A package that prevents AI slop by asking you questions about your code changes before allowing you to commit

Project description

Git Police

Git Police is a commit-time assistant designed to prevent low-quality or AI-slop code from being pushed. It challenges you with a senior-developer style question about your changes and only allows the commit when you demonstrate understanding of the code.

It supports both local models via Ollama and remote evaluation using Gemini.

Installation

Install inside your virtual environment

pip install git-police

Initialization

Run once inside a git repository

git-police init

This sets up the Git hook that triggers the code-understanding check before each commit.

To run global mode (Gemini only)

  1. Export your GEMINI_API_KEY
export GEMINI_API_KEY="your_api_key"
  1. Run a commit with global mode enabled
GIT_POLICE_MODE=global git commit -m "msg"

To run a different Ollama model

By default, Git Police uses phi4-mini:latest. To use a different local model:

  1. Ensure you have ollama in your system
  2. pull the model you want to use
  3. Commit using the model

You can either use

GIT_POLICE_MODEL="your_model" git commit -m "msg"

To use the model

Or set it up once

export GIT_POLICE_MODEL="your_model"

and now you can commit as normal and it will use your specified model

Adjusting Maximum Characters Sent to the Local Model

If you want faster responses from your local model, you can reduce the number of characters sent:

MAX_CHAR=5000 GIT_POLICE_MODEL="your_model" git commit -m "msg"

Adjust MAX_CHAR as needed

Bypassing the Check (Emergency Commits)

If you encounter hallucinations or need to bypass Git Police temporarily:

git commit -m "your msg" --no-verify

Example

See git-police in action

approved

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

git_police-0.1.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

git_police-0.1.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file git_police-0.1.5.tar.gz.

File metadata

  • Download URL: git_police-0.1.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for git_police-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1aafa6fc69797e9076610b260c6932cb2f1fdfd7dcd3d5d02447c2a6dc871ba8
MD5 07cc0146ff620b456380d417013b08da
BLAKE2b-256 7774e7ee24207031f5b6af652c7b2dd4737892be30613f415bc83474d92cd884

See more details on using hashes here.

File details

Details for the file git_police-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: git_police-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for git_police-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 90a3121c6eaf2e68aac33de9f5ba70978ca788496d1efb4d10642aa09eae943a
MD5 ce2eef79b3f76359d10d45f8f81234f7
BLAKE2b-256 e6aa7eda4ade341891a25414029e9f77129fc2399742559fde8e2cd08e15961d

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