aigh is a command-line interface (CLI) tool designed to streamline your Git and GitHub workflow by leveraging the power of AI. It acts as a wrapper around common git and gh commands, automatically generating commit messages and pull request descriptions based on your code changes.
Stop agonizing over the perfect commit message or PR description – let your AI pal handle the first draft!
- AI-Powered Commit Messages: Run
aigh committo automatically generate a conventional commit message based on your staged changes. - AI-Powered PR Descriptions: Run
aigh pr newto create a new draft pull request with a title and description generated from the difference between your current branch and the base branch. It can even use your existing.github/pull_request_template.md! - Interactive Confirmation: Never commit or open a PR blindly.
aighalways shows you the AI-generated content and asks for your confirmation before proceeding. - Seamless Integration: Uses your existing
gitandghCLI setup. - Configurable: Options to specify base branches, control draft PR status, and open PRs in the browser.
npm install -g aighNow you can run aigh from any directory.
-
API Keys:
aighuses AI to generate text. You need an API key for your chosen provider (OpenAI or Google Gemini).- Configure your keys using
aigh config set <key> <value>. Seeaigh config getfor available keys. - Alternatively, set environment variables (
OPENAI_API_KEYorGOOGLE_API_KEY). - Keys set via
aigh configare stored in~/.aigh/config.json.
- Configure your keys using
-
GitHub CLI (
gh): Theaigh pr newcommand relies on the official GitHub CLI (gh) being installed and authenticated.- Install
ghby following the instructions here. - Authenticate with your GitHub account by running
gh auth login.
- Install
Make sure you are inside a Git repository directory.
- Stage the changes you want to commit (
git add ...). - Run the command:
aigh commit
aighwill show the staged diff (if any) and then display the AI-generated commit message.- You will be prompted to confirm (Y/n) if you want to use the generated message.
- If confirmed,
aighwill executegit commitwith the message.
- Ensure your current feature branch has been pushed to GitHub (
git push -u origin your-branch-name). - Run the command:
aigh pr new
aighwill:- Determine your current branch and the base branch (defaults to
main). - Fetch the diff between your branch and the base branch.
- Look for a
.github/pull_request_template.mdfile. - Generate a PR title and description using AI based on the diff and template (if found).
- Display the generated title and description.
- Determine your current branch and the base branch (defaults to
- You will be prompted to confirm (Y/n) if you want to create the PR with this content.
- If confirmed,
aighwill executegh pr create --draft ...(draft by default).
--base <branch>: Specify a different base branch (e.g.,aigh pr new --base develop).--no-draft: Create the PR as ready for review instead of a draft.--web: Open the newly created PR in your web browser.
Example:
# Create a non-draft PR against the 'develop' branch and open it in the browser
aigh pr new --base develop --no-draft --web- Diffing: Uses
git diffcommands viaexecato get staged changes (commit) or changes relative to a base branch (pr new). - AI Generation: Sends the diff (and PR template content, if applicable) to the configured AI API (OpenAI or Gemini) using their respective libraries, with prompts designed to generate conventional commits or PR content.
- Interaction: Uses
inquirerto display generated content and ask for user confirmation. - Execution: If confirmed, runs the corresponding
git commitorgh pr createcommand usingexeca.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.