sync-template
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: sync-template
Skill: sync-template
WHAT
WHAT
Purpose và context
目的与上下文
- Purpose: Sync structural/template improvements between project and .
https://github.com/Rheinmir/setup.git - Trigger (when to use):
- Upstream: Improved template locally → save to Master.
- Downstream: Master has newer fixes → bring into project.
- Non-goals: không sync , credentials, business docs; không tự
.envđể rút ngắn thời gian; không--strategy pulltemplate; không tự kích hoạt (git clone); Antigravity không chạy được skill này (sandbox chặn tool).disable-model-invocation: true
- 目的: 在项目与 之间同步结构性/模板改进。
https://github.com/Rheinmir/setup.git - 触发条件(何时使用):
- 上游同步: 本地改进了模板 → 保存到 Master。
- 下游同步: Master 有更新的修复 → 引入项目。
- 非目标: 不同步 、凭据、业务文档;不自行使用
.env来缩短耗时;不--strategy pull模板;不自行调用(git clone);Antigravity 无法运行此 skill(沙箱会阻止工具调用)。disable-model-invocation: true
Mental model
心智模型
Downstream mặc định: . Upstream / migrate / debug đi MANUAL STEPS 0–8 với điểm STOP hỏi user ở Step 5.
version.json + manifest remote → phân loại hash 3 mốc (disk ↔ R0 remote_synced ↔ remote hiện tại) → NEW/UPDATE tự PULL · KEPT giữ · CONFLICT giữ local + lưu bản remote → OKF backfill → fingerprint → cài skill 3 chỗ → verify 3 vị trí → log下游默认路径: + manifest 中的 remote 信息 → 按哈希划出三个基准点(磁盘 ↔ R0 ↔ 当前 remote)→ NEW/UPDATE 自动 PULL · KEPT 保持不变 · CONFLICT 保留 local + 保存 remote 版本 → OKF backfill → fingerprint → 将 skill 安装到 3 个位置 → 验证 3 个位置 → log。上游同步、迁移或 debug 进入 MANUAL STEPS 0–8,并在 Step 5 停下询问用户。
version.jsonremote_syncedInput và output contract
输入与输出约定
| Field | Required? | Ý nghĩa | |
|---|---|---|---|
| In | hướng sync | có | downstream (mặc định, FAST PATH) hoặc upstream (MANUAL) |
| In | | có | inclusion list, remote URL, |
| In | | không | đổi branch, lấy remote cho CONFLICT, xem trước, output máy đọc |
| In | quyết định user | khi CONFLICT hoặc Step 5 | lấy remote hay giữ local; pull/push file nào |
| Out | file template đã sync + OKF backfill | có | file wiki cũ convert bold→YAML |
| Out | | có | fingerprint sau OKF + |
| Out | skill cài ở | downstream | verify 3 vị trí |
| Out | report + exit code | có | 0 sạch, 1 lỗi tải/OKF/verify, 3 CONFLICT cần quyết |
| Out | dòng | có | script tự ghi log khi |
| 字段 | 是否必需 | 含义 | |
|---|---|---|---|
| 输入 | 同步方向 | 是 | downstream(默认,FAST PATH)或 upstream(MANUAL) |
| 输入 | | 是 | 包含列表、remote URL、 |
| 输入 | | 否 | 切换 branch、在 CONFLICT 时获取 remote、预览、输出机器可读结果 |
| 输入 | 用户决策 | CONFLICT 或 Step 5 时 | 获取 remote 还是保留 local;pull/push 哪些文件 |
| 输出 | 已同步的模板文件 + OKF backfill | 是 | 将旧 wiki 文件从 bold 转换为 YAML |
| 输出 | 刷新后的 | 是 | OKF 后的 fingerprint + |
| 输出 | 安装在 | 下游同步时 | 验证 3 个位置 |
| 输出 | report + exit code | 是 | 0 表示干净,1 表示下载/OKF/verify 错误,3 表示 CONFLICT 需要决策 |
| 输出 | | 是 | 使用 |
Rules và capabilities
规则与能力
- RULE-01 (MUST): NEVER sync , credentials, business docs.
.env - RULE-02 (MUST): ALWAYS audit remote branches — non-default may be newest.
- RULE-03 (MUST): ALWAYS show diff for → wait for instruction.
[CONFLICT] - RULE-04 (MUST): NEVER — file by file.
cp -R - RULE-05 (MUST): Step 3 every sync — detect old , offer migrate.
skills/ - RULE-06 (MUST): Step 7 every downstream sync — install all 3 Claude Code locations.
- RULE-07 (MUST): : add to manifest BEFORE upstream commit.
[NEW] - RULE-08 (MUST): : add to manifest AFTER downstream copy.
[MISSING] - RULE-09 (MUST): Frontmatter: +
name:for skills;description:only for slash commands.description: - RULE-10 (MUST): Skip ,
README.md,index.md, no-Purpose/Steps files.log.md - Capabilities: đọc remote template (HTTP/GitHub API); ghi file trong project + thư mục skill/command cấp user; đẩy lên remote template khi upstream (chỉ sau duyệt).
- RULE-01(必须):绝不同步 、凭据、业务文档。
.env - RULE-02(必须):始终审计 remote branches——非默认 branch 可能是最新的。
- RULE-03(必须):始终为 显示 diff → 等待指示。
[CONFLICT] - RULE-04(必须):绝不执行 ——必须逐文件处理。
cp -R - RULE-05(必须):每次同步都要执行 Step 3——检测旧 ,并提供迁移选项。
skills/ - RULE-06(必须):每次下游同步都要执行 Step 7——安装到全部 3 个 Claude Code 位置。
- RULE-07(必须)::在上游 commit 前加入 manifest。
[NEW] - RULE-08(必须)::在下游复制后加入 manifest。
[MISSING] - RULE-09(必须):Frontmatter:skill 必须包含 +
name:;slash command 只需description:。description: - RULE-10(必须):跳过 、
README.md、index.md以及没有log.md/## Purpose的文件。## Steps - 能力:通过 HTTP/GitHub API 读取 remote 模板;写入项目文件及用户级 skill/command 目录;在上游同步时将变更推送到 remote 模板(仅在获批后执行)。
Failure boundaries
失败边界
- CONFLICT (cả hai cùng đổi) → giữ local, lưu bản remote ra , exit 3 → clarify với user.
/tmp/sync-template-conflicts/ - Lỗi tải / OKF / verify → exit 1 → failed, sửa trước khi xong.
✗ - Branch remote không rõ cái nào mới nhất → clarify, hỏi user branch nào.
- health-check → không cần sync, dừng (succeeded no-op).
OK - Old layout → đề xuất migrate, confirm trước khi xoá.
skills/
- CONFLICT(双方均有更改)→ 保留 local,将 remote 版本保存到 ,exit 3 → 向用户澄清(clarify)。
/tmp/sync-template-conflicts/ - 下载/OKF/verify 错误 → exit 1 → 失败(failed);完成前必须修复 。
✗ - 无法确定哪个 remote branch 更新 → 向用户澄清(clarify),询问用户选择哪个 branch。
- health-check → 无需同步,停止(成功(succeeded),no-op)。
OK - 旧 布局 → 建议迁移,删除前必须确认(confirm)。
skills/
HOW
HOW
Main workflow
主工作流
| Step | Type | Inputs | Action | Outputs/exit | Failure/next |
|---|---|---|---|---|---|
| W01 | judgment | yêu cầu | Chọn đường: downstream thường → FAST PATH | đường đi | — |
| W02 | effect | manifest, remote | | report | exit 1 → failed; exit 3 → W03 |
| W03 | judgment | report | Đọc report; CONFLICT muốn lấy remote → chạy lại | quyết định | không rõ → hỏi user |
| W04 | deterministic | report | Không gọi thêm okf-check, health-check, vòng verify, không tự sửa log | báo cáo cho user | — |
| W05 | effect | kết quả | Output Report draft | draft + index + log | 0 artefact → skip |
Chi tiết từng bước (nguồn chân lý cho W01–W05 và nhánh MANUAL):
| 步骤 | 类型 | 输入 | 操作 | 输出/exit | 失败/下一步 |
|---|---|---|---|---|---|
| W01 | 判断 | 用户请求 | 选择路径:通常走下游 → FAST PATH | 所选路径 | — |
| W02 | 执行 | manifest、remote | 仅执行一次 | report | exit 1 → failed;exit 3 → W03 |
| W03 | 判断 | report | 读取 report;CONFLICT 且希望获取 remote → 再次运行 | 决策 | 不明确 → 询问用户 |
| W04 | 确定性处理 | report | 不再调用额外的 okf-check、health-check、verify 循环,也不自行修改 log | 向用户报告 | — |
| W05 | 执行 | 结果 | 输出 Report 草稿 | draft + index + log | 0 个产物 → 跳过 |
各步骤明细(W01–W05 及 MANUAL 分支的事实来源):
FAST PATH — downstream 1 lệnh --full
(< 30s, mặc định)
--fullFAST PATH——下游单条 --full
命令(< 30s,默认)
--fullDownstream sync là 1 script non-interactive tự chứa. Gọi 1 lần với → mọi bước
hậu-sync (Step 6a/6b/8 + ghi log) chạy trong CÙNG process. Agent đọc 1 report rồi báo cáo —
KHÔNG lặp lại lệnh riêng. Bench repo này: full steady-state 0.27s · full pull+install+verify 0.76s
().
--fullharness/metrics/sync-template-bench.jsonbash
python3 harness/scripts/sync-template.py --full # ⭐ MẶC ĐỊNH: sync + OKF backfill + fingerprint + verify ×3 + ghi log, 1 process
python3 harness/scripts/sync-template.py --full --json # như trên, output máy đọc (đọc okf_migrated / verify_bad)
python3 harness/scripts/sync-template.py --dry-run # xem trước, không ghi (kèm --full để xem OKF sẽ migrate gì)
python3 harness/scripts/sync-template.py --strategy pull # ghi đè cả CONFLICT bằng remote (backup .local-bak)Chạy1 lần là xong — đừng gọi tiếp--full,okf-check, vòng verify, hay tựhealth-check --updatelog.md (script đã làm hết). Đó là cách giữ skill dưới 30s: nút thắt cũ là số round-trip agent quanh các bước hậu-sync, không phải CPU. Không cờEdit= hành vi cũ y nguyên.--full
Phân loại bằng hash 3 mốc — disk ↔ R0 (remote tại lần sync trước, lưu ở ) ↔ remote hiện tại:
version.json:remote_synced- (thiếu local) +
NEW(remote mới hơn, local chưa đụng) → tự PULL.UPDATE - (mình đã custom, remote không mới hơn) → giữ nguyên, không hỏi.
KEPT - (cả hai cùng đổi) → mặc định giữ local + lưu bản remote ra
CONFLICTđể diff; exit code 3. Không bao giờ tự/tmp/sync-template-conflicts/để rút ngắn thời gian.--strategy pull
Quy trình tự động trong script (): fetch remote + → phân loại → tải song song → OKF backfill in-process (migrate bold→YAML, idempotent) → refresh (fingerprint SAU OKF + + ) → cài skill ra 3 chỗ (, , ) → self-verify 3 vị trí → append . Exit: 0 sạch · 1 lỗi tải/OKF/verify · 3 CONFLICT cần quyết.
--fullversion.jsonmanifestversion.jsontemplate_versionremote_synced.claude/commands/~/.claude/skills/~/.claude/commands/wiki/log.mdKhi nào CẦN can thiệp tay (chạy script trước, đọc report):
- Report có và bạn muốn lấy remote → chạy lại
CONFLICT(1 quyết định, không phải 3).--strategy pull - Branch remote KHÁC →
version.json:branch(xem Step 2 để audit branch).--branch <tên> - Cấu trúc cũ cần migrate (Step 3), hoặc cần upstream (đẩy lên) → dùng MANUAL STEPS bên dưới.
skills/
⚠ Bug đã fix:đặt baseline = disk → sync KHÔNG phân biệt được "remote mới" vs "mình đã custom" → suýt ghi đè file custom. Script này dùng baseline riênghealth-check --update(hash remote tại lần sync) nên phân biệt đúng. Đừng quay lại dùngremote_synced(disk) làm baseline phân loại.patterns
下游同步是 1 个自包含的非交互式 script。仅调用 1 次 → 所有同步后步骤(Step 6a/6b/8 + 写 log)都在同一进程中运行。Agent 读取 1 份 report 后再汇报——不要重复执行单独命令。本基准 repo 的耗时:full steady-state 0.27s · full pull+install+verify 0.76s()。
--fullharness/metrics/sync-template-bench.jsonbash
python3 harness/scripts/sync-template.py --full # ⭐ MẶC ĐỊNH: sync + OKF backfill + fingerprint + verify ×3 + ghi log, 1 process
python3 harness/scripts/sync-template.py --full --json # như trên, output máy đọc (đọc okf_migrated / verify_bad)
python3 harness/scripts/sync-template.py --dry-run # xem trước, không ghi (kèm --full để xem OKF sẽ migrate gì)
python3 harness/scripts/sync-template.py --strategy pull # ghi đè cả CONFLICT bằng remote (backup .local-bak)运行1 次即完成——不要继续调用--full、okf-check、verify 循环,也不要自行health-check --updatelog.md(script 已全部处理)。这是将 skill 控制在 30s 内的方式:旧瓶颈是同步后步骤周围的 agent round-trip 次数,而不是 CPU。不传Edit= 行为与旧版完全相同。--full
按哈希进行三基准点分类——磁盘 ↔ R0(上次同步时的 remote,保存在 中)↔ 当前 remote:
version.json:remote_synced- (local 缺失)+
NEW(remote 较新,local 尚未改动)→ 自动 PULL。UPDATE - (local 已自定义,remote 没有更新)→ 保持不变,无需询问。
KEPT - (双方均发生更改)→ 默认保留 local + 将 remote 版本保存到
CONFLICT以供 diff;exit code 3。绝不自行使用/tmp/sync-template-conflicts/来缩短耗时。--strategy pull
script 中的自动流程():获取 remote 的 + manifest → 分类 → 并行下载 → 在进程内执行 OKF backfill(将 bold 迁移为 YAML,幂等)→ 刷新 (OKF 后的 fingerprint + + )→ 将 skill 安装到 3 个位置(、、)→ 自行验证 3 个位置→ 追加 。Exit:0 表示干净 · 1 表示下载/OKF/verify 错误 · 3 表示 CONFLICT 需要决策。
--fullversion.jsonversion.jsontemplate_versionremote_synced.claude/commands/~/.claude/skills/~/.claude/commands/wiki/log.md何时需要手动介入(先运行 script,再读取 report):
- Report 中有 ,且希望获取 remote → 再次运行
CONFLICT(只需 1 次决策,不是 3 次)。--strategy pull - Remote branch 与 不同 →
version.json:branch(参见 Step 2 的 branch 审计)。--branch <tên> - 旧 结构需要迁移(Step 3),或需要执行 upstream(推送)→ 使用下方的 MANUAL STEPS。
skills/
⚠ 已修复的 Bug:会将 baseline 设为 disk → sync 无法区分“remote 有新内容”和“local 已自定义”→ 险些覆盖自定义文件。本 script 使用独立的health-check --updatebaseline(上次同步时 remote 的哈希),因此能够正确区分。不要重新使用remote_synced(disk)作为分类 baseline。patterns
MANUAL STEPS (fallback — upstream, migrate cấu trúc cũ, hoặc debug)
MANUAL STEPS(fallback——upstream、旧结构迁移或 debug)
Step 0: Pre-flight — health-check (chẩn đoán trước khi sync)
Step 0:预检——health-check(同步前诊断)
Chạy () để biết NÊN sync hướng nào:
/health-checkpython3 harness/scripts/health-check.py --root .- (behind/missing) → downstream (kéo về).
NEEDS-SYNC - (đã sửa local) → upstream (đẩy lên) hoặc revert.
DRIFT - → không cần sync, dừng.
OK
运行 (),确定应该采用哪个同步方向:
/health-checkpython3 harness/scripts/health-check.py --root .- (落后/缺失)→ 下游同步(拉取到项目)。
NEEDS-SYNC - (已修改 local)→ 上游同步(推送)或 revert。
DRIFT - → 无需同步,停止。
OK
Step 1: Load Manifest
Step 1:加载 Manifest
Read — inclusion list + remote URL.
.template-manifest.json读取 ——其中包含包含列表 + remote URL。
.template-manifest.jsonStep 2: Fetch & Branch Audit
Step 2:获取与 Branch 审计
- CRITICAL: List all remote branches: .
gh api repos/<owner>/<repo>/branches - Check commit date per branch — don't assume /
masteris newest.main - Unclear → ask user which branch.
- Fetch via +
gh api— nocurl.git clone
- 关键操作: 列出所有 remote branches:。
gh api repos/<owner>/<repo>/branches - 检查每个 branch 的 commit date——不要假定 /
master最新。main - 不明确 → 询问用户选择哪个 branch。
- 通过 +
gh api获取——不要curl。git clone
Step 3: Detect Old Structure Migration
Step 3:检测旧结构迁移
Check for old layout needing migration to :
skills/llmwiki/bash
undefined检查是否存在需要迁移到 的旧 布局:
llmwiki/skills/bash
undefinedSigns of old structure:
Signs of old structure:
[ -d "skills/" ] && [ ! -d "llmwiki/skills/" ] # old only
[ -d "skills/" ] && [ -d "llmwiki/skills/" ] # both exist → migration in progress
**Old `skills/` + new `llmwiki/skills/` coexist:**
1. List `skills/` (flat .md + subdirs: `dev-loop/`, `wiki-loop/`, etc.)
2. Map old → new:
- `skills/dev-loop/*.md` → `llmwiki/skills/dev-loop/*.md`
- `skills/wiki-loop/*.md` → `llmwiki/skills/wiki-loop/*.md`
- `skills/orchestrate/*.md`→ `llmwiki/skills/orchestrate/*.md`
- `skills/utils/*.md` → `llmwiki/skills/utils/*.md`
- `skills/*.md` (flat) → already covered by subdirs, skip duplicates
3. Content matches → old stale, safe to remove.
4. Show migration table → confirm before delete.[ -d "skills/" ] && [ ! -d "llmwiki/skills/" ] # old only
[ -d "skills/" ] && [ -d "llmwiki/skills/" ] # both exist → migration in progress
**旧 `skills/` 与新 `llmwiki/skills/` 共存:**
1. 列出 `skills/`(平铺的 .md + 子目录:`dev-loop/`、`wiki-loop/` 等)。
2. 映射旧路径 → 新路径:
- `skills/dev-loop/*.md` → `llmwiki/skills/dev-loop/*.md`
- `skills/wiki-loop/*.md` → `llmwiki/skills/wiki-loop/*.md`
- `skills/orchestrate/*.md`→ `llmwiki/skills/orchestrate/*.md`
- `skills/utils/*.md` → `llmwiki/skills/utils/*.md`
- `skills/*.md`(平铺) → 已由子目录覆盖,跳过重复项
3. 内容一致 → 旧文件已过期,可以安全删除。
4. 显示迁移表 → 删除前确认。Step 4: Compare Manifest Files
Step 4:比较 Manifest 文件
diffincludesbash
BASE="https://raw.githubusercontent.com/<owner>/<repo>/<branch>"
for file in <includes>; do
http_code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/$file")
# SAME / DIFF / MISSING / NEW / ABSENT
doneStatus:
- — skip
SAME - — content differs
DIFF - — remote only → downstream candidate
MISSING - — local only → upstream candidate
NEW - — neither
ABSENT
对 中的每个文件执行 local 与 remote 的 :
includesdiffbash
BASE="https://raw.githubusercontent.com/<owner>/<repo>/<branch>"
for file in <includes>; do
http_code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/$file")
# SAME / DIFF / MISSING / NEW / ABSENT
done状态:
- ——跳过。
SAME - ——内容不同。
DIFF - ——仅 remote 存在 → 下游候选。
MISSING - ——仅 local 存在 → 上游候选。
NEW - ——两者均不存在。
ABSENT
Step 5: Sync Plan
Step 5:同步计划
Show table. STOP → ask user: pull all / push all / specific files / direction per DIFF.
显示表格。STOP → 询问用户:全部 pull / 全部 push / 指定文件 / 对每个 DIFF 分别指定方向。
Step 6: Execute
Step 6:执行
- Downstream: →
mkdir -p→ updatecurl -sfL <url> -o <local_path>wiki/log.md - Upstream: commit + push via /
ghgit - File by file — no
cp -R
Step 6a/6b/8 đã GỘP vào. Nếu bạn chạy FAST PATH--fullthì BỎ QUA 6a/6b/8 — script đã OKF-backfill + refresh fingerprint + verify + ghi log trong process. Các bước dưới chỉ dùng khi chạy MANUAL (debug / upstream / migrate cấu trúc cũ), không phải sau--full.--full
- 下游: →
mkdir -p→ 更新curl -sfL <url> -o <local_path>。wiki/log.md - 上游: 通过 /
ghcommit + push。git - 逐文件处理——不要使用 。
cp -R
Step 6a/6b/8 已合并到。 如果运行 FAST PATH--full,请跳过 6a/6b/8——script 已在同一进程内完成 OKF-backfill + 刷新 fingerprint + verify + 写 log。以下步骤仅用于 MANUAL(debug / upstream / 旧结构迁移),不应在--full之后执行。--full
Step 6a: OKF backfill (MANUAL — --full
đã làm)
--fullStep 6a:OKF backfill (MANUAL——--full
已完成)
--fullTemplate/skill mới có thể nâng định dạng wiki (vd chuẩn OKF v0.1). Sau khi pull, convert mọi file content cũ còn dùng pseudo-frontmatter dạng bold sang YAML frontmatter để khỏi vướng R9:
**Type:**bash
python3 harness/scripts/okf-check.py --check # exit 3 = có file chưa đạt OKF
python3 harness/scripts/okf-check.py --migrate # convert bold → YAML (chỉ THÊM frontmatter, giữ body/## Origin)- Idempotent — file đã có frontmatter được bỏ qua. Reserved (index/log/README/decisions/_template…) tự miễn.
--- - Sau migrate: chạy lại đến khi
--check, rồi cập nhật index/log như mọi thay đổi wiki.DAT CHUAN OKF v0.1
新的 template/skill 可能提升 wiki 格式标准(例如采用 OKF v0.1)。pull 后,将所有仍使用 形式 pseudo-frontmatter 的旧 content 文件转换为 YAML frontmatter,以避免违反 R9:
**Type:**bash
python3 harness/scripts/okf-check.py --check # exit 3 = có file chưa đạt OKF
python3 harness/scripts/okf-check.py --migrate # convert bold → YAML (chỉ THÊM frontmatter, giữ body/## Origin)- 幂等——已有 frontmatter 的文件会被跳过。Reserved 文件(index/log/README/decisions/_template…)自动豁免。
--- - 迁移后:再次运行 ,直至输出
--check,然后像更新其他 wiki 变更一样更新 index/log。DAT CHUAN OKF v0.1
Step 6b: Refresh version fingerprint (MANUAL — --full
đã làm)
--fullStep 6b:刷新版本指纹 (MANUAL——--full
已完成)
--fullNội dung pattern vừa đổi → cập nhật lại để health-check khỏi báo DRIFT giả:
harness/version.jsonbash
python3 harness/scripts/health-check.py --update # KHÔNG --bump ở project con- CHỈ chạy ở repo template
--bump major|minor|patchkhi PHÁT HÀNH version pattern mới.Rheinmir/setup - Upstream sync ở repo template: sau khi push, chạy rồi commit
--update --bump <part>.harness/version.json
刚刚修改了 pattern 内容 → 再次更新 ,避免 health-check 报告虚假的 DRIFT:
harness/version.jsonbash
python3 harness/scripts/health-check.py --update # KHÔNG --bump ở project con- 仅在
--bump major|minor|patch模板 repo 发布新 pattern 版本时运行。Rheinmir/setup - 在模板 repo 中执行上游同步时:push 后运行 ,然后 commit
--update --bump <part>。harness/version.json
Step 7: Install as Native Skills (runs every downstream sync)
Step 7:安装为原生 Skills (每次下游同步都会运行)
Collect skill files synced (under in manifest). Skip: , , , no-/ files.
llmwiki/skills/README.mdindex.mdlog.md## Purpose## StepsA. Project-level ( — this repo):
.claude/commands/bash
mkdir -p .claude/commands/收集 manifest 中已同步的 skill 文件(位于 下)。跳过:、、 以及没有 / 的文件。
llmwiki/skills/README.mdindex.mdlog.md## Purpose## StepsA. 项目级(——本 repo):
.claude/commands/bash
mkdir -p .claude/commands/Add description: frontmatter if missing, then copy
Add description: frontmatter if missing, then copy
printf -- "---\ndescription: %s\n---\n\n" "$desc" | cat - <src> > .claude/commands/<name>.md
**B. Global user-level** (`~/.claude/skills/<name>/SKILL.md` — all projects):
```bash
mkdir -p ~/.claude/skills/<name>/printf -- "---\ndescription: %s\n---\n\n" "$desc" | cat - <src> > .claude/commands/<name>.md
**B. 全局用户级**(`~/.claude/skills/<name>/SKILL.md`——适用于所有项目):
```bash
mkdir -p ~/.claude/skills/<name>/Requires name: + description: frontmatter
Requires name: + description: frontmatter
printf -- "---\nname: %s\ndescription: %s\n---\n\n" "$name" "$desc" | cat - <src> > ~/.claude/skills/<name>/SKILL.md
**C. Global slash command** (`~/.claude/commands/<name>.md`):
```bash
printf -- "---\ndescription: %s\n---\n\n" "$desc" | cat - <src> > ~/.claude/commands/<name>.mdInstall cả 3. Report:
| Skill | Project .claude/commands/ | ~/.claude/skills/ | ~/.claude/commands/ |
|----------------|---------------------------|-------------------|---------------------|
| propose | ✓ | ✓ | ✓ |
| ingest | ✓ | ✓ | ✓ |
| ... | ... | ... | ... |printf -- "---\nname: %s\ndescription: %s\n---\n\n" "$name" "$desc" | cat - <src> > ~/.claude/skills/<name>/SKILL.md
**C. 全局 slash command**(`~/.claude/commands/<name>.md`):
```bash
printf -- "---\ndescription: %s\n---\n\n" "$desc" | cat - <src> > ~/.claude/commands/<name>.md全部安装 3 处。报告:
| Skill | Project .claude/commands/ | ~/.claude/skills/ | ~/.claude/commands/ |
|----------------|---------------------------|-------------------|---------------------|
| propose | ✓ | ✓ | ✓ |
| ingest | ✓ | ✓ | ✓ |
| ... | ... | ... | ... |Step 8: Verify & Finalize
Step 8:验证与完成
bash
for name in <skill-list>; do
[ -f ".claude/commands/$name.md" ] && echo "✓ proj $name" || echo "✗ proj $name"
[ -f "$HOME/.claude/skills/$name/SKILL.md" ] && echo "✓ global $name" || echo "✗ global $name"
doneFix before done. No restart needed.
✗bash
for name in <skill-list>; do
[ -f ".claude/commands/$name.md" ] && echo "✓ proj $name" || echo "✗ proj $name"
[ -f "$HOME/.claude/skills/$name/SKILL.md" ] && echo "✓ global $name" || echo "✗ global $name"
done完成前修复所有 。无需重启。
✗Branches
Branches
| ID | Kind | Guard | Hành vi | Skip / failure | Rejoin |
|---|---|---|---|---|---|
| B01 | conditional_required | cần upstream, migrate cấu trúc | chạy MANUAL STEPS 0–8, STOP hỏi user ở Step 5 | downstream thường → FAST PATH | W05 |
| B02 | recovery | exit 3 CONFLICT và user chọn lấy remote | chạy lại | user giữ local → không làm gì | W04 |
| B03 | conditional_required | branch remote khác | | — | W02 |
| B04 | user_optional | muốn xem trước | | — | W02 |
| B05 | conditional_required | phát hiện old | hiện bảng migration, confirm rồi mới xoá | user từ chối → giữ | W05 |
| ID | 类型 | 守卫条件 | 行为 | 跳过/失败 | 汇合点 |
|---|---|---|---|---|---|
| B01 | conditional_required | 需要 upstream、迁移旧 | 运行 MANUAL STEPS 0–8,在 Step 5 STOP 并询问用户 | 通常的 downstream → FAST PATH | W05 |
| B02 | recovery | exit 3 CONFLICT 且用户选择获取 remote | 再次运行 | 用户保留 local → 不执行任何操作 | W04 |
| B03 | conditional_required | remote branch 与 | 审计 branch(Step 2)后使用 | — | W02 |
| B04 | user_optional | 希望预览 | | — | W02 |
| B05 | conditional_required | 检测到旧 | 显示迁移表,确认后才删除 | 用户拒绝 → 保留 | W05 |
Validation và stopping
验证与停止条件
Tất định: exit code script (0/1/3), self-verify 3 vị trí cài, ra (MANUAL), vòng Step 8 không còn . Dừng sau MỘT lần khi exit 0; exit 3 dừng chờ user quyết; MANUAL dừng ở Step 5 chờ duyệt.
okf-check.py --checkDAT CHUAN OKF v0.1[ -f … ]✗--full确定性条件:script exit code(0/1/3)、自行验证 3 个安装位置、 输出 (MANUAL)、Step 8 的 验证循环中不再出现 。一次 返回 exit 0 后立即停止;exit 3 时停止并等待用户决策;MANUAL 在 Step 5 停止并等待批准。
okf-check.py --checkDAT CHUAN OKF v0.1[ -f … ]✗--fullExamples
示例
- Positive: project con, Master có fix mới → → 2 UPDATE tự PULL, 1 KEPT giữ nguyên, OKF migrate 3 file, verify 3 vị trí ✓, exit 0 trong < 1s → báo report, không chạy thêm lệnh nào.
python3 harness/scripts/sync-template.py --full - Boundary/failure: file sửa ở cả local và remote → CONFLICT, giữ local, bản remote ở
llmwiki/skills/dev-loop/ship.md, exit 3 → hiện diff, chờ user; không tự/tmp/sync-template-conflicts/.--strategy pull
- 正向示例: 子项目,Master 有新修复 → → 2 个 UPDATE 自动 PULL,1 个 KEPT 保持不变,迁移 3 个 OKF 文件,验证 3 个位置 ✓,exit 0 且耗时 < 1s → 输出 report,不再运行其他命令。
python3 harness/scripts/sync-template.py --full - 边界/失败示例: 在 local 和 remote 中均被修改 → CONFLICT,保留 local,remote 版本保存到
llmwiki/skills/dev-loop/ship.md,exit 3 → 显示 diff 并等待用户;不自行使用/tmp/sync-template-conflicts/。--strategy pull
Reference — Agent Compatibility
参考——Agent 兼容性
| Agent | Run? | Reason |
|---|---|---|
| Claude Code | Yes | Full tool access |
| OpenCode | Yes | Full tool access |
| Antigravity | No | Sandbox blocks file/command tools |
| Agent | 可运行? | 原因 |
|---|---|---|
| Claude Code | Yes | 拥有完整工具访问权限 |
| OpenCode | Yes | 拥有完整工具访问权限 |
| Antigravity | No | 沙箱阻止文件/命令工具 |
Delivery — Output Report
交付——输出报告
After all main skill tasks complete, write a propose draft to the wiki.
所有主 skill 任务完成后,向 wiki 写入一份 propose 草稿。
Steps
Steps
1. Build the filename:
- Format:
DDMMYY-<ten>.md - = today (e.g.,
DDMMYYfor 2 June 2026)020626 - = 2–4 kebab-case words summarising what was done (e.g.,
<ten>,landing-page-coteccons,brand-kit-fintech)ingest-auth-spec
2. Write :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---1. 构建文件名:
- 格式:
DDMMYY-<ten>.md - = 当天日期(例如,2026 年 6 月 2 日对应
DDMMYY)020626 - = 2–4 个概括所完成工作的 kebab-case 单词(例如
<ten>、landing-page-coteccons、brand-kit-fintech)ingest-auth-spec
2. 写入 :
llmwiki/wiki/sources/draft/DDMMYY-<ten>.md---
type: draft
title: "DDMMYY-<ten>"
status: proposed
tags: [<skill-name>, output-report]
timestamp: YYYY-MM-DD
---DDMMYY-<ten>
DDMMYY-<ten>
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
Type: draft
Status: proposed
Tags: <skill-name>, output-report
Proposed: YYYY-MM-DD
What
What
<One sentence — what this skill invocation produced or decided>
<One sentence — what this skill invocation produced or decided>
Output
Output
<Key artefacts, files created/modified, or decisions made>
<Key artefacts, files created/modified, or decisions made>
Files
Files
| File | Action |
|---|---|
| created / modified |
| File | Action |
|---|---|
| created / modified |
Notes
Notes
- Invoked via: skill
/<skill-name>
- Invoked via: skill
/<skill-name>
Origin
Origin
- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. Update wiki index & log:**
- `llmwiki/wiki/index.md` — append one row: `| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md` — append: `## YYYY-MM-DD — <skill-name> — <ten>`
> Skip only when the skill produces zero artefacts and zero decisions (e.g., a pure display mode like `/caveman-stats`).- Draft:
wiki/sources/draft/DDMMYY-<ten>.md - Commit: (filled by verify-before-commit)
- Date promoted: (filled by verify-before-commit)
**3. 更新 wiki index 与 log:**
- `llmwiki/wiki/index.md`——追加一行:`| [DDMMYY-<ten>](sources/draft/DDMMYY-<ten>.md) | draft | YYYY-MM-DD |`
- `llmwiki/wiki/log.md`——追加:`## YYYY-MM-DD — <skill-name> — <ten>`
> 仅当 skill 产生 0 个产物且做出 0 项决策时跳过(例如 `/caveman-stats` 这类纯展示模式)。