AI-powered commit message generator that follows Conventional Commits specification. Simply run npx llmc and it will automatically generate a commit message from your staged changes and commit them for you.
- π€ AI-generated commit messages using multiple providers (Anthropic, OpenAI, Google, etc.)
- π Follows Conventional Commits specification
- βοΈ Configurable via TOML file with custom prompts
- π Automatic retry logic with visual progress indicators
- π¨ Rich terminal UI with real-time status updates and timers
- π Zero-config usage with sensible defaults
- β¨ Automatically commits your changes after generating the message
- π Git hook integration with message-only mode
# Initialize a configuration file (optional) npx llmc init # Stage your changes git add . # Generate commit message and commit automatically npx llmc # Or just generate the message without committing (for git hooks) npx llmc --message-only # Check version npx llmc -v # Show help npx llmc -h
That's it! llmc will:
- β Check for staged changes
- π€ Generate a commit message using AI
- π Commit your changes with the generated message
- π Show you the result with a beautiful progress interface
npm install -g llmc
To configure llmc, you can create a llmc.toml file in your project root. The easiest way to get started is to run the init command:
npx llmc init
This will create a llmc.toml file with the default settings, which you can then customize.
Here's an example of a llmc.toml file:
provider = "anthropic" model = "claude-sonnet-4-20250514" max_tokens = 250 temperature = 1.0 api_key_name = "ANTHROPIC_API_KEY" # Optional: Custom prompt with ${diff} interpolation prompt = """ Analyze this git diff and generate a commit message following Conventional Commits. Git diff: ${diff} Provide a clear, concise commit message. """
anthropic- Claude models (default)openai- GPT modelsgoogle- Gemini modelsgroq- Fast inferencecerebras- High-performance modelscohere- Command modelsdeepseek- DeepSeek modelsmistral- Mistral modelsperplexity- Perplexity modelsreplicate- Replicate modelstogetherai- Together AI modelsvercel- Vercel AI modelsxai- xAI models
Set the appropriate API key for your chosen provider:
export ANTHROPIC_API_KEY="your-api-key" export OPENAI_API_KEY="your-api-key" export GOOGLE_API_KEY="your-api-key" # ... etc
For git hook integration, use the --message-only or --no-commit flags to generate commit messages without automatically committing:
npx llmc --message-only
npx llmc --no-commit # Same as --message-onlyCreate .git/hooks/prepare-commit-msg:
#!/bin/sh # Generate commit message using llmc npx llmc --message-only > "1γγ«"
Make it executable:
chmod +x .git/hooks/prepare-commit-msg
Now when you run git commit, llmc will automatically generate the commit message for you.
For validation and generation combined:
#!/bin/sh # Generate commit message if none provided if [ -z "$(cat 1γγ« | grep -v '^#')" ]; then npx llmc --message-only > "1γγ«" fi
# Stage your changes git add . # Generate commit message and commit automatically npx llmc # Generate message only (for git hooks) npx llmc --message-only
# Use different provider echo 'provider = "openai"' > llmc.toml npx llmc # Use custom prompt cat > llmc.toml << EOF provider = "anthropic" prompt = """ Create a commit message for this diff: \${diff} Make it concise and professional. """ EOF npx llmc
When you run npx llmc, you'll see a beautiful progress interface:
β Checking for staged changes...
β Generating commit message...
Time elapsed: 2s
β Committing changes...
β Committed successfully!
Commit message: feat(components): add new Button component with accessibility features
# Install dependencies npm install # Format code npm run format # Build the project (includes formatting) npm run build # Run tests (excludes API integration tests) npm test # Run tests in watch mode npm run test:watch # Run API integration tests (requires valid API key) npm run test:integration # Run all tests (including API integration tests) npm run test:all # Type checking npm run lint # Releasing npm run release
The project uses a two-tier testing approach:
- Regular Tests (
npm test): Unit tests, React component tests, and basic integration tests that don't require API keys - API Integration Tests (
npm run test:integration): Full end-to-end tests that require valid API keys and test actual AI provider integration
This separation allows for fast development cycles while ensuring comprehensive coverage when needed.
-
API Key Not Found
# Make sure your API key is set echo $ANTHROPIC_API_KEY
-
No Staged Changes
# Make sure you have staged changes first git add . # Verify you have staged changes git diff --cached
-
Generation Failures llmc automatically retries up to 3 times if generation fails. You'll see:
β Retrying commit message generation (attempt 2/3)... Previous attempt failed. Retrying... (1 failed attempts) -
Commit Failures If the commit fails, check that:
- You have write permissions to the repository
- You're in a git repository
- There are actually staged changes to commit
llmc provides detailed error messages and visual feedback:
- β Green checkmark for success
- β Red X for errors
- π Automatic retry with progress indicators
- β±οΈ Real-time timer showing elapsed time
BSD 3-Clause License - see LICENSE file for details.
Contributions welcome! Please read CONTRIBUTING.md for guidelines.
For maintainers, here's how to publish new versions to npm:
-
Ensure all tests pass:
npm test npm run test:integration # Run API integration tests if needed npm run lint
-
Update version in package.json:
# Use Conventional Commits to drive release determination npm run release # For explicitly specifying patch releases (bug fixes) npm version patch # For explicitly specifying minor releases (new features) npm version minor # For explicitly specifying major releases (breaking changes) npm version major
-
Build and publish:
# The prepublishOnly script will automatically run 'npm run build' npm publish -
Push the version tag:
git push origin main --tags