| created | "2025-12-16T00:00:00.000Z" |
| modified | "2025-12-16T00:00:00.000Z" |
| reviewed | "2025-12-16T00:00:00.000Z" |
| name | chezmoi-expert |
| description | Comprehensive chezmoi dotfiles management expertise including templates, cross-platform
configuration, file naming conventions, and troubleshooting. Covers source directory
management, reproducible environment setup, and chezmoi templating with Go templates.
Use when user mentions chezmoi, dotfiles, cross-platform config, chezmoi apply,
chezmoi diff, .chezmoidata, or managing configuration files across machines.
|
| allowed-tools | Bash, Read, Write, Edit, Grep, Glob |
Chezmoi Expert
Expert knowledge for managing dotfiles with chezmoi, including templates, cross-platform support, and best practices.
Core Expertise
- Source vs Target Management: Always work in
~/.local/share/chezmoi/, never edit target files directly
- File Naming Conventions:
dot_, private_, readonly_, executable_, exact_, symlink_ prefixes
- Template System: Go templates with
.chezmoi.* variables for platform-specific configs
- Cross-Platform Support: Conditional logic for macOS/Linux differences
Critical Workflow
ALWAYS follow this workflow:
chezmoi diff - Preview changes before applying
chezmoi apply --dry-run - Safe testing
chezmoi apply -v <path> - Apply specific paths first
- Let user review before full
chezmoi apply
Finding the Source File — Don't Translate Prefixes by Hand
When you know a target path and need the source, ask chezmoi instead
of mentally translating dot_/private_/exact_/.tmpl/encrypted_.
Stacked prefixes make manual guessing error-prone, and a wrong guess points
at a nonexistent path.
chezmoi source-path ~/.zshrc
chezmoi source-path ~/.config/mise/config.toml
chezmoi target-path <source-file>
Canonical edit loop: chezmoi source-path <target> → Read it → Edit
it → chezmoi apply. source-path exits non-zero when the target is not
managed — check the exit code; if it errors, use chezmoi unmanaged <path>
or chezmoi managed <path> to confirm whether the file is unmanaged vs.
ignored (chezmoi ignored).
Essential Commands
chezmoi source-path ~/.zshrc
chezmoi target-path <src-file>
chezmoi unmanaged ~/.config
chezmoi diff
chezmoi status
chezmoi diff ~/.config/nvim
chezmoi apply --dry-run
chezmoi apply -v ~/.config/nvim
chezmoi apply -v
chezmoi add ~/.bashrc
chezmoi re-add ~/.bashrc
chezmoi managed
chezmoi verify
chezmoi data
chezmoi cat ~/.config/file
chezmoi execute-template < file
File Naming Reference
Source → Target
dot_bashrc → ~/.bashrc
private_dot_ssh/config → ~/.ssh/config (mode 0600)
dot_config/nvim/init.lua.tmpl → ~/.config/nvim/init.lua (templated)
exact_dot_config/app/ → ~/.config/app/ (exact match)
executable_script.sh → ~/script.sh (mode 0755)
Template Examples
Platform Detection
{{ if eq .chezmoi.os "darwin" }}
# macOS specific
export HOMEBREW_PREFIX="/opt/homebrew"
{{ else if eq .chezmoi.os "linux" }}
# Linux specific
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
{{ end }}
Architecture-Specific
{{ if eq .chezmoi.arch "arm64" }}
# Apple Silicon
export DOCKER_DEFAULT_PLATFORM=linux/arm64/v8
{{ else if eq .chezmoi.arch "amd64" }}
# Intel/AMD
export DOCKER_DEFAULT_PLATFORM=linux/amd64
{{ end }}
Special Files
.chezmoi.toml.tmpl - Main configuration template
.chezmoiignore - Files to ignore
.chezmoiremove - Files to remove from target
.chezmoiexternal.toml - External file management
run_once_*.sh - Run once on first apply
run_onchange_*.sh - Run when hash changes
Troubleshooting
Changes Not Applying
chezmoi managed | grep filename
chezmoi apply --force ~/.config/file
Template Errors
chezmoi execute-template < file.tmpl
chezmoi data
chezmoi apply -v --debug ~/.config/file
Merge Conflicts
chezmoi merge ~/.config/file
chezmoi source-path ~/.config/file
For detailed reference documentation, see REFERENCE.md.