commit-pr-generator
v1.0.1
Published
CLI tool that automates commit messages and pull request descriptions using AI. Follows Conventional Commits format and supports multiple AI platforms.
Maintainers
Readme
Commit & PR Generator 🤖📝
commit-pr-generator is a powerful CLI tool that automates the creation of professional commit messages and pull request descriptions. It intelligently analyzes your code using git diff following Conventional Commits standards and integrates seamlessly with AI platforms to help you create perfect documentation.
🌟 Key Features
- Intelligent Change Analysis - Automatically captures and formats your
git diffoutput - AI-Powered Assistance - Generates commit messages and PR descriptions with AI support
- Multi-Language Support - Responses in English (default) or Spanish
- Customizable Exclusions - Ignore unnecessary files (configurable via
.prignore) - Multi-Platform Support - Works with ChatGPT, DeepSeek, and Gemini
- Simplified Workflow - Saves results in markdown files as history
- Conventional Commits - Follows industry-standard format for commit messages
- Enhanced Interactive Mode - Clear interface for selecting processes
- Smart Fallback System - Uses clipboard and browser when API keys are not available
- Dynamic Menu - Adapts options based on available API keys
🔑 API Configuration
The tool supports three AI platforms. You can configure API keys for real AI responses or use clipboard fallback when API keys are not available.
Supported Platforms
| Platform | API Key Required | Fallback |
|----------|------------------|----------|
| 🤖 ChatGPT | OPENAI_API_KEY | ✅ Clipboard + Browser |
| 🧠 DeepSeek | DEEPSEEK_API_KEY | ✅ Clipboard + Browser |
| 💎 Gemini | GEMINI_API_KEY | ✅ Clipboard + Browser |
Getting API Keys
OpenAI (ChatGPT):
- Visit OpenAI API
- Create account and generate API key
- Add to
.env:OPENAI_API_KEY=sk-your-key-here
DeepSeek:
- Visit DeepSeek API
- Create account and generate API key
- Add to
.env:DEEPSEEK_API_KEY=sk-your-key-here
Google Gemini:
- Visit Google AI Studio
- Create account and generate API key
- Add to
.env:GEMINI_API_KEY=your-key-here
Environment Setup
# Copy example file
cp env.example .env
# Edit with your API keys
nano .envExample .env file:
# Only configure the APIs you plan to use
OPENAI_API_KEY=sk-your-openai-api-key-here
DEEPSEEK_API_KEY=sk-your-deepseek-api-key-here
GEMINI_API_KEY=your-gemini-api-key-here⚠️ Important: Never commit your
.envfile to version control. It's already included in.gitignore.
🚀 Installation
Prerequisites
- Node.js v18+ (required for all dependencies)
- Git installed and configured
- npm or yarn as package manager
Quick Installation
1. Clone the repository
git clone https://github.com/AlexisAyalaS/commit-pr-generator.git
cd commit-pr-generator2. Automatic setup
npm run setup3. Install dependencies
npm install4. Configure API Keys (Optional)
# Copy the example environment file
cp env.example .env
# Edit .env and add your API keys
# You only need to configure the APIs you plan to use5. Ready to use!
git-ai📖 Installation problems? Check the detailed Installation Guide for step-by-step instructions and troubleshooting. 🔑 API Keys: If you don't configure API keys, the system will copy prompts to clipboard and open the AI chat in your browser.
Manual Installation
If you prefer to configure manually:
1. Install dependencies
npm install2. Create directory for generated files
mkdir generated-files3. Configure configuration file
cp commit-pr-config.example.json commit-pr-config.json4. Run
git-aiInstall as global tool (recommended for frequent use)
npm install -g commit-pr-generator
# or
yarn global add commit-pr-generatorInstall as project dependency
npm install commit-pr-generator --save-dev
# or
yarn add commit-pr-generator --dev💻 Usage
Basic Usage (Interactive Mode)
git-aiUsage with Options
git-ai [OPTIONS]Available Options
Options:
-V, --version Show version number
-v, --verbose Show detailed debugging information
-h, --help Show help🎯 Available Processes
The enhanced interactive mode allows you to choose between these processes:
- 📝 Generate Pull Request message - Creates complete PR descriptions with demo section
- 💬 Suggest commit message - Generates commit messages following Conventional Commits
- 🌿 Suggest branch name - Proposes the best name for new branches (direct format)
- 🔄 Perform multiple processes - Runs several processes in a single session (only available with API keys)
- 🗑️ Delete generated files history - Cleans the history folder
Smart Menu System
The menu dynamically adapts based on your API key configuration:
- With API Keys: Shows all options including "Perform multiple processes"
- Without API Keys: Shows only individual processes with clipboard fallback
🌍 Multi-Language Support
The generator supports responses in multiple languages:
- 🇺🇸 English - Default language
- 🇪🇸 Spanish - Complete Spanish support
Language Configuration
Interactive Mode
The interactive mode allows you to select the language at the beginning of the process.
Configuration File
You can configure the default language in commit-pr-config.json:
{
"language": "es"
}🤖 Supported AI Platforms
- 🤖 ChatGPT - OpenAI
- 🧠 DeepSeek Chat - DeepSeek
- 💎 Google Gemini - Google
📁 History System
All results are automatically saved in the generated-files/ folder with date format:
generated-files/
├── pr-2025-01-22.md # Pull Request message
├── pr-2025-01-22-2.md # Second PR of the same day
├── commit-2025-01-22.md # Commit message
├── branch-name-2025-01-22.md # Branch name suggestions
└── multiple-2025-01-22.md # Multiple processes combined🔢 Automatic Numbering System
- No overwriting: If you generate multiple files of the same type on the same day, they are automatically numbered
- Format:
type-YYYY-MM-DD-N.mdwhere N is the sequential number - Example:
pr-2025-01-22.md,pr-2025-01-22-2.md,pr-2025-01-22-3.md
🔄 Multiple Processes
When you select "Perform multiple processes", all results are combined in a single file:
- File:
multiple-YYYY-MM-DD.md - Separation: Each process is separated with
-------- - Content: Branch, Commit and PR in a single organized file
- Order: Always displayed in order: Branch → Commit → PR
Each file includes:
- AI-generated content
- Clean and direct format
- Automatic opening: The file opens automatically after generation
🎯 Ultra Simplified Format
For maximum efficiency, some content types are generated in ultra simplified format:
- Branch names: Only the recommended name (e.g.,
feat/interactive-mode-implementation) - Commit messages: Only the message (e.g.,
feat: implement improved interactive mode) - Pull Requests: Complete content with detailed structure and demo section
🔧 Fallback System
When API keys are not available, the system provides a smart fallback:
Individual Process Fallback
- Copies prompt to clipboard - Complete prompt with git diff
- Opens AI chat - Direct link to the corresponding AI platform
- Instructions provided - Clear steps to paste and use the prompt
Multiple Process Fallback
- Combined prompt - Single prompt requesting all three results
- One clipboard copy - Prevents multiple overwrites
- One browser opening - Opens only the selected AI platform
- Organized format - Clear structure for all three results
⚙️ Advanced Configuration
Configuration File (commit-pr-config.json)
{
"prompts": {
"default": "Please draft markdown for a pull request...",
"commit": "Please generate a commit message...",
"detailed": "Please create a comprehensive pull request...",
"branch-name": "Please suggest appropriate branch names..."
},
"defaultExclusions": [
"package-lock.json",
"node_modules",
".env",
"*.log"
],
"logging": {
"level": "info",
"enableColors": true
},
"git": {
"checkStagedChanges": true,
"checkUnstagedChanges": true,
"maxDiffSize": 50000
},
"language": "en"
}Exclusion Patterns (.prignore)
Create a .prignore file in your project root to exclude specific files:
node_modules/
*.log
dist/
coverage/
.env*📝 Examples
Interactive Mode
# Start interactive mode
git-ai
# Select: Multiple processes (if API keys available)
# Select: English
# Select: DeepSeek
# Result: All files generated automaticallyGlobal Installation
# Install globally
npm install -g commit-pr-generator
# Use from anywhere
git-ai🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Conventional Commits for the commit message standard
- OpenAI for ChatGPT
- DeepSeek for DeepSeek Chat
- Google for Gemini
📞 Support
If you have any questions or need help:
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 📖 Documentation: README
Made with ❤️ by Alexis Ayala Solorio
