A modular CLI tool for AI-powered git commit and PR message generation using Gemini AI.
cookcommit/
βββ src/
β βββ cookcommit/
β βββ __init__.py
β βββ config.py # Configuration constants
β βββ commands/
β β βββ __init__.py
β β βββ save.py # Save diff command
β β βββ commit.py # Generate commit command
β β βββ pr.py # Generate PR command
β βββ services/
β β βββ __init__.py
β β βββ git_service.py # Git operations
β β βββ ai_service.py # AI message generation
β βββ utils/
β βββ __init__.py
β βββ text_utils.py # Text processing
β βββ file_utils.py # File operations
β βββ output_utils.py # Output formatting
βββ cli.py # Main entry point
βββ setup.py # Package setup
βββ requirements.txt # Dependencies
βββ README.md # This file
pip install -r requirements.txt# Save git diff to file
python cli.py save -o my-diff.txt
# Generate commit message
python cli.py commit
# Generate commit message and auto-commit
python cli.py commit --commit
# Generate PR message
python cli.py pr
# Generate PR title only
python cli.py pr --title-only# Generate commit message with output file
python cli.py commit -o commit-msg.txt
# Auto-commit with AI-generated message
python cli.py commit --commit
# Generate PR message and save to file
python cli.py pr -o pr-message.md- β
Saves
git diff --cachedto text file - β Checks for git repository
- β Handles empty staged changes
- β Generates AI-powered commit messages
- β Uses conventional commit format
- β Automatic chunking for large diffs
- β
Auto-commit flag (
--commit) - β Save to file option
- β Clean, minimal output
- β Generates comprehensive PR messages
- β Title-only option
- β Markdown formatting
- β Handles large codebases
- β Save to file option
- Smart Chunking: Automatically handles large diffs
- Conventional Commits: Follows industry standards
- Context-Aware: Understands code changes
- Multi-Model: Uses different models for speed/quality
python cli.py save [OPTIONS]
Options:
-o, --output TEXT Output file name [default: diff.txt]python cli.py commit [OPTIONS]
Options:
-o, --output TEXT Save commit message to file
-c, --commit Automatically commit with generated messagepython cli.py pr [OPTIONS]
Options:
-o, --output TEXT Save PR message to file
--title-only Generate only PR title# 1. Make changes and stage them
git add src/feature.py
# 2. Generate and auto-commit
python cli.py commit --commit
# 3. Generate PR message for GitHub
python cli.py pr -o pr-template.md- Modular Design: Separated concerns across multiple files
- Service Layer: Clean separation of git and AI operations
- Utility Functions: Reusable components
- Type Hints: Better code documentation and IDE support
- Error Handling: Comprehensive error management
- Extensible: Easy to add new commands and features