git-commit

otrebu 的头像作者 otrebu

从暂存/未暂存的更改创建常规提交。当用户要求提交、创建提交、提交更改、提交全部、创建提交、分离提交、提交所有内容、暂存并提交、提交这些更改、保存并推送、提交此工作或在提交后请求推送时使用。处理单个或多个提交、暂存、从差异生成消息和推送操作。

📖 中文导读:从暂存/未暂存的更改创建常规提交。当用户要求提交、创建提交、提交更改、提交全部、创建提交、分离提交、提交所有内容、暂存并提交、提交这些更改、保存并推送、提交此工作或在提交后请求推送时使用。处理单个或多个提交、暂存、从差异生成消息和推送操作。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: git-commit description: Create conventional commits from staged/unstaged changes. Use when user asks to commit, create commits, commit changes, commit all, make commits, separate commits, commit everything, stage and commit, commit these changes, save and push, commit this work, or requests push after committing. Handles single or multiple commits, staging, message generation from diffs, and push operations. allowed-tools: Bash(git add:), Bash(git status:), Bash(git commit:), Bash(git diff:), Bash(git log:), Bash(git branch:), Bash(git push:*)

Git Commit

Stage changes and create conventional commits from diff analysis.

Workflow

1. Gather Context

git status
git diff HEAD
git log --oneline -10

2. Determine Commit Strategy

Single commit: All changes relate to one logical change Multiple commits: Changes span distinct features/fixes/areas

If multiple commits needed:

  1. Group related changes by type and scope
  2. Create separate commits for each group
  3. Follow dependency order (e.g., deps before features)

3. Per Commit: Analyze & Stage

Review diff to extract:

  • Type: feat, fix, refactor, docs, test, chore
  • Scope: module/component affected
  • Description: imperative mood summary (50-72 chars)

Stage related files:

git add <files-for-this-commit>

Never stage:

  • .env files
  • Credentials
  • Secrets/tokens

4. Create Commit

Format:

<type>(scope): description

Optional body with details

Rules:

  • Imperative mood: "add" not "added"
  • Generate from diff, not user's words
  • NEVER add Claude signature/co-authorship
  • Atomic: one logical change per commit

5. Repeat or Push

Multiple commits: Return to step 3 for next commit Push requested: Run git push after all commits No push requested: Stop after committing

Conventional Commit Types

  • feat - New features
  • fix - Bug fixes
  • refactor - Code restructuring without behavior change
  • docs - Documentation only
  • test - Tests
  • chore - Tooling, deps, config

Examples

Single commit:

feat(api): add user authentication endpoint

Implements JWT token generation, login/logout routes,
and bcrypt password hashing.

Multiple commits scenario:

1. chore(deps): install jsonwebtoken and bcrypt
2. feat(auth): add JWT token signing function
3. feat(auth): add token verification middleware
4. docs(api): document authentication endpoints