关于
The commit-changes skill stages, commits, and amends Git changes using conventional commit messages. It enables selective staging, descriptive message writing via HEREDOC, and commit history verification. Use it when saving a logical unit of work to version control or creating/amending a commit with a proper conventional message.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/commit-changes在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
提交變更
選擇性暫存文件、撰寫清晰的提交訊息,並驗證提交歷史。
適用時機
- 將一個邏輯工作單元保存至版本控制
- 以描述性、符合慣例的訊息建立提交
- 修訂最近一次提交(訊息或內容)
- 提交前審查將納入提交的變更
輸入
- 必要:一個或多個待提交的變更文件
- 選擇性:提交訊息(若未提供則代為擬定)
- 選擇性:是否修訂前次提交
- 選擇性:共同作者標註
步驟
步驟一:審查當前變更
檢查工作樹狀態並察看差異:
# See which files are modified, staged, or untracked
git status
# See unstaged changes
git diff
# See staged changes
git diff --staged
預期: 清晰呈現所有已修改、已暫存與未追蹤的文件。
失敗時: 若 git status 失敗,驗證當前是否位於 git 倉庫內(git rev-parse --is-inside-work-tree)。
步驟二:選擇性暫存文件
以具名方式暫存特定文件,避免使用 git add . 或 git add -A,以免意外納入敏感文件或無關變更:
# Stage specific files by name
git add src/feature.R tests/test-feature.R
# Stage all changes in a specific directory
git add src/
# Stage parts of a file interactively (not supported in non-interactive contexts)
# git add -p filename
提交前審查已暫存內容:
git diff --staged
預期: 僅有預期的文件與變更被暫存。無 .env、憑證或大型二進制文件。
失敗時: 以 git reset HEAD <file> 取消暫存誤加的文件。若敏感資料已暫存,提交前立即取消暫存。
步驟三:撰寫提交訊息
採用慣例式提交格式。務必透過 HEREDOC 傳入訊息以確保格式正確:
git commit -m "$(cat <<'EOF'
feat: add weighted mean calculation
Implements weighted_mean() with support for NA handling and
zero-weight filtering. Includes input validation for mismatched
vector lengths.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
EOF
)"
慣例式提交類型:
| 類型 | 使用時機 |
|---|---|
feat | 新功能 |
fix | 錯誤修復 |
docs | 僅文件 |
test | 新增或更新測試 |
refactor | 既不修復亦不新增功能之代碼變更 |
chore | 構建、CI、依賴更新 |
style | 格式、空白(無邏輯變更) |
預期: 提交已建立,訊息具描述性,說明為何而非僅何事。
失敗時: 若 pre-commit 鉤子失敗,修復問題,以 git add 重新暫存,並建立新提交(勿用 --amend,因失敗的提交從未建立)。
步驟四:修訂最後一次提交(選擇性)
僅在提交尚未推送至共享遠端時修訂:
# Amend message only
git commit --amend -m "$(cat <<'EOF'
fix: correct weighted mean edge case for empty vectors
EOF
)"
# Amend with additional staged changes
git add forgotten-file.R
git commit --amend --no-edit
預期: 前次提交已就地更新。git log -1 顯示修訂後的內容。
失敗時: 若提交已推送,勿修訂。改建新提交。對共享分支強制推送已修訂提交會造成歷史分歧。
步驟五:驗證提交
# View the last commit
git log -1 --stat
# View recent commit history
git log --oneline -5
# Verify the commit content
git show HEAD
預期: 提交以正確的訊息、作者與文件變更出現於歷史中。
失敗時: 若提交包含錯誤文件,用 git reset --soft HEAD~1 撤銷提交同時保留暫存變更,再重新正確提交。
驗證
- 僅預期文件納入提交
- 無敏感資料(權杖、密碼、
.env文件)被提交 - 提交訊息遵循慣例式提交格式
- 訊息主體說明變更之因由
-
git log顯示提交具正確元資料 - Pre-commit 鉤子(如有)已通過
常見陷阱
- 一次提交過多:每次提交應代表一個邏輯變更。將無關變更拆分為獨立提交。
- 盲目使用
git add .:務必先審查git status。優先以具名方式暫存特定文件。 - 修訂已推送提交:切勿修訂已推送至共享分支的提交。此舉改寫歷史,為協作者帶來困擾。
- 模糊的提交訊息:「修復錯誤」或「更新」毫無訊息量。描述變更了什麼及為何。
- 內容修訂時遺漏
--no-edit:將遺漏文件加入最後一次提交時,用--no-edit保留既有訊息。 - 鉤子失敗後使用
--amend:當 pre-commit 鉤子失敗,提交從未建立。使用--amend將修改前次提交。修復鉤子問題後應建立新提交。
相關技能
manage-git-branches— 提交前的分支工作流程create-pull-request— 提交後的下一步resolve-git-conflicts— 處理合併或 rebase 時的衝突configure-git-repository— 倉庫設置與慣例
GitHub 仓库
Frequently asked questions
What is the commit-changes skill?
commit-changes is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform commit-changes-related tasks without extra prompting.
How do I install commit-changes?
Use the install commands on this page: add commit-changes to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does commit-changes belong to?
commit-changes is in the Meta category, tagged general.
Is commit-changes free to use?
Yes. commit-changes is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.
相关推荐技能
Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
