Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/claude/ai-commit/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"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"
}
},
"repository": "https://github.com/takai/git-ai-commit"
}
39 changes: 26 additions & 13 deletions plugins/claude/ai-commit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ 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

In any git repository with Claude Code, run:

```
/ai-commit:organize-commits
/ai-commit:organize
```

The plugin will:
Expand All @@ -31,23 +37,30 @@ The plugin will:

## Commands

### `/ai-commit:organize-commits`

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
- Invokes `git ai-commit` to generate commit messages automatically

### `/ai-commit:commit-staged`
### `/ai-commit:staged`

Commits only the currently staged changes. 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

### `/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:organize`

Organizes pending changes into multiple atomic commits. 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

## License

MIT
31 changes: 31 additions & 0 deletions plugins/claude/ai-commit/commands/all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git ai-commit:*)
context: fork
description: Stage and commit all changes 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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 <path>` when a file contains mixed changes.
- If you staged something by mistake, fix it with `git reset -p <path>` (or `git reset <path>` if appropriate).
- Use `git add <path>` 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 <path>`.
- 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).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
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: ""
---

## Context
Expand All @@ -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.