chezmoi-sync
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChezmoi 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 and to detect drift between the source repo and home directory.
chezmoi statuschezmoi diff --no-pagerbash
chezmoi source-path && chezmoi status && echo "---" && chezmoi diff --no-pager | head -80If output is empty (no drift), report "Chezmoi is clean — no drift detected" and stop.
运行和来检测源仓库和主目录之间的偏差。
chezmoi statuschezmoi diff --no-pagerbash
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 to show the user what drifted and ask what to do.
AskUserQuestionQuestion 1 (header: "Drift action"):
"Chezmoi detected N drifted file(s): [list files]. What would you like to do?"
Options:
- Sync all — all drifted files, commit, and push
chezmoi re-add - 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 cleanReport 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 :
AskUserQuestionQuestion (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 -- pushStep 3c: Ignore (if chosen)
步骤3c:忽略(如果选择此项)
Report: "Skipped chezmoi sync. Run when ready."
/dotfiles-tools:chezmoi-sync返回提示:「已跳过chezmoi同步。准备就绪后可运行」。
/dotfiles-tools:chezmoi-syncNotes
注意事项
- Always use (not bare
chezmoi forget --force) to avoid TTY prompt issuesforget - The chezmoi source dir is (configured in
~/own/dotfiles)~/.config/chezmoi/chezmoi.toml
- 始终使用(不要使用裸
chezmoi forget --force),避免TTY提示问题forget - chezmoi源目录为(配置在
~/own/dotfiles中)~/.config/chezmoi/chezmoi.toml
Post-Execution Reflection
执行后复盘
After this skill completes, reflect before closing the task:
- Locate yourself. — Find this SKILL.md's canonical path before editing.
- What failed? — Fix the instruction that caused it.
- What worked better than expected? — Promote to recommended practice.
- What drifted? — Fix any script, reference, or dependency that no longer matches reality.
- Log it. — Evolution-log entry with trigger, fix, and evidence.
Do NOT defer. The next invocation inherits whatever you leave behind.
本Skill执行完成后,关闭任务前请先复盘:
- 定位自身 — 编辑前先找到此SKILL.md的规范路径。
- 哪里出了问题? — 修复导致问题的说明。
- 哪些部分表现超出预期? — 将其升级为推荐实践。
- 哪些内容发生了偏差? — 修复所有不符合实际情况的脚本、引用或依赖。
- 记录日志 — 在演进日志中记录触发原因、修复内容和佐证信息。
不要推迟,下一次调用会继承你留下的所有内容。