JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q113393F
  • License Apache-2.0

Writes your git commit messages for you with AI providers

Package Exports

    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

    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/lazycommit

    Upgrading

    Check the installed version with:

    lazycommit --version

    If it's not the latest version, run:

    npm update -g @sachinthapa572/lazycommit

    Usage

    CLI mode

    You can call lazycommit directly to generate a commit message for your staged changes:

    git add <files...>
    lazycommit

    lazycommit 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 lzc alias if lazycommit is 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 conventional

    This 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 commit

    Exclude files from analysis

    You can exclude specific files from AI analysis using the --exclude flag:

    lazycommit --exclude package-lock.json --exclude dist/

    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 --history

    This 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 5

    You can also disable history if it's enabled in your config:

    lazycommit --no-history

    One-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-prompt from 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.

    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 --numstat to 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 install

    Uninstall

    In the Git repository you want to uninstall the hook from:

    lazycommit hook uninstall

    Usage

    1. Stage your files and commit:

      git add <files...>
      git commit # Only generates a message when it's not passed in

      If you ever want to write your own message instead of generating one, you can simply pass one in: git commit -m "My message"

    2. 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.

    3. Save and close the editor to commit!

    Configuration

    Guided setup (first-time)

    Run:

    lazycommit config

    You can also run the explicit setup mode:

    lazycommit config setup

    This 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

    At the end, lazycommit saves your config and prints the updated values.

    Interactive change mode

    To update settings later through a menu:

    lazycommit config change

    This 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_KEY

    You can also retrieve multiple configuration options at once by separating them with spaces:

    lazycommit config get GROQ_API_KEY generate

    To display all current configuration settings in a readable format, use:

    lazycommit config show

    Setting 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=en

    Options

    Note: generate supports values from 1 to 5.

    GROQ_API_KEY

    Required

    The Groq API key. You can retrieve it from Groq Console.

    CEREBRAS_API_KEY

    Required when provider=cerebras

    The Cerebras API key. You can retrieve it from Cerebras Platform.

    provider

    Default: groq

    Provider used to generate commit messages.

    Supported values:

    • groq
    • cerebras
    • github

    Examples:

    lazycommit config set provider=github
    lazycommit config set provider=groq
    lazycommit config set provider=cerebras

    When 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.

    Note, this will use more tokens as it generates more results.

    proxy

    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-0905
    • moonshotai/kimi-k2-instruct
    • groq/compound
    • groq/compound-mini
    • cerebras:
    • qwen-3-235b-a22b-instruct-2507 (default)
    • llama3.1-8b
    • github:
    • gpt-5-mini (default)
    • gpt-5.4-mini
    • gpt-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

    timeout

    The timeout for provider requests in milliseconds.

    Default: 1000 (1 second)

    lazycommit config set timeout=20000 # 20s

    max-length

    The maximum character length of the generated commit message.

    Default: 100

    lazycommit config set max-length=150

    type

    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=conventional

    You 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: 1000 characters.
    • 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 <contactsachin572@gmail.com>"

    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=true

    Including 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=5

    This setting only takes effect when history is enabled.

    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:

    • groq uses Groq API with GROQ_API_KEY
    • github uses 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:

    1. Detects large/many-file diffs and switches to enhanced analysis mode
    2. Creates compact summaries using git diff --cached --numstat to capture all changes efficiently
    3. Includes context snippets from the most changed files to provide semantic context
    4. Generates a single commit message that accurately reflects all changes without hitting API limits
    5. Smart truncation preserves sentence structure and meaning when messages approach length limits
    6. 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:

    1. Exclude build artifacts:

      lazycommit --exclude "dist/**" --exclude "node_modules/**" --exclude ".next/**"
    2. Use a different model:

      lazycommit config set model=groq/compound-mini
    3. 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, verify GROQ_API_KEY is set
    • For github, ensure copilot CLI is installed and run copilot 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"
    • 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=5000 for faster failures

    Why lazycommit?

    • Fast workflow: Generate commit messages directly from staged changes
    • Provider choice: Use Groq or GitHub Copilot
    • Works for large commits: Built-in compact summaries and context snippets
    • Flexible output: Generate one or multiple suggestions and edit before committing

    Maintainers

    License

    This project is licensed under the Apache-2.0 License - see the LICENSE file for details.