Skip to content

Add AI-powered commit and PR description generation#3

Merged
Cellcote merged 1 commit intomainfrom
claude/ai-message-summarization-PBY6S
Feb 10, 2026
Merged

Add AI-powered commit and PR description generation#3
Cellcote merged 1 commit intomainfrom
claude/ai-message-summarization-PBY6S

Conversation

@Cellcote
Copy link
Owner

Summary

This PR adds AI-powered generation of commit messages and pull request descriptions using GitHub Models API (Azure OpenAI). Users can now use the --ai flag with commit, ship, and pr commands to automatically generate descriptions based on git diffs.

Key Changes

  • New AiService: Created AiService.cs with methods to generate commit messages and PR descriptions via GitHub Models API

    • GenerateCommitMessageAsync(): Generates conventional commit messages from diffs
    • GeneratePrDescriptionAsync(): Generates PR titles and structured descriptions with summary and changes sections
    • GetTokenAsync(): Retrieves GitHub token from environment variable or gh CLI
    • Includes JSON serialization context for OpenAI-compatible API requests
    • Implements diff truncation (8000 char limit) and response parsing
  • CommitCommand: Added --ai flag to generate commit messages

    • Made message argument optional with null default
    • Prompts user to confirm AI-generated message or enter custom message
    • Falls back to interactive prompt if AI generation fails or is not requested
  • ShipCommand: Added --ai flag to generate commit messages

    • Made message argument optional
    • Reuses CommitCommand.GenerateCommitMessageWithAi() for consistency
  • PrCommand: Added --ai flag to generate PR title and description

    • Generates both title and body when --ai is used without explicit title
    • Passes generated body to gh pr create command
    • Shows generated content to user for confirmation before creating PR

Implementation Details

  • Uses GitHub Models API endpoint with gpt-4o-mini model
  • Requires GITHUB_TOKEN environment variable or authenticated gh CLI
  • Implements proper error handling with user-friendly messages
  • Uses Spectre.Console for interactive prompts and status spinners
  • All AI calls have 30-second timeout and 500 token limit
  • Temperature set to 0.3 for more deterministic outputs

https://claude.ai/code/session_01CSf8jFLPGw7CicGJpkaEiU

Uses GitHub Models API (gpt-4o-mini) to auto-generate commit messages
from staged diffs and PR titles/descriptions from branch diffs. Falls
back to interactive prompt when no message is provided and --ai is not
set. Auth via GITHUB_TOKEN env var or gh CLI token.

https://claude.ai/code/session_01CSf8jFLPGw7CicGJpkaEiU
@Cellcote Cellcote merged commit b891b0f into main Feb 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants