返回技能列表

commit-changes

pjt222
更新于 2 days ago
5 次查看
17
2
17
在 GitHub 上查看
文档general

关于

This Claude Skill handles Git staging, committing, and amending with support for conventional commit messages. It enables selective staging, commit message review via HEREDOC, and verification of history before finalizing. Use it to save logical units of work, amend the previous commit, or ensure staged changes are correct.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/commit-changes

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Commit Changes

Stage selective → clear msg → verify history.

Use When

  • Save logical unit → version control
  • Write conventional msg
  • Amend last commit (msg or content)
  • Review before commit

In

  • Required: Changed files
  • Optional: Commit msg (drafted if none)
  • Optional: Amend prev?
  • Optional: Co-author

Do

Step 1: Review

Check tree + diffs:

# See which files are modified, staged, or untracked
git status

# See unstaged changes
git diff

# See staged changes
git diff --staged

→ Clear view all modified, staged, untracked.

If err: git status fails → verify inside repo (git rev-parse --is-inside-work-tree).

Step 2: Stage Selective

Stage specific files, not git add . or -A → avoids secrets + unrelated changes:

# 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

Review staged before commit:

git diff --staged

→ Only intended files. No .env, creds, big binaries.

If err: accidental stage → git reset HEAD <file>. Secret staged → unstage immediately before commit.

Step 3: Write Msg

Conventional format. Always HEREDOC → proper formatting:

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
)"

Conventional types:

TypeWhen
featNew feature
fixBug fix
docsDocs only
testAdd/update tests
refactorNo behavior change
choreBuild, CI, deps
styleFormatting, whitespace

→ Commit created w/ msg explaining why, not what.

If err: pre-commit hook fails → fix, re-stage, create new commit (no --amend → failed commit never existed).

Step 4: Amend Last (Optional)

Amend only if not pushed:

# 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

→ Prev commit updated in-place. git log -1 shows amended.

If err: already pushed → no amend. New commit instead. Force-push → history divergence.

Step 5: Verify

# View the last commit
git log -1 --stat

# View recent commit history
git log --oneline -5

# Verify the commit content
git show HEAD

→ Commit in history w/ correct msg, author, files.

If err: wrong files → git reset --soft HEAD~1 (undo, keep staged), re-commit.

Check

  • Only intended files committed
  • No secrets (tokens, passwords, .env)
  • Msg conventional
  • Body explains why
  • git log shows correct metadata
  • Pre-commit hooks passed

Traps

  • Too much at once: One commit = one logical change. Split unrelated.
  • git add . blind: Always git status first. Stage by name.
  • Amend pushed: Never amend pushed commits → rewrites history, breaks collaborators.
  • Vague msgs: "fix bug" tells nothing. Say what + why.
  • Forget --no-edit: Content amend → use --no-edit → keeps msg.
  • Hook fail → --amend: Hook fail = no commit. --amend hits prev commit. Always new commit after hook fix.

  • manage-git-branches — branch workflow before commit
  • create-pull-request — next step after commit
  • resolve-git-conflicts — merge/rebase conflicts
  • configure-git-repository — repo setup + conventions

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman-ultra/skills/commit-changes
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

railway-docs

文档

Railway Docs Skill可实时获取最新的Railway官方文档,确保回答的准确性。当开发者询问Railway功能特性、工作原理或分享docs.railway.com链接时,应优先使用此技能。它通过专门的LLM优化文档源提供最新信息,避免依赖过时记忆来回答技术问题。

查看技能

n8n-code-python

文档

该Skill为在n8n平台的Python代码节点中编写代码提供专家指导,特别适用于需要使用_input/_json/_node语法、Python标准库或了解n8n中Python限制的场景。它强调JavaScript应作为首选方案,仅当需要特定Python功能或对Python语法更熟悉时才使用Python。Skill提供了快速入门模板和关键注意事项,帮助开发者在n8n中高效编写Python代码。

查看技能

archon

文档

Archon Skill为开发者提供了基于RAG的语义搜索和项目任务管理功能,可通过REST API访问知识库。它支持文档搜索、网站爬取、文件上传和版本控制,适用于技术文档查询和项目管理场景。首次使用时需要配置Archon主机地址,建议在处理外部文档时优先使用该Skill。

查看技能

n8n-code-javascript

文档

这个Skill为n8n工作流中的JavaScript代码节点提供专业指导,涵盖数据处理、HTTP请求和日期操作等核心场景。它详细解释了如何正确使用n8n特有的`$input`/`$json`语法、`$helpers`工具以及DateTime对象,并包含关键的错误排查和模式选择建议。开发者通过该Skill能快速掌握Code节点的正确返回格式、数据访问方法和常见陷阱解决方案。

查看技能