Commit is a PHP package that automates the generation of Conventional Commit messages using AI.
By analyzing your staged changes
, it generates clear and structured commit messages
that strictly follow the Conventional Commits standard.
composer global require ysocode/commit
To initialize the necessary configuration files:
commit init
To display all enabled AI providers:
commit ai:provider --list
To define which AI provider should be used as default:
commit ai:provider sourcegraph
If no provider argument is specified, an interactive prompt will appear, allowing you to select the desired AI provider.
To display the current AI provider:
commit ai:provider --get
Commit allows you to set your API keys for the AI providers you choose. To set your API key for an AI provider, use the following commands:
commit ai:api-key --provider=openai YOUR_API_KEY
If you don't specify a provider, an interactive prompt will appear with a list of enabled AIs for you to select from.
Display the currently stored API key for the specified AI provider:
commit ai:api-key --get --provider=openai
If you don't specify a provider, the default AI provider will be selected automatically.
Sourcegraph is available as an AI provider in our list of supported services. To use Sourcegraph, you must first install the Cody CLI:
npm install -g @sourcegraph/cody
For a comprehensive guide on Cody CLI installation and configuration, visit the Cody CLI documentation.
Now that you have the Cody CLI available, you can follow the same process as other AI providers by setting your key, and ysocode/commit will handle the rest for you:
commit ai:api-key --provider=sourcegraph YOUR_API_KEY
The key you set here corresponds directly to the SRC_ACCESS_TOKEN used by the Cody CLI.
To automatically generate a Conventional Commit message based on the current staged changes
:
commit generate
This will display the generated commit message for your confirmation before finalizing the commit.
You can provide a custom diff instead of using the automatically detected staged changes:
commit generate YOUR_CUSTOM_DIFF
Use the --provider
option to select the AI provider:
commit generate --provider=openai
Use the --lang
option to specify the language for the commit message:
commit generate --lang=pt_BR
Enabled languages:
en_US
for English (United States)pt_BR
for Portuguese (Brazil)es_ES
for Spanish (Spain)
Commit is open-sourced software licensed under the MIT license.