Review

/laravel-agent:git:commit

Smart commit with security review

Overview

The /git:commit command creates Git commits with automatic security review and intelligent message generation. It analyzes your staged changes, checks for security issues, and generates semantic commit messages following best practices.

Usage

/laravel-agent:git:commit [--skip-review] [--amend] [message]

Examples

# Auto-review and generate message
/laravel-agent:git:commit

# Use provided message
/laravel-agent:git:commit "feat: add PDF export functionality"

# Skip security review
/laravel-agent:git:commit --skip-review

# Amend previous commit
/laravel-agent:git:commit --amend

Process Flow

The command follows a comprehensive workflow to ensure quality and security:

Step Action Description
1 Check Staged Changes Verify that files are staged for commit
2 Security Review Scan for vulnerabilities, debug statements, and secrets
3 Analyze Changes Categorize changed files and understand scope
4 Generate Message Create semantic commit message based on changes
5 Present Preview Show commit details for approval
6 Create Commit Execute git commit with generated message

Security Review

Unless --skip-review is specified, the command runs /review:staged to check for:

  • Security vulnerabilities - SQL injection, XSS, CSRF issues
  • Debug statements - dd(), dump(), var_dump() calls
  • Hardcoded secrets - API keys, passwords, tokens
  • Critical quality issues - Poor error handling, missing validation

Example security review output:

## Security Review Results

Status: PASSED / FAILED

Issues:
- Found dd() statement in UserController.php:42
- Potential SQL injection in ReportService.php:156

[Continue] [Fix Issues] [Skip Review]

Commit Message Generation

The command analyzes your changes and generates appropriate commit messages:

Single File Change

feat(invoice): add PDF export functionality

Multiple Files, Same Feature

feat(invoice): add PDF export functionality

- Add InvoicePdfExporter service with DomPDF
- Add export endpoint to InvoiceController
- Add feature tests for PDF generation

Closes #123

Multiple Features

chore: multiple changes

- Update user authentication flow
- Fix pagination bug in products list
- Add logging to payment service

Commit Preview

Before committing, you'll see a detailed preview:

## Commit Preview

### Staged Files (3)
- app/Services/InvoiceService.php (+45 -12)
- app/Http/Controllers/InvoiceController.php (+23 -5)
- tests/Feature/InvoiceTest.php (+67 -0)

### Generated Message
```
feat(invoice): add PDF export functionality

- Add InvoicePdfExporter service with DomPDF
- Add export endpoint to InvoiceController
- Add feature tests for PDF generation

Closes #123
```

### Security: PASSED

[Commit] [Edit Message] [Cancel]

Message Templates

The command uses semantic commit conventions:

Feature Template

feat(<scope>): <add|implement> <feature>

- <detail 1>
- <detail 2>

Closes #<ticket>

Bug Fix Template

fix(<scope>): <correct|resolve|handle> <issue>

<What was wrong>
<What was fixed>

Fixes #<ticket>

Refactor Template

refactor(<scope>): <extract|simplify|reorganize> <target>

- <change 1>
- <change 2>

No functional changes.

Breaking Change Template

feat(<scope>)!: <change>

BREAKING CHANGE: <description of breaking change>

Migration: <steps to migrate>

Implementation Example

The command creates commits using HEREDOC format for proper message formatting:

git commit -m "$(cat <<'EOF'
feat(invoice): add PDF export functionality

- Add InvoicePdfExporter service with DomPDF
- Add export endpoint to InvoiceController
- Add feature tests for PDF generation

Closes #123
EOF
)"

Options

  • --skip-review - Skip the security review step (not recommended)
  • --amend - Amend the previous commit instead of creating a new one
  • [message] - Use the provided message instead of generating one

Exit Codes

Code Meaning
0 Commit successful
1 Nothing to commit
2 Review failed (critical issues)
3 User cancelled

Best Practices

  1. Always run security review - Only skip review for trivial changes like docs
  2. Stage related changes - Group related changes in a single commit
  3. Use semantic conventions - Follow feat:, fix:, refactor:, etc.
  4. Include ticket numbers - Reference issues with Closes #123 or Fixes #123
  5. Review the preview - Always check the generated message before committing
  6. Split large commits - If suggested, split unrelated changes into separate commits

File Categorization

The command analyzes and categorizes changed files:

  • Feature files - Controllers, Models, Services
  • Test files - Feature tests, unit tests
  • Config files - Configuration, environment
  • Migration files - Database migrations
  • View files - Blade templates, frontend assets

See Also