AgentSkillsCN

git-commit

完善 PyPTO 的 Git 提交流程,涵盖提交前的代码审查、暂存区管理、提交信息生成与验证。当您需要创建提交、为提交做准备,或当用户要求提交变更时,可选用此技能。

SKILL.md
--- frontmatter
name: git-commit
description: Complete git commit workflow for PyPTO including pre-commit review, staging, message generation, and verification. Use when creating commits, preparing changes for commit, or when the user asks to commit changes.

PyPTO Git Commit Workflow

Prerequisites

⚠️ ALWAYS run these agents first (IN PARALLEL):

  1. code-reviewer - Review code quality
  2. testing - Verify build and tests pass

Launch both simultaneously to save time.

Workflow

  1. Launch code-review and testing agents in parallel
  2. Wait for both to complete
  3. Address any issues found
  4. Stage changes
  5. Generate commit message
  6. Commit and verify

Stage Changes

Related changes together:

bash
git add path/to/file1.cpp path/to/file2.h
git diff --staged  # Review

Cross-layer pattern (C++ + Python + Type stubs + Tests):

bash
git add include/pypto/ir/expr.h python/bindings/ir_binding.cpp \
        python/pypto/pypto_core/__init__.pyi tests/ut/ir/test_expr.py

Never stage: Build artifacts (build/, *.o), temp files, IDE configs

Commit Message Format

Structure: type(scope): description (≤72 chars)

Types: feat, fix, refactor, test, docs, style, chore, perf Scope: Module/component (ir, printer, builder) Description: Present tense, action verb, no period

Good examples:

code
feat(ir): Add unique identifier field to MemRef
fix(printer): Update printer to use yield_ instead of yield
refactor(builder): Simplify tensor construction logic
test(ir): Add edge case coverage for structural comparison

Bad examples (avoid):

code
❌ feat(ir): Added feature.  # Past tense, has period
❌ Fix bug                   # Missing type prefix
❌ WIP                       # Not descriptive

Commit

bash
# Short message
git commit -m "feat(ir): Add tensor rank validation"

# Detailed message (in editor)
git commit

In editor:

code
feat(ir): Add tensor rank validation

Validates tensor rank is positive before setting shape.
Raises ValueError for invalid ranks.
Updates tests with edge case coverage.

Co-Author Policy

❌ NEVER add AI assistants: No Claude, ChatGPT, Cursor AI, etc. ✅ Only credit human contributors: Co-authored-by: Name <email>

Why? AI tools are not collaborators. Commits reflect human authorship.

Post-Commit Verification

bash
git show HEAD              # View commit
git log -1                 # Check message
git show HEAD --name-only  # Verify files

Fix issues (only if not pushed):

bash
git commit --amend -m "Corrected message"      # Fix message
git add file && git commit --amend --no-edit   # Add forgotten file

⚠️ Only amend unpushed commits!

Checklist

  • Code review completed
  • Tests passed
  • Only relevant files staged
  • No build artifacts
  • Message format: type(scope): description (≤72 chars, present tense, no period)
  • No AI co-authors

Remember

A good commit is thoroughly reviewed, groups related changes, has clear "why" message, and attributes only human authors.