--- name: commit description: Create a git commit with AI identification via Git trailers (no visible signature in message) argument-hint: "[message]" --- Create a git commit following repository conventions with AI identification through Git trailers instead of visible signatures in the commit message body. ## Commit Process ### Step 1: Gather Context Run these commands in parallel to understand the current state: ```bash # Check staged and unstaged changes git status # View staged changes git diff --cached # View recent commits for style reference git log --oneline -10 ``` ### Step 2: Analyze Changes Based on the diff output: 1. **Identify the type of change**: feat, fix, chore, docs, refactor, test, style, perf, ci, build 2. **Determine the scope** (optional): component or area affected 3. **Summarize the "why"**: Focus on purpose, not just what changed ### Step 3: Draft Commit Message Follow the repository's existing commit style. If Conventional Commits is used: ``` (): ``` **Guidelines:** - Subject line: max 50 characters, imperative mood ("add" not "added") - Body: wrap at 72 characters, explain motivation/context - **DO NOT include** emoji signatures, "Generated by AI", or Co-Authored-By in the message body ### Step 4: Create Commit with Trailers Use Git's `--trailer` parameter for AI identification. This keeps trailers separate from the message and follows Git's native trailer handling: ```bash git commit \ -m "(): " \ -m "" \ --trailer "Generated-by: Claude" \ --trailer "AI-Model: claude-opus-4-5-20251101" ``` **Available Trailers:** - `--trailer "Generated-by: Claude"` - Identifies AI assistance - `--trailer "AI-Model: "` - Specific model used - `--trailer "AI-Session: "` - Session identifier (optional) - `--trailer "Reviewed-by: "` - If human reviewed before commit ### Step 5: Verify Commit After committing, verify with: ```bash git log -1 --format=full git status ``` ## Examples ### Simple Feature ```bash git commit \ -m "feat(auth): add OAuth2 refresh token support" \ -m "Implements automatic token refresh when access token expires, preventing session interruptions for long-running operations." \ --trailer "Generated-by: Claude" \ --trailer "AI-Model: claude-opus-4-5-20251101" ``` ### Bug Fix ```bash git commit \ -m "fix(api): handle null response in user endpoint" \ --trailer "Generated-by: Claude" \ --trailer "AI-Model: claude-opus-4-5-20251101" ``` ### Chore/Refactor ```bash git commit \ -m "chore: update dependencies to latest versions" \ --trailer "Generated-by: Claude" \ --trailer "AI-Model: claude-opus-4-5-20251101" ``` ## Trailer Query Commands Trailers can be queried programmatically: ```bash # Find all AI-generated commits git log --all --grep="Generated-by: Claude" # Show trailers for a commit git log -1 --format="%(trailers)" # Filter by specific trailer git log --all --format="%H %s" | while read hash msg; do git log -1 --format="%(trailers:key=Generated-by)" $hash | grep -q Claude && echo "$hash $msg" done ``` ## Important Notes 1. **No visible AI signature** - The message body stays clean and professional 2. **Trailers are standard** - Git trailers are a recognized convention (like Signed-off-by) 3. **Machine-readable** - Easy to filter/query AI-generated commits 4. **Transparent** - AI assistance is documented, just not prominently displayed 5. **Do not use --no-verify** - Always run pre-commit hooks unless user explicitly requests ## When User Provides Message If the user provides a commit message as argument: 1. Use their message as the subject/body 2. Ensure proper formatting (50 char subject, etc.) 3. Append the trailers via `--trailer` parameter ```bash # User says: /ring-default:commit "fix login bug" git commit \ -m "fix: fix login bug" \ --trailer "Generated-by: Claude" \ --trailer "AI-Model: claude-opus-4-5-20251101" ``` ## Step 6: Offer Push (Optional) After successful commit, ask the user if they want to push: ```javascript AskUserQuestion({ questions: [{ question: "Push commit to remote?", header: "Push", multiSelect: false, options: [ { label: "Yes", description: "Push to current branch" }, { label: "No", description: "Keep local only" } ] }] }); ``` If user selects "Yes": ```bash git push ``` If branch has no upstream, use: ```bash git push -u origin ```