An intelligent CLI tool that automatically stages and commits files using AI-powered commit message generation.
⚠️ Note: This tool requires an OpenAI API key to function. It will analyze your code changes and generate commit messages using GPT-4.
⚠️ Vibe Coded: The majority of this code was "vibe coded". I use the tool for my own projects, and I checked for any serious bugs and issues, but still: Use at your own risk.
- 🤖 AI-powered commit messages using GPT-4.1 with conventional commit format
- 📊 Line-by-line diff analysis showing exactly what changed
- 🎯 Smart file grouping for logical commits
- 🔍 Detailed change tracking (added/removed/modified lines)
- ✅ Safety checks to prevent conflicts with existing staged files
- 🎨 Beautiful colored CLI with interactive confirmations
- ⚡ YOLO mode for automatic commits without confirmation
- Node.js (v18+) or Bun (v1.0+)
- Git configured with user.name and user.email
- OpenAI API key (Get one here)
You can also run gitprompt directly without installing it globally:
This approach downloads and runs the latest version on-demand, which is perfect for occasional use or trying out the tool.
After installation, you can use gitprompt command in any git repository:
Create a .env file or set your OpenAI API key:
If you're developing locally from the GitHub repository:
The CLI provides beautiful colored output with:
- 🤖 Progress indicators for each step
- ✅ Success messages when operations complete
- ❌ Error messages with helpful context
- 📦 Commit group previews showing files and messages
- ❓ Interactive prompts for confirmation
The main CLI application featuring:
- Argument parsing with yargs
- Colored output with yoctocolors
- Interactive prompts for commit confirmation
- YOLO mode for automated commits
- Error handling with user-friendly messages
Handles all git-related operations:
- getStatusMatrix() - Gets current git status
- getUnstagedChanges() - Filters for unstaged files
- getGitConfig() - Reads global git configuration
- stageFiles() - Stages specific files
- commitChanges() - Creates commits with author info
Manages diff calculation and file analysis:
- calculateLineDiffs() - Line-by-line comparison
- calculateDiffForFile() - Complete diff analysis for a file
- getDiffs() - Processes all unstaged files
- Determines change types: added, removed, modified, untracked
AI integration for intelligent commit grouping:
- generateCommitGroups() - Calls GPT-4 to analyze changes
- parseCommitGroups() - Parses AI response into structured data
- Groups related files and generates conventional commit messages
Validation and utility functions:
- validateNoStagedFiles() - Ensures clean staging area
- validateNoDiffs() - Checks for changes to process
- 🔍 Status Check: Reads git status and validates no files are already staged
- 📊 Diff Analysis: Calculates line-by-line diffs for all unstaged files
- 🤖 AI Processing: Sends diffs to GPT-4 for intelligent file grouping and commit message generation
- 📋 Interactive Review: Shows each commit group and asks for confirmation
- 📝 Staging & Committing: Stages and commits approved groups sequentially
- AI Model: Uses GPT-4.1, configurable in src/ai.ts
- Git Config: Automatically uses your global git user.name and user.email
- Colors: Fully customizable in the CLI code
- ✅ Prevents running when files are already staged
- ✅ Validates git configuration before proceeding
- ✅ Interactive confirmations by default (unless --yolo)
- ✅ Sequential processing to avoid git conflicts
- ✅ Detailed error handling and user feedback
- Node.js/Bun
- Git configured with user.name and user.email
- OpenAI API key for GPT-4 access
- yargs - Command line argument parsing
- yoctocolors - Terminal colors and styling
- @ai-sdk/openai - AI integration
- isomorphic-git - Git operations in JavaScript
This project was created using bun init in bun v1.2.12. Bun is a fast all-in-one JavaScript runtime.
"Git user.name and user.email must be configured"
"There are already staged files"
"OpenAI API Error"
- Verify your API key is set correctly
- Check your OpenAI account has credits
- Ensure you have access to GPT-4
"Could not find HEAD"
- Make sure you're in a git repository
- Ensure you have at least one commit in your repository
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Use conventional commit messages
- Code Analysis: This tool analyzes your code locally and sends diff information to OpenAI's API
- No Code Storage: Your code is not stored by the tool or OpenAI beyond the API call
- API Security: Uses OpenAI's secure API endpoints
- Local Processing: All git operations happen locally on your machine
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for the GPT-4 API
- isomorphic-git for JavaScript git operations
- yargs for CLI argument parsing
- yoctocolors for terminal colors
⭐ Star this repo if you find it helpful!
The project includes comprehensive tests for all core functionality:
- 🛠️ Utils: Validation functions, error handling, logging
- 📊 Diff: Line-by-line diff calculation, file change detection
- 🔧 Git: Status matrix parsing, configuration reading, file staging logic
- 🤖 AI: Commit group parsing, error handling
Tests use Bun's built-in test runner with mocking for external dependencies.