AgentSkillsCN

commit

严格遵循 Git 提交规范,对变更进行暂存与提交操作。

SKILL.md
--- frontmatter
name: commit
description: Stage and commit changes following git commit standards

Commit Changes

Stage and commit changes with proper commit message formatting.

Git Executable

If bin/scm-tools-git exists in the project root, use bin/scm-tools-git instead of git for the commit step. All other git commands (status, diff, add, log, etc.) use plain git.

Workflow

  1. If brivlo:send_event is available, use brivlo:send_event scm-tools:commit as your first step.

  2. Review changes:

    bash
    git status
    git diff
    git diff --staged
    
  3. Stage explicitly:

    bash
    git add app/models/user.rb
    git add spec/models/user_spec.rb
    

    Or interactively: git add -p

  4. Verify staging:

    bash
    git diff --staged
    
  5. Commit with heredoc:

    bash
    git commit -m "$(cat <<'EOF'
    Subject line here
    
    Optional body explaining why, wrapped at 72 chars.
    EOF
    )"
    
  6. Verify:

    bash
    git log --oneline -1
    

Git Tool Usage (Safety Rules)

Staging & Unstaging

TaskDoDon't
Stagegit add <path>, git add -pgit add -A, git add .
Unstagegit restore --staged <path>git reset <path>
  • Stage explicitly; no blanket adds
  • Use git add -p to split changes into logical commits

File Operations

TaskDoDon't
Delete trackedgit rm [-r] <path>rm <path>
Rename/movegit mv <old> <new>mv <old> <new>

History Safety

  • Use git revert <sha> to undo merged history on shared branches
  • If you must force push, use --force-with-lease (never plain --force)
  • Never run git reset --hard on shared work without confirmation

Commit Message Rules

  1. Subject line ≤50 characters
  2. Capitalize the subject
  3. No period at the end
  4. Imperative mood — "Add", "Fix", "Update" (not "Added", "Fixed")
  5. Wrap body at 72 characters — insert line breaks manually
  6. Explain what and why, not how
  7. NEVER add branding or footers — no Co-Authored-By, no signatures

Good Examples

code
Add validation for email format
Fix login timeout on slow connections
Update dependencies to patch CVE-2024-1234

Bad Examples

code
Fixed the bug                    # past tense, vague
Updates to the login page.       # third person, period, vague
WIP                              # meaningless

When to Split Commits

If changes span multiple concerns, make multiple commits:

  • Separate refactoring from feature work
  • Separate test additions from implementation
  • Separate dependency updates from code changes

Output

After committing, report:

  • What was committed (files, summary)
  • The commit hash
  • The commit message used