返回技能列表

commit-changes

pjt222
更新于 Yesterday
1 次查看
17
2
17
在 GitHub 上查看
general

关于

The commit-changes skill stages, commits, and amends Git changes using conventional commit messages. It enables selective staging, descriptive HEREDOC-formatted messages, and commit history verification. Use it to save logical work units to version control with proper commit practices.

快速安装

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 files selective. Write clear commit messages. Verify commit history.

When Use

  • Save logical unit of work to version control
  • Create commit with descriptive, conventional message
  • Amend most recent commit (message or content)
  • Review what commit before commit

Inputs

  • Required: One or more changed files to commit
  • Optional: Commit message (drafted if not given)
  • Optional: Whether amend previous commit
  • Optional: Co-author attribution

Steps

Step 1: Review Current Changes

Check working tree status. Inspect diffs.

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

# See unstaged changes
git diff

# See staged changes
git diff --staged

Got: Clear picture of all modified, staged, untracked files.

If fail: git status fail? Verify inside git repo (git rev-parse --is-inside-work-tree).

Step 2: Stage Files Selective

Stage specific files. Avoid git add . or git add -A — may grab sensitive files or 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

Got: Only intended files and changes staged. No .env, credentials, large binaries.

If fail: Unstage accidental files with git reset HEAD <file>. Sensitive data staged? Unstage now, before commit.

Step 3: Write Commit Message

Use conventional commits format. Always pass message via HEREDOC for 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 commit types:

TypeWhen use
featNew feature
fixBug fix
docsDocumentation only
testAdd or update tests
refactorCode change — no fix, no new feature
choreBuild, CI, dependency updates
styleFormatting, whitespace (no logic change)

Got: Commit created with descriptive message. Explains why, not just what.

If fail: Pre-commit hook fail? Fix issue, re-stage with git add, create new commit. No --amend — failed commit never created.

Step 4: Amend Last Commit (Optional)

Only amend if commit not pushed to shared remote.

# 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

Got: Previous commit updated in-place. git log -1 shows amended content.

If fail: Commit already pushed? No amend. Create new commit. Force-push amended commits to shared branches breaks history.

Step 5: Verify Commit

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

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

# Verify the commit content
git show HEAD

Got: Commit appears in history with correct message, author, file changes.

If fail: Commit has wrong files? Use git reset --soft HEAD~1 to undo commit, keep changes staged. Re-commit correct.

Checks

  • Only intended files in commit
  • No sensitive data (tokens, passwords, .env files) committed
  • Commit message follows conventional commits format
  • Message body explains why change made
  • git log shows commit with correct metadata
  • Pre-commit hooks (if any) passed

Pitfalls

  • Commit too much at once: Each commit = one logical change. Split unrelated changes into separate commits.
  • Using git add . blind: Always review git status first. Prefer stage specific files by name.
  • Amend pushed commits: Never amend commits pushed to shared branch. Rewrites history. Breaks collaborators.
  • Vague commit messages: "fix bug" or "update" tells nothing. Describe what changed and why.
  • Forget --no-edit on content amends: Adding forgotten files to last commit? Use --no-edit — keeps existing message.
  • Hook fail leading to --amend: Pre-commit hook fail → commit never created. --amend would modify previous commit. Always create new commit after fix hook issues.

See Also

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

GitHub 仓库

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

相关推荐技能

content-collections

Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。

查看技能

polymarket

这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。

查看技能

creating-opencode-plugins

该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。

查看技能

sglang

SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。

查看技能