Patchflows are LLM-assisted workflows defined using steps and prompts that can be triggered to automate a well-defined process.

What is a Patchflow?

In its simplest form, a patchflow is a Python script that defines a series of function (Steps) and LLM (Prompts) calls to execute a development task, generally in the context of a target code repository.

What makes a good Patchflow?

Patchflows are meant to automate repetitive, well-defined development tasks so that they can be executed end-to-end without active manual intervention.

When deciding what tasks to automate using a patchflow, consider the following:

  • Repetitive: The task should be something that is done frequently and is well understood.
  • Effort: The task should ideally be time-consuming or error-prone when done manually.
  • Scope: The task should be well-defined and have clearly identifiable inputs and outputs.
  • Asynchronous: The task should be something that can be done in the background, so as to not block active development or require manual intervention.
  • Expectations: An ideal task is one where the output can be easily verified manually.

A good example task that can be automated using a patchflow is PR reviews. Reviews are repetitive, have well-defined context in terms of the modified code, can be done asynchronously, and the output is easily verifiable.

A bad example task would be to automate the entire process of writing a new feature. Every feature is unique (not repetitive), requires a lot of context (not well-defined), requires active collaboration (not asynchronous), and the output quality is hard to assess (not easily verifiable).

Why are Patchflows the right way to automate?

A core tenet of software development is planning out the steps needed to achieve a goal. The absence of a plan often leads to confusion, wasted effort, and poor outcomes.

The same is true for LLMs and AI agents. An open-ended task without clear definition leads to poor outcomes. This is why even the best AI-engineers can only complete about 40% of the tasks assigned to them. And this is for a set of curated tasks that were known beforehand.

Patchflows in comparison can have an accuracy rate as high as 90%, made possible because of the well-defined structure and targeted context. The slightly higher upfront cost of defining a patchflow is more than offset by the increased accuracy and reduced effort in the long run. Plus, when a result is not as expected, patchflows make it incredibly simple to debug and improve them.