AgentSkillsCN

Commit

以规范的格式创建常规提交

SKILL.md
--- frontmatter
description: Create conventional commits with proper formatting
argument-hint: "[type] [scope] [message] - or leave blank for interactive"
model: sonnet
allowed-tools: Read, Bash

Commit

Create a well-formatted conventional commit.

Stage related files logically and create conventional commit messages following the format: type(scope): description

Variables

TYPE: $1 || "" # feat, fix, docs, style, refactor, test, chore SCOPE: $2 || "" # Component/area affected MESSAGE: $3 || "" # Commit message (auto-generated if blank)

Workflow

1. Analyze Changes

bash
echo "=== Analyzing Changes ==="
git status --short
echo ""
echo "=== Diff Summary ==="
git diff --stat
echo ""
echo "=== Staged Changes ==="
git diff --cached --stat

Review the changes to understand:

  • What files were modified
  • Whether changes are already staged
  • The nature of the changes (new feature, fix, docs, etc.)

2. Determine Commit Type

If TYPE not provided, analyze changes to suggest:

PatternSuggested Type
New files/featuresfeat
Bug fixes, error handlingfix
Documentation only (.md, comments)docs
Formatting, whitespacestyle
Code restructure, no behavior changerefactor
Test files onlytest
Dependencies, config, toolingchore

3. Determine Scope

If SCOPE not provided, infer from file paths:

Path PatternSuggested Scope
cli/cli
primitives/primitives
docs/docs
tests/tests
*.rscore
*.pypython
Multiple distinct areasomit scope

4. Generate Message

If MESSAGE not provided:

  • Summarize the changes in imperative mood ("add", not "added")
  • Keep under 72 characters
  • Focus on what changed, not how
  • Be specific but concise

Good examples:

  • feat(cli): add version bump command
  • fix(validators): handle empty metadata files
  • docs: update ADR-019 with examples

Bad examples:

  • fixed stuff (vague)
  • Updated the validation logic to check for... (too long, wrong tense)

5. Stage Changes

bash
# If nothing staged, selectively stage tracked file changes
if [ -z "$(git diff --cached --name-only)" ]; then
  echo "=== Staging Changes ==="
  # Use git add -u for tracked files, or explicitly add specific paths
  git add -u
  git status --short
fi

6. Create Commit

bash
# Build commit message
if [ -n "${SCOPE}" ]; then
  FULL_MESSAGE="${TYPE}(${SCOPE}): ${MESSAGE}"
else
  FULL_MESSAGE="${TYPE}: ${MESSAGE}"
fi

echo ""
echo "=== Creating Commit ==="
echo "Message: ${FULL_MESSAGE}"
echo ""

git commit -m "${FULL_MESSAGE}"

7. Verify

bash
echo ""
echo "=== Commit Created ==="
git log -1 --oneline
git log -1 --stat

Report

markdown
## Commit Created

**Hash:** <short-hash>
**Type:** ${TYPE}
**Scope:** ${SCOPE}
**Message:** ${MESSAGE}

**Full commit:**
\`\`\`
${TYPE}(${SCOPE}): ${MESSAGE}
\`\`\`

**Files Changed:**
<file list with +/- stats>

**Next Steps:**
- Run `/devops/push` to push to remote
- Or continue making changes

Conventional Commit Types

TypeWhen to UseExample
featNew feature for usersfeat(auth): add OAuth login
fixBug fix for usersfix(api): handle null response
docsDocumentation onlydocs: add setup instructions
styleFormatting, no code changestyle: fix indentation
refactorCode change, no behavior changerefactor: extract helper function
testAdding/updating teststest: add unit tests for parser
choreMaintenance, toolingchore(deps): update dependencies

Examples

Example 1: Auto-detect everything

code
/commit

Analyzes changes and suggests type, scope, and message.

Example 2: Specify type only

code
/commit feat

Uses feat type, auto-detects scope and message.

Example 3: Full specification

code
/commit feat cli "add version bump command"

Creates: feat(cli): add version bump command

Example 4: No scope

code
/commit docs "" "update README with examples"

Creates: docs: update README with examples