Github Worktree logo

Github Worktree

OrganizationPopular
TencentBlueKing
github-worktree

须用户 @ 本 skill 或明确说要按 GitHub Issue worktree 流程执行时再读取。 在 master 上:确定关联的 GitHub Issue(默认关联已有,明确要建时才在上游建单)、生成分支名、git fetch、脚本同时创建新分支与 worktree、cursor --new-window 打开新窗口;细节与分支命名见正文。 不因泛泛提到 GitHub、issue、worktree、建分支等词而自动套用。

Overview

PublisherTencentBlueKing
Repositorybk-ci
Skill namegithub-worktree
Stars
2.5K
Forks
524
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by TencentBlueKing on GitHub. Read the source before you install it.

Installation

Install the Github Worktree AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TencentBlueKing/bk-ci.git /tmp/bk-ci
mkdir -p .claude/skills
cp -r /tmp/bk-ci/ai/skills/github-worktree .claude/skills/github-worktree
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Github Worktree in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Github Worktree on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Github Worktree is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

GitHub Issue Worktree 工作流

当用户在 master 分支 上提出需要改动代码的需求时,执行以下工作流。本流程适配蓝盾(bk-ci)GitHub Issue 驱动的开发模式。

硬性约束:一旦用户选择创建分支,Agent 在本次对话轮次中禁止对项目文件做任何内容修改(包括写入、编辑、创建文件)。工作流结束后,提示用户在新打开的 worktree 窗口中继续操作。仅当用户明确选择"直接在 master 上改"时,才跳过工作流、正常执行需求。

固定参数

  • 仓库 owner = TencentBlueKing,repo = bk-ci
  • 远端 = origin,新分支基线 = origin/master
  • 当前 GitHub 用户:通过 get_me 获取 login(用于 issue assignee)
  • GitHub MCP server = user-github

前置检查

0. 检查运行环境

本 skill 仅在 Cursor IDE 中生效。如果当前环境不是 Cursor IDE(例如在 CLI、终端或其他编辑器中),跳过本工作流,直接执行用户需求。

判断方式:用户信息中存在 Workspace Path 且 Shell 可执行 cursor --version 命令。

1. 检查当前分支

bash
git branch --show-current

只有当前分支为 master 时才触发本工作流。如果不在 master,直接执行用户需求即可。

2. 检查 GitHub MCP 可用性

确认 user-github MCP 服务器可用。如果不可用,提醒用户:

当前未检测到 GitHub MCP 服务。请先在 Cursor Settings → MCP 中添加 GitHub 服务器后重试;或手动提供分支名,跳过 issue 关联步骤直接创建 worktree。

如果用户无 GitHub MCP 但仍想创建 worktree,跳过 issue 步骤,直接让用户手动提供分支名后执行 worktree 创建。

工作流

Step 1: 询问是否创建分支

使用 AskQuestion 工具向用户确认:

  • 提示:当前在 master 分支,需要先创建工作分支再改动代码。如何关联 GitHub Issue?
  • 选项:
    • 关联已有 Issue 建分支(需用户提供 issue 号)
    • 新建 Issue 后建分支(在上游公开仓库建单,需二次确认)
    • 不关联 Issue,直接建分支(需用户提供分支名)
    • 不建分支,直接在 master 上改(给出风险提示后继续)

Step 2: 确定关联的 Issue

A. 关联已有 Issue

用户提供 issue 号后,读取标题用于生成分支关键词:

CallMcpTool:
  server: user-github
  toolName: issue_read
  arguments:
    method: get
    owner: TencentBlueKing
    repo: bk-ci
    issue_number: <issue号>

从返回中取 title 与(如有)labelsissue_type,用于推断 type 与提炼关键词(见 Step 3「从 Issue 推断 type」)。

B. 新建 Issue(上游公开仓库,需二次确认)

在公开上游 TencentBlueKing/bk-ci 创建 Issue 前,必须用 AskQuestion 让用户确认标题/正文,确认后才调用创建接口。

Issue 标题规范(与分支 type、commit 标记对齐):

  • 格式:{type}: {简短描述}(英文冒号后保留一个空格)
  • type 与 Step 3 分支前缀一致:
type适用场景
feat新功能、能力增强
bug缺陷修复
pref性能、参数、配置优化
refactor重构(不改外部行为)
issue类型不明确、杂项跟踪

示例(参考 #13058 一类需求单):

  • feat: 蓝盾智能助手支持项目级知识库、插件级知识库
  • bug: 流水线构建完成后状态未更新
  • pref: 构建详情页接口减少冗余查询

标题中不要再写 issue 号;编号由 GitHub 分配。正文仍用背景 / 需求 / 验收等结构,与 github-repository-management 的 Issue 模板一致。

  1. get_me 获取当前用户 login,作为 assignee。
  2. 按上表从用户需求选定 type,起草 title(须含 {type}: 前缀)与 body
  3. (可选)list_issue_types(owner=TencentBlueKing)确认该组织是否启用 issue type;若启用且与 type 对应,可传 type(如 Feature / Bug);未启用则省略。
  4. 调用创建:
CallMcpTool:
  server: user-github
  toolName: issue_write
  arguments:
    method: create
    owner: TencentBlueKing
    repo: bk-ci
    title: "<type>: <简短描述>"
    body: <需求/缺陷描述,含背景、用例、实现要点>
    assignees: ["<当前用户 login>"]

从返回中取新 issue 的 number

C. 不关联 Issue

让用户直接提供分支名,或根据需求描述生成分支名(不含 issue 号后缀),跳到 Step 4。

Step 3: 生成分支名

分支命名规则:{type}-{issue号}{type}-{keywords}-{issue号}

从 Issue 推断 type(按优先级)
  1. 标题前缀:若 titlefeat:bug:pref:refactor:issue: 开头(不区分大小写),取冒号前一段作为 type(统一小写)。
  2. GitHub issue_type:如 FeaturefeatBugbug(与仓库配置一致时)。
  3. labels:如 kind/bugbugkind/enhancementfeat
  4. 仍无法判断 → issue
从标题提炼 keywords(可选)
  • 去掉 {type}: 前缀后,从剩余标题提取 1~3 个英文关键词(全小写、- 连接);中文标题可据语义翻译或缩写(如「知识库」→ knowledge)。

  • 例:标题 feat: 蓝盾智能助手支持项目级知识库、插件级知识库,issue #13058feat-ai-knowledge-13058feat-knowledge-13058

  • issue号:GitHub Issue 编号(纯数字),必须为分支名末段。

示例:

  • bug: … + #12994bug-12994
  • feat: … + #11524feat-11524feat-tenant-3-11524
  • 无类型前缀、仅 issue_type 为 Feature 的 #13058feat-knowledge-13058(按标题补 keywords)

可在 type 与 issue 号之间补充 1~3 个英文关键词增强可读性(与现网 feat-tenant-3-11524feat-ai-knowledge-13058 风格一致)。是否加关键词由你按标题判断,但末段必须是 issue 号,便于后续 commit/close skill 解析。

如果用户选择不关联 Issue,则让用户提供分支名或根据需求描述生成(末段可不含 issue 号)。

Step 4: 创建 Worktree 并同时创建分支

先拉取最新代码,确保基于最新 master 创建分支:

bash
git remote set-url origin https://github.com/TencentBlueKing/bk-ci.git
git fetch origin master

在执行脚本前,先确认目标分支名在本地尚不存在;本步骤要求创建 worktree 时同时新建分支,不复用已有本地分支。如果本地已存在同名分支,应提示用户改名,或先手动清理旧分支/旧 worktree 后再重试。

根据操作系统选择脚本,基线指定 origin/master

Windows(PowerShell):

powershell
powershell -File .cursor/skills/github-worktree/scripts/git-worktree.ps1 -Action Add -Branch "<分支名>" -Base origin/master

macOS / Linux(Bash):

bash
bash .cursor/skills/github-worktree/scripts/git-worktree.sh add -b "<分支名>" -B origin/master

脚本会显式执行“基于 origin/master 新建分支 + 创建 worktree”这两个动作;成功后会自动从主仓库同步 .idea.cursor 到新 worktree,保证 IDEA 项目配置、Gradle 导入配置、本地运行配置以及当前工程下的 Cursor rules/skills/config 尽量与主仓库窗口一致。

脚本随后会进入新 worktree 的 src/backend/ci,对所有使用 task-gen-jooq 的模型模块执行 jOOQ 生成任务。如果数据库不可访问或 jOOQ 生成失败,脚本会失败退出,需先处理数据库连接或生成错误。

操作系统判断
  • 用户信息中的 OS Version 包含 win32 → 使用 PowerShell 脚本
  • 包含 darwin → 使用 Bash 脚本
  • 包含 linux → 使用 Bash 脚本

Step 5: 在新窗口打开 Worktree

从 Step 4 脚本输出中提取 Created worktree: <path> 的实际路径(不要自己拼路径)。

使用以下命令在 Cursor 新窗口打开:

bash
cursor --new-window "<从脚本输出中提取的 worktree 路径>"

告知用户新窗口已打开,可以在新窗口中继续开发。本次对话到此结束,不要再对任何文件做修改。

脚本说明

脚本系统路径
git-worktree.ps1Windows.cursor/skills/github-worktree/scripts/git-worktree.ps1
git-worktree.shmacOS/Linux.cursor/skills/github-worktree/scripts/git-worktree.sh

两个脚本功能一致,支持三个操作:

  • add:基于 -B/-Base 指定的 base 同时新建分支与 worktree;若本地已存在同名分支则直接失败,避免误复用旧分支
  • list:列出所有 worktree
  • remove:移除 worktree(支持按分支名或路径)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Github Worktree AI skill do?

须用户 @ 本 skill 或明确说要按 GitHub Issue worktree 流程执行时再读取。 在 master 上:确定关联的 GitHub Issue(默认关联已有,明确要建时才在上游建单)、生成分支名、git fetch、脚本同时创建新分支与 worktree、cursor --new-window 打开新窗口;细节与分支命名见正文。 不因泛泛提到 GitHub、issue、worktree、建分支等词而自动套用。

Why use Github Worktree on TypingMind?

Because you install it once and use it with any model. Github Worktree is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Github Worktree in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/TencentBlueKing/bk-ci/tree/master/ai/skills/github-worktree. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Github Worktree?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Github Worktree?

As many as you like. As long as a model supports skills, you can use Github Worktree with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Github Worktree AI skill free?

It is published on GitHub by TencentBlueKing. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇