| name | chezmoi-migration |
| description | This skill should be used when the user asks to adopt chezmoi on new machines or migrate from other dotfile managers, such as setting up dotfiles on a new Mac, doing a fresh chezmoi install, migrating from stow/yadm/bare-git repos, setting up multi-account GitHub SSH, deploying dotfiles in CI/Docker with one-shot mode, or onboarding team members to chezmoi. |
Chezmoi Migration & Onboarding
Workflows for adopting chezmoi on new machines and migrating from other dotfile managers.
1. Fresh Install (New Machine)
One-line install + apply
sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply $GITHUB_USERNAME
This installs chezmoi, clones github.com/$USER/dotfiles, and applies.
Step-by-step install
brew install chezmoi
chezmoi init https://github.com/$USER/dotfiles.git
chezmoi diff
chezmoi apply
chezmoi doctor
Post-install configuration
[git]
autoCommit = true
autoPush = true
2. Migration from Stow
Overview: Stow uses symlinks; chezmoi uses file copies with templates.
ls ~/.dotfiles/
for pkg in ~/.dotfiles/*/; do
for file in "$pkg".*; do
target="$HOME/$(basename "$file")"
[ -L "$target" ] && chezmoi add "$target"
done
done
chezmoi managed
chezmoi cd
chezmoi git -- add -A
chezmoi git -- commit -m "Import from stow"
chezmoi git -- push
brew uninstall stow
3. Migration from Yadm
yadm list > /tmp/yadm-files.txt
while IFS= read -r file; do
chezmoi add "$HOME/$file"
done < /tmp/yadm-files.txt
chezmoi add --encrypt ~/.ssh/config
chezmoi diff
chezmoi git -- add -A && chezmoi git -- commit -m "Import from yadm"
4. Migration from Bare Git Repo
git clone --bare https://github.com/$USER/dotfiles.git /tmp/dotfiles-bare
git --git-dir=/tmp/dotfiles-bare --work-tree=/tmp/dotfiles-export checkout
for file in /tmp/dotfiles-export/.*; do
[ -f "$file" ] && cp "$file" "$HOME/$(basename "$file")"
done
chezmoi init
for file in /tmp/dotfiles-export/.*; do
[ -f "$file" ] && chezmoi add "$HOME/$(basename "$file")"
done
rm -rf /tmp/dotfiles-bare /tmp/dotfiles-export
5. Multi-Account GitHub SSH
Problem: Different SSH keys for personal and work GitHub accounts.
Host github.com-personal
HostName github.com
IdentityFile ~/.ssh/id_personal
User git
Host github.com-work
HostName github.com
IdentityFile ~/.ssh/id_work
User git
chezmoi init git@github.com-personal:user/dotfiles.git
chezmoi init git@github.com-work:workorg/dotfiles.git
Alternative: Override in chezmoi config
[git]
command = "git"
args = ["-c", "core.sshCommand=ssh -i ~/.ssh/id_work"]
6. One-Shot Mode (CI/Docker)
For ephemeral environments — install, apply, then clean up:
sh -c "$(curl -fsLS get.chezmoi.io)" -- init --one-shot $GITHUB_USERNAME
This does: install → init → apply → remove chezmoi binary and source.
In Dockerfile:
RUN sh -c "$(curl -fsLS get.chezmoi.io)" -- init --one-shot github-username
7. Team Onboarding
Shared team dotfiles with per-role customization:
[data]
name = "{{ promptString "Your name" }}"
role = "{{ promptChoice "Your role" (list "dev" "devops" "design") }}"
{{ if eq .role "devops" -}}
source ~/.config/zsh/devops-tools.zsh
{{ end -}}
Common Issues
| Issue | Cause | Fix |
|---|
| Network error on init | Bad URL or no SSH key | Verify repo URL, ssh-add -l |
| Stow symlinks conflict | Symlinks not replaced | Remove symlinks first, then chezmoi apply |
| Wrong SSH key used | SSH config routing | ssh -T git@github.com to verify |
| One-shot didn't clean up | Interrupted process | Manual: rm -rf ~/.local/share/chezmoi |
Related Skills
- chezmoi-workflows — Daily operations after migration
- chezmoi-config — Template syntax reference
- chezmoi-troubleshooting — Diagnose migration issues
- chezmoi-agent-config — Set up AI agent config distribution