Skip to content

jakiestfu/git-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-ai

For those of us who haven't fully succumbed to fully agentic coding, leverage AI to make your git experience a little nicer.

Commands

  • git ai commit — generate conventional commit messages from staged files (with optional split-into-multiple-commits, verbose bodies, and ticket extraction from your branch name)

Install

# Quick install (one-liner)
curl -fsSL https://raw.githubusercontent.com/jakiestfu/git-ai/main/install.sh | bash

# Or inspect first
curl -fsSL https://raw.githubusercontent.com/jakiestfu/git-ai/main/install.sh -o install.sh
less install.sh
bash install.sh

Requirements

  • git
  • jq
  • claude CLI, logged in
  • Bash 4+ (macOS users: the system bash 3.2 works for the dispatcher, but commit uses mapfile; install bash via Homebrew if needed: brew install bash)

Developing

git clone <this-repo> git-ai
cd git-ai
./install.sh

By default, files are installed to ~/.local/bin:

  • ~/.local/bin/git-ai — the dispatcher
  • ~/.local/bin/git-ai.d/* — individual subcommands

To install somewhere else:

PREFIX=/usr/local/bin ./install.sh

If ~/.local/bin is not on your PATH, the installer will tell you. Add this to ~/.zshrc or ~/.bashrc:

export PATH="$HOME/.local/bin:$PATH"

Re-running ./install.sh is safe — it overwrites in place.

Usage

Run git ai to list subcommands. Each supports -h for full options.

git ai commit

Generate a conventional commit message for staged changes.

git add .
git ai commit               # generate + confirm
git ai commit -y            # auto-commit
git ai commit -v            # include a body
git ai commit --split       # split into multiple logical commits
git ai commit --no-verify   # skip pre-commit hooks

Extracts a ticket from the branch name (feature/PROJ-123-foo(PROJ-123)), flags possible secrets/generated/large files, and handles pre-commit hooks (auto-fixes are re-staged silently). --split backs up the original staged diff to a temp file before applying per-commit patches.

git ai update

git ai update                       # latest from main
git ai update --ref v1.2.3          # pin to a tag/branch/commit
git ai update --repo myfork/git-ai  # install from a fork

Reinstalls in place at the same prefix.

git ai uninstall

git ai uninstall            # confirms first
git ai uninstall -y         # skip confirmation

Removes git-ai and git-ai.d/ from the install prefix.

How subcommand discovery works

git automatically treats any executable named git-<name> on your PATH as a subcommand (git <name>). The git-ai dispatcher mirrors that pattern one level deeper: it scans its own git-ai.d/ directory and runs whichever script matches the first argument.

Adding a new subcommand

  1. Drop an executable file in libexec/git-ai.d/ named <subcommand> (no git- prefix).

  2. Add a shebang and, optionally, a description comment that the dispatcher shows in git ai --help:

    #!/usr/bin/env bash
    # Description: One-line summary
    
    set -euo pipefail
    # ...
  3. Re-run ./install.sh.

Layout

git-ai/
├── install.sh
├── README.md
├── bin/
│   └── git-ai              # dispatcher
└── libexec/
    └── git-ai.d/
        ├── commit          # AI commit message generator
        ├── update          # pulls latest from GitHub and reinstalls
        └── uninstall       # removes git-ai from $INSTALL_DIR

After install, bin/git-ai and libexec/git-ai.d/* are flattened into a single directory ($INSTALL_DIR) so the dispatcher's sibling lookup just works.

Contributing

PRs are welcome. Open an issue first for anything non-trivial so we can align on the approach. New subcommands should follow the pattern in Adding a new subcommand and remember to add them to the SUBCOMMANDS array in install.sh so remote installs pick them up.

Credits

The commit subcommand started as turo/developer-machine#366, adapted to be a standalone repo with no external dependencies.

License

MIT

About

Subtle, unobtrusive AI tools to enrich your git workflow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages