A CLI tool that uses a local Ollama instance to generate Conventional Commits messages from your staged changes.
# Global installation
npm install -g commitgen-cc
# Or run directly with npx
npx commitgen-ccStage your changes:
git add .Run the tool:
commitgen-cc-m, --model <name>: Specify Ollama model (default:llama3)--host <url>: Ollama host (default:http://localhost:11434)--max-chars <n>: Max diff characters sent (range:500-200000, default:16000)--type <type>: Force a commit type (feat, fix, etc.)--scope <scope>: Optional commit scope--dry-run: Print message to stdout without committing--ci: Non-interactive mode for CI/hooks--allow-invalid: Override validation and allow invalid messages--timeout-ms <n>: Ollama request timeout in milliseconds (range:1000-300000, default:60000)--retries <n>: Retry count for transient Ollama failures (range:0-5, default:2)--output <text|json>: Output format (default:text)--no-verify: Pass--no-verifytogit commit
GIT_AI_MODELGIT_AI_HOSTGIT_AI_TIMEOUT_MSGIT_AI_RETRIES
Generate JSON output in non-interactive mode:
commitgen-cc --ci --dry-run --output json0: success1: usage/configuration error2: git context error (not a repo or no staged changes)3: Ollama/model error4: invalid AI output (blocked by default)5:git commitfailed6: unexpected internal error
You can set a shorter alias (e.g. aic) in your shell config (.zshrc, .bashrc, etc.):
echo 'alias aic="commitgen-cc"' >> ~/.aliases \
&& { [ -n "$ZSH_VERSION" ] && echo '[ -f ~/.aliases ] && source ~/.aliases' >> ~/.zshrc; } \
&& { [ -n "$BASH_VERSION" ] && echo '[ -f ~/.aliases ] && source ~/.aliases' >> ~/.bashrc; } \
&& source ~/.aliases