AgentSkillsCN

Git Workflow

严格遵循分支命名和提交信息规范,以实现一致的版本控制。

SKILL.md
--- frontmatter
name: Git Workflow
description: Follow strict branch naming and commit message conventions for consistent version control

Git Workflow Conventions

Purpose

This skill ensures consistent git practices across the codebase. It defines strict conventions for branch names, commit messages, and PR workflows that Claude should follow automatically when performing any git operations.

When to Use

  • Creating new branches for any work
  • Writing commit messages
  • Creating pull requests
  • Reviewing git history or suggesting git commands

Quick Reference

Branching Strategy (Solo Workflow)

code
feature/xxx ─┬─► staging ─────► main (production)
fix/xxx     ─┤   (direct)   (PR)     │
chore/xxx   ─┘                       ▼
                              Railway auto-deploy
BranchPurposeHow to Integrate
mainProduction (auto-deploys)PR from staging only
stagingIntegration/testingDirect merge from features
Feature branchesDevelopmentSquash merge to staging

Solo workflow: Feature → staging is direct (no PR). Staging → main uses PR for deploy checkpoint.

⚠️ Never merge feature branches directly to main

Branch Format

code
<type>/<description>
TypeUse ForExample
featureNew functionalityfeature/shopping-sync
fixBug fixesfix/auth-token-refresh
choreMaintenance, depschore/update-deps
refactorCode restructuringrefactor/api-client
docsDocumentationdocs/api-reference
testTest changestest/shopping-integration

Description rules:

  • kebab-case only
  • 2-4 words
  • No special characters except hyphens

Commit Format (Conventional Commits)

code
<type>: <description>

or with scope:

code
<type>(<scope>): <description>
TypeMeaningExample
featNew featurefeat: add shopping sync
fixBug fixfix: resolve auth token refresh
choreMaintenancechore: update dependencies
refactorRestructurerefactor: simplify api client
docsDocumentationdocs: add api docs
testTeststest: add sync tests
styleFormattingstyle: fix indentation
perfPerformanceperf: optimize query

Commit rules:

  • Type is lowercase
  • Description starts lowercase
  • No period at end
  • Imperative mood ("add" not "added")
  • Under 72 characters
  • Always include co-author line

Co-Author Line

All commits must end with:

code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

PR Title Format

Derive from branch name or summarize commits:

  • feature/shopping-sync → "Add shopping sync feature"
  • fix/auth-bug → "Fix auth bug"

PR Body Template

markdown
## Summary
- [Key changes in user terms]

## Changes
- [Modified files/areas]

## Test Plan
- [ ] [Testing steps]

---
🤖 Generated with Claude Code

Critical Rules

Rule❌ Wrong✅ Correct
Branch typebugfix/authfix/auth-bug
Branch casefeature/ShoppingSyncfeature/shopping-sync
Commit typeFEAT: add featurefeat: add feature
Commit moodadded featureadd feature
Commit endingfeat: add feature.feat: add feature
Commit separatorfeat - add featurefeat: add feature

Workflow

Starting Work

  1. Ensure clean working tree or stash changes
  2. Fetch latest from origin
  3. Create branch from staging: /git start <type> <description>

Committing

  1. Stage relevant files (prefer specific files over git add -A)
  2. Write conventional commit message
  3. Include co-author line
  4. Use /git commit to validate and commit

Merging to Staging (Solo Workflow)

  1. Ensure all changes committed
  2. Sync with staging if behind: /git sync
  3. Merge directly to staging: /git merge
  4. Branch is squash-merged and deleted

Deploying to Production

  1. Test changes on staging
  2. Create deploy PR: /git deploy
  3. Review and merge PR in GitHub
  4. Railway auto-deploys from main

Related