This skill should be used whenever the user mentions "chezmoi" in any way.
Use this skill when the user needs to:
⚠️ NEVER use these dangerous commands:
chezmoi apply - Overwrites local changes with stored config (destructive!)chezmoi apply --force - Bypasses safety checks--force flag✅ Safe workflow:
chezmoi add <file> - Add local changes TO chezmoi trackingchezmoi diff - Compare tracked config with local fileschezmoi status - Show files needing updateschezmoi add ~/.config/hypr/hyprland.conf
This saves the current local file to chezmoi's source directory.
chezmoi diff
Shows differences between chezmoi's tracked version and local files.
chezmoi status
Lists files that differ between chezmoi source and local system.
chezmoi execute-template < ~/.local/share/chezmoi/dot_config/example.conf.tmpl
Previews how a template will render without applying it.
Chezmoi source files are stored in ~/.local/share/chezmoi/
dot_* files become .* in home directory.tmpl files are processed as Go templates~/.bashrc)chezmoi add ~/.bashrcchezmoi diff (optional)~/.local/share/chezmoi/When a user reports that their local file has changes that differ from the chezmoi template:
The user has ALREADY made changes to their local file and wants the template updated to MATCH those changes. Do NOT suggest applying the template to overwrite their local changes.
CRITICAL - Template Conditionals:
{{ if .is_work }}...{{ end }}) from .tmpl files unless EXPLICITLY requestedIdentify the exact local changes:
chezmoi diff ~/.config/path/to/file
This shows the difference between what chezmoi would generate vs what exists locally.
CRITICAL - Understanding chezmoi diff output:
Chezmoi diff compares two things:
~/.local/share/chezmoi/ (the "source state")The diff format shows:
- prefix: Content that exists in chezmoi's SOURCE (would be written to target)+ prefix: Content that exists in the TARGET (actual local file)Common scenario: User edits local file, hasn't run chezmoi add yet
- = old content still in chezmoi source+ = new content in local file that needs to be savedchezmoi add or manually edit the source file to match the + linesOpposite scenario: User pulled changes from git, hasn't applied them yet
- = new content in chezmoi source+ = old content in local filechezmoi apply (but ONLY if you want to overwrite local changes!)Critical: The -/+ symbols show LOCATION (source vs target), NOT time (old vs new). Always check timestamps to determine which direction to sync.
Find the template source file:
chezmoi source-path ~/.config/path/to/file
This returns the path to the .tmpl file (e.g., ~/.local/share/chezmoi/dot_config/path/to/file.tmpl)
Check modification timestamps to determine which is newer:
stat -c '%y %n' ~/.config/path/to/file && chezmoi source-path ~/.config/path/to/file | xargs stat -c '%y %n'
This shows the modification times of both files. The newer file typically represents the user's intended state.
Read both files to understand the exact difference:
cat -A or od -c to reveal hidden characters (trailing spaces, tabs, etc.)Confirm with user if needed:
Use chezmoi add for non-template files:
.tmpl file and local is newer, use chezmoi add <file> to save local changes to the templatechezmoi add ~/.bashrcFor template files, update manually:
chezmoi execute-template or by reading the template to see what conditionals and variables exist{{ if }}, {{ range }}, etc.) - preserve these unless explicitly asked to change{{ .chezmoi.username }}, etc.) - preserve theseVerify the fix:
chezmoi diff ~/.config/path/to/file
This should show NO diff if the template was updated correctly.
{{ if }}...{{ end }} blocks or other template logic unless explicitly requested. These conditionals exist for environment-specific configuration and should be preserved.- and + symbols show SOURCE (template vs local), NOT time (old vs new). Use timestamps to determine which change is newer.cat -A or od -c to see them.User says: "My local monitors.conf has changes"
Correct approach:
chezmoi diff ~/.config/hypr/configs/monitors.conf+ lines show what the local file containschezmoi source-path ~/.config/hypr/configs/monitors.conf+ lines from the diff)chezmoi diff - should show no differencesIncorrect approach:
chezmoi apply to overwrite local changesAccess chezmoi data in templates:
{{ .chezmoi.hostname }}
{{ .chezmoi.os }}
{{ .chezmoi.username }}
If chezmoi commands fail:
chezmoi managed | grep filenamels ~/.local/share/chezmoi/chezmoi execute-template on specific fileDo not use chezmoi commands for: