跳到正文
Skillpedia
通用编程33k · #8878

commit-work

它能做什么

这项技能帮你的智能体准备易于审查的 git 提交。适合希望每次提交只包含预定改动,并且提交信息清楚描述这些改动的开发者。

适用场景

  • ✓当你想提交工作成果,并需要先审查改动并正确暂存时。
  • ✓当你的改动混合了几项无关任务,应拆分为独立的提交时。
  • ✓当你想要 Conventional Commits 格式的提交信息的时候。

技能链接

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/productivity/commit-work/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/productivity/commit-work/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我提交改动,但把重构和新功能拆分成两个独立的提交,并写清楚提交信息。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查工作区,判断每次提交的起点和终点,只暂存应属于该提交的内容,检查暂存差异中是否有机密信息或调试代码,然后编写提交信息。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Commit work

Goal

Make commits that are easy to review and safe to ship:

  • only intended changes are included
  • commits are logically scoped (split when needed)
  • commit messages describe what changed and why

Inputs to ask for (if missing)

  • Single commit or multiple commits? (If unsure: default to multiple small commits when there are unrelated changes.)
  • Commit style: Conventional Commits are required.
  • Any rules: max subject length, required scopes.

Workflow (checklist)

  1. Inspect the working tree before staging
    • git status
    • git diff (unstaged)
    • If many changes: git diff --stat
  2. Decide commit boundaries (split if needed)
    • Split by: feature vs refactor, backend vs frontend, formatting vs logic, tests vs prod code, dependency bumps vs behavior changes.
    • If changes are mixed in one file, plan to use patch staging.
  3. Stage only what belongs in the next commit
    • Prefer patch staging for mixed changes: git add -p
    • To unstage a hunk/file: git restore --staged -p or git restore --staged <path>
  4. Review what will actually be committed
    • git diff --cached
    • Sanity checks:
      • no secrets or tokens
      • no accidental debug logging
      • no unrelated formatting churn
  5. Describe the staged change in 1-2 sentences (before writing the message)
    • "What changed?" + "Why?"
    • If you cannot describe it cleanly, the commit is probably too big or mixed; go back to step 2.
  6. Write the commit message
    • Use Conventional Commits (required):
      • type(scope): short summary
      • blank line
      • body (what/why, not implementation diary)
      • footer (BREAKING CHANGE) if needed
    • Prefer an editor for multi-line messages: git commit -v
    • Use references/commit-message-template.md if helpful.
  7. Run the smallest relevant verification
    • Run the repo's fastest meaningful check (unit tests, lint, or build) before moving on.
  8. Repeat for the next commit until the working tree is clean

Deliverable

Provide:

  • the final commit message(s)
  • a short summary per commit (what/why)
  • the commands used to stage/review (at minimum: git diff --cached, plus any tests run)
常见问题

如果一个文件的改动属于两次提交怎么办?

这项技能使用分块暂存,让你只暂存文件中的部分改动。

提交前它会检查什么?

它会检查机密信息或令牌、误留的调试日志,以及无关的格式改动。

它使用哪种提交格式?

Conventional Commits,这是这项技能要求的格式。

详情

作者的原始描述

Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.

repo: davila7/claude-code-templates

热度

GitHub 星标
33k
排名
#8878
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能