update-skills
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAbout
简介
Skills are distributed as git branches (). 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.
skill/*Run in Claude Code.
/update-skillsSkill以Git分支()的形式分发。当你安装一个Skill时,会将其分支合并到你的仓库中。本Skill用于检查上游的这些skill分支是否有新提交,并帮助你进行更新。
skill/*在Claude Code中运行 命令。
/update-skillsHow it works
工作原理
Preflight: checks for clean working tree and upstream remote.
Detection: fetches upstream, lists all branches, determines which ones you've previously merged (via merge-base), and checks if any have new commits.
upstream/skill/*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.
预检:检查工作区是否干净以及是否存在上游远程仓库。
检测:拉取上游代码,列出所有分支,判断哪些分支是你之前已合并的(通过merge-base),并检查是否有新提交。
upstream/skill/*选择:展示有可用更新的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 commands, only open files with actual conflicts.
git
- 工作区不干净时绝不执行操作。
- 仅为用户已合并(已安装)的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 is missing:
upstream- 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>- Check if the user has merged this skill branch before:
- — 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 merge-base --is-ancestor upstream/skill/<name>~1 HEADto see if there's a merge commit referencing this branch.git log --oneline --merges --grep="skill/<name>" HEAD - Alternative: — if the merge base is NOT the initial commit and the merge base includes commits unique to the skill branch, it has been merged.
MERGE_BASE=$(git merge-base HEAD upstream/skill/<name>) - Simplest reliable check: compare with
git merge-base HEAD upstream/skill/<name>. If the skill merge-base is strictly ahead of (or different from) the main merge-base, the user has merged this skill.git merge-base HEAD upstream/main
- 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>- 检查用户是否曾合并过该Skill分支:
- 执行—— 如果该命令成功(退出码0),说明用户曾合并过该分支。更简单的检查方式:
git merge-base --is-ancestor upstream/skill/<name>~1 HEAD,查看是否存在引用该分支的合并提交。git log --oneline --merges --grep="skill/<name>" HEAD - 替代方式:—— 如果合并基准不是初始提交,且包含该Skill分支独有的提交,则说明已合并。
MERGE_BASE=$(git merge-base HEAD upstream/skill/<name>) - 最简单可靠的检查方式:比较和
git merge-base HEAD upstream/skill/<name>的结果。如果Skill分支的合并基准严格领先于(或不同于)主分支的合并基准,则说明用户已合并该Skill。git merge-base HEAD upstream/main
- 执行
- 检查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 to let the user pick which skills to update.
multiSelect: true- 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(供参考)。
- 使用支持的AskUserQuestion功能,让用户选择需要更新的Skill。
multiSelect: true- 每个有更新的Skill对应一个选项,标注Skill名称和提交数量。
- 添加选项:“跳过——暂不更新任何Skill”
- 如果用户选择跳过,终止流程。
Step 3: Apply updates
步骤3:执行更新
For each selected skill (process one at a time):
- Tell the user which skill is being updated.
- Run:
git merge upstream/skill/<name> --no-edit - If the merge is clean, move to the next skill.
- If conflicts occur:
- Run to identify conflicted files.
git status - 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
- Run
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(逐个处理):
- 告知用户当前正在更新哪个Skill。
- 执行:
git merge upstream/skill/<name> --no-edit - 如果合并无冲突,继续处理下一个Skill。
- 如果发生冲突:
- 执行识别冲突文件。
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- (do not fail the flow if tests are not configured)
npm test
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 - 已解决的冲突(列出文件)
如果服务正在运行,提醒用户重启服务以应用更改。