agentleFS
deancoursedeancourse/claude-code-docker-container/.agents/skills/git-smart-commit/SKILL.md

Git Smart Commit

Skill18 starsChanged 2 months agoMITView on GitHub

將雜亂的 git 變更,依功能邏輯自動拆分成多個有意義的 conventional commit

  • Reads credentials

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. deancourse/openspec-agent-skills-practice★ 2100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository3 other files it gives its agents.

The file

Files
SKILL.md

Git Smart Commit — 智慧拆分提交

將目前所有 staged / unstaged 變更,依功能邏輯分群後,逐批 git add + git commit。


流程

1. 檢查變更狀態

執行以下指令取得完整變更清單:

git status --short

若沒有任何變更,告知使用者「目前沒有需要提交的變更」後結束。

接著取得所有變更的 diff 內容(用來判斷分群邏輯):

git diff
git diff --cached

2. 分析並分群

根據以下維度,將檔案變更分成多個 commit 群組,每組代表一個獨立的邏輯單元:

分群依據(優先順序)

優先級維度範例
1專案腳手架 / 設定檔package.json, vite.config.*, .gitignore, README.md, tsconfig.json
2資料層 / config datasrc/data/*.js, src/constants/*, src/config/*
3元件(按元件名稱分組)src/components/Hero.jsx + 對應測試 + 對應樣式
4頁面 / 路由src/pages/*, src/routes/*, src/App.jsx
5全域樣式src/index.css, src/styles/*, src/theme/*
6工具 / hooks / 型別src/utils/*, src/hooks/*, src/types/*
7測試__tests__/*, *.test.*, *.spec.*
8文件 / 其他docs/*, *.md(非 README), 其他雜項

分群規則

  • 同一元件的 JSX/TSX + CSS Module + 測試 → 歸為同一組
  • 相關的資料檔如果是為某個元件服務 → 可考慮合併或獨立,取決於變更量
  • 若某一組只有 1 個檔案且改動極小(< 5 行)→ 合併到最相關的鄰近組
  • 新增檔案用 feat,修改用 fix / refactor / style,刪除用 chore

3. 產出 Commit 計畫

在執行任何 git 操作之前,先列出計畫讓使用者確認:

📋 Commit 計畫(共 N 個 commit)

1. chore(project): 初始化專案設定與相依套件
   → package.json, vite.config.js, .gitignore

2. feat(data): 新增首頁各區塊的設定資料
   → src/data/navigation.js, src/data/hero.js, ...

3. feat(navbar): 新增 Navbar 元件(含 RWD 漢堡選單)
   → src/components/Navbar.jsx

...

確認執行?(Y/n)

使用 notify_user 工具向使用者展示計畫並等待確認。


4. 逐批執行 Commit

使用者確認後,對每一組依序執行:

git add <file1> <file2> ...
git commit -m "<type>(<scope>): <subject>"

Commit Message 格式

<type>(<scope>): <簡短描述,繁體中文>

type 對照表:

type使用時機
feat新增功能、元件、頁面
fix修復 bug
style純樣式調整(不影響邏輯)
refactor重構(不改變行為)
chore雜務(設定檔、腳手架、CI)
docs文件更新
test測試相關

scope 規則:

  • 元件:用元件名稱小寫,例如 hero, navbar, pricing
  • 資料層:data
  • 全域樣式:style
  • 專案設定:project
  • 多個範圍:用最主要的一個,不要用斜線串接

subject 規則:

  • 使用繁體中文
  • 不超過 50 字
  • 不以句號結尾
  • 用「動詞開頭」:新增、調整、修正、移除、重構

5. 確認結果

所有 commit 完成後,執行:

git log --oneline -20

將結果展示給使用者,確認所有 commit 都已正確建立。


邊界情況處理

  • 有衝突或 merge 狀態:提醒使用者先解決衝突,不執行任何操作
  • 有 .env 或敏感檔案:提醒使用者確認是否應被 gitignore,不自動提交
  • 變更量極大(> 50 個檔案):先產出分組摘要,請使用者確認後再執行
  • 使用者已有部分 staged 變更:尊重已 staged 的狀態,將其視為一個獨立群組或合併到最相關的群組

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.