Community程式設計與開發github.com

jaimegago/agent-skills

提交已暫存和未暫存的變更,並自動產生 Conventional Commit 訊息,然後將分支與遠端同步。當使用者說出「commit」、「save my changes」、「push this」、「commit and push」、「sync」或任何想提交工作並推送至遠端的變體時,請使用此技能。也適用於「ship it」、「land this」、「save and sync」或要求結束編碼階段時觸發。請勿用於複雜的 git 操作,如 rebase、cherry-pick 或合併衝突解決。

agent-skills 是什麼?

此技能旨在簡化開發者工作流程,自動執行提交和同步程式碼變更的常見步驟。它會先評估工作目錄的狀態,清理髒的子模組,然後根據使用者的要求暫存所有或特定檔案。接著,它會自動偵測並執行專案的 lint 工具(如 ESLint、gofmt、Ruff 等)進行自動修復,確保提交的程式碼品質。之後,它會根據暫存的差異分析,自動產生符合 Conventional Commit 格式的提交訊息,包括類型、範圍和主體。最後,它會將變更提交並與遠端分支同步,若遠端領先則會自動執行 rebase。此技能支援多種語言和框架,並能妥善處理邊緣情況,例如無遠端設定或分離 HEAD 狀態。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jaimegago/agent-skills/tree/HEAD/git-commit

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

工作流程

依序執行以下步驟。如果任何步驟失敗,請停止並向使用者回報。

1. 評估工作目錄

執行 git status 和 git diff(包括已暫存和未暫存)以了解變更內容。如果完全沒有變更,請告知使用者沒有可提交的內容並停止。

2. 清理髒的子模組

如果 git status 顯示子模組有「(modified content)」,但沒有暫存或預期的子模組指標變更,這些是巢狀的子子模組發生偏離(通常是因為遞迴 --remote 更新所致)。針對每個這樣的髒子模組,執行 git -C <子模組路徑> submodule update --init 以將巢狀參考還原至父子模組預期的提交。清理後,重新檢查 git status 以確認髒狀態已消失。除非使用者明確變更了子模組指標,否則請勿暫存子模組指標變更。

3. 暫存所有內容,除非使用者另有指定

如果使用者沒有指定特定檔案,請使用 git add -A 暫存所有變更(包括已追蹤和未追蹤的檔案)。如果使用者指定了特定檔案或路徑,則僅暫存這些檔案。

4. Lint 與自動修復

在提交之前,請偵測專案的 lint 工具並對已暫存檔案執行自動修復。偵測順序:

  • 專案層級的 lint 目標優先:如果 Makefile 有 lint 或 lint:fix 目標,或 package.json 有 lint 或 lint:fix 腳本,請優先使用——這會尊重專案自身的慣例。僅在沒有專案層級目標時,才移至依語言偵測。
  • Go(存在 go.mod):對已暫存的 .go 檔案執行 gofmt -w,然後執行 go vet ./...
  • JavaScript/TypeScript(存在 package.json):如果存在 ESLint 配置,請對已暫存的 JS/TS 檔案執行 npx eslint --fix。如果已配置 Prettier,也請對這些檔案執行 npx prettier --write。
  • Python(存在 pyproject.toml、setup.py 或 requirements.txt):如果已配置 Ruff,請對已暫存的 .py 檔案執行 ruff check --fix 和 ruff format。若已安裝 black,則回退使用。若以上皆非,則回退使用 flake8(僅報告,無自動修復)。
  • Rust(存在 Cargo.toml):執行 cargo fmt 和 cargo clippy --fix --allow-dirty
  • 未偵測到 linter:跳過此步驟並繼續。

自動修復後,使用 git add -u 重新暫存任何已修改的檔案。如果 linter 報告無法自動修復的錯誤,請停止並向使用者回報——請勿在已知 lint 失敗的情況下提交。

如果偵測到 linter 但二進位檔未安裝,請警告使用者並詢問是否要在不進行 lint 的情況下繼續或中止。

5. 產生提交訊息

分析暫存的差異以產生 Conventional Commit 訊息:

type(scope): short summary

Optional body with context on what changed and why.

規則:

  • type:以下之一:feat、fix、refactor、docs、test、chore、ci、perf、style、build
  • scope:可選但最好有——從受影響的主要套件、模組或目錄衍生。僅當變更範圍過於廣泛,單一 scope 無意義時才省略。
  • 摘要行:小寫、祈使語氣、句尾無句號、最多 72 個字元。
  • 主體:僅在 diff 非瑣碎且僅摘要無法為審查者提供足夠上下文時才添加。保持簡潔。
  • 多項邏輯變更:為 type/scope 選擇主要的變更,並在主體中提及次要變更。除非使用者明確要求,否則請勿拆分為多個提交。
  • 破壞性變更:新增 BREAKING CHANGE 頁尾或使用 ! 後綴(例如 feat!: ...)。
  • 如果 linter 自動修復了檔案,請在主體中提及(例如「包含 gofmt 自動修復。」)。

6. 提交

使用產生的訊息執行 git commit。對於僅有摘要的訊息,使用 -m。對於包含主體的訊息,請寫入暫存檔並使用 git commit -F 以保留換行符號,然後清理暫存檔。

7. 與遠端同步

確定目前的分支名稱。然後:

  • 如果分支有上游,執行 git push。
  • 如果分支沒有上游,執行 git push -u origin <branch-name>。
  • 如果推送因遠端領先而被拒絕,執行 git pull --rebase 然後再次推送。如果 rebase 產生衝突,請停止並報告——請勿自動解決合併衝突。

8. 確認

向使用者回報:

  • 提交雜湊(短格式)
  • 使用的提交訊息
  • 分支名稱和遠端同步狀態
  • 變更的檔案、插入行數、刪除行數(來自該提交的 git diff --stat)
  • 執行了哪個 linter(或未偵測到任何 linter)

邊緣情況

  • 未設定遠端:僅在本地提交並告知使用者。
  • 分離 HEAD:在提交前發出警告,並建議先建立一個分支。
  • 僅有未追蹤的檔案:正常暫存並提交它們。
  • 尊重 .gitignore——除非使用者明確要求,否則請勿強制新增被忽略的檔案。

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

jaimegago/agent-skills

Load general development standards. Applies to all repos. Invoke at the start of a session or when standards need reinforcing.

jaimegago/agent-skills

Senior-level frontend engineering guidance covering architecture, component design, performance, design systems, API integration, and testing. Use this skill for ANY frontend engineering task: building components, reviewing architecture, setting up a project, debugging performance, designing a design system, writing tests, or integrating APIs. Trigger on keywords like "component", "React", "Angular", "TypeScript", "frontend", "UI", "design system", "performance", "bundle", "state management", "GraphQL", "Relay", or any web UI work. Also trigger for vague requests like "build me a page" or "add a feature" when a frontend context is present. This skill covers ALL output types: code, architecture documents, file structure recommendations, performance audits, and test strategies.

jaimegago/agent-skills

Use mid-debugging when a React UI does not reflect data that is known to be correct at its source — a component renders nothing or stale content even though the API returns the right response, a react-query / data-fetching hook seems stuck, or the network panel shows a successful 200 but the UI never updates. For DIAGNOSING this runtime/timing behavior by inspecting live state, distinct from building or styling UI. Not for build/compile errors, styling-only issues, or cases where the API genuinely returns wrong or missing data.

相關技能