AgentSkillsCN

branch-management

在创建 PR、合并代码,或在涉及 main 分支、develop 分支与 release 分支的分支操作中,审阅并指导分支策略。

SKILL.md
--- frontmatter
name: branch-management
description: Review and guide branch strategy when creating PRs, merging, or creating branches involving main, develop, and release branches
allowed-tools: [Bash, Read, Grep, Glob]

Branch Management Guide

Purpose

Manage branch strategy, naming conventions, and PR rules for breakdownprompt.

  • Full release flow (version bump -> tag -> merge): see /release-procedure skill
  • CI execution and troubleshooting: see /local-ci skill

Branch Strategy

Flow

mermaid
flowchart LR
    subgraph Protected["Protected (no direct push)"]
        main[main]
        develop[develop]
    end

    subgraph Release["Release branches"]
        release[release/vX.Y.Z]
    end

    subgraph Work["Work branches"]
        feature[feature/*]
        fix[fix/*]
        refactor[refactor/*]
        docs[docs/*]
    end

    develop -->|branch from| release
    release -->|branch from| feature
    release -->|branch from| fix
    release -->|branch from| refactor
    release -->|branch from| docs

    feature -->|PR| release
    fix -->|PR| release
    refactor -->|PR| release
    docs -->|PR| release

    release -->|PR| develop
    develop -->|PR| main

Merge Direction

code
Work branch → release/vX.Y.Z → develop → main → vtag

Rules

OperationAllowedProhibited
Changes to mainPR merge from develop onlyDirect push, merge from other branches
Changes to developPR merge from release/* onlyDirect push
Create release/*Branch from developBranch from main or work branches
Create work branchesBranch from release/*Branch from main or develop directly

Procedures

Create a work branch

bash
git checkout release/vX.Y.Z
git checkout -b feature/my-feature

Create a PR

Current branchPR targetCommand
feature/, fix/, refactor/, docs/release/vX.Y.Zgh pr create --base release/vX.Y.Z
release/*developgh pr create --base develop
developmaingh pr create --base main

Merge a PR

  1. Verify CI passes: gh pr checks <PR#>
  2. Merge with appropriate strategy:
Merge methodUse caseCommand
SquashWork branch -> release (clean history)gh pr merge --squash
Mergerelease -> develop (preserve history)gh pr merge --merge
Mergedevelop -> main (preserve history)gh pr merge --merge
  1. Update local:
bash
git checkout <target-branch>
git pull origin <target-branch>

Branch naming conventions

code
feature/*  - New features
fix/*      - Bug fixes
refactor/* - Refactoring
docs/*     - Documentation changes
release/vX.Y.Z - Release preparation

Warning patterns

OperationWarning
git push origin mainDirect push to main is prohibited. Create a PR from develop.
git push origin developDirect push to develop is prohibited. Create a PR from release/*.
git checkout -b feature/* developWork branches must branch from release/*.
git merge mainMerging from main is not expected. Check the branch origin.