Skip to content

AI-assisted commit message generation #3

@jordanpartridge

Description

@jordanpartridge

Overview

Use local LLM (Ollama) or cloud AI to generate commit messages from diffs.

Commands

commit ai

commit ai                       # Generate message from staged diff
commit ai --model llama3       # Use specific model
commit ai --style conventional # Enforce conventional commits
commit ai --verbose            # Include reasoning

commit suggest

commit suggest                  # Show 3 message options
commit suggest --pick 2        # Use option 2

Implementation

Local LLM (Ollama)

// Use Ollama for privacy/speed
$response = Http::post('http://localhost:11434/api/generate', [
    'model' => 'llama3',
    'prompt' => $this->buildPrompt($diff),
]);

Prompt Template

Analyze this git diff and generate a conventional commit message.

Rules:
- Use format: type(scope): description
- Types: feat, fix, docs, refactor, test, chore
- Keep description under 50 chars
- Focus on WHY not WHAT

Diff:
{diff}

Commit message:

Fallback

  • If Ollama not running, offer cloud option
  • Cache common patterns for speed

Configuration

commit config --ai-model llama3
commit config --ai-provider ollama
commit config --ai-style conventional

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions