This skill should be used whenever the user mentions "chezmoi" in any way...
ā ļø NEVER run these without explicit user confirmation:
chezmoi apply ā overwrites local files with source state (destructive to local edits)--forceā
Safe anytime: chezmoi add, chezmoi diff, chezmoi status, chezmoi managed, chezmoi source-path, chezmoi execute-template.
chezmoi diff ā direction matterschezmoi diff shows the patch that chezmoi apply WOULD make:
- lines = current LOCAL file content (destination, what you have now)+ lines = SOURCE-rendered content (what apply would write)So if the user edited a local file and hasn't run chezmoi add, their new
edits appear on - lines (apply would remove them). The -/+ symbols show
direction of apply, NOT chronology. To decide which side is newer, compare
timestamps:
stat -c '%y %n' <local-file>; chezmoi source-path <local-file> | xargs stat -c '%y %n'
chezmoi add or edit the template)chezmoi apply (with confirmation) syncs them inWhen in doubt, read BOTH files directly rather than reasoning from the diff alone.
chezmoi add ~/.bashrc # save local file ā source (the normal direction)
chezmoi diff [file] # what apply would change
chezmoi status # drifted files (MM = both sides changed, A = apply would create, M = apply would modify, R = run script)
chezmoi source-path <file> # locate the source file (dot_*, .tmpl, executable_*, private_*)
chezmoi execute-template < x.tmpl # preview template rendering
chezmoi managed | grep <name> # is a file tracked?
Source dir: ~/.local/share/chezmoi/. dot_* ā .*, executable_* ā +x,
private_* ā restricted perms, .tmpl ā Go template. This repo has
autoCommit/autoPush enabled: chezmoi operations (add/forget) commit and
push automatically, but direct edits to source files need a manual git
commit + push.
chezmoi status ā note MM (local changes apply would overwrite) and DA (local files apply would delete).MM/DA exist: run chezmoi diff, show it, and explicitly warn which local changes will be lost. Get confirmation before continuing.chezmoi git pullchezmoi diff ā show what the pull will apply.chezmoi apply (use --force only if chezmoi prompts interactively AND the user already confirmed).The user has usually ALREADY made the change locally and wants it saved to
source ā do NOT suggest chezmoi apply (that would destroy their edit).
chezmoi add <file>..tmpl) files: edit the source template manually (chezmoi add would flatten it):{{ if }}/{{ range }} conditional and {{ .var }} variable.is_work). If the local file differs only because of conditional logic, the local file is correct as-rendered ā don't "fix" the template.cat -A if trailing whitespace might matter).chezmoi diff <file> should show nothing.chezmoi diff/apply to see them.chezmoi add cannot add files that exist only in source; it copies live ā source.chezmoi managed | grep <name> and .chezmoiignore (it's templated ā test with chezmoi execute-template < .chezmoiignore)..claude/settings.json, .config/zed/settings.json, btop.conf, fish_variables, mako/config.chezmoi add credentials; use chezmoi's encryption or keep them ignored.