Package Exports
- @sachinthapa572/lazycommit
- @sachinthapa572/lazycommit/dist/cli.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sachinthapa572/lazycommit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lazycommit
A CLI that writes your git commit messages for you with AI providers. Never write a commit message again.
Setup
The minimum supported version of Node.js is v18. Check your Node.js version with
node --version.
Prerequisites
- Git installed and available in your PATH
- Node.js
>=18
Install
Install lazycommit globally:
npm install -g @sachinthapa572/lazycommitUpgrading
Check the installed version with:
lazycommit --versionIf it's not the latest version, run:
npm update -g @sachinthapa572/lazycommitAutomatic Update Notifications
lazycommit checks for updates in the background once per day, so normal runs stay fast.
Default behavior is notify mode:
- Checks happen in a detached background process.
- When an update is found, you'll get a one-time prompt on a future run.
- The prompt defaults to
Noto avoid interrupting your flow.
You can also enable auto mode to install updates in the background for the next run.
Example when an update is available:
lazycommit
# Output when update available (notify mode):
# 📦 Update available: v1.2.4 → v1.3.0
# Update now? (default: No)Set update mode:
# Notify once (default)
lazycommit config set update-mode=notify
# Auto update in background
lazycommit config set update-mode=auto
# Disable background checks
lazycommit config set update-mode=offDeprecated legacy compatibility option:
lazycommit config set update-check-enabled=falseMapping behavior for legacy key:
update-check-enabled=truemaps toupdate-mode=notifyupdate-check-enabled=falsemaps toupdate-mode=off
In this release, lazycommit also performs a one-time startup migration for older configs: if it finds update-check-enabled, it writes the mapped update-mode and removes the deprecated key automatically.
Manual Version Check
To check for updates immediately (bypassing the daily cache):
lazycommit --version-checkThis is useful for testing or when you want to force an update check regardless of when the last check occurred.
Test a local branch as your active global CLI
If you want your shell to pick the lazycommit built from this repo (instead of the published package), use:
bun run dev:use-local
# or: npm run dev:use-local
hash -r
which lazycommit
lazycommit --versionThe script automatically detects package manager support:
- Uses Bun first when
bunis available - Falls back to npm when Bun is not installed
It links lazycommit and lzc in the detected package manager's global bin directory to this repo's dist/cli.mjs using absolute symlinks.
If which lzc still resolves somewhere else (for example ~/node_modules/.bin/lzc), move your global bin path (bun pm bin -g or npm bin -g) earlier in your PATH.
To switch back to the published package:
bun run dev:use-published
# or: npm run dev:use-published
hash -r
which lazycommitFor shell-completion testing after switching to local:
mkdir -p ~/.local/share/bash-completion/completions
lazycommit completion bash > ~/.local/share/bash-completion/completions/lazycommitUsage
CLI mode
You can call lazycommit directly to generate a commit message for your staged changes:
git add <files...>
lazycommitlazycommit passes unknown flags to git commit, so you can pass commit flags.
For example, you can stage all changes in tracked files as you commit:
lazycommit --all # or -a👉 Tip: Use the
lzcalias iflazycommitis too long for you.
Generate multiple recommendations
Sometimes the recommended commit message isn't the best so you want it to generate a few to pick from. You can generate multiple commit messages at once by passing in the --generate <i> flag, where 'i' is the number of generated messages:
lazycommit --generate <i> # or -g <i>Warning: this uses more tokens, meaning it costs more.
Generating Conventional Commits
If you'd like to generate Conventional Commits, you can use the --type flag followed by conventional. This will prompt lazycommit to format the commit message according to the Conventional Commits specification:
lazycommit --type conventional # or -t conventionalThis feature can be useful if your project follows the Conventional Commits standard or if you're using tools that rely on this commit format.
Review, edit, and confirm messages
Lazycommit now lets you review the generated message, optionally edit it, and then confirm before it is committed.
- You'll see a menu: Use as-is, Edit, or Cancel
- If you choose Use as-is, it commits immediately without additional prompts
- If you choose Edit, you can modify the message; then you'll be asked to confirm the final message before committing
Example (single commit):
git add .
lazycommit
# Review generated commit message:
# feat: add lazycommit command
# → Choose "Use as-is" to commit immediately
# → Or choose "Edit" to modify, then confirm the final message before commitExclude files from analysis
You can exclude specific files from AI analysis using the --exclude flag:
lazycommit --exclude package-lock.json --exclude dist/Using .lazycommitignore file
For persistent, repository-level file exclusions, create a .lazycommitignore file in your repository root. This file works similarly to .gitignore, allowing you to define patterns for files that should always be excluded from AI analysis.
Creating the file:
# Create .lazycommitignore in your repository root
touch .lazycommitignoreFormat:
The .lazycommitignore file uses a simple format:
- One pattern per line
- Supports glob patterns (
*,**, etc.) - Lines starting with
#are treated as comments - Empty lines are ignored
Example .lazycommitignore:
# Build outputs
dist/
build/
.next/
out/
# Dependencies
node_modules/
vendor/
# Generated files
*.min.js
*.min.css
*.bundle.js
# Lock files (usually don't need AI analysis)
package-lock.json
yarn.lock
pnpm-lock.yaml
# IDE and editor files
.vscode/
.idea/
# Environment and secrets
.env
.env.*
*.pem
# Test coverage
coverage/
.nyc_output/
# Logs
*.logHow it works:
- Patterns are applied automatically to all
lazycommitruns in the repository - Works alongside
--excludeflags (both are combined) - Patterns use gitignore-style syntax for excluding files and directories
- The file is repository-specific and can be committed to version control
Precedence:
Both .lazycommitignore patterns and --exclude flags are applied together, so you can use .lazycommitignore for common exclusions and --exclude for one-time exclusions:
# Excludes everything in .lazycommitignore PLUS temp files for this run
lazycommit --exclude "*.tmp" --exclude "scratch/"Include commit history for style consistency
You can include recent commit history in the AI prompt to generate messages that match your project's commit style:
lazycommit --historyThis includes recent commit messages as context, helping the AI match your project's style and conventions. You can customize how many commits to include:
lazycommit --history --history-count 5You can also disable history if it's enabled in your config:
lazycommit --no-historyOne-time guidance override (single run)
You can pass one-time advisory guidance with --guidance-prompt:
lazycommit --guidance-prompt "Prefer concise verbs and mention auth subsystem"Behavior:
- Applies only to the current run.
- Overrides
guidance-promptfrom config for that run. - Passing an empty value clears guidance for that run.
- Does not persist unless you set it through
lazycommit config set.
Safety behavior:
- Guidance is advisory only (style preference).
- Output must still follow commit format, be diff-grounded, and remain relevant.
- Prompt hijacking attempts or unrelated instructions are ignored.
Version Check
To manually check for updates immediately:
lazycommit --version-checkThis bypasses the daily cache and checks for the latest version immediately. Useful for testing or when you want to force an update check.
Dry-run mode
Preview the generated commit message without actually committing:
lazycommit --dry-runThis is useful for:
- Testing how lazycommit would commit your changes
- CI/CD pipelines that need to preview messages
- Verifying commit message quality before automation
The generated message will be displayed but no commit is made.
Handling large diffs
For large commits with many files, lazycommit automatically stays within API limits and generates relevant commit messages:
- Smart summarization: Uses
git diff --cached --numstatto create compact summaries of all changes - Context snippets: Includes truncated diff snippets from top changed files for better context
- Token-safe processing: Keeps prompts small while maintaining accuracy for 20+ file changes
- Single commit: Always generates one commit message, no matter how many files are staged
- Enhanced analysis: Uses improved prompts and smart truncation for better commit message quality
Git hook
You can also integrate lazycommit with Git via the prepare-commit-msg hook. This lets you use Git like you normally would, and edit the commit message before committing. The hook uses the same enhanced analysis and quality improvements as the CLI mode.
Install
In the Git repository you want to install the hook in:
lazycommit hook installUninstall
In the Git repository you want to uninstall the hook from:
lazycommit hook uninstallUsage
Stage your files and commit:
git add <files...> git commit # Only generates a message when it's not passed in
Local pre-commit lint + format checks
If you want every commit to automatically format and lint staged files (and block commit on lint errors), this repo includes a pre-commit hook under .githooks/pre-commit.
Enable it once per local clone:
bun run hooks:installWhat it does on each git commit:
Runs
oxfmton staged, supported filesRuns
oxlint --fixon staged JS/TS filesRuns
oxlintto fail the commit if lint errors remainRe-stages updated files automatically
If you ever want to write your own message instead of generating one, you can simply pass one in:
git commit -m "My message"
Lazycommit will generate a high-quality commit message using the same enhanced analysis as the CLI mode and pass it back to Git. Git will open it with the configured editor for you to review/edit it.
Save and close the editor to commit!
Shell completion
lazycommit can generate completion scripts for Bash, Zsh, and Fish directly from the CLI definition.
Generate scripts:
lazycommit completion bash
lazycommit completion zsh
lazycommit completion fishQuick setup examples:
Bash
lazycommit completion bash >> ~/.bashrc
source ~/.bashrcZsh
mkdir -p ~/.zsh/completions
lazycommit completion zsh > ~/.zsh/completions/_lazycommit
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo 'autoload -U compinit && compinit' >> ~/.zshrc
source ~/.zshrc
whence -w _lazycommitIf your shell already runs compinit elsewhere, make sure the fpath=... line is loaded before it. If whence -w _lazycommit still prints none, start a fresh Zsh session after updating ~/.zshrc.
Fish
mkdir -p ~/.config/fish/completions
lazycommit completion fish > ~/.config/fish/completions/lazycommit.fishConfiguration
Environment Variables (Recommended for API Keys)
For better security, especially when committing to version control, it's recommended to use environment variables for API keys instead of storing them in the config file.
Create a
.envfile (copy from.env.example):cp .env.example .envAdd your API keys to
.env:# Groq API Key GROQ_API_KEY=gsk_your_groq_api_key_here # Cerebras API Key CEREBRAS_API_KEY=cb_your_cerebras_api_key_here # OpenRouter API Key OPENROUTER_API_KEY=sk-or-v1-your_openrouter_api_key_here
Never commit
.env- it's already in.gitignore
Priority Order: lazycommit checks for API keys in this order:
- Environment variables (highest priority)
- Config file values (fallback)
This approach keeps your API keys secure while allowing you to commit configuration files to version control.
Config File Structure
{
"activeProvider": "groq",
"global": {
"generate": 1,
"locale": "en",
"timeout": 10000,
"max-length": 100,
"type": "",
"signoff-message": "",
"history-enabled": false,
"history-count": 3,
"guidance-prompt": "",
"update-mode": "notify"
},
"preference": {
"ascii-logo-enabled": true,
"ask-to-push": false
},
"providers": {
"groq": {
"apiKey": "", // Leave empty when using environment variables
"model": "openai/gpt-oss-20b",
"customModels": []
},
"cerebras": {
"model": "qwen-3-235b-a22b-instruct-2507",
"customModels": []
},
"openrouter": {
"model": "openrouter/free",
"customModels": []
},
"github": {
"model": "gpt-5-mini",
"customModels": []
}
}
}JSON schema auto-suggestions
lazycommit now writes a $schema entry into ~/.lazycommit/config.json, pointing to:
https://raw.githubusercontent.com/sachinthapa572/lazycommit/main/src/schema/config-schema.jsonThis enables editor IntelliSense/autocomplete, inline docs, and validation for config keys and values when editing the config file.
If your editor does not automatically pick this up, add a JSON schema mapping (example for VS Code):
{
"json.schemas": [
{
"fileMatch": ["*/.lazycommit/config.json", ".lazycommit/config.json"],
"url": "https://raw.githubusercontent.com/sachinthapa572/lazycommit/main/src/schema/config-schema.json"
}
]
}Guided setup (first-time)
Run:
lazycommit configYou can also run the explicit setup mode:
lazycommit config setupThis opens a step-by-step setup flow for:
- provider
- provider API key
- model
- generate
- locale
- proxy
- timeout
- max-length
- type
- signoff-message
- history-enabled
- history-count
- guidance-prompt
- update-mode
At the end, lazycommit saves your config and prints the updated values.
Interactive change mode
To update settings later through a menu:
lazycommit config changeThis lists all editable settings, lets you choose one, prompts for a new value, saves it, and shows the updated config.
Reading a configuration value
To retrieve a configuration option, use the command:
lazycommit config get <key>For example, to retrieve the API key, you can use:
lazycommit config get GROQ_API_KEYYou can also retrieve multiple configuration options at once by separating them with spaces:
lazycommit config get GROQ_API_KEY generateTo display all current configuration settings in a readable format, use:
lazycommit config showSetting a configuration value
To set a configuration option, use the command:
lazycommit config set <key>=<value>For example, to set the API key, you can use:
lazycommit config set GROQ_API_KEY=<your-api-key>You can also set multiple configuration options at once by separating them with spaces, like
lazycommit config set GROQ_API_KEY=<your-api-key> generate=3 locale=enOptions
Note:
generatesupports values from1to10. Higher values increase API token costs.
GROQ_API_KEY
Required
The Groq API key. Get it from https://console.groq.com/keys.
CEREBRAS_API_KEY
Required when provider=cerebras
The Cerebras API key. Get it from https://cloud.cerebras.ai.
OPENROUTER_API_KEY
Required when provider=openrouter
The OpenRouter API key. Get it from https://openrouter.ai/settings/keys.
provider
Default: groq
Provider used to generate commit messages.
Supported values:
groqcerebrasopenroutergithub
Examples:
lazycommit config set provider=github
lazycommit config set provider=groq
lazycommit config set provider=cerebras
lazycommit config set provider=openrouterWhen switching providers, lazycommit automatically resets model to that provider's default if the current model is incompatible.
locale
Default: en
The locale to use for the generated commit messages. Consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes.
generate
Default: 1
The number of commit messages to generate to pick from. Valid range: 1 to 10.
Note, this will use more tokens as it generates more results, meaning higher API costs.
lazycommit config set generate=3proxy
Set a HTTP/HTTPS proxy to use for requests.
To clear the proxy option, you can use the command (note the empty value after the equals sign):
lazycommit config set proxy=model
Default: depends on provider
The model to use for generating commit messages.
Available models by provider:
groq:openai/gpt-oss-20b(default)openai/gpt-oss-120bqwen/qwen3-32bmeta-llama/llama-4-scout-17b-16e-instructcerebras:qwen-3-235b-a22b-instruct-2507(default)llama3.1-8bopenrouter:openrouter/free(default)github:gpt-5-mini(default)gpt-5.4-minigpt-4o-mini-2024-07-18
Example:
lazycommit config set provider=github model=gpt-5.4-mini
lazycommit config set CEREBRAS_API_KEY=<your-api-key> provider=cerebras model=qwen-3-235b-a22b-instruct-2507
lazycommit config set OPENROUTER_API_KEY=<your-api-key> provider=openrouter model=openrouter/freetimeout
The timeout for provider requests in milliseconds.
Default: 10000 (10 seconds)
lazycommit config set timeout=20000 # 20smax-length
The maximum character length of the generated commit message.
Default: 100
lazycommit config set max-length=150type
Default: "" (Empty string)
The type of commit message to generate. Set this to "conventional" to generate commit messages that follow the Conventional Commits specification:
lazycommit config set type=conventionalYou can clear this option by setting it to an empty string:
lazycommit config set type=guidance-prompt
Default: "" (Empty string)
Optional advisory style guidance for commit message generation.
This value helps steer style preferences (for example: wording nuances, subsystem keywords, or verbosity), but it is treated as soft guidance only.
Safety behavior and precedence:
- It does not override core commit constraints.
- Messages must remain grounded in staged diff context.
- Conflicting, invalid-format, or irrelevant guidance is ignored.
- Max length:
1000characters. - Whitespace-only values are normalized to empty (feature off).
Example:
lazycommit config set guidance-prompt="Prefer concise verbs and include subsystem keywords when relevant"To clear it:
lazycommit config set guidance-prompt=signoff-message
Default: "" (Empty string)
Optional sign-off identity to append at the end of generated messages.
If set, lazycommit instructs the AI to end with:
--
Signed-off-by: <signoff-message>Example:
lazycommit config set signoff-message="Sachin Thapa <contactsachin572@gmail.com>"Deprecated alias: signup-message is still accepted for backward compatibility and is auto-migrated to signoff-message.
history-enabled
Default: false
Whether to include recent commit history in the AI prompt for generating commit messages that match your project's style.
lazycommit config set history-enabled=trueIncluding history helps the AI understand your project's commit message conventions and style, leading to more consistent suggestions.
history-count
Default: 3
The number of recent commit messages to include when history-enabled is true. Valid range: 2 to 10.
lazycommit config set history-count=5This setting only takes effect when history is enabled.
update-check-enabled
Deprecated legacy key.
Legacy compatibility toggle for background update checks.
lazycommit config set update-check-enabled=falseMapping behavior:
truemaps toupdate-mode=notifyfalsemaps toupdate-mode=off
Prefer using update-mode directly for new configs.
update-mode
Default: notify
Controls update UX behavior:
off: disable background update checksnotify: check in background and ask once later (default no)auto: check and install in background for next run
lazycommit config set update-mode=autoHow it works
This CLI tool runs git diff to grab all your latest code changes, then sends them to the configured provider model and returns AI-generated commit messages.
Provider behavior:
groquses Groq API withGROQ_API_KEYgithubuses GitHub Copilot SDK and your local Copilot CLI login session (copilot auth login)
Large diff handling (automatic)
For large commits that exceed API token limits, lazycommit automatically:
- Detects large/many-file diffs and switches to enhanced analysis mode
- Creates compact summaries using
git diff --cached --numstatto capture all changes efficiently - Includes context snippets from the most changed files to provide semantic context
- Generates a single commit message that accurately reflects all changes without hitting API limits
- Smart truncation preserves sentence structure and meaning when messages approach length limits
- Enhanced prompts provide better context for AI to generate complete, professional commit messages
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits, while maintaining accuracy, relevance, and high-quality commit messages.
Troubleshooting
"Request too large" error (413)
If you get a 413 error, your diff is too large for the API. Try these solutions:
Exclude build artifacts:
lazycommit --exclude "dist/**" --exclude "node_modules/**" --exclude ".next/**"
Create a
.lazycommitignorefile for persistent exclusions:# .lazycommitignore dist/ node_modules/ .next/ *.min.js package-lock.jsonUse a different model:
lazycommit config set model=openai/gpt-oss-20b
Commit in smaller batches:
git add src/ # Stage only source files lazycommit git add docs/ # Then stage documentation lazycommit
No commit messages generated
- Check provider settings:
lazycommit config show - For
groq, verifyGROQ_API_KEYis set - For
github, ensurecopilotCLI is installed and runcopilot auth login - Verify you have staged changes:
git status - Try excluding large files or using a different model
Slow performance with large diffs
- Use the default model:
lazycommit config set model=openai/gpt-oss-20b - Exclude unnecessary files:
lazycommit --exclude "*.log" --exclude "*.tmp"or use.lazycommitignore - Use the built-in large diff handling for better context and accuracy
- Lower generate count:
lazycommit config set generate=1(default) - Reduce timeout:
lazycommit config set timeout=5000for faster failures - Transient errors are retried automatically: Rate limits (429) and service timeouts (503/504) are automatically retried with exponential backoff
Why lazycommit?
- Fast workflow: Generate commit messages directly from staged changes
- Provider choice: Use Groq, GitHub Copilot, Cerebras, or OpenRouter
- Works for large commits: Built-in compact summaries and context snippets
- Flexible output: Generate one or multiple suggestions and edit before committing
- Resilient: Automatic retry with exponential backoff for transient errors
- Repository-level config:
.lazycommitignorefor persistent file exclusions - Dry-run support: Preview messages before committing with
--dry-run
Maintainers
- Sachin Thapa: @sachinthapa572
- Kshitiz Sharma (imxitiz): @imxitiz
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.