AiCommitMessage 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global AiCommitMessage --version 2.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local AiCommitMessage --version 2.0.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=AiCommitMessage&version=2.0.1
                    
nuke :add-package AiCommitMessage --version 2.0.1
                    

GIT Hooks + OpenAI - Generate GIT commit messages from OpenAI

🧠 🤖 This tool generates AI-powered commit messages via Git hooks, automating meaningful message suggestions from OpenAI and others to improve commit quality and efficiency.

GitHub last commit GitHub license time tracker

Continuous Integration Infisical secrets check Linter check


What this tool does

Generates a commit message based on the git diff result using the OpenAI API.


Requirements


Getting started

AICommitMessage NuGet Version AICommitMessage NuGet Downloads

This repository is available at NuGet under the name AICommitMessage.

Installation

  1. Install the tool globally (or per project/repository).
  2. Move to the project folder.
  3. Install the Git hook on the default hooks directory.
dotnet tool install -g AiCommitMessage
cd my-project/
dotnet-aicommitmessage install-hook
git add .
git commit -m ""

Use git log -1 to review the last commit details and find the automatically generated commit message.


Model Configuration and Settings

To configure and use models with dotnet-aicommitmessage, users need to set their settings once. This setup involves specifying the model, API key, and API URL. These settings will be stored as environment variables for future use.

Initial Setup

Run the following commands to configure the model and related settings:

# OpenAI GPT-5.1 (flagship model - best quality)
dotnet-aicommitmessage set-settings -m gpt-5.1 -k {api-key} -u {api-url}

# OpenAI GPT-5 Mini (balanced performance and cost)
dotnet-aicommitmessage set-settings -m gpt-5-mini -k {api-key} -u {api-url}

# OpenAI GPT-5 Nano (fastest and most cost-effective)
dotnet-aicommitmessage set-settings -m gpt-5-nano -k {api-key} -u {api-url}

# OpenAI GPT-4o Mini
dotnet-aicommitmessage set-settings -m gpt-4o-mini -k {api-key} -u {api-url}

# Azure AI Llama
dotnet-aicommitmessage set-settings -m llama-3-1-405b-instruct -k {api-key} -u {api-url}

Replace {api-key} with your API key and {api-url} with the URL of your API provider.

Switching Models

After the initial setup, you can easily switch between models without needing to provide the API key or URL again:

dotnet-aicommitmessage set-settings -m gpt-5.1
dotnet-aicommitmessage set-settings -m gpt-5-mini
dotnet-aicommitmessage set-settings -m gpt-5-nano
dotnet-aicommitmessage set-settings -m gpt-4o-mini
dotnet-aicommitmessage set-settings -m llama-3-1-405b-instruct

This allows for quick model changes while retaining your previously configured API details.


Supported Models

The tool supports the following AI models:

Model Provider Description
gpt-5.1 OpenAI Flagship GPT-5 model with best quality and capabilities
gpt-5-mini OpenAI Balanced model offering good performance at lower cost
gpt-5-nano OpenAI Most cost-effective option with fastest response times
gpt-4o-mini OpenAI Previous generation model, still highly capable
llama-3-1-405b-instruct Azure AI Meta's Llama model via Azure AI services

Default Model: gpt-5.1 (automatically used if no model is specified)


Commit message pattern

The training model for the AI used is designed using as reference these guidelines:


Sequence of Execution

Here's a flow diagram showing the sequence of execution of the prepare-commit-msg hook and its integration with dotnet-aicommitmessage to generate commit messages using the OpenAI API:

graph TD
    A[Git Commit] --> B[prepare-commit-msg Hook Trigger]
    B --> C[Invoke dotnet-aicommitmessage Tool]
    C --> D{API Disabled?}
    D -->|No| E[Send Data to OpenAI API]
    D -->|Yes| F[Use Fallback Message Generation]
    E --> G[Generate Commit Message]
    F --> G
    G --> H[Check and append pre-defined commands to Commit Message]
    H --> I[Return Generated Commit Message]
    I --> J[Insert Commit Message into Git Commit]
    J --> K[Finalize Commit]

Commands

This tool accepts an argument as the command to execute. Here is a list of available commands:

Command Description
install-hook Installs GIT hooks in the default .git/hooks directory or in the custom directory configured in GIT settings.
generate-message Generates a commit message based on the current changes (git diff context).
set-settings Set the OpenAI settings.
help Display information about this program.
version Display version information.

Example output

Here is an example of the commit messages generated in a real-world project:

example

Debug

You can run the message generation manually to debug it, but it will not commit the content to your GIT repository. If you also want to check the OpenAI JSON response, append the -D parameter.

Manually generating the commit message

To manually generate a commit message without committing the staged changes, run the following command:

dotnet-aicommitmessage generate-message -m "."

Saving the OpenAI JSON response

If you want to persist the OpenAI JSON response, add the -D parameter, and a debug.json file will be created with the response JSON.

dotnet-aicommitmessage generate-message -Dm "."

Here is a sample debug.json content:

{
  "Value": {
    "CreatedAt": "2024-11-20T12:54:03+00:00",
    "FinishReason": 0,
    "ContentTokenLogProbabilities": [],
    "RefusalTokenLogProbabilities": [],
    "Role": 2,
    "Content": [
      {
        "Kind": 0,
        "Text": "feat - add reactivation handling for refunds due today",
        "ImageUri": null,
        "ImageBytes": null,
        "ImageBytesMediaType": null,
        "ImageDetailLevel": null,
        "Refusal": null
      }
    ],
    "ToolCalls": [],
    "Refusal": null,
    "FunctionCall": null,
    "Id": "chatcmpl-[[REDACTED]]",
    "Model": "gpt-4o-mini-2024-07-18",
    "SystemFingerprint": "fp-[[REDACTED]]",
    "Usage": {
      "OutputTokenCount": 10,
      "InputTokenCount": 6229,
      "TotalTokenCount": 6239,
      "OutputTokenDetails": {
        "ReasoningTokenCount": 0
      }
    }
  }
}

Configuration Options

The tool supports several configuration options through environment variables:

Disable API Calls

In some network environments, the OpenAI API may be blocked due to firewall or proxy restrictions. You can disable API calls entirely by setting the following environment variable:

export DOTNET_AICOMMITMESSAGE_DISABLE_API=true

Or on Windows:

set DOTNET_AICOMMITMESSAGE_DISABLE_API=true

When this option is enabled, the tool will:

  • Skip any calls to the OpenAI API
  • Display a warning message indicating that API calls are disabled
  • Use fallback commit message generation (either the provided message or a placeholder)
  • Continue to work with branch name processing and issue number extraction

Contributors

<table> <tbody> <tr> <td align="center"> <a href="https://github.com/guibranco"> <img src="https://avatars.githubusercontent.com/u/3362854?v=4" width="100;" alt="guibranco"/> <br /> <sub><b>Guilherme Branco Stracini</b></sub> </a> </td> <td align="center"> <a href="https://github.com/krisbiradar"> <img src="https://avatars.githubusercontent.com/u/104765390?v=4" width="100;" alt="krisbiradar"/> <br /> <sub><b>Kris</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Malay-dev"> <img src="https://avatars.githubusercontent.com/u/91375797?v=4" width="100;" alt="Malay-dev"/> <br /> <sub><b>Malay Kumar</b></sub> </a> </td> <td align="center"> <a href="https://github.com/RyanFloresTT"> <img src="https://avatars.githubusercontent.com/u/53247675?v=4" width="100;" alt="RyanFloresTT"/> <br /> <sub><b>Ryan Flores</b></sub> </a> </td> </tr> <tbody> </table>

Bots

<table> <tbody> <tr> <td align="center"> <a href="https://github.com/dependabot[bot]"> <img src="https://avatars.githubusercontent.com/in/29110?v=4" width="100;" alt="dependabot[bot]"/> <br /> <sub><b>dependabot[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/penify-dev[bot]"> <img src="https://avatars.githubusercontent.com/in/399279?v=4" width="100;" alt="penify-dev[bot]"/> <br /> <sub><b>penify-dev[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/gitauto-ai[bot]"> <img src="https://avatars.githubusercontent.com/in/844909?v=4" width="100;" alt="gitauto-ai[bot]"/> <br /> <sub><b>gitauto-ai[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/github-actions[bot]"> <img src="https://avatars.githubusercontent.com/in/15368?v=4" width="100;" alt="github-actions[bot]"/> <br /> <sub><b>github-actions[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/pixeebot[bot]"> <img src="https://avatars.githubusercontent.com/in/193111?v=4" width="100;" alt="pixeebot[bot]"/> <br /> <sub><b>pixeebot[bot]</b></sub> </a> </td> <td align="center"> <a href="https://github.com/snyk-bot"> <img src="https://avatars.githubusercontent.com/u/19733683?v=4" width="100;" alt="snyk-bot"/> <br /> <sub><b>Snyk bot</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/codefactor-io"> <img src="https://avatars.githubusercontent.com/u/11671095?v=4" width="100;" alt="codefactor-io"/> <br /> <sub><b>CodeFactor</b></sub> </a> </td> </tr> <tbody> </table>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
2.0.5 75 12/15/2025
2.0.4 73 12/15/2025
2.0.3 74 12/15/2025
2.0.2 79 12/15/2025
2.0.1 185 12/4/2025
2.0.0 182 12/4/2025
1.1.45 182 12/4/2025
1.1.44 169 11/24/2025
1.1.43 173 11/24/2025
1.1.42 169 11/24/2025
1.1.41 183 11/24/2025
1.1.40 173 11/24/2025
1.1.39 171 11/24/2025
1.1.38 172 11/24/2025
1.1.37 170 11/24/2025
1.1.36 271 11/11/2025
1.1.35 216 11/10/2025
1.1.34 216 11/10/2025
1.1.33 193 11/3/2025
1.1.32 165 10/22/2025
1.1.31 166 10/22/2025
1.1.30 164 10/22/2025
1.1.29 168 10/15/2025
1.1.28 163 10/15/2025
1.1.27 164 10/15/2025
1.1.26 175 10/6/2025
1.1.25 184 10/2/2025
1.1.24 273 9/15/2025
1.1.23 257 9/15/2025
1.1.22 176 9/8/2025
1.1.21 180 9/8/2025
1.1.20 180 9/8/2025
1.1.19 180 9/3/2025
1.1.18 174 9/3/2025
1.1.17 195 9/3/2025
1.1.16 165 8/18/2025
1.1.15 168 8/11/2025
1.1.14 244 8/6/2025
1.1.13 148 7/28/2025
1.1.12 150 7/28/2025
1.1.11 554 7/22/2025
1.1.10 440 7/21/2025
1.1.9 113 7/18/2025
1.1.8 118 7/18/2025
1.1.7 167 7/17/2025
1.1.6 157 7/17/2025
1.1.5 166 7/17/2025
1.1.4 163 7/17/2025
1.1.3 168 7/17/2025
1.1.2 175 7/15/2025
1.1.1 172 7/15/2025
1.1.0 179 7/14/2025
1.0.29 171 7/14/2025
1.0.28 166 7/14/2025
1.0.27 174 7/14/2025
1.0.26 175 7/10/2025
1.0.25 168 6/30/2025
1.0.24 209 6/16/2025
1.0.23 263 6/9/2025
1.0.22 243 6/9/2025
1.0.21 184 5/26/2025
1.0.20 191 5/26/2025
1.0.19 171 5/19/2025
1.0.18 182 5/19/2025
1.0.17 180 5/19/2025
1.0.16 252 5/12/2025
1.0.15 238 5/12/2025
1.0.14 191 5/8/2025
1.0.13 186 5/8/2025
1.0.12 184 5/8/2025
1.0.11 181 5/6/2025
1.0.10 207 4/21/2025
1.0.9 249 4/14/2025
1.0.8 226 4/14/2025
1.0.7 194 4/7/2025
1.0.6 193 3/31/2025
1.0.5 386 3/24/2025
1.0.4 185 3/19/2025
1.0.3 176 3/19/2025
1.0.2 188 3/17/2025
1.0.1 186 3/17/2025
1.0.0 257 3/5/2025
0.12.34 189 3/3/2025
0.12.33 191 3/3/2025
0.12.32 198 3/3/2025
0.12.31 205 3/3/2025
0.12.30 172 2/26/2025
0.12.29 142 2/24/2025
0.12.28 149 2/17/2025
0.12.27 152 2/10/2025
0.12.26 159 2/3/2025
0.12.25 138 1/27/2025
0.12.24 137 1/27/2025
0.12.23 146 1/27/2025
0.12.22 125 1/21/2025
0.12.21 134 1/21/2025
0.12.20 153 1/20/2025
0.12.19 154 1/20/2025
0.12.18 133 1/20/2025
0.12.17 132 1/13/2025
0.12.16 129 1/13/2025
0.12.15 118 1/13/2025
0.12.14 150 1/6/2025
0.12.13 137 1/6/2025
0.12.12 141 1/6/2025
0.12.11 149 1/6/2025
0.12.10 152 12/31/2024
0.12.9 145 12/31/2024
0.12.8 155 12/30/2024
0.12.7 149 12/30/2024
0.12.6 165 12/25/2024
0.12.5 155 12/25/2024
0.12.4 152 12/25/2024
0.12.3 161 12/23/2024
0.12.2 129 12/23/2024
0.12.1 169 12/16/2024
0.12.0 178 12/12/2024
0.11.12 161 12/9/2024
0.11.11 142 12/9/2024
0.11.10 156 12/3/2024
0.11.9 133 12/3/2024
0.11.8 128 12/2/2024
0.11.7 157 12/2/2024
0.11.6 156 12/2/2024
0.11.5 143 12/2/2024
0.11.4 150 11/26/2024
0.11.3 139 11/26/2024
0.11.2 133 11/26/2024
0.11.1 148 11/25/2024
0.11.0 141 11/23/2024
0.10.2 156 11/23/2024
0.10.1 149 11/23/2024
0.10.0 164 11/20/2024
0.9.1 152 11/20/2024
0.9.0 139 11/20/2024
0.8.8 149 11/18/2024
0.8.7 148 11/18/2024
0.8.6 148 11/15/2024
0.8.5 147 11/15/2024
0.8.4 168 11/12/2024
0.8.3 154 11/11/2024
0.8.2 143 11/11/2024
0.8.1 136 11/4/2024
0.8.0 159 11/1/2024
0.7.9 138 11/1/2024
0.7.8 156 11/1/2024
0.7.7 146 11/1/2024
0.7.6 130 11/1/2024
0.7.5 153 11/1/2024
0.7.4 148 10/28/2024
0.7.3 148 10/28/2024
0.7.2 141 10/28/2024
0.7.1 151 10/27/2024
0.7.0 136 10/26/2024
0.6.1 151 10/26/2024
0.6.0 146 10/22/2024
0.5.1 132 10/22/2024
0.5.0 128 10/22/2024
0.4.23 143 10/22/2024
0.4.22 145 10/22/2024
0.4.21 159 10/21/2024
0.4.20 229 10/19/2024
0.4.19 172 10/19/2024
0.4.18 163 10/19/2024
0.4.17 167 10/19/2024
0.4.16 175 10/19/2024
0.4.15 170 10/19/2024
0.4.14 178 10/19/2024
0.4.13 185 10/19/2024
0.4.12 172 10/19/2024
0.4.11 184 10/19/2024
0.4.10 184 10/19/2024
0.4.9 133 10/14/2024
0.4.8 151 10/14/2024
0.4.7 175 10/14/2024
0.4.6 156 10/8/2024
0.4.5 145 10/8/2024
0.4.4 152 10/8/2024
0.4.3 149 10/8/2024
0.4.2 149 10/8/2024
0.4.1 146 10/8/2024
0.4.0 150 10/8/2024
0.3.11 137 10/8/2024
0.3.10 189 10/8/2024
0.3.9 149 10/8/2024
0.3.8 161 10/8/2024
0.3.7 138 10/8/2024
0.3.6 150 10/8/2024
0.3.5 139 10/7/2024
0.3.4 144 10/7/2024
0.3.3 179 9/30/2024
0.3.2 161 9/30/2024
0.3.1 162 9/25/2024
0.3.0 160 9/25/2024
0.2.7 160 9/23/2024
0.2.6 167 9/23/2024
0.2.5 163 9/23/2024
0.2.4 165 9/23/2024
0.2.3 152 9/23/2024
0.2.2 192 9/23/2024
0.2.1 148 9/21/2024
0.2.0 160 9/20/2024
0.1.29 149 9/20/2024
0.1.28 150 9/20/2024
0.1.27 150 9/20/2024
0.1.26 159 9/20/2024
0.1.25 152 9/20/2024
0.1.24 152 9/20/2024
0.1.23 167 9/17/2024
0.1.22 166 9/17/2024
0.1.21 149 9/17/2024
0.1.20 156 9/17/2024
0.1.19 169 9/17/2024
0.1.18 156 9/17/2024
0.1.17 161 9/17/2024
0.1.16 155 9/16/2024
0.1.15 206 9/16/2024
0.1.14 161 9/16/2024
0.1.12 148 9/16/2024
0.1.11 155 9/16/2024