commit 3b4f3145ad3204e596e63f02c7e8a017a0053a78 Author: Zhongwei Li Date: Sun Nov 30 08:41:01 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..865f2ba --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,24 @@ +{ + "name": "git", + "description": "Git workflow automation with smart commits, conflict resolution, rebase management, worktree creation, and worktree cleanup", + "version": "0.18.0", + "author": { + "name": "Craig Motlin" + }, + "skills": [ + "./skills/git-workflow/SKILL.md" + ], + "agents": [ + "./agents/commit-handler.md", + "./agents/rebaser.md", + "./agents/conflict-resolver.md" + ], + "commands": [ + "./commands/worktree.md", + "./commands/commit.md", + "./commands/commit-chunks.md", + "./commands/conflicts.md", + "./commands/rebase-all.md", + "./commands/clean-worktrees.md" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c46eaa5 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# git + +Git workflow automation with smart commits, conflict resolution, rebase management, worktree creation, and worktree cleanup diff --git a/agents/commit-handler.md b/agents/commit-handler.md new file mode 100644 index 0000000..6b6b755 --- /dev/null +++ b/agents/commit-handler.md @@ -0,0 +1,9 @@ +--- +name: commit-handler +description: Commit local changes to git +model: haiku +color: red +skills: code:cli +--- + +See [shared/git-commit-instructions.md](../shared/git-commit-instructions.md) for commit context. diff --git a/agents/conflict-resolver.md b/agents/conflict-resolver.md new file mode 100644 index 0000000..8c16b90 --- /dev/null +++ b/agents/conflict-resolver.md @@ -0,0 +1,9 @@ +--- +name: conflict-resolver +description: Use this agent to handle git merge conflicts +model: haiku +color: yellow +skills: code:cli +--- + +See [shared/conflict-resolution-instructions.md](../shared/conflict-resolution-instructions.md) for conflict resolution instructions. diff --git a/agents/rebaser.md b/agents/rebaser.md new file mode 100644 index 0000000..a0372e8 --- /dev/null +++ b/agents/rebaser.md @@ -0,0 +1,47 @@ +--- +name: rebaser +description: Use this agent to rebase local commits on top of the upstream remote/branch after committing code to git.\n\n\nContext: The user has just committed code and wants to rebase on upstream changes.\nuser: "Now rebase my changes on the upstream branch"\nassistant: "I'll use the rebaser agent to rebase your commits on top of the upstream branch."\n\n\n\n\nContext: Code has been committed using the commit-handler agent.\nuser: "Implement the new authentication feature"\nassistant: "I've implemented the authentication feature and committed the changes."\n\nassistant: "Now I'll rebase these changes on the upstream branch to ensure they're up to date."\n\nAfter committing, launch the rebaser agent to rebase on upstream.\n\n +model: haiku +color: orange +--- + +Rebase local git commits on upstream branch. + +You rebase local git commits on top of the upstream remote/branch. + +**Your Primary Responsibilities:** + +1. **Pre-rebase Verification**: First, verify there are no uncommitted changes using `git status`. If there are uncommitted changes, stop immediately and report this to the user - do not proceed with the rebase. + +2. **Execute Rebase**: Run `${CLAUDE_PLUGIN_ROOT}/scripts/rebase` to perform the rebase operation. This script reads the project's configured upstream remote and branch (usually origin/main) from environment variables. + + **CRITICAL**: You MUST use `${CLAUDE_PLUGIN_ROOT}/scripts/rebase`. Do NOT use: + - `git rebase` (doesn't know which upstream to use) + - `git pull --rebase` (uses tracking info, would rebase onto origin/) + - `git rebase @{upstream}` (uses tracking info, not the configured upstream) + - Any other git rebase variant + + Do not add any arguments or environment variables to this command. + +3. **Handle Outcomes**: + - **Success**: If the rebase completes without errors, report success and exit. Your work is complete. + - **Merge Conflicts**: If the command fails due to merge conflicts, immediately invoke the git-rebase-conflict-resolver agent to handle the conflicts. Do not attempt to resolve conflicts yourself. + - **Other Errors**: If the rebase fails for reasons other than merge conflicts, report the specific error to the user and stop. + +**Operational Guidelines:** + +- You must execute exactly one rebase attempt per invocation +- Do not modify any files or make any commits yourself +- Do not attempt to continue or abort rebases manually - the conflict resolver agent handles all conflict resolution workflows +- Trust that the rebase script knows how to find the correct upstream +- After delegating to the git-rebase-conflict-resolver agent for conflicts, consider your task complete - that agent will handle the entire conflict resolution process + +**Workflow:** + +1. Check `git status` for uncommitted changes +2. Execute `${CLAUDE_PLUGIN_ROOT}/scripts/rebase` +3. If successful: Report success and exit +4. If conflicts: Invoke git-rebase-conflict-resolver agent and exit +5. If other error: Report error and exit + +You are a focused, single-purpose agent. Once you've either completed the rebase successfully or delegated conflict resolution, your task is complete. diff --git a/commands/clean-worktrees.md b/commands/clean-worktrees.md new file mode 100644 index 0000000..a3f7327 --- /dev/null +++ b/commands/clean-worktrees.md @@ -0,0 +1,13 @@ +--- +argument-hint: worktree paths +description: Remove git worktrees safely +--- + +๐Ÿงน Remove the following worktrees, as long it is possible to do so without using the `--force` flag. + +$ARGUMENTS + +- Don't bother checking if the repo has changes with `git -C status --porcelain` +- Don't bother checking for unpushed commits with `git -C log` + +Just run `git worktree remove ` and git will exit with an error code if it's not safe to do so and if `--force` is correctly ommitted. diff --git a/commands/commit-chunks.md b/commands/commit-chunks.md new file mode 100644 index 0000000..66d474f --- /dev/null +++ b/commands/commit-chunks.md @@ -0,0 +1,9 @@ +--- +description: Split local changes into multiple logical commits +--- + +๐Ÿ“ Commit the local changes to git. Analyze my local changes and propose splitting them into multiple logical commits. + +For each proposed commit, show me the message and the list of files. Show all proposals at once. Wait for my confirmation, then commit all. + +See [shared/git-commit-instructions.md](../shared/git-commit-instructions.md) for commit context. diff --git a/commands/commit.md b/commands/commit.md new file mode 100644 index 0000000..58e29cf --- /dev/null +++ b/commands/commit.md @@ -0,0 +1,5 @@ +--- +description: Commit local changes to git +--- + +See [shared/git-commit-instructions.md](../shared/git-commit-instructions.md) for commit context. diff --git a/commands/conflicts.md b/commands/conflicts.md new file mode 100644 index 0000000..b32baf0 --- /dev/null +++ b/commands/conflicts.md @@ -0,0 +1,5 @@ +--- +description: Fix all merge conflicts and continue the git rebase +--- + +See [shared/conflict-resolution-instructions.md](../shared/conflict-resolution-instructions.md) for conflict resolution instructions. diff --git a/commands/rebase-all.md b/commands/rebase-all.md new file mode 100644 index 0000000..b4b18af --- /dev/null +++ b/commands/rebase-all.md @@ -0,0 +1,20 @@ +--- +description: Rebase all branches onto a configurable upstream branch +--- + +Keep all branches in a repository up-to-date by rebasing them onto a configurable upstream branch. + +Initial Rebase Attempt: Run `${CLAUDE_PLUGIN_ROOT}/scripts/git-all` to attempt rebasing all branches. + +- If the command fails with merge conflicts, use the `git-rebase-conflict-resolver` agent to resolve all conflicts in the affected branch +- After resolving conflicts run `${CLAUDE_PLUGIN_ROOT}/scripts/git-all` again. +- Continue this cycle until the command completes successfully without errors or conflicts. + +When communicating: + +- Clearly indicate which branch you're working on. +- Summarize the conflicts found. +- Report progress after each iteration. +- Notify when the entire rebase process is complete. + +Remember: Your goal is to ensure all branches are successfully rebased onto the upstream branch, with all conflicts properly resolved. diff --git a/commands/worktree.md b/commands/worktree.md new file mode 100644 index 0000000..b0b9fe4 --- /dev/null +++ b/commands/worktree.md @@ -0,0 +1,44 @@ +--- +argument-hint: branch-name +description: Create a git worktree in a peer directory +--- + +Create a git worktree in a peer directory. + +## Arguments + +The argument should be a kebab-case task name (e.g., "auth-feature", "database-migration"). + +The user passed in: `$ARGUMENTS` + +If that text is already kebab case, use it directly as the branch name. Otherwise come up with a good kebab-case name based on what the user passed in. + +## Steps + +- Run `bash ${CLAUDE_PLUGIN_ROOT}/scripts/worktree.sh ` from the repository root +- If the command exits with a non-success exit code, stop here and give a good summary to the user + +## Conclusion + +Run a command to create a new terminal tab in the newly created worktree. + +If we are running in iTerm: + +```console +osascript -e 'tell application "iTerm" + tell current window + create tab with default profile + tell current tab + tell current session + write text "cd " + end tell + end tell + end tell +end tell' +``` + +If we are running in xfce4-terminal: + +```console +xfce4-terminal --tab --working-directory="" -x bash -c "cd ; exec bash" +``` diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..91cbb36 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,81 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:motlin/claude-code-plugins:plugins/git", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "2ee0fa2c272f9f7802d184b0f401a3c04722b19b", + "treeHash": "8a75099157faa4c9d8deca3733cd174edeaac36e3144a7ece3af3e20253287eb", + "generatedAt": "2025-11-28T10:27:09.891915Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "git", + "description": "Git workflow automation with smart commits, conflict resolution, rebase management, worktree creation, and worktree cleanup", + "version": "0.18.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "907d0c37ef618b16700e428c94e9bd89c197311c9772b7ab6014feeef92f4988" + }, + { + "path": "agents/commit-handler.md", + "sha256": "ffd95e4ce8ee98c109325b0c48165108e9ff8733d03683c1c44f8ba2b8d2efde" + }, + { + "path": "agents/conflict-resolver.md", + "sha256": "491e3e46d07ba766ac2608314fe45c3984b2aed51e867e370440ec865546d18d" + }, + { + "path": "agents/rebaser.md", + "sha256": "2c95f9bafcdb1c68f8e47aca594711d0a0f19af7e519976e50a44c90a994eba5" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "f5a0ad8aa0a7d875e4031c146e01b16de1efd48c4cbb9f0d83b1deef0fb53cde" + }, + { + "path": "commands/worktree.md", + "sha256": "478cd3d41cabddbd7ef21e69e4cd33c333ce973f26e7328309242a76e542c739" + }, + { + "path": "commands/conflicts.md", + "sha256": "ec3ca4cd7797f6fab043318ee14fd89fb7ec033e3a4d4b9c0d43e2edd91ff7df" + }, + { + "path": "commands/clean-worktrees.md", + "sha256": "26151f58ff8a0e716fe02e7fe34060628a7115dea3dd72a1ce324027d63d64fd" + }, + { + "path": "commands/rebase-all.md", + "sha256": "aeca10c5f80b06ea6d8335c227f8e2f85ef900eb8bba63ad14bbbc09ec060b11" + }, + { + "path": "commands/commit.md", + "sha256": "c22786d637e67a63be1da1368e129fe64e8e5f3a87c87d9c2fc08239c26ae4dd" + }, + { + "path": "commands/commit-chunks.md", + "sha256": "c092bb4dddeeb2c5a9b6dc5afdc10f577875e4e4322ba31a1d0ff44e0d73397b" + }, + { + "path": "skills/git-workflow/SKILL.md", + "sha256": "ddbfcb4d3745812dfad7f7b3f5218b458bbfc06e2354c4346c5382dcb6f3a5f7" + } + ], + "dirSha256": "8a75099157faa4c9d8deca3733cd174edeaac36e3144a7ece3af3e20253287eb" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/git-workflow/SKILL.md b/skills/git-workflow/SKILL.md new file mode 100644 index 0000000..0fd83d5 --- /dev/null +++ b/skills/git-workflow/SKILL.md @@ -0,0 +1,30 @@ +--- +name: git-workflow +description: Git workflow best practices for commits, rebasing, conflict resolution, and branch management. Use when working with git operations, creating commits, resolving conflicts, or managing branches. +--- + +# Git Workflow Best Practices + +This skill provides guidelines for git operations including commits, conflict resolution, and branch management. + +## Commit Guidelines + +Use the `/git:commit` command or `git:commit-handler` agent. + +## Splitting Changes into Multiple Commits + +Use the `/git:commit-chunks` command. + +## Conflict Resolution + +Use the `/git:conflicts` command or `git:conflict-resolver` agent. + +## Rebasing All Branches + +Use the `/git:rebase-all` command. + +## Worktree Management + +Use the `/git:worktree` command for creating worktrees. + +Use the `/git:clean-worktrees` command for cleaning up worktrees.