Package detail

@elsikora/commitizen-plugin-commitlint-ai

ElsiKora1.1kMIT2.0.1

AI-powered Commitizen adapter with Commitlint integration

conventional-changelog, commitlint, cz, commitizen

readme

project-logo

🤖 Commitizen Plugin Commitlint AI

Transform your Git workflow with AI-powered commit messages that follow conventional standards and pass Commitlint validation every time

ElsiKora TypeScript Node.js npm Git OpenAI ESLint Prettier Vitest Rollup

📚 Table of Contents

📖 Description

Commitizen Plugin Commitlint AI revolutionizes the way developers write commit messages by combining the power of artificial intelligence with strict conventional commit standards. Built with clean architecture principles, this plugin seamlessly integrates with your existing Commitizen workflow to generate meaningful, context-aware commit messages that adhere to your project's Commitlint rules.

Whether you're working on a solo project or collaborating in a large team, this tool eliminates the cognitive overhead of crafting perfect commit messages while maintaining a consistent, high-quality Git history. It supports multiple AI providers including OpenAI's GPT-4.1, Anthropic's Claude 4, Google's Gemini 2.5, and even local models through Ollama.

The plugin intelligently analyzes your staged changes, understands the context of your modifications, and generates commit messages that not only follow the conventional format but also provide meaningful descriptions of the changes. With automatic validation and smart retry mechanisms, it ensures every commit message meets your project's standards.

🚀 Features

  • 🤖 AI-Powered Generation - Leverage GPT-4.1, Claude 4, Gemini 2.5, and more to create contextually relevant commit messages
  • Commitlint Integration - Automatically validates and fixes messages to comply with your project's Commitlint rules
  • 🔄 Smart Retry Mechanism - Intelligently retries generation and validation with configurable attempts
  • 🎯 Clean Architecture - Built with SOLID principles, dependency injection, and clear separation of concerns
  • 🌐 Multi-Provider Support - Choose from OpenAI, Anthropic, Google, Azure, AWS Bedrock, or local Ollama models
  • 🛡️ Type-Safe - Fully typed with TypeScript for enhanced developer experience and reliability
  • Flexible Configuration - Cosmiconfig support for easy setup via JSON, YAML, or JavaScript
  • 🔐 Secure API Key Handling - Environment variable support with session-based key input options
  • 📝 Manual Mode Fallback - Seamlessly switch to guided manual entry when needed
  • 🚀 Breaking Change Detection - Automatically identifies and documents breaking changes

🛠 Installation

# Install the plugin as a dev dependency
npm install --save-dev @elsikora/commitizen-plugin-commitlint-ai

# Initialize Commitizen with this adapter
npx commitizen init @elsikora/commitizen-plugin-commitlint-ai --save-dev --save-exact

# Install Commitlint (if not already installed)
npm install --save-dev @commitlint/cli @commitlint/config-conventional

# Create a commitlint config file
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js

💡 Usage

Basic Usage

Quick Start

# Stage your changes
git add .

# Run the AI-powered commit wizard
git cz
# or
npm run commit

Configuration Methods

The plugin supports multiple configuration approaches:

1. Environment Variables (Recommended)

# .env file
OPENAI_API_KEY=sk-...
# or
ANTHROPIC_API_KEY=sk-ant-...
# or
GOOGLE_API_KEY=AIza...
# or (Azure OpenAI)
AZURE_OPENAI_API_KEY=https://your-resource.openai.azure.com|your-api-key|your-deployment-name
# or (AWS Bedrock)
AWS_BEDROCK_API_KEY=us-east-1|access-key-id|secret-access-key
# or (Ollama)
OLLAMA_API_KEY=localhost:11434|llama3.2

2. Configuration File

Create .elsikora/commitlint-ai.config.js:

export default {
  provider: 'openai',
  model: 'gpt-4.1',
  mode: 'auto',
  maxRetries: 3,
  validationMaxRetries: 3
};

3. Package.json

{
  "elsikora": {
    "commitlint-ai": {
      "provider": "anthropic",
      "model": "claude-opus-4-20250514",
      "mode": "auto"
    }
  }
}

Commit Modes

Auto Mode (AI-Powered)

The AI analyzes your changes and generates appropriate commit messages:

$ git cz
✔ Using AI-powered commit mode...
✔ AI generated initial commit message
✔ AI generated commit message successfully!

┌─────────────────────────────────┐
│ Generated commit message:        │
├─────────────────────────────────┤
│ feat(auth): implement OAuth2    │
│                                 │
│ Added OAuth2 authentication     │
│ flow with JWT token support.    │
│ Includes refresh token logic    │
│ and secure session management.  │
│                                 │
│ BREAKING CHANGE: Auth API       │
│ endpoints have been updated     │
└─────────────────────────────────┘

✔ Do you want to proceed with this commit message? (Y/n)

Manual Mode

Guided commit message creation with validation:

$ git cz
✔ Using manual commit mode...
? Select commit type: (Use arrow keys)
❯ feat: A new feature ✨
  fix: A bug fix 🐛
  docs: Documentation only changes 📚
  style: Code style changes 🎨
  refactor: Code refactoring 📦
  perf: Performance improvements 🚀
  test: Adding tests 🚨

? Enter scope (optional): auth
? Enter commit subject: add login functionality
? Enter commit body (optional): 
? Is this a breaking change? No

Advanced Features

Custom Instructions

Provide project-specific guidance to the AI:

// commitlint-ai.config.js
export default {
  provider: 'openai',
  model: 'gpt-4.1',
  instructions: 'Focus on business impact and user-facing changes. Use present tense.'
};

Retry Configuration

export default {
  maxRetries: 5,              // AI generation retries
  validationMaxRetries: 3     // Validation fix attempts
};

Provider-Specific Setup

Azure OpenAI:

AZURE_OPENAI_API_KEY=https://myresource.openai.azure.com|api-key|gpt-4-deployment

AWS Bedrock:

AWS_BEDROCK_API_KEY=us-west-2|AKIAIOSFODNN7EXAMPLE|wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Ollama (Local):

# Default setup
OLLAMA_API_KEY=localhost:11434

# Custom model
OLLAMA_API_KEY=localhost:11434|codellama

Commitlint Integration

The plugin respects all your Commitlint rules:

// commitlint.config.js
export default {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor']],
    'scope-case': [2, 'always', 'lower-case'],
    'subject-max-length': [2, 'always', 72],
    'body-max-line-length': [2, 'always', 100]
  }
};

Troubleshooting

Force Manual Mode

# Create manual mode marker
mkdir -p .elsikora
touch .elsikora/manual

Clear Configuration Cache

rm -rf .elsikora/commitlint-ai.config.*

Debug Mode

DEBUG=commitizen-ai git cz

🛣 Roadmap

Task / Feature Status
Core AI-powered commit generation ✅ Done
Multi-provider support (OpenAI, Anthropic, Google) ✅ Done
Commitlint rule integration ✅ Done
Clean architecture implementation ✅ Done
Automatic validation and fixing ✅ Done
Environment variable support ✅ Done
Cosmiconfig integration ✅ Done
Interactive mode switching ✅ Done
Breaking change detection ✅ Done
AWS Bedrock and Azure OpenAI support ✅ Done
Local Ollama model support ✅ Done
Custom prompt templates 🚧 In Progress
Multi-language commit messages 🚧 In Progress
Git hook integration 🚧 In Progress
VS Code extension 🚧 In Progress
Team collaboration features 🚧 In Progress
Commit message analytics 🚧 In Progress
GitHub Copilot integration 🚧 In Progress
Performance optimizations for monorepos 🚧 In Progress

❓ FAQ

Q: Which AI providers are supported? A: The plugin supports OpenAI (GPT-4.1, GPT-4o), Anthropic (Claude 4, Claude 3.5), Google (Gemini 2.5), Azure OpenAI, AWS Bedrock, and local Ollama models. Each provider offers different models optimized for various use cases.

Q: How does the AI understand my code changes? A: The plugin analyzes your git diff, staged files, and file paths to understand the context. It then uses this information along with your Commitlint rules to generate appropriate conventional commit messages.

Q: Is my code sent to AI services? A: Only the git diff and file names are sent to generate accurate commit messages. Full source code files are not transmitted unless they appear in the diff. For sensitive projects, consider using Ollama for local processing.

Q: What happens if the AI service is unavailable? A: The plugin has a configurable retry mechanism with real-time status updates. If all retries fail, it automatically falls back to the guided manual mode, ensuring you can always create commits.

Q: Can I customize the commit message format? A: Yes! The plugin fully respects your Commitlint configuration. You can define custom types, scopes, and rules. Additionally, you can provide custom instructions to guide the AI's generation style.

Q: How do I switch between AI and manual modes? A: When you run git cz, you'll be prompted to choose your mode. You can also set a default mode in the configuration or create a .elsikora/manual file to force manual mode.

Q: Is it safe to store API keys? A: The plugin prioritizes security by reading API keys from environment variables. Keys are never stored in configuration files. For added security, you can also input keys per session.

Q: Can I use this with my existing Commitizen setup? A: Absolutely! This is a drop-in replacement for other Commitizen adapters. It works seamlessly with your existing Commitlint configuration and Git workflow.

Q: What's the difference between generation and validation retries? A: Generation retries (maxRetries) handle AI service failures, while validation retries (validationMaxRetries) attempt to fix commit messages that don't pass Commitlint rules.

Q: How much does it cost to use? A: The plugin itself is free and open-source. You'll need to pay for API usage with your chosen AI provider, or use free local models with Ollama.

🔒 License

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

changelog

2.0.1 (2025-06-04)

2.0.0 (2025-05-25)

Code Refactoring

  • architecture: migrate to clean architecture with domain-driven design (ee754c9)
  • core: migrate to esm modules and update dependencies (ed2c8df)
  • prompts: replace inquirer with custom prompts interface (aaa49e8)

Features

  • llm: add support for multiple llm providers (14aa53e)

BREAKING CHANGES

  • llm: Configuration format has changed. Users must update their commitlint-ai.config.js to specify the provider and model explicitly. The old format is no longer supported.

Implemented comprehensive LLM provider support with clean architecture principles. Added four new LLM service implementations:

  • AWS Bedrock with Claude models support
  • Azure OpenAI with GPT-4 and GPT-3.5 models
  • Google AI with Gemini models
  • Ollama for local model execution

Each provider includes:

  • Proper error handling and retry logic
  • Model-specific configurations and constraints
  • Token counting and validation
  • Streaming response support where applicable

Updated configuration system to support provider-specific settings. Enhanced documentation with detailed setup instructions for each provider.

  • core: This package now requires Node.js with ESM support. Consumers must update their import statements to use ESM syntax.

This commit refactors the entire codebase to use ESM modules instead of CommonJS. Key changes include:

  • Updated all import/export statements to use ESM syntax
  • Converted require() calls to import statements
  • Updated package.json to use "type": "module"
  • Refactored rollup configuration for ESM compatibility
  • Updated all file extensions in imports to include .js
  • Reorganized exports to use named exports consistently

Additionally, this commit includes dependency updates and improvements to the overall code structure for better maintainability.

  • architecture: Internal architecture completely changed. External API remains compatible.

Restructured the entire codebase to follow clean architecture principles and domain-driven design patterns. This major refactoring improves code organization, testability, and maintainability.

Key changes:

  • Separated code into domain, application, infrastructure, and presentation layers
  • Introduced use cases for core business logic (configure LLM, generate commit, manual commit, validate commit)
  • Created domain entities and value objects for type safety and business rule enforcement
  • Implemented repository pattern for git operations
  • Added dependency injection container for better decoupling
  • Migrated from class-based to functional approach in use cases
  • Removed old monolithic classes (Process, ManualProcess, Question, etc.)
  • Reorganized LLM services with proper interfaces and implementations
  • Enhanced configuration management with dedicated service

This refactoring maintains all existing functionality while providing a more scalable and maintainable foundation for future development.

  • prompts: The public API has changed. The prompter function no longer requires an inquirer instance as the first parameter. The parameter is kept for backward compatibility but is ignored. Applications using this library will need to update their integration code.

Replaced the inquirer dependency with a custom prompts interface built on top of the prompts library. This change provides a more consistent and maintainable API for handling user prompts throughout the application.

Key changes:

  • Created new PromptsInterface abstraction in src/services/promptsInterface.ts
  • Replaced all inquirer.prompt calls with promptsInterface.prompt
  • Updated question types to match the new interface
  • Removed inquirer from dependencies
  • Added prompts library as a dependency
  • Updated AI model configurations (Anthropic and OpenAI models)
  • Fixed various linting issues and improved type safety.

1.2.0 (2025-04-17)

Features

  • commit: add interactive commit message editor for rejected ai suggestions (67c7fab)

1.1.0 (2025-04-16)

Features

  • commit-flow: add option to switch between manual and ai commit modes (fd8d653)

1.0.0 (2025-03-03)

Features

  • commitlint: enhance rule processing and ai integration (fb7c49c)
  • czai: Add AI-powered commit message generation (32b7676), closes #123 #456
  • FFF (39ecf7b)
  • global: remove unused test and utility files (3b54585)
  • validation: add commit message validation and auto-fixing capability (e7ae73b)