This repository contains two powerful Git automation tools: diff-tool.mjs and autocommit.mjs. These tools help streamline your Git workflow by generating pull request descriptions and automating commit messages.
-
Clone the repository to your local machine:
git clone ssh://git@github.com:devular/ai-dev-scripts.git cd ai-dev-scripts -
Set up the environment:
- Create a
.envfile in the root directory of the project. - Add your API keys and choose your model provider:
ANTHROPIC_API_KEY=your_anthropic_api_key_here OPENAI_API_KEY=your_openai_api_key_here MODEL_PROVIDER=anthropic # or 'openai' - Set
MODEL_PROVIDERto eitheranthropicoropenaito choose which AI model to use.
- Create a
-
Install dependencies:
pnpm install
-
Set up aliases for easy access:
For Bash or Zsh, add the following to your
~/.bashrcor~/.zshrc:alias autocommit='node /path/to/git-automation-tools/autocommit.mjs' alias difftool='node /path/to/git-automation-tools/diff-tool.mjs'
For Fish, add the following to your
~/.config/fish/config.fish:alias autocommit='node /path/to/git-automation-tools/autocommit.mjs' alias difftool='node /path/to/git-automation-tools/diff-tool.mjs'
Replace
/path/to/git-automation-tools/with the actual path where you cloned the repository. -
Reload your shell configuration or restart your terminal.
The tools support both Anthropic's Claude and OpenAI's GPT models using the Vercel AI SDK. To choose which model to use:
- Open the
.envfile in the root directory of the project. - Set the
MODEL_PROVIDERvariable to eitheranthropicoropenai. - Ensure you have the corresponding API key set (
ANTHROPIC_API_KEYorOPENAI_API_KEY).
The tools will automatically use the selected model for generating commit messages and pull request descriptions.
To use the autocommit tool:
- Make changes to your Git repository.
- Run the following command:
autocommit
- Follow the prompts to provide a short description of your changes.
- The tool will generate a commit message following the Conventional Commits format.
Example of a conventional commit:
feat(auth): add login functionality
Added login functionality to the authentication module. This includes user session management and validation.Options:
--skip-contextor-s: Skip inputting extra context for the prompt.--no-verifyor-n: Skip the confirmation step.
To use the diff tool for generating pull request descriptions:
- Make sure you have changes in your repository compared to the main branch.
- Run the following command:
difftool
- The tool will generate a pull request description based on the differences between your current branch and the main branch.
- The tool will then run the generated pull request description through AI again to generate a concise and informative PR title.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.