update-skills

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

About

简介

Skills are distributed as git branches (
skill/*
). When you install a skill, you merge its branch into your repo. This skill checks upstream for newer commits on those skill branches and helps you update.
Run
/update-skills
in Claude Code.
Skill以Git分支(
skill/*
)的形式分发。当你安装一个Skill时,会将其分支合并到你的仓库中。本Skill用于检查上游的这些skill分支是否有新提交,并帮助你进行更新。
在Claude Code中运行
/update-skills
命令。

How it works

工作原理

Preflight: checks for clean working tree and upstream remote.
Detection: fetches upstream, lists all
upstream/skill/*
branches, determines which ones you've previously merged (via merge-base), and checks if any have new commits.
Selection: presents a list of skills with available updates. You pick which to update.
Update: merges each selected skill branch, resolves conflicts if any, then validates with build + test.

预检:检查工作区是否干净以及是否存在上游远程仓库。
检测:拉取上游代码,列出所有
upstream/skill/*
分支,判断哪些分支是你之前已合并的(通过merge-base),并检查是否有新提交。
选择:展示有可用更新的Skill列表,由你选择需要更新的Skill。
更新:合并每个选中的Skill分支,如有冲突则解决冲突,然后通过构建+测试进行验证。

Goal

目标

Help users update their installed skill branches from upstream without losing local customizations.
帮助用户从上游更新已安装的Skill分支,同时不丢失本地自定义内容。

Operating principles

操作原则

  • Never proceed with a dirty working tree.
  • Only offer updates for skills the user has already merged (installed).
  • Use git-native operations. Do not manually rewrite files except conflict markers.
  • Keep token usage low: rely on
    git
    commands, only open files with actual conflicts.
  • 工作区不干净时绝不执行操作。
  • 仅为用户已合并(已安装)的Skill提供更新选项。
  • 使用Git原生操作。除冲突标记外,不手动修改文件。
  • 尽量降低Token使用量:依赖
    git
    命令,仅打开存在实际冲突的文件。

Step 0: Preflight

步骤0:预检

Run:
  • git status --porcelain
If output is non-empty:
  • Tell the user to commit or stash first, then stop.
Check remotes:
  • git remote -v
If
upstream
is missing:
  • Ask the user for the upstream repo URL (default:
    https://github.com/qwibitai/nanoclaw.git
    ).
  • git remote add upstream <url>
Fetch:
  • git fetch upstream --prune
运行以下命令:
  • git status --porcelain
如果输出非空:
  • 告知用户先提交或暂存更改,然后终止流程。
检查远程仓库:
  • git remote -v
如果缺少
upstream
远程仓库:
  • 询问用户上游仓库的URL(默认:
    https://github.com/qwibitai/nanoclaw.git
    )。
  • 执行
    git remote add upstream <url>
拉取上游代码:
  • git fetch upstream --prune

Step 1: Detect installed skills with available updates

步骤1:检测已安装Skill是否有可用更新

List all upstream skill branches:
  • git branch -r --list 'upstream/skill/*'
For each
upstream/skill/<name>
:
  1. Check if the user has merged this skill branch before:
    • git merge-base --is-ancestor upstream/skill/<name>~1 HEAD
      — if this succeeds (exit 0) for any ancestor commit of the skill branch, the user has merged it at some point. A simpler check:
      git log --oneline --merges --grep="skill/<name>" HEAD
      to see if there's a merge commit referencing this branch.
    • Alternative:
      MERGE_BASE=$(git merge-base HEAD upstream/skill/<name>)
      — if the merge base is NOT the initial commit and the merge base includes commits unique to the skill branch, it has been merged.
    • Simplest reliable check: compare
      git merge-base HEAD upstream/skill/<name>
      with
      git merge-base HEAD upstream/main
      . If the skill merge-base is strictly ahead of (or different from) the main merge-base, the user has merged this skill.
  2. Check if there are new commits on the skill branch not yet in HEAD:
    • git log --oneline HEAD..upstream/skill/<name>
    • If this produces output, there are updates available.
Build three lists:
  • Updates available: skills that are merged AND have new commits
  • Up to date: skills that are merged and have no new commits
  • Not installed: skills that have never been merged
列出所有上游Skill分支:
  • git branch -r --list 'upstream/skill/*'
对于每个
upstream/skill/<name>
分支:
  1. 检查用户是否曾合并过该Skill分支:
    • 执行
      git merge-base --is-ancestor upstream/skill/<name>~1 HEAD
      —— 如果该命令成功(退出码0),说明用户曾合并过该分支。更简单的检查方式:
      git log --oneline --merges --grep="skill/<name>" HEAD
      ,查看是否存在引用该分支的合并提交。
    • 替代方式:
      MERGE_BASE=$(git merge-base HEAD upstream/skill/<name>)
      —— 如果合并基准不是初始提交,且包含该Skill分支独有的提交,则说明已合并。
    • 最简单可靠的检查方式:比较
      git merge-base HEAD upstream/skill/<name>
      git merge-base HEAD upstream/main
      的结果。如果Skill分支的合并基准严格领先于(或不同于)主分支的合并基准,则说明用户已合并该Skill。
  2. 检查Skill分支是否有未同步到HEAD的新提交:
    • 执行
      git log --oneline HEAD..upstream/skill/<name>
    • 如果有输出,说明存在可用更新。
构建三个列表:
  • 有可用更新:已合并且有新提交的Skill
  • 已更新至最新:已合并且无新提交的Skill
  • 未安装:从未合并过的Skill

Step 2: Present results

步骤2:展示结果

If no skills have updates available:
  • Tell the user all installed skills are up to date. List them.
  • If there are uninstalled skills, mention them briefly (e.g., "3 other skills available in upstream that you haven't installed").
  • Stop here.
If updates are available:
  • Show the list of skills with updates, including the number of new commits for each:
    skill/<name>: 3 new commits
    skill/<other>: 1 new commit
  • Also show skills that are up to date (for context).
  • Use AskUserQuestion with
    multiSelect: true
    to let the user pick which skills to update.
    • One option per skill with updates, labeled with the skill name and commit count.
    • Add an option: "Skip — don't update any skills now"
  • If user selects Skip, stop here.
如果没有Skill有可用更新:
  • 告知用户所有已安装Skill均为最新版本,并列出这些Skill。
  • 如果存在未安装的Skill,简要提及(例如:“上游还有3个你未安装的Skill”)。
  • 终止流程。
如果有可用更新:
  • 展示有更新的Skill列表,包括每个Skill的新提交数量:
    skill/<name>: 3个新提交
    skill/<other>: 1个新提交
  • 同时展示已更新至最新的Skill(供参考)。
  • 使用支持
    multiSelect: true
    的AskUserQuestion功能,让用户选择需要更新的Skill。
    • 每个有更新的Skill对应一个选项,标注Skill名称和提交数量。
    • 添加选项:“跳过——暂不更新任何Skill”
  • 如果用户选择跳过,终止流程。

Step 3: Apply updates

步骤3:执行更新

For each selected skill (process one at a time):
  1. Tell the user which skill is being updated.
  2. Run:
    git merge upstream/skill/<name> --no-edit
  3. If the merge is clean, move to the next skill.
  4. If conflicts occur:
    • Run
      git status
      to identify conflicted files.
    • For each conflicted file:
      • Open the file.
      • Resolve only conflict markers.
      • Preserve intentional local customizations.
      • git add <file>
    • Complete the merge:
      git commit --no-edit
If a merge fails badly (e.g., cannot resolve conflicts):
  • git merge --abort
  • Tell the user this skill could not be auto-updated and they should resolve it manually.
  • Continue with the remaining skills.
对每个选中的Skill(逐个处理):
  1. 告知用户当前正在更新哪个Skill。
  2. 执行:
    git merge upstream/skill/<name> --no-edit
  3. 如果合并无冲突,继续处理下一个Skill。
  4. 如果发生冲突:
    • 执行
      git status
      识别冲突文件。
    • 对每个冲突文件:
      • 打开文件。
      • 仅解决冲突标记。
      • 保留用户的本地自定义内容。
      • 执行
        git add <file>
    • 完成合并:
      git commit --no-edit
如果合并失败(例如:无法解决冲突):
  • 执行
    git merge --abort
  • 告知用户该Skill无法自动更新,需要手动解决。
  • 继续处理剩余Skill。

Step 4: Validation

步骤4:验证

After all selected skills are merged:
  • npm run build
  • npm test
    (do not fail the flow if tests are not configured)
If build fails:
  • Show the error.
  • Only fix issues clearly caused by the merge (missing imports, type mismatches).
  • Do not refactor unrelated code.
  • If unclear, ask the user.
所有选中的Skill合并完成后:
  • 执行
    npm run build
  • 执行
    npm test
    (如果未配置测试,流程不终止)
如果构建失败:
  • 展示错误信息。
  • 仅修复明显由合并导致的问题(如缺失导入、类型不匹配)。
  • 不重构无关代码。
  • 若问题不明确,询问用户。

Step 5: Summary

步骤5:总结

Show:
  • Skills updated (list)
  • Skills skipped or failed (if any)
  • New HEAD:
    git rev-parse --short HEAD
  • Any conflicts that were resolved (list files)
If the service is running, remind the user to restart it to pick up changes.
展示以下内容:
  • 已更新的Skill(列表)
  • 已跳过或更新失败的Skill(如有)
  • 新的HEAD版本:
    git rev-parse --short HEAD
  • 已解决的冲突(列出文件)
如果服务正在运行,提醒用户重启服务以应用更改。