Skip to content

πŸ€– AI-powered Git branch name generator using OpenAI and Conventional Branch naming convention. VoltAgent + Rust CLI.

License

Notifications You must be signed in to change notification settings

sakkeam/aibranch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

aibranch

An AI-powered Git branch name generator that follows the Conventional Branch naming convention. This tool analyzes your Git diff and automatically generates descriptive, standardized branch names.

Overview

aibranch consists of two components:

  1. Cloudflare Worker (TypeScript/Bun) - An AI workflow service powered by VoltAgent and OpenAI
  2. CLI Tool (Rust) - A command-line interface that interacts with your Git repository

The CLI tool reads your current Git changes, sends them to the AI service, and suggests a conventional branch name based on your modifications.

Features

  • πŸ€– AI-Powered: Uses OpenAI's GPT models to analyze code changes
  • πŸ“ Conventional Branch Standard: Follows industry-standard branch naming conventions
  • ⚑ Fast & Lightweight: Rust CLI with minimal dependencies
  • 🌐 Serverless: Runs on Cloudflare Workers for scalability
  • πŸ”’ Secure: Uses rustls-tls for secure communications

Getting Started

curl https://i.jpillora.com/sakkeam/aibranch@latest! | bash

Example

(main) $ git switch -c work
(work) $ git commit

(work) $ aibranch
Generating the new branch name...

Generated branch name: chore/add-devcontainer

Reason: Adds a new .devcontainer/devcontainer.json to set up devcontainer (VS Code extensions and pnpm onCreateCommand) β€” non-feature configuration change, classified as chore.

Do you want to approve this branch name? [Y/n] y

(chore/add-devcontainer) $ git push origin chore/add-devcontainer

Branch Naming Convention

The tool generates branch names following these prefixes:

  • feature/ or feat/ - New features
  • bugfix/ or fix/ - Bug fixes
  • hotfix/ - Urgent fixes
  • release/ - Release preparation
  • chore/ - Non-code tasks (docs, dependencies, etc.)

Branch names are always lowercase with hyphens separating words (e.g., feature/add-user-authentication).

Installation

Prerequisites

Setup

  1. Install dependencies:
bun install
  1. Build the CLI tool:
cd cli
cargo build --release

The compiled binary will be available at cli/target/release/cli.

Usage

Running the Worker Locally

Start the development server:

bun run dev

The worker will be available at http://0.0.0.0:8787.

Using the CLI

  1. Make some changes in your Git repository
  2. Commit or stage your changes
  3. Run the CLI:
./cli/target/release/cli
  1. The tool will:
    • Analyze your Git diff (comparing main..HEAD)
    • Generate a suggested branch name
    • Provide a reason for the suggestion
    • Prompt you to approve and apply the branch name

Environment Variables

Configure the CLI to use a custom worker endpoint:

export AIBRANCH_HOST="https://your-custom-domain.workers.dev"

Default: https://aibranch-worker.sakkeam.workers.dev

Deployment

Deploy the worker to Cloudflare:

bun run deploy

Make sure to configure your environment variables in Wrangler:

  • OPENAI_API_KEY - Your OpenAI API key (required)
  • VOLTAGENT_PUBLIC_KEY - VoltAgent public key (optional)
  • VOLTAGENT_SECRET_KEY - VoltAgent secret key (optional)

Development

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts                          # Main worker entry point
β”‚   └── workflows/
β”‚       └── branch-name-generator.ts      # AI workflow logic
β”œβ”€β”€ cli/
β”‚   └── src/
β”‚       └── main.rs                       # CLI implementation
β”œβ”€β”€ package.json                          # Bun/Node dependencies
β”œβ”€β”€ wrangler.jsonc                        # Cloudflare Worker config
└── tsconfig.json                         # TypeScript config

Tech Stack

Worker:

  • VoltAgent - AI agent framework
  • OpenAI SDK - GPT model integration
  • Hono - Lightweight web framework
  • Cloudflare Workers - Serverless platform

CLI:

  • Clap - Command-line argument parsing
  • Reqwest - HTTP client with rustls-tls
  • Tokio - Async runtime
  • Serde - JSON serialization

Available Scripts

bun run start      # Run TypeScript entry point locally
bun run dev        # Start Wrangler dev server
bun run build      # Build the worker
bun run deploy     # Deploy to Cloudflare

How It Works

  1. The CLI runs git diff main..HEAD to get your changes
  2. The diff is sent to the Cloudflare Worker's /workflows/branch-name-generator/execute endpoint
  3. VoltAgent processes the request through the AI workflow
  4. OpenAI's GPT model analyzes the diff and generates a branch name following Conventional Branch conventions
  5. The result (branch name + reasoning) is returned to the CLI
  6. The CLI prompts for approval and can automatically rename your branch

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.


Built with ❀️ using Bun, Rust, VoltAgent, and Cloudflare Workers