Git Stacking in the World of AI

Published on

Whether you're a fan of it or not, artificial intelligence, or more specifically, LLMs (Large Language Models) has landed in the world of software development and I don't expect to see it go away anytime soon.

I've been playing with LLMs properly for a few years now, and while I don't see them replacing human developers anytime soon, I do see them becoming an integral part of the software development process.

While they change the levels of productivity and efficiency in the software development, they also present a unique challenge: the need to review AI-generated code.

The Problem

While LLMs are producing great results, the need for human review remains arguably more important than ever. The problem is the amount of code generated by LLMs can be overwhelming to review manually. With huge codebases and complex AI-generated code, it can be difficult to keep up with the changes and ensure quality.

If we're honest, this is not really a new issue. Large PRs have always been a challenge for developers, and AI-generated code is no different. It is simply making it more obvious at scale due to the speed at which LLMs can pump out lines of code.

The Solution

One way to tackle the problem has also remained the same. The concept of stacking in Git predates the modern LLM code generation and has been a reliable way to manage large code changes over the years.

It provides a way to organize large code changes into smaller, more manageable units in a "stack" of changes. This allows developers to review and merge changes more efficiently, as they can focus on smaller, more digestible PRs.

Stacking changes manually comes with the challenge of resolving conflicts. Resolving conflicts can be time-consuming and error-prone, especially when dealing with large codebases, or when multiple developers are working in the same codebase. Many stacking tools exist to help automate this process, requiring you to manually resolve conflicts only when necessary and automatically applying those resolutions to the entire stack for you.

git-spice and AI

I personally use git-spice which has served me very well.

  • Create, edit, and navigate stacks of branches with ease.
  • Submit the entire stack or parts of it with a single command. Supports GitHub, GitLab, and BitBucket.
  • Keep using your existing workflow and adopt git-spice incrementally.
  • Completely offline operation with no external dependencies until you push or pull from a remote repository.
  • Easy-to-remember shorthands for most commands.

The documentation includes LLM friendly documentation you can feed into your preferred LLM to get things conected (all I really had to do was create a skill with the contents of the documentation and adjust according to my needs)

With this all set up, I can now use planning mode to help me build entire features in a codebase while keeping my workflow intact, PRs small, and any changes handle in the stack automatically.