craftcommit-cli
v0.4.1
Published
Generate AI-powered commit messages from terminal
Maintainers
Readme
CommitCraft CLI
Generate AI-powered commit messages from your terminal.
Installation
npm install -g commitcraft-cliOr use with npx:
npx commitcraft-cliQuick Start
- Stage your changes:
git add .- Generate commit message:
commitcraft- Select from 3 AI-generated options:
? Select a commit message:
❯ 1. feat(auth): add OAuth2 login support
2. feat(auth): implement authentication flow
3. feat: add social login feature
Cancel- The selected message is copied to your clipboard!
Usage
Generate commit message (default command)
commitcraft
# or
commitcraft generateAuto-commit with selected message
commitcraft --commit
# or
commitcraft -cSpecify provider and options
commitcraft -p openai -m gpt-4 -l english
commitcraft -p groq
commitcraft -p ollama -m llama3.2Configure API keys
commitcraft configOptions
| Option | Alias | Description |
|--------|-------|-------------|
| --provider | -p | AI provider: openai, groq, gemini, ollama |
| --model | -m | Specific model to use |
| --language | -l | Language: english or korean |
| --commit | -c | Auto-commit with selected message |
| --issue-pattern | | Regex to extract issue from branch |
| --issue-prefix | | Prefix for issue (e.g., #) |
Configuration
Environment Variables
export OPENAI_API_KEY="sk-..."
export GROQ_API_KEY="gsk_..."
export GEMINI_API_KEY="AI..."
export OLLAMA_URL="http://localhost:11434"Config File (~/.commitcraftrc)
{
"provider": "openai",
"model": "gpt-4o-mini",
"language": "english",
"openaiApiKey": "sk-...",
"groqApiKey": "gsk_...",
"geminiApiKey": "AI..."
}.env File
You can also use a .env file in your project or home directory:
OPENAI_API_KEY=sk-...
GROQ_API_KEY=gsk_...
COMMITCRAFT_PROVIDER=openai
COMMITCRAFT_LANGUAGE=englishGit Hook Integration
Auto-generate commit messages on every git commit:
Install hook
commitcraft hook installUninstall hook
commitcraft hook uninstallCheck status
commitcraft hook statusHow it works
Once installed, CommitCraft will automatically generate a commit message when you run git commit. The hook:
- Detects staged changes
- Calls the AI provider to generate a message
- Pre-fills the commit message editor
You can still edit the message before confirming.
Skip auto-generation
The hook automatically skips when:
- You provide a message with
-mflag - It's a merge, squash, or amend commit
- There's already a commit message
Debug mode
To see hook logs, set the environment variable:
export COMMITCRAFT_HOOK_DEBUG=1Issue Linking
Extract issue numbers from branch names:
# Branch: feature/123-add-login
commitcraft --issue-pattern "feature/(\d+)" --issue-prefix "#"
# Result: feat(auth): add login validation #123# Branch: JIRA-456-fix-bug
commitcraft --issue-pattern "(JIRA-\d+)"
# Result: fix(api): resolve null pointer JIRA-456Providers
OpenAI (default)
- Default model:
gpt-4o-mini - Requires:
OPENAI_API_KEY - Get key: https://platform.openai.com/api-keys
Groq
- Default model:
llama-3.1-8b-instant - Requires:
GROQ_API_KEY - Get key: https://console.groq.com/keys
- Fast and free tier available
Gemini
- Default model:
gemini-1.5-flash - Requires:
GEMINI_API_KEY - Get key: https://aistudio.google.com/app/apikey
Ollama (Local/Offline)
- Default model:
llama3.2 - No API key required
- Install: https://ollama.ai/
- Run:
ollama pull llama3.2
Examples
Basic usage
$ git add src/auth.ts
$ commitcraft
✓ Got staged changes
✓ Generated commit messages
? Select a commit message:
❯ 1. feat(auth): add password validation
2. feat(auth): implement input validation for login
3. feat: add authentication validation
Cancel
✓ Copied to clipboard: feat(auth): add password validationAuto-commit
$ commitcraft --commit
✓ Got staged changes
✓ Generated commit messages
? Select a commit message: 1. feat(auth): add password validation
✓ Committed: feat(auth): add password validationKorean language
$ commitcraft -l korean
✓ Got staged changes
✓ Generated commit messages
? Select a commit message:
❯ 1. feat(auth): 비밀번호 유효성 검사 추가
2. feat(auth): 로그인 입력값 검증 구현
3. feat: 인증 유효성 검사 추가
CancelSupported Commit Types
| Type | Description |
|------|-------------|
| feat | New feature |
| fix | Bug fix |
| docs | Documentation |
| style | Formatting |
| refactor | Code refactoring |
| perf | Performance |
| test | Tests |
| build | Build system |
| ci | CI/CD |
| chore | Maintenance |
License
MIT
