chezmoi-sync

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Chezmoi Sync (Interactive)

Chezmoi 同步(交互式)

On-demand replacement for the automatic chezmoi stop guard. Run this skill whenever you want to check for chezmoi drift and sync tracked dotfiles.
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
可按需替代chezmoi自动停止防护机制。当你需要检查chezmoi偏差并同步已跟踪的dotfiles时,运行本skill即可。
自演进Skill: 本Skill会随着使用不断优化。如果说明有误、参数发生偏差,或者需要使用临时解决方案,请立即修复此文件,不要推迟。仅针对真实可复现的问题进行更新。

Workflow

工作流

Step 1: Check for drift

步骤1:检查偏差

Run
chezmoi status
and
chezmoi diff --no-pager
to detect drift between the source repo and home directory.
bash
chezmoi source-path && chezmoi status && echo "---" && chezmoi diff --no-pager | head -80
If output is empty (no drift), report "Chezmoi is clean — no drift detected" and stop.
运行
chezmoi status
chezmoi diff --no-pager
来检测源仓库和主目录之间的偏差。
bash
chezmoi source-path && chezmoi status && echo "---" && chezmoi diff --no-pager | head -80
如果输出为空(无偏差),则提示「Chezmoi状态干净——未检测到偏差」并终止运行。

Step 2: Present drift to user (AskUserQuestion)

步骤2:向用户展示偏差(AskUserQuestion)

If drift exists, use
AskUserQuestion
to show the user what drifted and ask what to do.
Question 1 (header: "Drift action"):
"Chezmoi detected N drifted file(s): [list files]. What would you like to do?"
Options:
  • Sync all
    chezmoi re-add
    all drifted files, commit, and push
  • Review each — Walk through each file individually with per-file choices
  • Ignore — Skip sync, I'll handle it later
如果存在偏差,使用
AskUserQuestion
向用户展示偏差内容并询问后续操作。
问题1(标题:「偏差处理操作」):
「Chezmoi检测到N个存在偏差的文件:[文件列表]。你想要如何处理?」
选项:
  • 全部同步 — 对所有偏差文件执行
    chezmoi re-add
    ,提交并推送
  • 逐个审查 — 逐个遍历每个文件,针对单个文件选择处理方式
  • 忽略 — 跳过同步,我稍后自行处理

Step 3a: Sync all (if chosen)

步骤3a:全部同步(如果选择此项)

bash
chezmoi re-add --verbose
chezmoi git -- add -A && chezmoi git -- commit -m "sync: dotfiles" && chezmoi git -- push
chezmoi status  # Verify clean
Report the commit hash and confirm clean state.
bash
chezmoi re-add --verbose
chezmoi git -- add -A && chezmoi git -- commit -m "sync: dotfiles" && chezmoi git -- push
chezmoi status  # Verify clean
返回提交哈希值并确认状态已清理。

Step 3b: Review each (if chosen)

步骤3b:逐个审查(如果选择此项)

For each drifted file, use
AskUserQuestion
:
Question (header: "File action"):
"[filename] has changed. What should we do?"
Options:
  • Sync — Add this file to chezmoi source (
    chezmoi add <path>
    )
  • Diff — Show the full diff first, then ask again
  • Forget — Stop tracking this file (
    chezmoi forget --force <path>
    )
  • Skip — Leave it drifted for now
After processing all files, if any were synced:
bash
chezmoi git -- add -A && chezmoi git -- commit -m "sync: dotfiles" && chezmoi git -- push
针对每个存在偏差的文件,使用
AskUserQuestion
询问:
问题(标题:「文件处理操作」):
「[文件名]已变更。我们应该如何处理?」
选项:
  • 同步 — 将此文件添加到chezmoi源(
    chezmoi add <路径>
  • 查看差异 — 先展示完整的diff内容,之后再次询问
  • 取消跟踪 — 停止跟踪此文件(
    chezmoi forget --force <路径>
  • 跳过 — 暂时保留偏差状态
处理完所有文件后,如果有文件被同步:
bash
chezmoi git -- add -A && chezmoi git -- commit -m "sync: dotfiles" && chezmoi git -- push

Step 3c: Ignore (if chosen)

步骤3c:忽略(如果选择此项)

Report: "Skipped chezmoi sync. Run
/dotfiles-tools:chezmoi-sync
when ready."
返回提示:「已跳过chezmoi同步。准备就绪后可运行
/dotfiles-tools:chezmoi-sync
」。

Notes

注意事项

  • Always use
    chezmoi forget --force
    (not bare
    forget
    ) to avoid TTY prompt issues
  • The chezmoi source dir is
    ~/own/dotfiles
    (configured in
    ~/.config/chezmoi/chezmoi.toml
    )
  • 始终使用
    chezmoi forget --force
    (不要使用裸
    forget
    ),避免TTY提示问题
  • chezmoi源目录为
    ~/own/dotfiles
    (配置在
    ~/.config/chezmoi/chezmoi.toml
    中)

Post-Execution Reflection

执行后复盘

After this skill completes, reflect before closing the task:
  1. Locate yourself. — Find this SKILL.md's canonical path before editing.
  2. What failed? — Fix the instruction that caused it.
  3. What worked better than expected? — Promote to recommended practice.
  4. What drifted? — Fix any script, reference, or dependency that no longer matches reality.
  5. Log it. — Evolution-log entry with trigger, fix, and evidence.
Do NOT defer. The next invocation inherits whatever you leave behind.
本Skill执行完成后,关闭任务前请先复盘:
  1. 定位自身 — 编辑前先找到此SKILL.md的规范路径。
  2. 哪里出了问题? — 修复导致问题的说明。
  3. 哪些部分表现超出预期? — 将其升级为推荐实践。
  4. 哪些内容发生了偏差? — 修复所有不符合实际情况的脚本、引用或依赖。
  5. 记录日志 — 在演进日志中记录触发原因、修复内容和佐证信息。
不要推迟,下一次调用会继承你留下的所有内容。