Skip to main content

AI-powered git commit and PR creation tool

Project description

AI CLI ๐Ÿค–

AI-powered git commit and pull request creation tool using Google Gemini.

Python 3.13+ Code style: ruff Checked with mypy

โœจ Features

  • ๐Ÿค– AI-Powered Commits: Generate conventional commit messages using Google Gemini (latest google.genai package)
  • ๐Ÿ“‹ Smart Pull Requests: Create PR titles and descriptions automatically
  • ๐Ÿš€ Auto Push: Automatically push commits to remote repository
  • ๐Ÿ“ Smart Commit All: Commit all changes grouped by folder and context
  • ๐Ÿ”— Branch-based PRs: Create PRs based on all changes in a branch
  • ๐ŸŽฏ Conventional Commits: Follows the conventional commits specification
  • ๐Ÿ›ก๏ธ Type Safety: Fully typed with mypy support
  • ๐Ÿงช Well Tested: Comprehensive test suite with pytest
  • ๐Ÿ“ฆ Professional Structure: Clean architecture with proper separation of concerns
  • โš™๏ธ Pydantic Settings: Modern configuration management with validation
  • ๐Ÿ“‹ Taskipy Integration: Convenient task runner for development workflow

๐Ÿ—๏ธ Architecture

The project follows a clean architecture pattern with well-defined layers:

src/ai_cli/
โ”œโ”€โ”€ core/           # Domain models, interfaces, and exceptions
โ”œโ”€โ”€ services/       # Business logic and orchestration
โ”œโ”€โ”€ infrastructure/ # External integrations (Git, AI, GitHub)
โ”œโ”€โ”€ cli/           # Command-line interface
โ””โ”€โ”€ config/        # Configuration management

Layers Overview

  • Core Layer: Domain models, business interfaces, and custom exceptions
  • Services Layer: Business logic and workflow orchestration
  • Infrastructure Layer: External service integrations (Git, AI APIs, GitHub CLI)
  • CLI Layer: User interface and command handling
  • Config Layer: Environment-based configuration management

๐Ÿš€ Installation

Requirements

  • Python 3.13 or higher (recommended)
  • Git
  • GitHub CLI (optional, for PR creation)
  • Google Gemini API key

Quick Setup

  1. Install using uv (recommended):

    # Clone and install
    git clone <repository-url>
    cd ai-cli
    uv sync
    
    # Install globally
    uv tool install .
    
  2. Configure your API key:

    # Interactive setup (easiest)
    ai-cli setup
    
    # Or set directly
    ai-cli setup --api-key YOUR_API_KEY
    

    Get your API key from: https://makersuite.google.com/app/apikey

  3. Start using:

    ai-cli smart-commit    # AI-powered commits
    ai-cli create-pr       # Create PRs
    ai-cli --help          # See all commands
    

Alternative Setup Methods

Manual .env configuration
# Generate .env file with all options
python scripts/env-gen.py --stdout  # Preview
python scripts/env-gen.py           # Generate local .env
python scripts/env-gen.py --global  # Generate global config
Install GitHub CLI (optional, for PR creation)
# macOS
brew install gh

# Ubuntu/Debian
sudo apt install gh

# Windows
winget install GitHub.cli
  1. Install globally (to use in other projects):

    uv tool install .
    

    Configuration is stored at ~/.config/ai-cli/.env

๐Ÿ“– Usage

Basic Usage

Stage your changes and run the smart commit:

git add .
ai-cli smart-commit

Available Commands

# Basic commit (with push)
ai-cli smart-commit

# Commit without pushing
ai-cli smart-commit --no-push

# Commit with automatic PR creation
ai-cli smart-commit --pr

# Auto-confirm all prompts
ai-cli smart-commit --yes

# Commit ALL changes with smart grouping by folder
ai-cli smart-commit-all

# Create PR based on current branch changes
ai-cli create-pr

# Create PR against specific base branch
ai-cli create-pr --base develop

# Create a new GitHub repository
ai-cli create-repo my-project --visibility public --description "My project"

# Show version
ai-cli version

Command Reference

Command Description
setup Configure ai-cli with your API key (interactive or direct)
config Show configuration status and manage models
config -s Interactive model selection from history
config -m MODEL Set model directly
smart-commit Create AI-powered commit from staged changes
smart-commit-all Commit all changes with smart grouping by folder
create-pr Create PR based on current branch changes
create-repo Create a new GitHub repository
version Show version information

๐Ÿค– Model Selection

Easily switch between AI models with the interactive selector:

ai-cli config --select   # or -s

This shows a list of previously used models:

๐Ÿค– Select AI Model
โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ # โ”ƒ Model            โ”ƒ Status   โ”ƒ
โ”กโ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 1 โ”‚ gemini-2.0-flash โ”‚ โ— currentโ”‚
โ”‚ 2 โ”‚ gemini-1.5-flash โ”‚          โ”‚
โ”‚ 3 โ”‚ gemini-1.5-pro   โ”‚          โ”‚
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Commands: [1-9] select | [n] new model | [d1-d9] delete | [q] quit
  • Press a number to select a model
  • Press n to add a new model
  • Press d + number (e.g., d2) to delete a model from history
  • Press q to quit

Or set directly: ai-cli config -m gemini-2.0-flash

Environment Variables

Variable Description Default
GEMINI_API_KEY Google Gemini API key (required) -
GEMINI_MODEL Gemini model to use gemini-2.5-flash
GEMINI_SYSTEM_INSTRUCTION AI system instruction Default DevOps instruction
MAX_DIFF_SIZE Maximum diff size for AI analysis 10000
DEFAULT_BRANCH Default git branch main
DEBUG Enable debug mode false

๐ŸŽจ Customizing AI Prompts

You can customize all AI prompts by editing the prompts.json file. The tool looks for prompts in this order:

  1. ./prompts.json (project directory - highest priority)
  2. ~/.config/ai-cli/prompts.json (global config)
  3. Built-in defaults (fallback)

Available prompts:

Key Description
commit_message Prompt for generating commit messages
pull_request Prompt for generating PR title and description
file_correlation Prompt for analyzing which files should be committed together
system_instruction System instruction for the AI model

Example prompts.json:

{
  "commit_message": {
    "description": "Prompt for generating commit messages",
    "prompt": "Generate a commit message following Conventional Commits..."
  },
  "pull_request": {
    "description": "Prompt for generating PR content",
    "prompt": "Create a title and description for a Pull Request..."
  }
}

This allows you to:

  • Change the language of generated messages
  • Modify the commit message format
  • Customize PR templates
  • Adjust AI behavior per project

๐Ÿ”ง Development

Setup Development Environment

# Install development dependencies
uv sync --group dev

# Install pre-commit hooks
pre-commit install

Code Quality

# Format code
uv run ruff format src tests

# Lint code
uv run ruff check src tests

# Fix lint issues automatically
uv run ruff check src tests --fix

# Type checking
mypy src

# Run all checks
uv run task check

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=src/ai_cli

# Run only unit tests
pytest tests/unit

# Run only integration tests
pytest tests/integration

Project Structure

ai-cli/
โ”œโ”€โ”€ src/ai_cli/              # Main application code
โ”‚   โ”œโ”€โ”€ core/                # Domain layer
โ”‚   โ”‚   โ”œโ”€โ”€ models.py        # Domain models
โ”‚   โ”‚   โ”œโ”€โ”€ interfaces.py    # Abstract interfaces
โ”‚   โ”‚   โ””โ”€โ”€ exceptions.py    # Custom exceptions
โ”‚   โ”œโ”€โ”€ services/            # Business logic layer
โ”‚   โ”‚   โ””โ”€โ”€ smart_commit_service.py
โ”‚   โ”œโ”€โ”€ infrastructure/      # Infrastructure layer
โ”‚   โ”‚   โ”œโ”€โ”€ git_repository.py    # Git operations
โ”‚   โ”‚   โ”œโ”€โ”€ ai_service.py        # AI integration
โ”‚   โ”‚   โ””โ”€โ”€ pr_service.py        # GitHub PR service
โ”‚   โ”œโ”€โ”€ cli/                 # Presentation layer
โ”‚   โ”‚   โ””โ”€โ”€ main.py          # CLI interface
โ”‚   โ””โ”€โ”€ config/              # Configuration layer
โ”‚       โ””โ”€โ”€ settings.py      # App configuration
โ”œโ”€โ”€ tests/                   # Test suite
โ”‚   โ”œโ”€โ”€ unit/               # Unit tests
โ”‚   โ”œโ”€โ”€ integration/        # Integration tests
โ”‚   โ””โ”€โ”€ conftest.py         # Test fixtures
โ”œโ”€โ”€ pyproject.toml          # Project configuration
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ .env.example            # Environment template

๐Ÿ”„ Workflow

The AI CLI follows this workflow:

  1. Analyze: Examines staged git changes
  2. Generate: Creates commit message using AI
  3. Review: Presents suggestion for user approval
  4. Commit: Creates git commit with the message
  5. Push: Pushes changes to remote (optional)
  6. PR: Creates pull request with AI-generated description (optional)

๐ŸŽฏ Conventional Commits

The tool generates commits following the Conventional Commits specification:

<type>(<scope>): <subject>

[optional body]

[optional footer]

Supported Types

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • style: Code style changes
  • refactor: Code refactoring
  • test: Test additions/modifications
  • chore: Maintenance tasks
  • build: Build system changes
  • ci: CI/CD changes
  • perf: Performance improvements
  • revert: Reverts previous commits

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and quality checks
  5. Commit using conventional commits
  6. Push to your branch
  7. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Include error messages and environment details

Made with โค๏ธ by developers, for developers.

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

parcky_cli-2026.6.0a1.tar.gz (78.9 kB view details)

Uploaded Source

Built Distribution

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

parcky_cli-2026.6.0a1-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file parcky_cli-2026.6.0a1.tar.gz.

File metadata

  • Download URL: parcky_cli-2026.6.0a1.tar.gz
  • Upload date:
  • Size: 78.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for parcky_cli-2026.6.0a1.tar.gz
Algorithm Hash digest
SHA256 cded6cdd8b715b78cacbd181f88aab93755d38fe46414dd5dc478e638a32a8ee
MD5 edba24f08bfa8db29b0a07bd21bb9b02
BLAKE2b-256 234d3780f2216e64e346c08289a6ea9dabc798cf3fd20f0c9f73fc7a5d97fd7a

See more details on using hashes here.

File details

Details for the file parcky_cli-2026.6.0a1-py3-none-any.whl.

File metadata

  • Download URL: parcky_cli-2026.6.0a1-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for parcky_cli-2026.6.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f1d8ab6a6a57dc01e7359c67ff1646318ada63836e6492c95af48f039920330
MD5 575de95152fea5bd5f7e117a272eaa45
BLAKE2b-256 4b05569eec0a5cad13061d946d7ec1828cededb3ce48549a49786d5adf47f272

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