--- description: Smart git commit with conventional message and emoji argument-hint: [message] - Optional custom commit message --- # Smart Commit ## Pre-computed Context **Branch:** !`git branch --show-current` **Staged Files:** !`git diff --cached --name-only` **Staged Changes (stat):** !`git diff --cached --stat` **Unstaged Changes:** !`git diff --name-only` **Recent Commits (style reference):** !`git log --oneline -5` --- ## Instructions You are creating a commit with a conventional commit message and appropriate emoji. ### 1. Verify Staged Changes If no files are staged, suggest staging: ```bash git add ``` Never use `git add -A` or `git add .` without explicit user approval - these can accidentally stage sensitive files. ### 2. Analyze Changes Review the staged diff to determine: - **Type**: What kind of change is this? - **Scope**: What area of the codebase is affected? - **Description**: What does this change do? ### 3. Determine Commit Type & Emoji | Type | Emoji | When to use | |------|-------|-------------| | feat | `feat:` | New feature or functionality | | fix | `fix:` | Bug fix | | refactor | `refactor:` | Code restructuring without behavior change | | docs | `docs:` | Documentation only | | test | `test:` | Adding or updating tests | | chore | `chore:` | Maintenance, dependencies, config | | style | `style:` | Formatting, whitespace, semicolons | | perf | `perf:` | Performance improvement | ### 4. Generate Commit Message Format: ``` (): [optional body - explain WHY, not WHAT] Co-Authored-By: Claude Opus 4.5 ``` Rules: - Description: imperative mood, lowercase, no period - Max 72 characters for first line - Body explains motivation if not obvious ### 5. Execute Commit If user provided a message argument, use it. Otherwise, use the generated message. ```bash git commit -m "$(cat <<'EOF' (): Co-Authored-By: Claude Opus 4.5 EOF )" ``` ### 6. Verify Show the commit result: ```bash git log -1 --stat ``` --- ## Examples **Single file fix:** ``` fix(auth): resolve token refresh race condition Co-Authored-By: Claude Opus 4.5 ``` **New feature:** ``` feat(api): add user preferences endpoint Allows users to save and retrieve their app preferences. Includes validation for preference keys. Co-Authored-By: Claude Opus 4.5 ``` **Refactoring:** ``` refactor(utils): simplify date formatting helpers Co-Authored-By: Claude Opus 4.5 ```