DEV Community

Cover image for Let AI generate Pull Requests from your GitHub issues!
Mad Mirrajabi
Mad Mirrajabi

Posted on

Let AI generate Pull Requests from your GitHub issues!

It's time we all stop wasting time on those small and medium-sized tasks that make our day miserable. Create small issues and let AI deal with them.

My (probably) last gift of 2023 for you all is a GitHub action + workflow which generates Pull Requests from your GitHub issues!

Check them out:

Aider is a coding assistant that handles all the prompting and communication with OpenAI.

Getting started

Follow the instruction's to add the 'aider-issue-to-pr' workflow to your project.

And that's all the setup you need to do!

Now let's test things out.

  1. Create a GitHub issue and assign aider label to it.
  2. An action automatically runs when the label is added and commits requested changes to the source code on a new branch. Lastly, it creates a pull-request for you to review.
  3. You review the code, possibly tweak it and merge it!

Example

I've created an example repo to demonstrate the full flow. See the readme of this repo

How does it work under the hood?

aider-github-action runs aider in a container and runs a single prompt on it, commits, and pushes its changes on a branch that you pass to it as an input.

aider-github-workflows uses aider-github-action to facilitate the creation of pull requests and new branches.

For more information see the documentation and the source code of these repos. They are currently very small and simple to review!

How much OpenAI credit does it cost?

I was positively surprised when I first started using Aider! I had 10 chats about some quite large changes and it only cost me less than $0.5 even though I was using the latest GPT-4 Turbo model (gpt-4-1106-preview). Aider optimises the prompts and only works with diffs rather than generating whole files. It also sends a map of your project to GPT instead of whole files. All of these nice features make it a great tool to use on larger code bases with really low cost.

Future of the project

I'm pretty sure GitHub will very soon make their own better version of "Issue to PR" tool available to those with either a GitHub copilot or Pro plans but until then, I think it's nice to have this open-source alternative.

Top comments (0)