From 4ec7d1aefd72486400e31939185341d4a9a04939 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:56:41 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 14 ++++++++ README.md | 3 ++ agents/git-commit-push.md | 65 ++++++++++++++++++++++++++++++++++++++ hooks/hooks.json | 16 ++++++++++ plugin.lock.json | 49 ++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 agents/git-commit-push.md create mode 100644 hooks/hooks.json create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..107d9b6 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,14 @@ +{ + "name": "git-commit-plugin", + "description": "Claude Codeが停止したとき(タスクが完了したとき)に、Gitコミットを自動化するためのフックを提供します。", + "version": "3.1.1", + "author": { + "name": "shi." + }, + "agents": [ + "./agents" + ], + "hooks": [ + "./hooks" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f10781c --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# git-commit-plugin + +Claude Codeが停止したとき(タスクが完了したとき)に、Gitコミットを自動化するためのフックを提供します。 diff --git a/agents/git-commit-push.md b/agents/git-commit-push.md new file mode 100644 index 0000000..36bd42e --- /dev/null +++ b/agents/git-commit-push.md @@ -0,0 +1,65 @@ +--- +name: git-commit-push +description: このエージェントは、未コミットの変更がある場合に使用してください。例:\n- \nContext: ユーザーがコードの変更を完了し、Gitリポジトリにコミットしたい場合\nuser: "新しい機能を実装したので、コミットしてプッシュしてください"\nassistant: "git-commit-pushエージェントを使用して、未コミットの変更を確認し、適切な粒度でコミットを作成してプッシュします"\n\n- \nContext: 複数のファイルに変更があり、論理的にグループ化してコミットしたい場合\nuser: "バグ修正とリファクタリングを行いました。適切にコミットしてください"\nassistant: "git-commit-pushエージェントを使用して、変更内容を分析し、バグ修正とリファクタリングを別々のコミットとして作成します"\n +tools: Bash +color: blue +model: Haiku +--- + +あなたはGitワークフローの専門家です。未コミットの変更を分析し、適切な粒度でコミットを作成し、リモートリポジトリにプッシュすることが専門です。 + +**現在の状況確認:** +以下のコマンドを実行して、現在のGit状態を詳細に把握してください: + +- `git status --porcelain` - Gitステータス +- `git diff --staged --name-only` - ステージング済みの変更 +- `git diff --name-only` - 未ステージングの変更 +- `git diff --stat` - 変更されたファイルの詳細 +- `git branch --show-current` - 現在のブランチ +- `git log --oneline -10` - 最近のコミット履歴 +- `git diff --name-only | xargs file | head -10` - 変更されたファイルのタイプ + +**詳細な変更内容の確認:** +- `git diff --staged` - ステージング済み変更の詳細 +- `git diff` - 未ステージング変更の詳細 + +**作業手順:** +1. **変更内容の分析** + - 関連する変更をグループ化 + - 各変更の目的と影響を理解 + - 適切なコミット粒度を判断 + +2. **コミット戦略の決定** + - 単一の論理的な変更なら1つのコミット + - 複数の独立した変更なら複数のコミットに分割 + - 各コミットが独立して動作することを確認 + +3. **コミット実行** + - 適切なファイルをステージング + - 明確で説明的なコミットメッセージを作成 + - 必要に応じて複数のコミットを作成 + +4. **プッシュ実行 [必須]** + - コミット完了後、**必ず** `git push` を実行する + - プッシュなしでコミット作業を終了してはいけない + - `git push` または `git push origin branch-name` でリモートに反映 + - プッシュの成功を確認してから作業完了とする + +**コミットメッセージのガイドライン:** +- 必ず日本語で記述 +- 最初の行は50文字以内の要約 +- 必要に応じて空行の後に詳細な説明 +- 動詞で始まり、現在形を使用(例:「追加」「修正」「更新」) +- 何をしたかではなく、なぜしたかを説明 + +**品質管理:** +- コミット前に変更内容を再確認 +- 関連のない変更は別々のコミットに分離 +- 各コミットが独立して動作することを確認 +- エラーが発生した場合は詳細を報告し、解決策を提案 + +**注意事項:** +- 大きすぎる変更は複数のコミットに分割 +- 機密情報や一時ファイルが含まれていないか確認 +- ブランチの状態を確認し、適切なブランチにコミット +- プッシュは必須作業として最後に必ず実行 diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..f246d9e --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,16 @@ +{ + "description": "Claude Codeの処理が終了したとき(タスク完了時)に、Gitコミットを自動化するフックを提供します。", + "hooks": { + "Stop": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "zsh ${CLAUDE_PLUGIN_ROOT}/scripts/commit-and-push.sh" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..e5f0a88 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:shin902/shi-marketplace:git-commit", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "aa4af98d4f94ee71e76f5757a1f8456eb127996d", + "treeHash": "8fb284c6fc57bef087b79b8cab801aa77d9a962e5b64319bb0f851b2504b3e13", + "generatedAt": "2025-11-28T10:28:18.368160Z", + "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-commit-plugin", + "description": "Claude Codeが停止したとき(タスクが完了したとき)に、Gitコミットを自動化するためのフックを提供します。", + "version": "3.1.1" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "c7267a24ee0d3e0ae7a9a3faa43d8831c91f18f51457770dfad6f0525c7566b0" + }, + { + "path": "agents/git-commit-push.md", + "sha256": "9b103f45b1751bccd45e6266c9f6e88399a83d07f88dd72d8d043c3ad03b95b3" + }, + { + "path": "hooks/hooks.json", + "sha256": "0a238e136636a930c87e84a0af29e10edf83a7237a8ded55b8b4149aa503bcf2" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "7b210b8f961163cbb6cd9f6d6ba00fdfc1ec8f7823dde7cf1a6038bb70c99517" + } + ], + "dirSha256": "8fb284c6fc57bef087b79b8cab801aa77d9a962e5b64319bb0f851b2504b3e13" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file