Download the PHP package tharlesamaro/laravel-git-ai without Composer
On this page you can find all versions of the php package tharlesamaro/laravel-git-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tharlesamaro/laravel-git-ai
More information about tharlesamaro/laravel-git-ai
Files in tharlesamaro/laravel-git-ai
Package laravel-git-ai
Short Description AI-powered Git workflow automation for Laravel: smart commit messages, changelog generation, and commit validation using Conventional Commits.
License MIT
Informations about the package laravel-git-ai
Laravel Git AI
English | Portugues
AI-powered Git workflow automation for Laravel. Generate smart commit messages, changelogs, and validate commits using Conventional Commits.
Why use this package instead of Claude Code directly?
If you already use Claude Code CLI, you might wonder: "Why not just ask Claude to commit for me?" Here's what this package brings to the table:
| Feature | Claude Code alone | Laravel Git AI |
|---|---|---|
| Conventional Commits format | You have to ask every time | Enforced automatically via structured output |
| Consistent JSON schema | Free-form text, may vary | Validated against a strict schema every time |
| Project-specific scopes | Must remember to mention them | Configured once, enforced on every commit |
| Allowed commit types | Manual discipline | Restricted by config, AI cannot use others |
| Multi-language support | Must specify in every prompt | Configured once, always applied |
| Changelog generation | Manual work | Automated from commit history between tags |
| Git hook validation | Not available | Optional hook rejects non-conventional commits |
| Team consistency | Each developer prompts differently | Same rules for everyone via shared config |
| Max diff size control | No control, may exceed context | Auto-truncated to configured limit |
| Works without CLI installed | N/A | Falls back to API providers (Anthropic/OpenAI) |
In short: this package turns AI-generated commits into a repeatable, team-wide standard instead of a one-off prompt.
Features
git:commit-- Generate commit messages from staged changes using AI, following Conventional Commitsgit:changelog-- Generate structured changelogs from commit history between tagsgit:setup-- Interactive configuration wizard- 3 providers -- Anthropic API, OpenAI API, or Claude Code CLI (no API key needed)
- 9 languages -- English, Portuguese, Spanish, French, German, Italian, Japanese, Korean, Chinese
- Scope enforcement -- Restrict commits to project-specific scopes
- Type restriction -- Limit which Conventional Commits types are allowed
- Commit templates -- Built-in (
minimal,detailed) and custom presets for body + footer settings - Body control -- Configure whether AI always includes body, never includes it, or decides automatically
- Footer control -- Toggle BREAKING CHANGE footer, add custom footer lines, control Co-Authored-By trailer
- Git hook -- Optional
commit-msghook to reject non-conventional commits - Structured output -- AI responses are validated against a JSON schema, never free-form text
- Diff truncation -- Large diffs are automatically truncated to fit AI context windows
Requirements
- PHP 8.4+
- Laravel 12+
- One of the following:
- Laravel AI SDK (
laravel/ai) + an API key from Anthropic or OpenAI - OR Claude Code CLI installed on your machine (uses your existing Claude subscription, e.g. Max plan -- no API key required)
- Laravel AI SDK (
Installation
Publish the configuration file:
Run the interactive setup:
Provider Setup
Option 1: Anthropic API (default)
Option 2: OpenAI API
Option 3: Claude Code CLI (no API key)
If you have a Claude subscription (e.g. Max plan) and the Claude Code CLI installed, you can use it directly without any API key:
Make sure the claude binary is available in your PATH. Install it from: https://docs.anthropic.com/en/docs/claude-code
This option invokes the Claude Code CLI as a subprocess, passing a structured prompt and parsing the JSON response. It consumes from your existing subscription usage -- no separate API tokens needed.
Usage
git:commit -- Generate a commit message
Stage your changes and run:
Or stage everything automatically with the --all (-a) flag:
Available options:
| Option | Short | Description |
|---|---|---|
--all |
-a |
Stage all changes before committing |
--template= |
Use a named commit template (e.g. minimal, detailed) |
|
--no-body |
Strip body from the commit message | |
--footer= |
Add custom footer line(s) (can be used multiple times) |
What happens:
- Reads your staged diff (truncated if it exceeds
max_diff_size) - Sends it to the configured AI provider
- Receives a structured response with
type,scope,description,body, andis_breaking_change - Validates the type and scope against your config
- Formats the message following Conventional Commits
- Lets you choose what to do next
Interactive menu:
- Accept and commit -- Creates the commit with the generated message
- Edit the message -- Opens an editor to modify the title and body separately
- Generate a new suggestion -- Calls the AI again for a different message
- Cancel -- Aborts without committing
Example with body and breaking change:
git:changelog -- Generate a changelog
Available options:
| Option | Description | Default |
|---|---|---|
--from= |
Starting tag or commit hash | Latest tag (or first commit if no tags) |
--to= |
Ending tag or commit hash | HEAD |
--tag= |
Version tag for the changelog header | Interactive prompt |
--dry-run |
Preview without writing to file | false |
Examples:
What happens:
- Resolves the starting reference (priority:
--from> latest tag > first commit) - Gets all commits between
fromandto - Parses each commit message using the Conventional Commits format
- Groups commits by type (
feat,fix,docs, etc.) - Sends the grouped commits to the AI for human-readable descriptions
- Formats the output as Markdown with emojis (configurable)
- Shows a preview and asks for confirmation before writing
Output example (CHANGELOG.md):
If changelog.with_emojis is enabled (default), section titles include emojis:
The changelog is prepended to the existing file. If CHANGELOG.md already exists, new content is added at the top (below the header), preserving previous entries.
git:setup -- Interactive configuration
The wizard walks you through every configurable option:
- AI provider -- Anthropic API, OpenAI API, or Claude Code CLI
- Language -- English, Portuguese (Brazil), Spanish, French, German, Italian, Japanese, Korean, or Chinese
- Scopes -- Define allowed scopes for your project (e.g.,
auth,api,ui,database) - Types -- Restrict which commit types are allowed (e.g., only
feat,fix,docs) - Body preference -- How the AI handles commit message body (auto, always, never)
- Git hook -- Install a
commit-msghook that rejects non-conventional commits
After setup, it writes config/git-ai.php and shows the environment variables you need to add to .env.
Configuration
All options in config/git-ai.php:
Environment variables
| Variable | Description | Default |
|---|---|---|
GIT_AI_PROVIDER |
AI provider (anthropic, openai, claude-code) |
anthropic |
GIT_AI_MODEL |
AI model override | Provider default |
GIT_AI_LANGUAGE |
Commit message language | en |
GIT_AI_MAX_DIFF_SIZE |
Max diff size in characters | 15000 |
GIT_AI_COMMIT_BODY |
Body behavior (auto, always, never) |
auto |
GIT_AI_CO_AUTHORED_BY |
Include Co-Authored-By trailer | false |
GIT_AI_TEMPLATE |
Default commit template name | -- |
ANTHROPIC_API_KEY |
Anthropic API key (when provider is anthropic) |
-- |
OPENAI_API_KEY |
OpenAI API key (when provider is openai) |
-- |
Commit Templates
Templates bundle body and footer preferences into named presets. They're entirely optional -- without a template, the commit config section is used directly.
Built-in templates
| Template | Body | BREAKING CHANGE footer | Use case |
|---|---|---|---|
minimal |
Never | No | Quick, one-line commits |
detailed |
Always | Yes | Thorough commits with full context |
Using templates
Set a default template
In your .env:
Or in config/git-ai.php:
Custom templates
Define your own presets in config/git-ai.php:
Then use it:
Disabling Co-Authored-By
By default, the Co-Authored-By trailer is not included in commit messages. If you want to enable it:
Or via environment variable:
When enabled, commits will include a trailer like:
Set it to false (default) to keep commits clean without AI attribution.
Git Hook
The package includes an optional commit-msg git hook that validates commit messages against the Conventional Commits specification.
What it validates:
- The message must match the format:
<type>(<scope>): <description> - The type must be one of:
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert - The first line must not exceed 72 characters
- Merge commits, reverts, fixups, and squashes are automatically allowed
Install the hook:
Example of a rejected commit:
Conventional Commits
This package follows the Conventional Commits v1.0.0 specification:
Supported types
| Type | Emoji | Description |
|---|---|---|
feat |
โจ | A new feature |
fix |
๐ | A bug fix |
docs |
๐ | Documentation only changes |
style |
๐ | Code style changes (formatting, semicolons, etc.) |
refactor |
โป๏ธ | Code refactoring (no feature or fix) |
perf |
โก | Performance improvements |
test |
๐งช | Adding or fixing tests |
build |
๐ฆ | Build system or dependency changes |
ci |
๐ง | CI configuration changes |
chore |
๐จ | Other changes (tooling, configs, etc.) |
revert |
โช | Reverts a previous commit |
Breaking changes
Breaking changes are indicated by:
- An
!after the type/scope:feat(api)!: remove deprecated endpoints - A
BREAKING CHANGE:footer in the body
The AI detects breaking changes automatically from the diff and sets is_breaking_change accordingly.
Architecture
The package uses a service abstraction layer (AiService contract) that allows swapping between providers without changing command logic:
AgentAiService-- Uses the Laravel AI SDK agents with structured output for API-based providers (Anthropic, OpenAI)ClaudeCodeAiService-- Invokes theclaudeCLI as a subprocess for users with a Claude subscription
The provider is resolved at runtime based on config('git-ai.provider'). Both implementations return the same structured array format, ensuring consistent behavior regardless of the provider.
Testing
This package uses Pest PHP for testing. To run with coverage:
Using Docker:
Contributing
Contributions are welcome! Please follow Conventional Commits for your commit messages.
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
php artisan git:commit๐) - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
License
The MIT License (MIT). See LICENSE for details.