Aider is a tool that uses AI to help you write code. It’s a chatbot that can help you write code, fix bugs, and even write tests.
OpenRouter is a tool that allows you to route requests to different APIs. In this case, we’ll use it to route the request to Aider.
With Aider we can run the following command to generate a pull request instruction:
1
2
3
4
5
6
7
8
9
aider \
--model "openrouter/meta-llama/llama-3-8b-instruct:free"\
--message="/ask Generate PR description from diff.log using INSTRUCTIONS.MD and PR_TEMPLATE.MD"\
--read INSTRUCTIONS.MD \
--read PR_TEMPLATE.MD \
--read diff.log \
--no-stream \
--dry-run \
--no-git
As you can see, we’re passing the model we want to use, the message we want to send to Aider, and the files we want to use to generate the pull request.
INSTRUCTIONS.MD is a file that contains the instructions for the pull request, i.e:
# Description:-Provideaclearandconcisedescriptionofthechangesintroducedinthispullrequest.-Highlightkeyupdatesorfeatures.# Jira:-[x]Relatedticket:ENG-# What areas of the site does it impact?-(Describewhatpartsofthesiteareimpactedand_if_codeupdatedotherareas)Ex.Checkout,Redemption,Homepage# Other Notes-(AddanyadditionalinformationthatwouldbeusefultothedeveloperorQAtester)# How to Test-Bestwaytotest?-IsthispartofanA/Btest?(Giveexperimentslug&variants)-Whatshouldthetesterlookoutfor?# Visual changes (if applicable)### - Before:|Mobile|Tablet|Desktop||-------------------|-------------------|--------------------||<screenshot_mobile>|<screenshot_tablet>|<screenshot_desktop>|### - After:|Mobile|Tablet|Desktop||-------------------|-------------------|--------------------||<screenshot_mobile>|<screenshot_tablet>|<screenshot_desktop>|# Developer Checklist-[]Ihaveperformedself-reviewofmycode-[]Ihaveaddedunitteststhatprovemyfeatureworks-[]IhaveconfirmedallthePRcheckspass-[]IhaveaddedReviewerstothisPRonGithub# Rollback Plan-[]Ihaveadocumentedplantodeployandrollbackifthereisanissue
diff.log is the file that contains the changes we made to the code (basically git diff > diff.log).
#!/bin/bash
PROVIDER="openrouter/"MODEL="google/gemini-2.0-flash-exp:free"script_dir="$(cd"$(dirname "$0")"&&pwd)"# Parse command line argumentsproject="my-default-project-folder"# Default projectwhilegetopts"p:" opt;docase$opt in
p)project="$OPTARG";;\?)echo"Invalid option: -$OPTARG" >&2exit1;;esacdone# Change to project directorycd ~/projects/$project# Ticket number to use in the PR templatebranch_name=$(git rev-parse --abbrev-ref HEAD)ticket_number=$(echo"$branch_name"| awk -F'/''{print $2}')# Generate diff filegit diff origin/develop...HEAD > "$script_dir/diff.log"# Go to the path where the script is locatedcd"$script_dir"aider \
--model "$PROVIDER$MODEL"\
--cache-prompts \
--message="/ask Generate PR description from diff.log using INSTRUCTIONS.MD and PR_TEMPLATE.MD (#$ticket_number)"\
--read INSTRUCTIONS.MD \
--read PR_TEMPLATE.MD \
--read diff.log \
--no-stream \
--dry-run \
--no-git \
--no-show-model-warnings