AgentSkillsCN

commit

分析已暂存或未暂存的变更,并生成符合规范的提交信息。

SKILL.md
--- frontmatter
name: commit
description: Analyze staged/unstaged changes and create a conventional commit
user-invocable: true
disable-model-invocation: true

Commit

Create a conventional commit from current changes.

Workflow

  1. Run git status and git diff (staged + unstaged) in parallel
  2. Run git log --oneline -10 to match repo's commit style
  3. Analyze all changes and determine the commit type:
    • feat - New feature
    • fix - Bug fix
    • refactor - Code restructuring without behavior change
    • docs - Documentation only
    • test - Adding/updating tests
    • chore - Build process, dependencies, tooling
    • perf - Performance improvement
    • ci - CI/CD changes
  4. Draft a commit message: <type>: <description> (1-2 sentences, focus on WHY not WHAT)
  5. Stage relevant files by name (never use git add -A or git add .)
  6. Skip files that look like secrets (.env, credentials, tokens)
  7. Show the user the proposed commit message and staged files
  8. Create the commit using HEREDOC format:
bash
git commit -m "$(cat <<'EOF'
type: description
EOF
)"

Rules

  • Never amend previous commits unless explicitly asked
  • Never push unless explicitly asked
  • Never skip hooks (no --no-verify)
  • Never stage .env files, credentials, or secrets
  • If pre-commit hook fails, fix the issue and create a NEW commit
  • Keep message under 72 characters for the first line