@sachinthapa572/lazycommit
v1.3.4
Published
Writes your git commit messages for you with AI providers
Readme
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 automatically checks for updates once per day and notifies you when a new version is available:
lazycommit
# Output when update available:
# 📦 Update available: v1.2.4 → v1.3.0
# Run: npm install -g @sachinthapa572/lazycommit@latestYou can disable this feature with:
lazycommit config set update-check-enabled=falseManual 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.
Usage
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!
Configuration
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
- signup-message
- history-enabled
- history-count
- guidance-prompt
- update-check-enabled
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-120b(default)moonshotai/kimi-k2-instruct-0905moonshotai/kimi-k2-instructgroq/compoundgroq/compound-minicerebras: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=signup-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: <signup-message>Example:
lazycommit config set signup-message="Sachin Thapa <[email protected]>"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
Default: true
Whether to automatically check for updates once per day when running lazycommit.
lazycommit config set update-check-enabled=falseWhen enabled, lazycommit will check for updates periodically and notify you when a new version is available. The check is limited to once per day to avoid excessive network requests.
How 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=groq/compound-miniCommit 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-120b - 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.
