Thank you for taking the time to contribute! This guide will help you get set up and understand the project conventions.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Making Changes
- Tests
- Commit Message Style
- Pull Request Guidelines
- Reporting Bugs
- Requesting Features
Be respectful and constructive. We welcome contributors of all skill levels.
- Fork the repository on GitHub.
- Clone your fork locally:
git clone https://github.com/<your-username>/ai-commit-msg cd ai-commit-msg
- Add upstream remote:
git remote add upstream https://github.com/hidearmoon/ai-commit-msg
Python 3.9+ is required.
# Create and activate a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Install the package in editable mode with dev dependencies
pip install -e ".[dev]"
# Verify the CLI is available
acm --versionai-commit-msg/
├── src/ai_commit_msg/
│ ├── __init__.py # Version
│ ├── cli.py # Click entry point (acm / ai-commit-msg)
│ ├── config.py # Config loading, merging, persistence
│ ├── git.py # Git operations + smart diff chunking
│ ├── hook.py # Git hook install/uninstall
│ ├── prompt.py # Jinja2 prompt templates + candidate parsing
│ └── providers/
│ ├── __init__.py # Factory + registry
│ ├── base.py # Abstract BaseProvider
│ ├── openai.py # OpenAI provider (also covers DeepSeek)
│ ├── claude.py # Anthropic Claude provider
│ ├── deepseek.py # DeepSeek provider
│ └── ollama.py # Ollama provider
├── tests/
│ ├── conftest.py # Shared pytest fixtures
│ ├── test_cli.py
│ ├── test_config.py
│ ├── test_git.py
│ ├── test_hook.py
│ ├── test_prompt.py
│ └── test_providers.py
├── pyproject.toml
├── README.md
└── CONTRIBUTING.md
-
Create a branch off
main:git checkout -b feat/my-feature
-
Make your changes. Keep PRs focused — one feature or fix per PR.
-
Write tests for any new behaviour (see Tests below).
-
Run the test suite and ensure it passes:
pytest tests/ -v
-
Check coverage (aim to keep it above 80%):
pytest --cov=src --cov-report=term-missing
- Create
src/ai_commit_msg/providers/<name>.pyimplementingBaseProvider. - Register it in
src/ai_commit_msg/providers/__init__.py(PROVIDER_NAMESlist +registrydict inget_provider). - Add default config in
src/ai_commit_msg/config.py(Configdataclass). - Add the provider section to the config CLI in
cli.py(config listcommand). - Write tests in
tests/test_providers.py(mock all HTTP calls withpytest-mock). - Document it in
README.md.
We use pytest with pytest-mock for all tests. All HTTP calls to AI providers must be mocked — never make real API calls in tests.
# Run all tests
pytest tests/ -v
# Run a specific test file
pytest tests/test_providers.py -v
# Run with coverage
pytest --cov=src --cov-report=htmlKey conventions:
- Use
mocker.patch(frompytest-mock) to mockhttpx.post/httpx.Clientcalls. - Test both the happy path and error paths (
ProviderError,GitError, config errors). - Use the fixtures in
conftest.pyfor shared setup (temp directories, mock git repos, etc.).
This project uses Conventional Commits (naturally, we eat our own dog food):
<type>(<scope>): <short description>
[optional body]
[optional footer]
Types: feat, fix, docs, refactor, test, chore, perf, ci
Examples:
feat(providers): add Gemini provider support
fix(chunking): handle binary files in diff splitting
docs(readme): add Ollama setup instructions
test(config): add coverage for env var override order
- Target the
mainbranch. - Fill in the PR template: describe what changed and why.
- Link any related issues (
Closes #123). - Keep PRs small and focused. Large PRs are harder to review and slower to merge.
- All CI checks must pass before merge.
- A maintainer will review within a few days; please be patient.
Use the Bug Report issue template. Include:
- Your OS and Python version (
python --version) - Package version (
acm --version) - The full command you ran
- The complete error output
- Steps to reproduce
Use the Feature Request issue template. Describe the problem you want solved, not just the solution you have in mind.
Open a Discussion or file an issue with the question label.