--- description: Create git commit with intelligent message generation using conventional commits format argument-hint: [message] allowed-tools: Bash(git:*) --- # Intelligent Git Commit Assistant Create well-formatted git commits with optional automatic message generation following conventional commits standards. ## Overview The `/commit` command provides a simplified workflow that orchestrates multiple specialized skills to create intelligent, well-formatted commits following conventional commits standards. ### Skills Orchestrated This command coordinates these granular skills: 1. **commit-error-handling** - Validates git repository state and checks for issues - Operation: `/commit-error-handling diagnose-issues` - Purpose: Ensure repository is in a clean state before committing 2. **commit-analysis** - Analyzes changes to determine type, scope, and atomicity - Operation: `/commit-analysis analyze` - Purpose: Understand what changes are being committed 3. **history-analysis** (optional) - Learns project commit conventions - Operation: `/history-analysis analyze-style` - Purpose: Match team's existing commit style 4. **commit-best-practices** - Validates commit readiness - Operation: `/commit-best-practices check-pre-commit` - Purpose: Ensure tests pass, no debug code, lint clean 5. **message-generation** - Generates conventional commit messages - Operation: `/message-generation complete` - Purpose: Create well-formatted conventional commit message 6. **atomic-commit** (conditional) - Suggests splitting if needed - Operation: `/atomic-commit analyze` - Purpose: Determine if changes should be split into multiple commits ### For Granular Control If you need precise control over individual operations: - Use `/commit-error-handling` for error diagnosis - Use `/commit-analysis` for change analysis - Use `/message-generation` for message generation - Use `/atomic-commit` for commit splitting - Use `/commit-best-practices` for validation - Use `/history-analysis` for project conventions See the commit-assistant agent for complete skill documentation. ## Usage ```bash /commit # Analyze changes and generate commit message /commit "feat: add login" # Use provided message directly ``` ## Complete Workflow ``` User: /commit [optional message] ↓ ┌────────────────────────────────┐ │ 1. Error Check │ │ /commit-error-handling │ │ diagnose-issues │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 2. Analyze Changes │ │ /commit-analysis analyze │ └────────────┬───────────────────┘ ↓ ┌─────┴──────┐ │ Atomic? │ └─────┬──────┘ │ ┌────────┴────────┐ │ NO │ YES ↓ ↓ ┌───────────────┐ ┌──────────────────┐ │ Suggest Split │ │ Continue │ │ /atomic-commit│ │ │ │ analyze │ │ │ └───────┬───────┘ └────────┬─────────┘ │ │ └───────────────────┘ ↓ ┌────────────────────────────────┐ │ 3. Learn Project Style │ │ /history-analysis (optional) │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 4. Pre-Commit Check │ │ /commit-best-practices │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 5. Generate Message │ │ /message-generation complete │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 6. Present & Confirm │ │ User reviews message │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 7. Create Commit │ │ git add . && git commit │ └────────────┬───────────────────┘ ↓ ┌────────────────────────────────┐ │ 8. Post-Commit Review │ │ /commit-best-practices │ │ review-commit │ └────────────────────────────────┘ ``` ## Process ### Step 1: Verify Git Repository and Check for Issues **Orchestrates**: `/commit-error-handling diagnose-issues` This operation checks: - Repository validity (is this a git repo?) - Changes present (are there files to commit?) - No merge conflicts - Not in detached HEAD state - Git configuration present Internally executes: ```bash git rev-parse --git-dir 2>/dev/null git status --short git status --porcelain git config user.name git config user.email ``` If issues are found, the operation provides specific guidance: **Not a git repository:** ``` ERROR: Not a git repository This directory is not initialized as a git repository. Initialize one with: git init ``` **No changes to commit:** ``` No changes to commit Working tree is clean. Make some changes first, then run /commit again. ``` **For detailed error handling**: Use `/commit-error-handling` skill directly with operations: - `/commit-error-handling handle-no-repo` - Not a repository error - `/commit-error-handling handle-no-changes` - No changes error - `/commit-error-handling handle-conflicts` - Merge conflict guidance - `/commit-error-handling handle-detached-head` - Detached HEAD handling ### Step 2: Check for Atomic Commit Opportunity **Orchestrates**: `/atomic-commit analyze` Before proceeding with message generation, check if the changes should be split into multiple atomic commits. This operation analyzes: - Number of files changed - Logical groupings of changes - Mixed concerns (e.g., feature + refactor + tests) If changes should be split, provide guidance: ``` RECOMMENDATION: Split into atomic commits Your changes involve multiple concerns: 1. Feature: New authentication module (3 files) 2. Refactor: Code cleanup in utils (2 files) 3. Tests: Test coverage for auth (1 file) Consider using /atomic-commit interactive to split these into 3 commits. ``` **For granular atomic commit analysis**: - `/atomic-commit group` - Group related files together - `/atomic-commit suggest` - Recommend commit breakdown - `/atomic-commit sequence` - Generate commit execution plan - `/atomic-commit interactive` - Step-by-step guided splitting ### Step 3: Analyze Changes **Orchestrates**: `/commit-analysis analyze` If user provided a message ($ARGUMENTS is not empty), skip to Step 5 and use their message. If no message provided, this operation analyzes your changes to determine: - **Type**: feat, fix, docs, style, refactor, test, chore, perf, ci - **Scope**: Primary module/component affected (auth, api, ui, etc.) - **Atomicity**: Whether changes should be in one commit or split - **Files**: What files are being modified The analysis uses git commands: ```bash # Get detailed diff git diff HEAD # Get status for summary git status --short # Get recent commits for style reference git log --oneline -10 ``` **For granular analysis**: Use these operations directly: - `/commit-analysis detect-type` - Just determine type - `/commit-analysis identify-scope` - Just identify scope - `/commit-analysis assess-atomicity` - Just check if should split - `/commit-analysis file-stats` - Get file change statistics ### Step 4: Learn Project Conventions (Optional) **Orchestrates**: `/history-analysis analyze-style` (optional, caches results) This operation (run periodically, results cached): 1. **Learns project conventions** - Analyzes recent 50-100 commits - Detects conventional commits usage - Identifies common scopes - Determines average subject length - Identifies team patterns The analysis helps ensure generated messages match your project's existing style. **For custom history analysis**: - `/history-analysis detect-patterns` - Identify project conventions - `/history-analysis extract-scopes` - Discover commonly used scopes - `/history-analysis suggest-conventions` - Recommend conventions - `/history-analysis learn-project` - Full project learning ### Step 5: Pre-Commit Validation (Recommended) **Orchestrates**: `/commit-best-practices check-pre-commit` This operation validates: - Tests pass (npm test, pytest, cargo test, go test) - Lint passes (eslint, pylint, clippy) - No debug code (console.log, debugger, print, pdb) - No TODO/FIXME in new code - No merge conflict markers If validation fails, commit is blocked with specific guidance: ``` PRE-COMMIT VALIDATION FAILED Issues found: Tests: 2 tests failing in auth.test.js Lint: 3 errors in src/auth/oauth.js Debug: Found console.log in src/utils/debug.js Fix these issues before committing. Run /commit-best-practices check-pre-commit for details. ``` **For validation control**: - Enable/disable via configuration - Run manually: `/commit-best-practices check-pre-commit` - Skip with: `/commit --skip-validation` (not recommended) ### Step 6: Generate Commit Message **Orchestrates**: `/message-generation complete` Based on the analysis from Steps 3-4, this operation generates a conventional commit message following this format: ``` ():