AgentSkillsCN

git-workflow

Git 工作流:分支、提交与 PR。适用于提交、分支、PR、拉取请求、常规提交、推送、feat、fix、chore、合并、变基等操作。

SKILL.md
--- frontmatter
name: git-workflow
description: Git workflow for branches, commits, and PRs. Use for commit, branch, pr, pull request, conventional, push, feat, fix, chore, merge, rebase

Git Workflow

Quick Start

bash
# Create feature branch
git checkout -b feat/add-user-auth

# Make changes and commit
git add src/auth/
git commit -m "feat(auth): add user authentication"

# Push and create PR
git push -u origin feat/add-user-auth
gh pr create --title "feat(auth): add user authentication" --body "..."

Branch Naming

text
type/description
TypeUse ForExample
featNew featuresfeat/add-user-auth
fixBug fixesfix/login-redirect
choreMaintenancechore/update-deps
docsDocumentationdocs/api-reference
refactorCode restructuringrefactor/auth-module

Conventional Commits

text
type(scope): subject

body (optional)

footer (optional)

Types

TypeDescription
featNew features
fixBug fixes
docsDocumentation changes
styleCode style (formatting, no logic changes)
refactorCode changes (neither fix nor feature)
perfPerformance improvements
testAdding or correcting tests
choreDependencies, tooling, build
ciCI configuration changes
revertRevert a previous commit

Scopes

CategoryScopes
Appsweb
Packagesauth, config, database, ui, eslint-config, typescript-config
Toolingdeps, ci

Custom scopes allowed. Scope is optional.

Rules

  • Subject: imperative mood, no period, lowercase
  • Header max length: 200 characters
  • Body: optional, use | for line breaks in interactive mode

Examples

bash
# Feature
git commit -m "feat(auth): add password reset flow"

# Bug fix
git commit -m "fix(ui): correct button alignment on mobile"

# Chore
git commit -m "chore(deps): update react to v19"

# With scope
git commit -m "refactor(database): simplify user queries"

# Without scope
git commit -m "docs: update README installation steps"

PR Creation

bash
gh pr create --title "feat(auth): add user authentication" --body "$(cat <<'EOF'
## Summary
- Add login/logout functionality
- Add session management
- Add auth middleware

## Test plan
- [ ] Verify login flow works
- [ ] Verify logout clears session
- [ ] Verify protected routes redirect
EOF
)"

PR Template

markdown
## Summary

<1-3 bullet points describing the change>

## Test plan

- [ ] Unit tests pass
- [ ] Manual testing completed
- [ ] Edge cases verified

Full Workflow

bash
# 1. Create branch from main
git checkout main
git pull
git checkout -b feat/my-feature

# 2. Make changes
# ... edit files ...

# 3. Stage and commit
git add src/
git commit -m "feat(scope): add feature description"

# 4. Push to remote
git push -u origin feat/my-feature

# 5. Create PR
gh pr create --title "feat(scope): add feature description" --body "..."

# 6. After review, merge
gh pr merge --squash

Common Mistakes

MistakeCorrect Pattern
Fix bugfix(scope): correct bug description
feat: Added featurefeat: add feature (imperative mood)
feat(ui): Fix button.feat(ui): fix button (no period)
FEAT: add featurefeat: add feature (lowercase)
Committing without staginggit add <files> first
Pushing to main directlyCreate feature branch first

Delegation

  • Branch strategy questions: Ask user for preferences
  • Merge conflicts: Use git mergetool or resolve manually
  • PR reviews: Use code-reviewer agent