AgentSkillsCN

scm

A2A 项目中的 Git 工作流与源码管理。涵盖常规提交规范、分支策略、Pull Request 工作流,以及冲突解决机制。可通过“Git”、“提交”、“分支”、“合并”、“变基”、“拉取请求”、“PR”、“常规提交”、“Git 工作流”、“推送”、“提交信息”等短语触发。主动出击:在执行 Git 操作时务必调用。

SKILL.md
--- frontmatter
name: scm
description: >-
  Git workflow and source control management for A2A project. Covers
  Conventional Commits, branch strategy, PR workflow, and conflict resolution.
  Triggers on "git", "commit", "branch", "merge", "rebase", "pull request", "PR",
  "conventional commits", "git workflow", "push", "commit message".
  PROACTIVE: MUST invoke when performing Git operations.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep

Source Control Management (SCM) Skill

Quick Reference

PrincipleRule
Atomic CommitsOne logical change per commit
Conventional Commitstype(scope): description format
Branch Namingtype/description format
Never Force PushTo shared branches (main)

Branching Strategy (GitHub Flow)

code
main ─────●───────●───────●───────●──────
          │       ↑       │       ↑
          ↓       │       ↓       │
feature ──●──●──●─┘ fix ──●──●────┘

Branches:

  • main: Always deployable (protected)
  • feature/*: New features
  • fix/*: Bug fixes
  • chore/*: Maintenance
  • docs/*: Documentation

Conventional Commits

Format

code
<type>(<scope>): <description>

[optional body]

[optional footer]

Types

TypeDescriptionExample
featNew featurefeat(agent): add memory agent
fixBug fixfix(auth): correct permission check
docsDocumentationdocs(readme): update setup guide
styleFormattingstyle(storage): fix indentation
refactorCode restructurerefactor(base): extract validation
testTeststest(echo): add response tests
choreBuild/toolingchore(deps): update pydantic

Scopes (A2A Project)

ScopeArea
agentAgent classes
storageStorage implementations
authPermissions system
protocolMCP server
mcpMCP integration
testsTest files

Branch Naming

code
<type>/<description>

Examples:
- feature/memory-agent
- fix/permission-decorator
- chore/update-dependencies

Commit Workflow

TDD Commit Pattern

bash
# Red phase
git add tests/
git commit -m "test(agent): add calculator tests"

# Green phase
git add agents/
git commit -m "feat(agent): implement calculator logic"

# Refactor phase
git add agents/
git commit -m "refactor(agent): extract math operations"

Multi-line Commit (HEREDOC)

bash
git commit -m "$(cat <<'EOF'
feat(storage): add file-based storage

- Implement FileStorage class
- Support JSON serialization
- Add backup rotation

Closes #12
EOF
)"

Before Creating PR

bash
# 1. Ensure branch is up to date
git fetch origin
git rebase origin/main

# 2. Run tests locally
pytest

# 3. Review changes
git diff origin/main...HEAD
git log origin/main..HEAD --oneline

Safety Rules

Never Do

bash
# Never force push to main
git push --force origin main  # DANGEROUS

# Never rebase shared branches
git rebase main  # on shared feature branch

# Never reset pushed commits
git reset --hard HEAD~3  # if already pushed

Safe Alternatives

bash
# Use force-with-lease
git push --force-with-lease

# Merge instead of rebase on shared
git merge origin/main

# Revert instead of reset
git revert <sha>

Common Operations

Undo Operations

bash
# Undo last commit (keep changes)
git reset --soft HEAD~1

# Undo uncommitted changes
git checkout -- path/to/file

# Revert pushed commit
git revert <sha>

Stashing

bash
# Stash changes
git stash save "WIP: feature description"

# List stashes
git stash list

# Apply and drop
git stash pop

Checklist

Before committing:

  • Changes are atomic (one logical change)
  • Commit message follows Conventional Commits
  • Tests pass locally (pytest)
  • No debug code or print statements
  • No secrets or credentials
  • Branch is up to date with main

Before creating PR:

  • Rebased on latest main
  • All commits have meaningful messages
  • Description explains what and why
  • CI checks pass