Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计未展示

blocklet-branch小块分支

Agent Skill

blocklet-branch 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

196

周安装

8

GitHub Stars

公开资料未说明

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:blocklet-branch(小块分支)
来源仓库:https://github.com/arcblock/agent-skills
仓库路径:skills/blocklet-branch
安装命令:
npx skills add arcblock/agent-skills --skill "blocklet-branch"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add arcblock/agent-skills --skill "blocklet-branch"

简介

用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 支持基于关键词、任务场景或来源线索进行信息筛选与匹配。
  • 通过 npx skills add arcblock/agent-skills --skill "blocklet-branch" 安装使用。
  • 安装前需确认权限范围、维护状态及是否触发联网或文件操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

name
blocklet-branch
description
Git branch management tool. Detects main iteration branch and branch naming conventions, handles branch creation and switching. Referenced by blocklet-dev-setup, blocklet-pr, and other skills.

Blocklet Branch

Unified Git branch management tool providing branch detection, creation, and switching capabilities.

Core Philosophy

"Detect dynamically, never assume."

Branch management must not hardcode main or master. Different ArcBlock repositories follow different branch conventions. By analyzing PR history dynamically, branch operations adapt to each repository automatically.

Design Principles

  • Never assume the main branch is main or master; detect dynamically through merged PR history
  • Learn branch naming conventions from project history
  • Must handle uncommitted changes before switching branches

1. Repository Information Retrieval

1.1 Parse Remote Repository

REMOTE_URL=$(git remote get-url origin)

# Parse org/repo
ORG=$(echo $REMOTE_URL | sed -E 's/.*[:/]([^/]+)\/([^/]+)(\.git)?$/\1/')
REPO=$(echo $REMOTE_URL | sed -E 's/.*[:/]([^/]+)\/([^/]+)(\.git)?$/\2/' | sed 's/\.git$//')

echo "Repository: $ORG/$REPO"

1.2 Get Current Branch

CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"

2. Main Iteration Branch Detection

Important: Must determine the main iteration branch by analyzing the last 10 merged PRs, rather than simply assuming it is main or master.

2.1 Detect Main Iteration Branch

# Get target branches of the last 10 merged PRs, count occurrences to find the main iteration branch
MAIN_BRANCH=$(gh pr list --repo $ORG/$REPO --state merged --limit 10 --json baseRefName \
  | jq -r '.[].baseRefName' | sort | uniq -c | sort -rn | head -1 | awk '{print $2}')

# Get detection rationale
BRANCH_STATS=$(gh pr list --repo $ORG/$REPO --state merged --limit 10 --json baseRefName \
  | jq -r '.[].baseRefName' | sort | uniq -c | sort -rn)

echo "Main iteration branch: $MAIN_BRANCH"
echo "Detection rationale (target branch statistics from last 10 merged PRs):"
echo "$BRANCH_STATS"

2.2 Output Variables

VariableDescriptionExample
MAIN_BRANCHDetected main iteration branchmain, develop, master
MAIN_BRANCH_REASONDetection rationale"8 out of 10 recent merged PRs targeted main"

3. Branch Naming Convention Detection

Important: Determine branch naming prefix conventions by analyzing the last 10 merged PRs.

3.1 Analyze Historical Branch Naming

# Get source branch names from the last 10 merged PRs, analyze naming conventions
BRANCH_NAMES=$(gh pr list --repo $ORG/$REPO --state merged --limit 10 --json headRefName \
  | jq -r '.[].headRefName')

# Extract prefixes (supports both / and - separators)
BRANCH_PREFIXES=$(echo "$BRANCH_NAMES" | sed -E 's/^([a-zA-Z]+)[\/\-].*/\1/' | sort | uniq -c | sort -rn)

echo "Branch naming prefix statistics (from last 10 merged PRs):"
echo "$BRANCH_PREFIXES"

# Detect separator style (/ or -)
if echo "$BRANCH_NAMES" | grep -q '/'; then
    SEPARATOR="/"
else
    SEPARATOR="-"
fi
echo "Separator style: $SEPARATOR"

3.2 Common Branch Prefixes

PrefixPurposeExample
feat / featureNew featurefeat/add-login, feature/user-profile
fix / bugfixBug fixfix/login-error, bugfix/issue-123
choreRoutine maintenancechore/update-deps
refactorCode refactoringrefactor/auth-module
docsDocumentation updatedocs/api-guide
testTest-relatedtest/add-unit-tests
styleCode stylestyle/format-code
perfPerformance optimizationperf/optimize-query

3.3 Output Variables

VariableDescriptionExample
BRANCH_PREFIX_CONVENTIONPrimary prefix conventionfeat, fix
BRANCH_SEPARATORSeparator style/ or -

4. Uncommitted Changes Handling

Important: Before switching branches, uncommitted changes must be handled first.

4.1 Check Change Status

UNCOMMITTED_CHANGES=$(git status --porcelain)

if [ -n "$UNCOMMITTED_CHANGES" ]; then
    echo "⚠️ Uncommitted changes detected:"
    git status --short
fi

4.2 Handle Changes

If there are uncommitted changes, use AskUserQuestion to ask the user:

Uncommitted changes detected. Please choose how to proceed:

Options:
A. Stash changes (git stash) - can be restored later (Recommended)
B. Commit changes - create a temporary commit
C. Discard changes (git checkout .) - ⚠️ cannot be undone
D. Cancel operation

Execute handling:

# Option A: Stash
git stash push -m "Auto stash before branch switch"

# Option B: Commit
git add -A && git commit -m "WIP: auto commit before branch switch"

# Option C: Discard
git checkout . && git clean -fd

5. Branch Switching

5.1 Switch to Main Iteration Branch

# Ensure local has latest remote branch info
git fetch origin

# Switch to main iteration branch and update
git checkout $MAIN_BRANCH
git pull origin $MAIN_BRANCH

echo "✅ Switched to main iteration branch: $MAIN_BRANCH"

5.2 Switch to Specified Branch

TARGET_BRANCH="feat/my-feature"

# Check if branch exists
if git show-ref --verify --quiet refs/heads/$TARGET_BRANCH; then
    # Local branch exists
    git checkout $TARGET_BRANCH
elif git show-ref --verify --quiet refs/remotes/origin/$TARGET_BRANCH; then
    # Remote branch exists, create local tracking branch
    git checkout -b $TARGET_BRANCH origin/$TARGET_BRANCH
else
    echo "❌ Branch $TARGET_BRANCH does not exist"
fi

6. Working Branch Creation

6.1 Generate Branch Name Suggestion

Generate suggested branch name based on task type and repository naming conventions:

# Input parameters
TASK_TYPE="fix"           # feat, fix, chore, refactor, docs, test
TASK_DESCRIPTION="login"  # Brief description
ISSUE_NUMBER=""           # Optional issue number

# Generate branch name
if [ -n "$ISSUE_NUMBER" ]; then
    SUGGESTED_BRANCH="${TASK_TYPE}${BRANCH_SEPARATOR}issue-${ISSUE_NUMBER}-${TASK_DESCRIPTION}"
else
    SUGGESTED_BRANCH="${TASK_TYPE}${BRANCH_SEPARATOR}${TASK_DESCRIPTION}"
fi

echo "Suggested branch name: $SUGGESTED_BRANCH"

6.2 Create Working Branch

Prerequisite: Must be created based on the latest main iteration branch.

# 1. Ensure main iteration branch is up to date
git fetch origin $MAIN_BRANCH
git checkout $MAIN_BRANCH
git pull origin $MAIN_BRANCH

# 2. Create and switch to new branch
NEW_BRANCH="feat/my-new-feature"
git checkout -b $NEW_BRANCH

echo "✅ Created and switched to branch: $NEW_BRANCH (based on $MAIN_BRANCH)"

6.3 User Confirmation Flow

Use AskUserQuestion to confirm branch name:

Will create new branch based on {MAIN_BRANCH}.

Please select branch name:

Options:
A. {SUGGESTED_BRANCH} (Recommended)
B. Enter custom branch name
C. Cancel operation

7. Branch Status Check

7.1 Check If on Main Iteration Branch

if [ "$CURRENT_BRANCH" = "$MAIN_BRANCH" ]; then
    echo "⚠️ Currently on main iteration branch"
    ON_MAIN_BRANCH=true
else
    ON_MAIN_BRANCH=false
fi

7.2 Check Branch Naming Convention Compliance

# Check if branch name follows common prefix conventions
if echo "$CURRENT_BRANCH" | grep -qE "^(feat|fix|chore|refactor|docs|test|style|perf|hotfix|release)[/\-]"; then
    echo "✅ Branch naming follows convention"
    BRANCH_NAME_VALID=true
else
    echo "⚠️ Branch naming does not follow common conventions: $CURRENT_BRANCH"
    BRANCH_NAME_VALID=false
fi

7.3 Check Branch Sync Status with Remote

# Get local and remote differences
git fetch origin

LOCAL_COMMIT=$(git rev-parse HEAD)
REMOTE_COMMIT=$(git rev-parse origin/$CURRENT_BRANCH 2>/dev/null || echo "")

if [ -z "$REMOTE_COMMIT" ]; then
    echo "📤 Branch not yet pushed to remote"
    SYNC_STATUS="not_pushed"
elif [ "$LOCAL_COMMIT" = "$REMOTE_COMMIT" ]; then
    echo "✅ Branch is in sync with remote"
    SYNC_STATUS="synced"
else
    AHEAD=$(git rev-list origin/$CURRENT_BRANCH..HEAD --count)
    BEHIND=$(git rev-list HEAD..origin/$CURRENT_BRANCH --count)
    echo "📊 Local is $AHEAD commits ahead, $BEHIND commits behind"
    SYNC_STATUS="diverged"
fi

8. Usage Scenarios

Scenario A: Development Environment Setup (blocklet-dev-setup)

  1. Detect main iteration branch
  2. Handle uncommitted changes
  3. Switch to main iteration branch and update
  4. (Optional) Create working branch

Scenario B: Submit PR (blocklet-pr)

  1. Detect main iteration branch
  2. Detect branch naming conventions
  3. Check current branch

- If on main iteration branch → Must create working branch - If on working branch → Check naming convention compliance

Scenario C: Switch Tasks

  1. Handle uncommitted changes (stash/commit/discard)
  2. Switch to target branch
  3. Restore previous changes (if needed)

9. Referenced by Other Skills

This skill is referenced by the following skills:

SkillFeatures Used
blocklet-dev-setupDetect main iteration branch, handle uncommitted changes, switch branches, create working branch
blocklet-prDetect main iteration branch, branch naming conventions, enforce working branch creation

How to reference:

Refer to blocklet-branch skill for branch operations.
Skill location: `blocklet-branch/SKILL.md`

10. Error Handling

ErrorCauseSolution
Cannot get PR historygh not authenticated or network issueRun gh auth status to check authentication
Branch switch failedConflicting uncommitted changesHandle uncommitted changes first
Branch creation failedBranch name already existsUse different branch name or switch to existing branch
Cannot detect main iteration branchRepository has no merged PRsFall back to default branch gh repo view --json defaultBranchRef

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenCode

26.92%
按下载量换算17

Cursor

23.38%
按下载量换算15

Codex

17.31%
按下载量换算11

Claude Code

13.92%
按下载量换算9

Antigravity

8.61%
按下载量换算5

Gemini CLI

3.43%
按下载量换算2

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills