gitwit
v1.0.2
Published
AI-powered commit message generator from staged git changes
Maintainers
Readme
gitwit 🤖
AI-powered commit message generator that creates conventional commit messages from your staged git changes
Features
- 🚀 One command:
npx gitwit - 🎯 Smart analysis: Reads your
git diff --cachedand understands what changed - 📝 Conventional commits: Generates messages following Conventional Commits standard
- ⚡ Auto-commit: Optional
--commitflag to automatically commit with the generated message - 🎨 Beautiful output: Colorful, informative CLI interface
- 🔒 Secure: Uses your OpenAI API key, no data stored
Installation
Global Installation (Recommended)
npm install -g gitwitOne-time Usage
npx gitwitSetup
You need an OpenAI API key to use this tool:
- Get your API key from OpenAI
- Set it as an environment variable:
export OPENAI_API_KEY=your_api_key_hereOr add it to your shell profile (.bashrc, .zshrc, etc.):
echo 'export OPENAI_API_KEY=your_api_key_here' >> ~/.zshrc
source ~/.zshrcUsage
Basic Usage
- Stage your changes:
git add .- Generate commit message:
gitwitExample output:
✅ Git repository found
✅ Staged changes found
✅ Commit message generated
🚀 Generated commit message:
"feat(auth): add OAuth login support"
💡 To commit with this message, run:
git commit -m "feat(auth): add OAuth login support"Auto-commit
Generate and automatically commit in one step:
git add .
gitwit --commitOr use the short flag:
git add . && gitwit -cComplete Workflow
# Make your changes
echo "console.log('hello world')" > hello.js
# Stage changes
git add hello.js
# Generate and commit automatically
gitwit --commitCommand Line Options
Usage: gitwit [options]
Options:
-c, --commit Auto-commit with the generated message
-h, --help Show help message
Examples:
gitwit # Generate commit message only
gitwit --commit # Generate and auto-commit
git add . && gitwit -c # Stage changes and auto-commitExample Generated Messages
gitwit follows Conventional Commits format:
feat(api): add user authentication endpointfix(ui): resolve button alignment issuedocs(readme): update installation instructionsrefactor(utils): simplify date formatting logictest(auth): add login validation testschore(deps): update dependencies to latest
Requirements
- Node.js: Version 16 or higher
- Git: Must be run in a git repository
- OpenAI API Key: Required for AI-powered generation
- Staged Changes: Run
git addbefore using gitwit
Error Handling
gitwit provides helpful error messages:
- ❌ Not in git repo: "Not a git repository"
- ❌ No staged changes: "No staged changes found" + helpful tip
- ❌ Missing API key: Instructions to set
OPENAI_API_KEY - ❌ API issues: Clear error messages for quota/auth problems
Configuration
API Model
By default, gitwit uses gpt-4o-mini for fast, cost-effective generation. The model is optimized for:
- Understanding code diffs
- Following conventional commit standards
- Generating concise, descriptive messages
Diff Size Limits
Large diffs are automatically truncated to stay within API token limits while preserving the most important changes.
Contributing
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
License
MIT © [Debjit Dey]
Changelog
v1.0.2
- Initial release
- Basic commit message generation
- Auto-commit functionality
- Conventional commits support
- Error handling and validation
Made with ❤️
If you find this tool useful, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting features
- 📢 Sharing with your team
