AI Commits IntelliJ Plugin

repository·main·Indexed 21 days ago

https://github.com/blarc/ai-commits-intellij-plugin

An IntelliJ and Android Studio plugin that uses Large Language Models (LLMs) to automatically generate git and SVN commit messages based on code diffs. It supports a wide range of providers via langchain4j, including OpenAI, Amazon Bedrock, Anthropic, Gemini, and Ollama, as well as CLI-based clients like Claude Code and Codex. Features include customizable prompt templates with variables, integration with the IntelliJ Task Manager, and support for multiple JetBrains IDEs.

Tokens
3.3K
Snippets
4
Records
16
Agent score
74%

What's inside AI Commits

  1. Overview of AI Commits

    main

    AI Commits is a plugin for IntelliJ-based IDEs and Android Studio that automates the generation of git commit messages. It uses the git diff and Large Language Models (LLMs) to create descriptive messages.

    Key features include:

    • Generating commit messages from git diffs.
    • Computing diffs based only on selected files and lines within the commit dialog.
    • Customizing commit message generation via user-defined prompts.
    • Using predefined variables and hints in prompts.
    • Support for both Git and Subversion (SVN) version control systems.
  2. Use prompt template variables in AI Commits

    main

    When creating custom prompts for commit message generation, you can use placeholder variables. These variables are automatically replaced with real values (like the git diff or branch name) at the time the commit message is generated.

    Commonly used variables include:

    • {locale}: The project's configured locale (e.g., "English").
    • {diff}: The git diff of staged changes. If omitted, the diff is automatically appended to the end of the prompt.
    • {branch}: The current VCS branch name.
    • {hint}: The free-text hint provided by the user in the commit dialog.
    • {previousCommitMessages}: A list of previous commit messages (count determined by prompt settings, default is 5).
    • {taskId}, {taskSummary}, {taskDescription}, {taskTimeSpent}: Data from the active IntelliJ Task Manager (e.g., JIRA keys or task descriptions).
  3. Use conditional hint syntax in prompts

    main

    The {hint} variable supports a Conditional form, which is the recommended way to include user hints. This prevents the prompt from containing awkward empty instructions when a user doesn't provide a hint.

    Syntax: Wrap the instruction and the $hint variable (note the $ prefix) inside curly braces {}.

    • If a hint is provided: The braces are removed, and $hint is replaced with the text.
    • If no hint is provided: The entire block (including the braces) is deleted from the final prompt.
    {Use this hint to improve the commit message: $hint}
  4. Install AI Commits from a ZIP file

    main

    If you prefer manual installation, follow these steps:

    1. Download the plugin .zip file from the official releases.
    2. In your IDE, navigate to <kbd>Settings</kbd> > <kbd>Plugins</kbd>.
    3. Click the <kbd>Cog</kbd> (Settings) icon and select <kbd>Install plugin from disk...</kbd>.
    4. Select the downloaded .zip file.
    5. After installation, configure your LLM client in <kbd>Settings</kbd> > <kbd>Tools</kbd> > <kbd>AI Commits</kbd>.
  5. Install AI Commits via IDE Marketplace

    main

    You can install the plugin directly through the JetBrains Marketplace within your IDE.

    For Windows & Linux:

    1. Go to <kbd>File</kbd> > <kbd>Settings</kbd> > <kbd>Plugins</kbd>.
    2. Select the <kbd>Marketplace</kbd> tab.
    3. Search for "AI Commits".
    4. Click <kbd>Install Plugin</kbd>.
    5. <kbd>Restart IntelliJ IDEA</kbd>.

    For Mac:

    1. Go to <kbd>IntelliJ IDEA</kbd> > <kbd>Preferences</kbd> > <kbd>Plugins</kbd>.
    2. Select the <kbd>Marketplace</kbd> tab.
    3. Search for "AI Commits".
    4. Click <kbd>Install Plugin</kbd>.
    5. <kbd>Restart IntelliJ IDEA</kbd>.
  6. Examples of custom prompt templates

    main

    Below are several patterns for constructing effective custom prompts using variables and conditional syntax.

    ### Minimal prompt
    ```text
    Write a concise commit message in {locale} for the following diff:
    {diff}

    Conventional commits with branch and hint

    Write a commit message following the conventional commit convention.
    Use {locale} language. The branch is: {branch}.
    {Use this additional context: $hint}
    {diff}

    With task manager integration

    Write a commit message in {locale}.
    Task: {taskId} - {taskSummary}
    {diff}
  7. Configure AI Commit plugin settings

    main

    The AI Commit plugin stores its configuration in AICommit.xml. Users can configure several parameters related to the AI model, connection settings, and prompt behavior.

    Key configuration areas include:

    • OpenAI Connection: Set the openAIHost (defaults to https://api.openai.com/v1), openAIToken (via the UI), and proxyUrl if a proxy is required. You can also adjust the openAISocketTimeout.
    • Model Selection: Choose from available openAIModelIds (e.g., gpt-3.5-turbo, gpt-4) and adjust the openAITemperature (defaults to 0.7).
    • Prompts: The plugin uses a set of prompts to generate commit messages. You can switch the currentPrompt from the available prompts map.
    • Localization: The locale setting determines the language used for certain operations.
    • Exclusions: appExclusions allows you to define a set of strings to exclude from the AI processing context.
    /* 
    Configuration keys available in the plugin settings:
    
    - openAIHost: String (default: "https://api.openai.com/v1")
    - openAIModelId: String (default: "gpt-3.5-turbo")
    - openAITemperature: String (default: "0.7")
    - openAISocketTimeout: String (default: "30")
    - proxyUrl: String?
    - currentPrompt: Prompt
    - locale: Locale
    - appExclusions: Set<String>
    */
  8. Configure the Codex CLI client

    main

    The Codex CLI client allows the plugin to generate commit messages using the codex command-line tool. To use this client, you must provide a valid path to the executable in the plugin settings.

    Key configuration parameters include:

    • cliPath: The absolute path to the codex executable.
    • modelId: The ID of the model to use (e.g., gpt-5.1-codex-mini).
    • reasoningLevel: The level of reasoning effort. For gpt-5.1-codex-mini, allowed values are Medium or High. For other models, it uses the default reasoning levels defined in the configuration.
    • timeout: The maximum time to wait for the CLI to respond.
  9. Configure Amazon Bedrock LLM client

    main

    When using Amazon Bedrock as the LLM provider for AI commits, you can configure several parameters related to authentication, model behavior, and AWS region settings.

    Authentication

    You can choose between using static credentials or an AWS profile:

    • useStaticCredentialsProvider: Set to true to use specific access keys. If null, it defaults to true for backward compatibility.
    • accessKeyId: The AWS access key ID.
    • accessKey: The secret access key (not stored in serialized configuration).
    • accessKeyIsStored: Indicates if the access key is currently stored.
    • profileName: The name of the AWS profile to use if not using static credentials.

    Model Parameters

    Control the randomness and constraints of the generated commit messages:

    • temperature: Controls randomness (default: "0.7").
    • topP: Nucleus sampling parameter.
    • topK: Top-k sampling parameter.
    • maxOutputTokens: Limits the length of the generated message.

    Connection and Region

    • region: The AWS region to target (e.g., EU_CENTRAL_1).
    • timeout: Request timeout in seconds (default: 30).
  10. Configure the Claude Code CLI client

    main

    To use the Claude Code CLI as an LLM provider, you must configure the ClaudeCodeClientConfiguration in the plugin settings. The following parameters are required or supported:

    • cliPath: The absolute path to the claude executable. This must be a valid, executable file.
    • modelId: (Optional) The specific model ID to use with the CLI. If left blank, the CLI's default model is used.
    • timeout: The maximum time in seconds to wait for the CLI to respond before timing out.

    The plugin executes the CLI using the following command structure: [cliPath] -p --output-format json [optional --model modelId] [prompt]