From 599a2eee0560a8721ac9132d4bf2d2d3d9060e40 Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 06:53:28 +0900 Subject: [PATCH 1/6] feat(plugin): enhance ai-commit commands with safety, context, and improved staging Add argument-hint metadata to both commands. Replace interactive `git add -p` with file-level staging to improve reliability. Include recent git log context in organize-commits for better understanding of the codebase. Add explicit safety rules: check for merge/rebase/cherry-pick states, report failures immediately, enforce iteration limits, and require manual error handling. --- plugins/claude/ai-commit/commands/commit-staged.md | 3 +++ .../claude/ai-commit/commands/organize-commits.md | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/claude/ai-commit/commands/commit-staged.md b/plugins/claude/ai-commit/commands/commit-staged.md index f8dc277..6a35c47 100644 --- a/plugins/claude/ai-commit/commands/commit-staged.md +++ b/plugins/claude/ai-commit/commands/commit-staged.md @@ -2,6 +2,7 @@ allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git ai-commit:*) context: fork description: Commit staged changes only using git-ai-commit +argument-hint: "" --- ## Context @@ -19,9 +20,11 @@ Follow these rules strictly: - Do NOT stage, unstage, or modify any files. - If there are no staged changes, do nothing. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt a commit. - Generate and apply the commit by invoking `git ai-commit`. - Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. - Do not manually write a commit message and run `git commit` directly. +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. - Do not output explanations or confirmations. Respond with tool invocations only. diff --git a/plugins/claude/ai-commit/commands/organize-commits.md b/plugins/claude/ai-commit/commands/organize-commits.md index f4c3522..6e1d54d 100644 --- a/plugins/claude/ai-commit/commands/organize-commits.md +++ b/plugins/claude/ai-commit/commands/organize-commits.md @@ -2,6 +2,7 @@ allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git reset:*), Bash(git ai-commit:*), Bash(git log:*) context: fork description: Organize changes into atomic commits using git-ai-commit +argument-hint: "" --- ## Context @@ -10,6 +11,7 @@ description: Organize changes into atomic commits using git-ai-commit - Staged diff: !`git diff --staged` - Unstaged diff: !`git diff` - Current branch: !`git branch --show-current` +- Recent commits: !`git log --oneline -10 2>/dev/null || true` ## Your task @@ -26,13 +28,20 @@ You must create multiple commits if needed. Prefer small, coherent commits over 2) Execute loop (repeat for each logical unit) - Step A: Identify the exact files or hunks that belong to one unit. - Step B: Stage only that unit. - - Prefer partial staging with `git add -p ` when a file contains mixed changes. - - If you staged something by mistake, fix it with `git reset -p ` (or `git reset ` if appropriate). + - Use `git add ` to stage entire files. + - When a file contains changes belonging to different logical units, stage the whole file in the unit where the majority of changes belong. + - If you staged something by mistake, fix it with `git reset `. - Step C: Create the commit by invoking `git ai-commit`. - Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. - Do not manually write a commit message and run `git commit` directly. - Step D: Repeat until `git status` is clean (no staged or unstaged changes). +### Safety rules + +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt commits. +- Do not loop more than 20 iterations. If changes remain after 20 commits, stop and report. + ### Output rules - Respond with tool invocations only (no explanations, no confirmations). From 68095279b054d94b33a711a51e8ec229b7a56b2f Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 06:53:43 +0900 Subject: [PATCH 2/6] feat(plugin): add repository field to plugin.json manifest --- plugins/claude/ai-commit/.claude-plugin/plugin.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/claude/ai-commit/.claude-plugin/plugin.json b/plugins/claude/ai-commit/.claude-plugin/plugin.json index aff2008..f051d13 100644 --- a/plugins/claude/ai-commit/.claude-plugin/plugin.json +++ b/plugins/claude/ai-commit/.claude-plugin/plugin.json @@ -4,5 +4,6 @@ "version": "0.1.0", "author": { "name": "Naoto Takai" - } + }, + "repository": "https://github.com/takai/git-ai-commit" } From f6e3331de9a3570f97316110f2718b23aa2147a1 Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 06:53:57 +0900 Subject: [PATCH 3/6] docs(plugin): update README installation instructions for in-repo usage - Add guidance for using plugin from go install source tree - Document plugin-dir and symlink registration options - Clarify installation workflow for local development --- plugins/claude/ai-commit/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/claude/ai-commit/README.md b/plugins/claude/ai-commit/README.md index 5bfd119..d1c381f 100644 --- a/plugins/claude/ai-commit/README.md +++ b/plugins/claude/ai-commit/README.md @@ -9,10 +9,16 @@ A Claude Code plugin that organizes git changes into atomic, logical commits usi ## Installation -Clone this repository into your Claude Code plugins directory: +If you installed `git-ai-commit` via `go install`, the plugin is already available at `plugins/claude/ai-commit/` inside the source tree. + +To register it with Claude Code, add the plugin directory to your project or global settings: ```bash -git clone https://github.com/takai/git-ai-commit-plugin ~/.claude/plugins/git-ai-commit-plugin +# If you have the git-ai-commit source cloned +claude --plugin-dir /path/to/git-ai-commit/plugins/claude/ai-commit + +# Or symlink into your plugins directory +ln -s /path/to/git-ai-commit/plugins/claude/ai-commit ~/.claude/plugins/ai-commit ``` ## Usage @@ -37,7 +43,7 @@ Organizes pending changes into multiple atomic commits. The command: - Examines current git status and diffs - Groups related changes together -- Stages files/hunks for each logical unit +- Stages files for each logical unit - Invokes `git ai-commit` to generate commit messages automatically ### `/ai-commit:commit-staged` From 6ec6cd84eb6941ec57c3614ce680d96f0801ef54 Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 06:57:49 +0900 Subject: [PATCH 4/6] feat(plugin): add commit-all command for staging and committing all changes --- plugins/claude/ai-commit/README.md | 7 +++++ .../claude/ai-commit/commands/commit-all.md | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 plugins/claude/ai-commit/commands/commit-all.md diff --git a/plugins/claude/ai-commit/README.md b/plugins/claude/ai-commit/README.md index d1c381f..503f798 100644 --- a/plugins/claude/ai-commit/README.md +++ b/plugins/claude/ai-commit/README.md @@ -46,6 +46,13 @@ Organizes pending changes into multiple atomic commits. The command: - Stages files for each logical unit - Invokes `git ai-commit` to generate commit messages automatically +### `/ai-commit:commit-all` + +Stages all pending changes and commits them as a single commit. The command: + +- Stages all tracked and untracked changes with `git add -A` +- Invokes `git ai-commit` to generate the commit message automatically + ### `/ai-commit:commit-staged` Commits only the currently staged changes. The command: diff --git a/plugins/claude/ai-commit/commands/commit-all.md b/plugins/claude/ai-commit/commands/commit-all.md new file mode 100644 index 0000000..a2925a4 --- /dev/null +++ b/plugins/claude/ai-commit/commands/commit-all.md @@ -0,0 +1,31 @@ +--- +allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git ai-commit:*) +context: fork +description: Stage all changes and commit using git-ai-commit +argument-hint: "" +--- + +## Context + +- Current git status: !`git status` +- Staged diff: !`git diff --staged` +- Unstaged diff: !`git diff` +- Current branch: !`git branch --show-current` +- Recent commits: !`git log --oneline -10 2>/dev/null || true` + +## Your task + +Stage **all** pending changes (both staged and unstaged) and create a single Git commit. + +Follow these rules strictly: + +- If there are no staged or unstaged changes, do nothing. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt a commit. +- Stage all changes with `git add -A`. +- Generate and apply the commit by invoking `git ai-commit`. +- Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. +- Do not manually write a commit message and run `git commit` directly. +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. +- Do not output explanations or confirmations. + +Respond with tool invocations only. From 380f8ffe07f8acce54d0adaf704a3b838ed23920 Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 07:04:23 +0900 Subject: [PATCH 5/6] refactor(plugin): shorten ai-commit command names to reduce redundancy Rename commands from `organize-commits`, `commit-all`, and `commit-staged` to `organize`, `all`, and `staged` respectively. This eliminates repetition of the "commit" keyword which is already present in the plugin name `ai-commit`. --- plugins/claude/ai-commit/README.md | 26 +++++++++---------- .../commands/{commit-all.md => all.md} | 2 +- .../{organize-commits.md => organize.md} | 0 .../commands/{commit-staged.md => staged.md} | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) rename plugins/claude/ai-commit/commands/{commit-all.md => all.md} (94%) rename plugins/claude/ai-commit/commands/{organize-commits.md => organize.md} (100%) rename plugins/claude/ai-commit/commands/{commit-staged.md => staged.md} (94%) diff --git a/plugins/claude/ai-commit/README.md b/plugins/claude/ai-commit/README.md index 503f798..9b505fb 100644 --- a/plugins/claude/ai-commit/README.md +++ b/plugins/claude/ai-commit/README.md @@ -26,7 +26,7 @@ ln -s /path/to/git-ai-commit/plugins/claude/ai-commit ~/.claude/plugins/ai-commi In any git repository with Claude Code, run: ``` -/ai-commit:organize-commits +/ai-commit:organize ``` The plugin will: @@ -37,29 +37,29 @@ The plugin will: ## Commands -### `/ai-commit:organize-commits` +### `/ai-commit:staged` -Organizes pending changes into multiple atomic commits. The command: +Commits only the currently staged changes. The command: -- Examines current git status and diffs -- Groups related changes together -- Stages files for each logical unit -- Invokes `git ai-commit` to generate commit messages automatically +- Works exclusively with already staged changes +- Does not stage, unstage, or modify any files +- Invokes `git ai-commit` to generate the commit message automatically -### `/ai-commit:commit-all` +### `/ai-commit:all` Stages all pending changes and commits them as a single commit. The command: - Stages all tracked and untracked changes with `git add -A` - Invokes `git ai-commit` to generate the commit message automatically -### `/ai-commit:commit-staged` +### `/ai-commit:organize` -Commits only the currently staged changes. The command: +Organizes pending changes into multiple atomic commits. The command: -- Works exclusively with already staged changes -- Does not stage, unstage, or modify any files -- Invokes `git ai-commit` to generate the commit message automatically +- Examines current git status and diffs +- Groups related changes together +- Stages files for each logical unit +- Invokes `git ai-commit` to generate commit messages automatically ## License diff --git a/plugins/claude/ai-commit/commands/commit-all.md b/plugins/claude/ai-commit/commands/all.md similarity index 94% rename from plugins/claude/ai-commit/commands/commit-all.md rename to plugins/claude/ai-commit/commands/all.md index a2925a4..b6e0b0a 100644 --- a/plugins/claude/ai-commit/commands/commit-all.md +++ b/plugins/claude/ai-commit/commands/all.md @@ -1,7 +1,7 @@ --- allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git ai-commit:*) context: fork -description: Stage all changes and commit using git-ai-commit +description: Stage and commit all changes using git-ai-commit argument-hint: "" --- diff --git a/plugins/claude/ai-commit/commands/organize-commits.md b/plugins/claude/ai-commit/commands/organize.md similarity index 100% rename from plugins/claude/ai-commit/commands/organize-commits.md rename to plugins/claude/ai-commit/commands/organize.md diff --git a/plugins/claude/ai-commit/commands/commit-staged.md b/plugins/claude/ai-commit/commands/staged.md similarity index 94% rename from plugins/claude/ai-commit/commands/commit-staged.md rename to plugins/claude/ai-commit/commands/staged.md index 6a35c47..31acbe0 100644 --- a/plugins/claude/ai-commit/commands/commit-staged.md +++ b/plugins/claude/ai-commit/commands/staged.md @@ -1,7 +1,7 @@ --- allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git ai-commit:*) context: fork -description: Commit staged changes only using git-ai-commit +description: Commit staged changes using git-ai-commit argument-hint: "" --- From 2c2c8f8f56ac1c39324aa52b48d6d281614112dc Mon Sep 17 00:00:00 2001 From: Naoto Takai Date: Wed, 4 Feb 2026 07:09:40 +0900 Subject: [PATCH 6/6] chore(plugin): bump ai-commit version to 0.2.0 BREAKING CHANGE: Command names have been renamed to reduce redundancy. Use the new shortened command names in place of previous versions. --- plugins/claude/ai-commit/.claude-plugin/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/claude/ai-commit/.claude-plugin/plugin.json b/plugins/claude/ai-commit/.claude-plugin/plugin.json index f051d13..ddb22db 100644 --- a/plugins/claude/ai-commit/.claude-plugin/plugin.json +++ b/plugins/claude/ai-commit/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "ai-commit", "description": "Generate Git commit messages from staged diffs and apply them automatically, using git-ai-commit as the execution backend.", - "version": "0.1.0", + "version": "0.2.0", "author": { "name": "Naoto Takai" },