autosync-ic-skills
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSet up self-updating Internet Computer skills
配置自更新的 Internet Computer 技能
This skill installs a small amount of project configuration so that every new
Claude Code session automatically downloads the latest Internet Computer skills
into , where Claude discovers and triggers them natively.
.claude/skills/It is a one-time installer. After you complete the steps below, the user never
needs this link again — the installed hook does the work from then on.
SessionStart此 skill 会安装少量项目配置,使每个新的 Claude Code 会话自动下载最新的 Internet Computer 技能并保存到 ,Claude 会在该目录中原生地发现并触发这些技能。
.claude/skills/这是一个一次性安装程序。完成以下步骤后,用户将不再需要此链接——已安装的 hook 从此会负责完成这项工作。
SessionStartWhat you will create
将创建的内容
- — a differential sync script that mirrors the live skill index into
.claude/sync-ic-skills.sh..claude/skills/ - A hook in
SessionStartthat runs that script..claude/settings.json - An immediate first run, so skills are present right away.
The script is a differential mirror. It fetches the discovery index once and
compares each skill's published against a stored manifest, re-downloading only
the skills that actually changed (and pruning ones removed upstream). Unchanged skills
are skipped with no per-file downloads, and the script writes nothing to stdout unless
something changed. If the server does not publish a for a skill, the script falls back to
re-downloading it every run, so it remains correct either way.
hashhash- ——一个差异同步脚本,用于将实时 skill 索引镜像到
.claude/sync-ic-skills.sh。.claude/skills/ - 中的一个
.claude/settings.jsonhook,用于运行该脚本。SessionStart - 立即执行首次运行,使技能马上可用。
该脚本是一个差异镜像。它只获取一次发现索引,并将每个技能发布的 与已存储的 manifest 进行比较,仅重新下载实际发生变化的技能(并清理上游已移除的技能)。未变化的技能会被跳过,不会逐文件下载;除非发生某些更改,否则脚本不会向 stdout 写入任何内容。如果服务器未为某个技能发布 ,脚本会在每次运行时退回到重新下载该技能,从而确保结果始终正确。
hashhashImportant: tell the user what to expect
重要:告知用户预期行为
Adding a hook means a shell script will run automatically at the start of future
sessions. Claude Code will ask the user to review and trust the new hook before
it activates — this is expected and correct. Let the user know:
"I'm adding ahook that runsSessionStart. Claude Code will ask you to approve/trust it before it runs automatically. After that, your IC skills stay current on every session.".claude/sync-ic-skills.sh
Do not attempt to bypass that approval.
添加 hook 意味着 shell 脚本将在未来会话开始时自动运行。Claude Code 会要求用户审查并信任新 hook,然后才会激活它——这是预期且正确的行为。请告知用户:
“我正在添加一个hook,用于运行SessionStart。Claude Code 会在自动运行前要求你批准/信任它。完成后,你的 IC 技能将在每个会话中保持最新。”.claude/sync-ic-skills.sh
不要尝试绕过该批准流程。
Step 0 — Check prerequisites (curl
, jq
)
curljq第 0 步——检查先决条件(curl
、jq
)
curljqThe sync script needs (virtually always present) and (often not).
Before writing anything, check for them:
curljqbash
command -v curl >/dev/null 2>&1 && echo "curl: ok" || echo "curl: MISSING"
command -v jq >/dev/null 2>&1 && echo "jq: ok" || echo "jq: MISSING"- If is missing, offer to install it (ask the user before running an install command). Pick the right one for their platform:
jq- macOS (Homebrew):
brew install jq - Debian/Ubuntu:
sudo apt-get update && sudo apt-get install -y jq - Fedora/RHEL:
sudo dnf install -y jq - Alpine:
apk add jq - Arch:
sudo pacman -S --noconfirm jq - Windows (winget):
winget install jqlang.jq
- macOS (Homebrew):
- If the user declines, still proceed — the script is written to degrade gracefully
(it exits cleanly with a warning when is absent), and they can install
jqlater and the next session will sync.jq
同步脚本需要 (几乎总是已安装)和 (通常未安装)。在写入任何内容之前,检查它们是否存在:
curljqbash
command -v curl >/dev/null 2>&1 && echo "curl: ok" || echo "curl: MISSING"
command -v jq >/dev/null 2>&1 && echo "jq: ok" || echo "jq: MISSING"- 如果缺少 ,请提供安装选项(在运行安装命令前询问用户)。根据其平台选择合适的命令:
jq- macOS(Homebrew):
brew install jq - Debian/Ubuntu:
sudo apt-get update && sudo apt-get install -y jq - Fedora/RHEL:
sudo dnf install -y jq - Alpine:
apk add jq - Arch:
sudo pacman -S --noconfirm jq - Windows(winget):
winget install jqlang.jq
- macOS(Homebrew):
- 如果用户拒绝安装,仍可继续——脚本已设计为优雅降级(缺少 时会输出警告并正常退出),用户之后可以安装
jq,下一个会话即可进行同步。jq
Step 1 — Download the sync script
第 1 步——下载同步脚本
The script is published as a file alongside this skill, so you fetch it verbatim rather
than transcribing it (this guarantees byte-exact content). Create the directory
and download it:
.claudebash
mkdir -p .claude
curl -fsSL https://skills.internetcomputer.org/.well-known/skills/autosync-ic-skills/scripts/sync-ic-skills.sh \
-o .claude/sync-ic-skills.shDo not hand-write or paraphrase the script — always fetch the published copy so the
sync logic stays correct as it is updated upstream.
What the script does (for the user's awareness):
- Fetches once.
https://skills.internetcomputer.org/.well-known/skills/index.json - For each skill, compares the published against
hash(a.claude/skills/.ic-managed.jsonmanifest of skills it manages) and re-downloads only the skills whose hash changed or are new.{ "<skill>": "<hash>" } - Prunes skills it previously installed that are no longer in the index, and replaces a changed skill's whole directory via an atomic staging swap — so files renamed or removed upstream don't linger inside a skill, and an interrupted download leaves the existing copy intact.
- Writes nothing to stdout on a no-op sync. When something changed it prints one JSON
object whose carries the
systemMessagesummary — that string is what the user sees, because SessionStart hooks surface JSON fields rather than raw output. Its diagnostics (interrupted-sync recovery, unsafe skill names) go to stderr and so are not displayed.added / updated / removed - Degrades gracefully: exits cleanly (keeping cached skills) if the network is down or
is missing, and falls back to re-downloading skills the server publishes no
jqfor.hash
该脚本与此 skill 一同作为文件发布,因此应原样下载,而不是转录它(这样可保证内容逐字节一致)。创建 目录并下载:
.claudebash
mkdir -p .claude
curl -fsSL https://skills.internetcomputer.org/.well-known/skills/autosync-ic-skills/scripts/sync-ic-skills.sh \
-o .claude/sync-ic-skills.sh不要手动编写或改写脚本——始终获取已发布的副本,以确保上游更新同步逻辑后,脚本仍能保持正确。
脚本的作用(供用户了解):
- 只获取一次 。
https://skills.internetcomputer.org/.well-known/skills/index.json - 对每个技能,将发布的 与
hash(一个由脚本管理的技能及其.claude/skills/.ic-managed.json组成的hashmanifest)进行比较,并且只重新下载 hash 发生变化或新出现的技能。{ "<skill>": "<hash>" } - 清理此前安装、但已不在索引中的技能,并通过原子化暂存替换来替换发生变化的整个技能目录——这样,上游重命名或移除的文件就不会残留在技能目录中,而下载中断时也会保留现有副本。
- 无变更同步时不向 stdout 写入任何内容。发生更改时,它会输出一个 JSON 对象,其 字段包含
systemMessage摘要——由于 SessionStart hook 会展示 JSON 字段而不是原始输出,因此用户看到的就是该字符串。它的诊断信息(同步中断恢复、不安全的 skill 名称)会写入 stderr,因此不会显示。added / updated / removed - 优雅降级:如果网络中断或缺少 ,脚本会正常退出并保留缓存技能;对于服务器未发布
jq的技能,则退回到每次重新下载。hash
Step 2 — Register the SessionStart hook (idempotently)
第 2 步——注册 SessionStart hook(幂等)
Add a hook to that runs the script.
SessionStart.claude/settings.json- If does not exist, create it with the content below.
.claude/settings.json - If it does exist, merge — preserve all existing keys, hooks, and
permissions. Only add the entry, and only if an equivalent
SessionStartcommand is not already present (do not create a duplicate). Parse the existing JSON, insert into thebash .claude/sync-ic-skills.sharray, and write it back; never blindly overwrite the file.hooks.SessionStart
The entry to ensure is present:
json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{ "type": "command", "command": "bash .claude/sync-ic-skills.sh" }
]
}
]
}
}在 中添加一个用于运行脚本的 hook。
.claude/settings.jsonSessionStart- 如果 不存在,则使用以下内容创建它。
.claude/settings.json - 如果它已存在,则进行合并——保留所有现有键、hook 和权限。仅添加 条目,并且仅当其中不存在等效的
SessionStart命令时才添加(不要创建重复项)。解析现有 JSON,将条目插入bash .claude/sync-ic-skills.sh数组,然后写回;绝不要直接覆盖文件。hooks.SessionStart
需要确保存在以下条目:
json
{
"hooks": {
"SessionStart": [
{
"hooks": [
{ "type": "command", "command": "bash .claude/sync-ic-skills.sh" }
]
}
]
}
}Step 3 — Run it once now
第 3 步——立即运行一次
Run the script immediately so the skills are available in this session without
waiting for the next session start:
bash
bash .claude/sync-ic-skills.sh立即运行脚本,使技能在当前会话中可用,而不必等到下一个会话开始:
bash
bash .claude/sync-ic-skills.shStep 4 — Verify and report
第 4 步——验证并报告
- Confirm now contains skill directories (e.g.
.claude/skills/,writing-motoko,static-site, …) each with auser-sign-in.SKILL.md - Confirm maps each synced skill name to its hash.
.claude/skills/.ic-managed.json - Tell the user: how many skills were installed, that the hook is in place, and that they'll be prompted to trust the hook before it auto-runs next session. From then on, their IC skills refresh automatically every session.
SessionStart
- 确认 现在包含技能目录(例如
.claude/skills/、writing-motoko、static-site等),且每个目录中都有user-sign-in。SKILL.md - 确认 将每个已同步的技能名称映射到其 hash。
.claude/skills/.ic-managed.json - 告知用户:安装了多少个技能、hook 已配置完成,并且下一个会话自动运行前 they'll be prompted to trust the hook。从那以后,其 IC 技能将在每个会话中自动刷新。
SessionStart
Notes
说明
- Safe to re-run. Re-invoking this skill or the script is idempotent: the hook is
not duplicated, and only skills tracked in are ever pruned.
.ic-managed.json - Differential by hash. The script keys off the per-skill field in the discovery index, so a normal session that touches nothing downloads only
hashand exits silently. Skills are re-downloaded only when their hash changes. Migrating from an older version of this script (whose manifest was a bare name array) is handled automatically on the next run.index.json - Optional mid-session refresh. For very long-running sessions, the user can also
run manually, or schedule it (e.g. via
bash .claude/sync-ic-skills.shor a cron routine) — but the SessionStart hook covers the normal case./loop
- 可安全重复运行。 再次调用此 skill 或脚本具有幂等性:不会重复添加 hook,并且只会清理 中跟踪的技能。
.ic-managed.json - 按 hash 进行差异同步。 脚本以发现索引中每个技能的 字段为依据,因此没有变更的普通会话只会下载
hash并静默退出。只有技能的 hash 发生变化时才会重新下载。从此脚本的旧版本(其 manifest 是纯名称数组)迁移时,脚本会在下一次运行时自动处理。index.json - 可选的会话中刷新。 对于运行时间很长的会话,用户也可以手动运行 ,或进行调度(例如通过
bash .claude/sync-ic-skills.sh或 cron 例程)——但 SessionStart hook 已覆盖常规场景。/loop