Back to Home

Build an AI-Powered PR Description Generator with Git, OpenAI, and Cloudflare Workers


artificial-intelligence

If you've ever stared at a GitHub PR wondering how to summarize your recent commits, this project is for you. In this post, I'll walk you through how I built pr-desc-ai — an AI-powered tool that takes your Git commit messages and turns them into high-quality, human-friendly pull request descriptions.

The best part? It's built with a modern stack: TypeScript, Cloudflare Workers, OpenAI, and even comes with a VSCode extension. It's also structured as a monorepo managed by Turborepo.


🏛 Project Overview

pr-desc-ai helps you:

Monorepo Structure

pr-desc-ai/
├── git-parser/          # Node.js CLI tool
├── inference-worker/    # Cloudflare Worker as backend API
└── vscode-extension/    # Optional VSCode integration

🤝 Step-by-Step Guide

1. Scaffold the Monorepo with Turbo

mkdir pr-desc-ai && cd pr-desc-ai
pnpm init -y
pnpm add -D turbo

Then add a turbo.json in the root:

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", "build/**"]
    },
    "dev": {
      "cache": false
    },
    "lint": {
      "outputs": []
    },
    "test": {
      "outputs": []
    }
  }
}

Update your package.json to enable workspaces:

{
  "name": "pr-desc-ai",
  "private": true,
  "workspaces": ["git-parser", "inference-worker", "vscode-extension"],
  "scripts": {
    "build": "turbo run build",
    "dev": "turbo run dev"
  }
}

2. Create the Git Parser CLI

In /git-parser, write a script that runs this:

git log origin/main..HEAD --pretty=format:"%s"

Then send the commits to the backend using fetch or axios.

Key tools:


3. Build the Cloudflare Worker

In /inference-worker:

npm create cloudflare@latest
# Choose 'hello world' template

Then:

const prompt = `Write a PR description for these commits:\n\n${commits.join('\n')}`

Deploy with:

wrangler publish

Don't forget:

wrangler secret put OPENAI_API_KEY

4. Optional: Add a VSCode Extension

Use yo code to bootstrap:

npm install -g yo generator-code
yo code

In src/extension.ts:

Make it configurable:

{
  "prGen.apiEndpoint": "https://your-cloudflare-endpoint",
  "prGen.apiKey": "your-api-key"
}

🌐 Hosting & Deployment

Use Cloudflare Workers and Pages (optional) to host your API and docs.


🚀 Final Thoughts

This was a fun and practical weekend project that helped me:

If you're curious about building AI-native developer tools, this kind of project is a fantastic place to start.

Happy shipping!

Repo: github.com/akbarsahata/pr-desc-ai