I found my happy place coding again over a December and January break. I can't emphasise how good it feels to get knee deep in code, in the zone, and using Go. I've started a new project which helps automate large parts of the Zettelkasten Method. I'm a big fan of the method, and as I am reading more I find myself wanting to follow the method but it does take a lot of time. By building automation around large parts of Zettelkasten I believe I can get the benefits of the system in much less time, using AI of course.

Genesis of GitPilotAI

During the development of this project, I found myself getting frustrated in the commit process. I wanted to commit often and have decent descriptions, but felt that when I had to go and investigate each file changed to get a coherent view I lost the flow. I decided to write a small tool to do this for me so I could keep focusing on the job at hand.

I've been using GitPilotAI since and have found it to be both fantastic and accurate - I'll be using it in all projects moving forward. Through a simple command it stages files, scans the diff, creates a logical description of what was changed and pushes it to the repo. While it may not seem like much, the value this brings is keeping me in the flow while not losing the upside of commit messages - no more "changes" messages. Instead, commit messages look like this:

Add Makefile for building and installing GitPilotAI

- Add a new Makefile to automate the build and install process using `make`.
- Provide detailed instructions in README.md for building and installing GitPilotAI using the Makefile.
- Include prerequisites and steps to build the binary and install it to /usr/bin/.
- Clarify that the Makefile is intended for Unix-like systems.
- Add relevant targets to the Makefile: 'all', 'build', and 'install'.

Mechanics and Technical Details

As is clear from this website, I love Go. It's an obvious choice for several use cases, one of the most clear ones being CLI applications.

The entire application right now is only around 200 lines of code and split into several high level functions:

  • Check if the repo has any git changes. This uses git status --porcelain to bring back a neat list.
  • Stage all files by running git add ..
  • Get the output of git diff.
  • Generate the diff message by sending the entire diff to OpenAI with a given prompt.
  • Use the diff message to commit the changes using git commit -m [message].
  • Push the changes to the remote branch.

There's nothing too fancy going on in the flow, it follows exactly the normal workflow you would be used to using. I am using GPT model gpt-4-1106-preview so I can make use of the larger context window (128k at time of writing). The prompt I use is as follows:

Generate a git commit message based on the output of a diff command. The commit message should be a detailed but brief overview of the changes.
Here is the diff output: %s
Commit message:

This prompt definitely has room for improvement. On occasion I get an output that has backticks before and after the message, a separate description detailing the output ("This commit message describes...") and more weird behaviour.

Using GitPilotAI

The project's README is fairly detailed, but in summary:

  1. Download the repo.
  2. Run make build and make install.
  3. Set an OPENAI_API_KEY environment variable.
  4. Run gitpilotai generate in the root of your git repo.

Right now there is no dry-run so this will add all unstaged files, generate the commit message and push it to the repo without any further intervention.

Roadmap and Improvements

In the short term, I'd mainly like to ensure the commit messages are consistent and have the right level of detail and context. This is all prompt engineering, so will come with a few trial and errors. It might also be helpful to optionally review what files get staged and what the commit message is.

Further down the line, there are a few nice additions that could be made:

  • Pull Requests. Automatically generate a description for a pull request and submit it.
  • Release Notes. Generate detailed release notes based on changes made.
  • Change Impact Assessments. Help describe what potential impact a set of given changes might have on a given system.
  • Better Installation. Using releases, creating executables and adding to homebrew.


GitPilotAI is open source and if you want to contribute to help improve, please do. I've found it really useful and so far it seems other people do too.