CommitScribe is an Azure DevOps pipeline task that uses AI to automatically format and describe your commits. It supports multiple AI providers, including OpenAI, Anthropic, and Azure OpenAI.
The commit message and git diff are passed to the AI provider, which generates a new commit message based on the provided context. The new commit message is then used to update the commit message in the repository.
- Install the extension from the Visual Studio Marketplace
- Configure your AI provider credentials:
- Create a pipeline variable or variable group with your AI provider API key
- Mark the variable as secret
- Ensure your pipeline has a checkout step with
persistCredentials
enabled &fetchDepth
set to0
:
steps:
- checkout: self
fetchDepth: "0"
persistCredentials: true
- Configure Git identity in your pipeline before the CommitScribe task:
steps:
- script: |
git config --global user.email "azure-pipelines@example.com"
git config --global user.name "Azure Pipelines"
displayName: "Configure Git"
- Grant repository permissions:
- For Azure Repos: Grant the build service account 'Contribute' & 'Force Push' permissions.
- For GitHub repos: Configure GitHub service connection with write permissions
- For other Git providers: Ensure the pipeline's service account has write access
Note
Why is force push required?
CommitScribe rewrites history. Use of the --force
flag is necessary to persist updated commit messages in the target branch.
This is a destructive operation, so use with caution! For more information, see Git's documentation on rewriting history.
Add the task to your pipeline:
steps:
- checkout: self
fetchDepth: "0"
persistCredentials: true
- script: |
git config --global user.email "azure-pipelines@example.com"
git config --global user.name "Azure Pipelines"
displayName: "Configure Git"
- task: commitscribe@0
inputs:
aiprovider: "openai" # Options: openai, anthropic, azure
aiproviderkey: "$(YOUR_API_KEY)"
Input | Required | Default | Description |
---|---|---|---|
aiprovider |
Yes | openai |
AI provider (OpenAI, Anthropic, or Azure OpenAI) |
aiproviderkey |
Yes | - | API key for the selected provider |
model |
No | Provider-specific | Model to use (gpt-4 for OpenAI, claude-3-sonnet-20240229 for Anthropic) |
azendpoint |
No* | - | Azure OpenAI endpoint URL (*Required for Azure) |
systempromptoverride |
No | - | Override the default system prompt |
projectspecificcontext |
No | - | Additional project context for better results |
maxtokens |
No | 2000 | Maximum tokens for API requests |
recurse |
No | false | Process commits recursively until [commitscribe_signoff] |
Warning
The recurse
flag will parse your entire commit history and rewrite every commit message until it finds a commit message that contains [commitscribe_signoff]
. This is useful for updating commit messages in bulk, but it can be dangerous if you're not careful. Use with caution!
- task: commitscribe@0
inputs:
aiprovider: "openai"
aiproviderkey: "$(OPENAI_API_KEY)"
model: "gpt-4"
- task: commitscribe@0
inputs:
aiprovider: "anthropic"
aiproviderkey: "$(ANTHROPIC_API_KEY)"
model: "claude-3-sonnet-20240229"
- task: commitscribe@0
inputs:
aiprovider: "azure"
aiproviderkey: "$(AZURE_OPENAI_KEY)"
azendpoint: "https://your-resource.openai.azure.com/"
model: "your-deployment-name"
- Always store API keys as secret variables
- Use
projectspecificcontext
to provide domain-specific knowledge - Set appropriate
maxtokens
for your commit message size
Contributions are welcome! Please open an issue or submit a pull request.