From 79de88d25c084de5b9f142b486bec3fc58fb9528 Mon Sep 17 00:00:00 2001 From: windyboy Date: Mon, 5 Jan 2026 21:38:47 +0800 Subject: [PATCH] feat(commands): add AI git commit message generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add comprehensive slash command for generating conventional commit messages using AI. The command analyzes staged git changes and creates well-structured commit messages following best practices. Features: - Conventional commit format (type, scope, description) - Interactive message editing and regeneration - Context-aware analysis of git diffs - Learning from existing commit history style - Support for custom type and scope hints - Multi-step workflow with user confirmation Command supports multiple usage patterns: - Basic: /git-commit-msg - With hints: /git-commit-msg fix - With context: /git-commit-msg "feat(api)" Also updates command README with documentation for the new command. 🤖 Generated with Claude Code --- .claude/commands/README.md | 10 + .claude/commands/git-commit-msg.md | 320 ++++++++++++++++++ .../conv-1767607708938-lh0h0m9vo.jsonl | 2 +- .../conv-1767614390266-63uej6rqk.jsonl | 5 + .../conv-1767619655890-v05b9nw60.jsonl | 3 + .../conv-1767620030117-cqj3f0arx.jsonl | 3 + .claude/settings.json | 102 ++++++ .obsidian/plugins/claudian/data.json | 2 +- .obsidian/vault-stats.json | 2 +- 9 files changed, 446 insertions(+), 3 deletions(-) create mode 100644 .claude/commands/git-commit-msg.md create mode 100644 .claude/sessions/conv-1767614390266-63uej6rqk.jsonl create mode 100644 .claude/sessions/conv-1767619655890-v05b9nw60.jsonl create mode 100644 .claude/sessions/conv-1767620030117-cqj3f0arx.jsonl diff --git a/.claude/commands/README.md b/.claude/commands/README.md index 5dbc951..b5c301f 100644 --- a/.claude/commands/README.md +++ b/.claude/commands/README.md @@ -54,6 +54,16 @@ Create a comprehensive synthesis of the week's work. Best for: Weekly reviews, pattern recognition +### 💬 git-commit-msg + +AI-generated conventional commit messages from staged changes. + +``` +/git-commit-msg +``` + +Best for: Creating meaningful commit messages, maintaining clean git history + ## Creating Custom Commands 1. Create a new `.md` file in this directory diff --git a/.claude/commands/git-commit-msg.md b/.claude/commands/git-commit-msg.md new file mode 100644 index 0000000..f4260a8 --- /dev/null +++ b/.claude/commands/git-commit-msg.md @@ -0,0 +1,320 @@ +--- +allowed-tools: Bash, AskUserQuestion +description: AI-generated git commit messages from staged changes +argument-hint: [optional: type or scope hint] +--- + +# AI Git Commit Message Generator + +Analyzes your staged git changes and generates a well-structured conventional commit message using AI. Perfect for creating meaningful, consistent commit messages that follow best practices. + +## Task + +Review staged changes, analyze the modifications, and generate a descriptive conventional commit message that accurately describes what was changed and why. + +## Process + +### 1. **Check Git Status** + +First, verify there are changes to commit: + +```bash +git status +``` + +If no changes are staged, check if there are unstaged changes: +- If yes: Ask user if they want to stage all changes +- If no: Exit with message "No changes to commit" + +### 2. **Review Changes** + +Show detailed diff of staged changes: + +```bash +# Show staged changes +git diff --cached --stat +git diff --cached +``` + +Also check recent commits for context on commit message style: + +```bash +git log --oneline -5 +``` + +### 3. **Analyze Changes** + +Examine the diff output to understand: +- **What changed**: Files modified, added, or deleted +- **Scope**: Which modules/components are affected +- **Type**: Is this a feature, fix, refactor, docs, etc.? +- **Impact**: Breaking changes, new functionality, bug fixes +- **Details**: Specific changes worth mentioning + +### 4. **Generate Commit Message** + +Create a conventional commit message following this format: + +``` +(): + + + +