Thank you for your interest in contributing. This guide explains how to set up a development environment, make changes, and test them before you open a pull request.
You can work in one of two environments:
- Dev Container (recommended) — requires Docker or Podman and Visual Studio Code with the Dev Containers extension, or a GitHub Codespace.
- Local machine — requires Git, Python 3.12, uv, Node.js, and Docker or Podman for linting.
-
Clone the repository:
git clone https://github.com/electrocucaracha/ai-prepare-commit-msg.git cd ai-prepare-commit-msg -
Open the folder in Visual Studio Code and select Dev Containers: Reopen in Container from the Command Palette.
-
Wait for the container to build. The
postCreateCommandinstalls all dependency groups withuv sync --all-groupsand registers the Git hooks withpre-commit install.
The container forwards LITELLM_PROXY_MODEL, LITELLM_PROXY_API_BASE,
LITELLM_PROXY_API_KEY, OPENAI_API_KEY, and ANTHROPIC_API_KEY
from your host environment.
See Configuration
for the full list of variables.
By default,
the hook uses the local Ollama server
that starts with the container on port 11434:
LITELLM_PROXY_MODEL defaults to ollama/llama3.2
and LITELLM_PROXY_API_BASE defaults to http://localhost:11434.
On every start,
the container pulls the configured Ollama model in the background
and logs progress to /tmp/ollama.log.
To use a different model or a cloud provider,
export LITELLM_PROXY_MODEL on the host before you open the container.
-
Clone the repository as shown above.
-
Install the project and all dependency groups into
.venv:uv sync --all-groups
-
Install the Git hooks:
uvx pre-commit install
This registers both the
pre-commitchecks and theprepare-commit-msghook that runsuv run prepare-commit, so your own commits use the development version of the tool.
-
Create a branch from
main:git checkout -b my-feature
-
Make your changes:
- Application code lives in
src/ai_prepare_commit_msg/. - Unit tests live in
tests/. - Behavior-driven scenarios live in
features/. - Documentation lives in
docs/and follows Semantic Line Breaks.
- Application code lives in
-
Add or update tests that cover the change.
-
Update the documentation when behavior or configuration changes.
The Makefile wraps the tox environments
defined in pyproject.toml:
| Command | Description |
|---|---|
make test |
Run the unit tests with pytest. |
make coverage |
Run the unit tests with a coverage report. |
make bdd |
Run the Behave BDD scenarios in features/. |
make mutation |
Run mutation tests with mutmut. |
make fmt |
Format Python, Markdown, YAML, and shell sources. |
make lint |
Run Super-Linter in a container. |
The test targets run on Python 3.12, 3.13, and 3.14.
Use make -j3 test to run the version-specific test jobs in parallel;
for example, make test-py312 runs only the Python 3.12 unit tests.
Coverage and BDD targets support the same version-specific pattern.
Mutation targets run serially because mutmut shares cache and report files.
Pass extra arguments to pytest through tox, for example:
uvx tox -e test -- tests/test_git.py -k stagedTo try the hook end-to-end, stage a change and run the CLI directly:
git add <file>
uv run prepare-commit --log-level DEBUGNote
make lint uses the ghcr.io/super-linter/super-linter image,
which only publishes linux/amd64.
On Apple Silicon hosts it may fail
unless you run it with --platform=linux/amd64.
- Run
make fmt,make lint, andmake testand fix any reported issues. - Commit your changes with the
prepare-commit-msghook installed bypre-commit. We encourage contributors to dogfood the project this way: the hook generates the commit message in the Conventional Commits format for you, and using it on real changes helps us find bugs and improve the prompts. Review the draft before you accept it, and edit it if it does not describe the change accurately. - Push your branch and open a pull request against
main. - Describe the motivation for the change and how you tested it.
By contributing, you agree that your contributions are licensed under the Apache License, Version 2.0.