gitai)A command-line tool that acts as a general-purpose AI assistant for your git workflow. It can automatically generate PR titles and descriptions, provide code reviews, generate commit messages, and more, streamlining your workflow.
This CLI tool connects to the GitHub (gh) CLI and a generative AI to perform two main functions:
GitHub Interaction (gh subcommand):
Commit Message Generation (commit subcommand):
Before you begin, ensure you have the following installed and configured:
gh auth login.This tool requires a Google AI API key to function. You must set the GOOGLE_AI_API_KEY environment variable for the application to work.
You can export the variable in your shell. Note that this is not the most secure method for long-term use.
export GOOGLE_AI_API_KEY="your-api-key-here"
To make it persist between sessions, you can add this line to your shell's configuration file (e.g., ~/.zshrc, ~/.bashrc).
For better security, it is highly recommended to use a secret manager to handle your API key. This prevents storing secrets in plain text.
The application will automatically read the environment variable if it's provided by a secret manager's CLI.
Example with Bitwarden CLI:
# The `bw run` command injects the secret into the command's environment
bw run -- gitai gh
Example with Doppler:
# The `doppler run` command works similarly
doppler run -- gitai commit
Using this wrapper pattern is the most secure way to provide credentials to the application.
We recommend using Nix and direnv for an easy and reproducible setup. This project provides a flake.nix and .envrc for seamless development environment configuration.
After cloning the repository, run:
direnv allow
This will automatically set up the development environment using Nix, as defined in flake.nix and .envrc.
With the environment active, install the necessary packages using Bun:
bun install
Run the build script to compile the application into a single executable file:
bun run build
This will create a gitai executable in the project root.
To use the gitai command from anywhere, create a symbolic link from the compiled binary to a directory in your system's PATH. For example:
ln -s "$(pwd)/gitai" /usr/local/bin/gitai
Note: You might need to use
sudoto create the link in/usr/local/bindepending on your system's permissions. If a file already exists at that location, you may need to remove it first.
Once linked, you can run gitai from any directory.
Once installed, you can use the gitai command from within any local Git repository directory that has a GitHub remote.
gh)Run the gh subcommand to start an interactive session for PR-related tasks.
gitai gh
The tool will then guide you through the process:
? Please enter the PR number: › 123
? What would you like to do?
❯ Generate title and description
Generate title only
Generate a review and post as a comment
commit)Run the commit subcommand to generate a commit message for your staged changes.
gitai commit
The tool will analyze your staged changes, generate a message, and ask for confirmation before committing.
Generated commit message:
feat(cli): add commit message generation
- Adds a new `commit` subcommand to generate commit messages from staged changes.
- Implements a `GitClient` to interact with git.
- Updates the AI generator to create commit messages.
? Would you like to commit with this message? › yes
✅ Successfully committed changes!
For local development, you can run the tool directly from its source code without needing to build it after every change. This is the most efficient way to work when you are actively writing or testing code.
Simply use the gitai script, which is configured in package.json to execute the main script:
bun run gitai
Any changes you save to the source files will be reflected immediately when you run this command.
To see all available commands and options, use the --help flag.
gitai --help
You can also get help for a specific subcommand:
gitai gh --help
gitai commit --help
To create a new release:
npm run release
This script will:
v1.0.0)The release workflow will automatically:
bun run buildUsers can then download the gitai binary directly from the GitHub releases page.
41 commits
TypeScript
97.3%
JavaScript
2.4%
gitai)A command-line tool that acts as a general-purpose AI assistant for your git workflow. It can automatically generate PR titles and descriptions, provide code reviews, generate commit messages, and more, streamlining your workflow.
This CLI tool connects to the GitHub (gh) CLI and a generative AI to perform two main functions:
GitHub Interaction (gh subcommand):
Commit Message Generation (commit subcommand):
Before you begin, ensure you have the following installed and configured:
gh auth login.This tool requires a Google AI API key to function. You must set the GOOGLE_AI_API_KEY environment variable for the application to work.
You can export the variable in your shell. Note that this is not the most secure method for long-term use.
export GOOGLE_AI_API_KEY="your-api-key-here"
To make it persist between sessions, you can add this line to your shell's configuration file (e.g., ~/.zshrc, ~/.bashrc).
For better security, it is highly recommended to use a secret manager to handle your API key. This prevents storing secrets in plain text.
The application will automatically read the environment variable if it's provided by a secret manager's CLI.
Example with Bitwarden CLI:
# The `bw run` command injects the secret into the command's environment
bw run -- gitai gh
Example with Doppler:
# The `doppler run` command works similarly
doppler run -- gitai commit
Using this wrapper pattern is the most secure way to provide credentials to the application.
We recommend using Nix and direnv for an easy and reproducible setup. This project provides a flake.nix and .envrc for seamless development environment configuration.
After cloning the repository, run:
direnv allow
This will automatically set up the development environment using Nix, as defined in flake.nix and .envrc.
With the environment active, install the necessary packages using Bun:
bun install
Run the build script to compile the application into a single executable file:
bun run build
This will create a gitai executable in the project root.
To use the gitai command from anywhere, create a symbolic link from the compiled binary to a directory in your system's PATH. For example:
ln -s "$(pwd)/gitai" /usr/local/bin/gitai
Note: You might need to use
sudoto create the link in/usr/local/bindepending on your system's permissions. If a file already exists at that location, you may need to remove it first.
Once linked, you can run gitai from any directory.
Once installed, you can use the gitai command from within any local Git repository directory that has a GitHub remote.
gh)Run the gh subcommand to start an interactive session for PR-related tasks.
gitai gh
The tool will then guide you through the process:
? Please enter the PR number: › 123
? What would you like to do?
❯ Generate title and description
Generate title only
Generate a review and post as a comment
commit)Run the commit subcommand to generate a commit message for your staged changes.
gitai commit
The tool will analyze your staged changes, generate a message, and ask for confirmation before committing.
Generated commit message:
feat(cli): add commit message generation
- Adds a new `commit` subcommand to generate commit messages from staged changes.
- Implements a `GitClient` to interact with git.
- Updates the AI generator to create commit messages.
? Would you like to commit with this message? › yes
✅ Successfully committed changes!
For local development, you can run the tool directly from its source code without needing to build it after every change. This is the most efficient way to work when you are actively writing or testing code.
Simply use the gitai script, which is configured in package.json to execute the main script:
bun run gitai
Any changes you save to the source files will be reflected immediately when you run this command.
To see all available commands and options, use the --help flag.
gitai --help
You can also get help for a specific subcommand:
gitai gh --help
gitai commit --help
To create a new release:
npm run release
This script will:
v1.0.0)The release workflow will automatically:
bun run buildUsers can then download the gitai binary directly from the GitHub releases page.
41 commits
TypeScript
97.3%
JavaScript
2.4%