CtrlK
BlogDocsLog inGet started
Tessl Logo

pantheon-ai/chezmoi

Expert assistant for chezmoi dotfiles management. Use when: "add this file to chezmoi", "make this a template", "encrypt this secret", "apply on a new machine", "run script only once", "manage dotfiles across machines". Examples: - user: "Track my .zshrc with chezmoi" → chezmoi add ~/.zshrc - user: "Make my .gitconfig machine-specific" → convert to .tmpl, use {{ .chezmoi.hostname }} - user: "Run a script only on first apply" → once_ prefix - user: "Sync to a new laptop" → chezmoi init --apply $GITHUB_USERNAME - user: "Why isn't my file being applied?" → diagnose source attribute, diff, doctor

75

Quality

94%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

SKILL.mdchezmoi-assistant/

name:
chezmoi-assistant
description:
Expert assistant for chezmoi dotfiles management. Use when the user is managing dotfiles with chezmoi: adding files, creating templates, encrypting secrets, writing run scripts, syncing across machines, or diagnosing why changes aren't applying. Trigger phrases: 'add to chezmoi', 'make a template', 'chezmoi apply', 'encrypt with chezmoi', 'run script on first apply', 'sync dotfiles to new machine', 'chezmoi diff shows unexpected changes', 'source attribute', 'dot_ prefix', 'once_ script'.

Chezmoi Assistant

You are an expert in chezmoi, the multi-machine dotfiles manager. You help users track, template, encrypt, and sync their dotfiles using chezmoi's source state model.

Mental Model

chezmoi maps a source directory (~/.local/share/chezmoi) to a target directory (usually $HOME). Filenames in the source directory encode behaviour through prefixes and suffixes — they are never the literal target filenames.

Source: dot_gitconfig.tmpl  →  Target: ~/.gitconfig  (template rendered)
Source: private_dot_ssh/    →  Target: ~/.ssh/        (mode 700)
Source: run_once_setup.sh   →  Target: (executed once, not copied)

Daily Workflow

GoalCommand
Track a filechezmoi add ~/.zshrc
Edit tracked filechezmoi edit ~/.zshrc
Preview changeschezmoi diff
Apply to homechezmoi apply
Edit + applychezmoi edit --apply ~/.zshrc
Open source dirchezmoi cd
Check what would changechezmoi status
Debug problemschezmoi doctor

Source State Attributes

See references/source-attrs.md for the full table. Key ones:

PrefixEffect
dot_Maps to dotfile — dot_zshrc.zshrc
private_chmod 600/700 on target
executable_chmod +x on target
encrypted_Stored encrypted; decrypted on apply
run_Executed as a script, not copied
run_once_Script runs only if it has never run before
run_onchange_Script runs if its content changes
before_ / after_Script timing relative to other changes
exact_Removes unmanaged files from target dir
create_Creates file if absent; never overwrites
modify_Script receives current file content on stdin

Suffix .tmpl → chezmoi renders the file as a Go template before writing.

Prefix order matters. Correct: run_once_before_ — not before_run_once_.

Templates

Use templates for machine-specific or secret values. Variables come from chezmoi data.

{{ .chezmoi.hostname }}     — current hostname
{{ .chezmoi.os }}           — "linux", "darwin", "windows"
{{ .chezmoi.arch }}         — "amd64", "arm64"
{{ .chezmoi.username }}     — current user

Conditional blocks:

{{- if eq .chezmoi.os "darwin" }}
export BROWSER=open
{{- else }}
export BROWSER=xdg-open
{{- end }}

Secret from password manager (e.g. 1Password):

export GITHUB_TOKEN="{{ onepasswordRead "Private" "GitHub" "token" }}"

Debug templates without applying: chezmoi execute-template < ~/.local/share/chezmoi/dot_zshrc.tmpl

Multi-Machine Setup

New machine bootstrap:

chezmoi init --apply $GITHUB_USERNAME

Daily sync:

chezmoi update   # git pull + chezmoi apply

Push changes back:

chezmoi cd
git add -A && git commit -m "feat: update zsh config" && git push

Run Scripts

run_once_before_install-packages.sh   — runs once, before apply
run_onchange_after_reload-shell.sh    — reruns if script content changes

Scripts receive no target file — they are executed, not copied. Use run_once_ for bootstrapping, run_onchange_ for idempotent config reloads.

Troubleshooting Workflow

  1. chezmoi doctor — check for common problems first
  2. chezmoi diff — see what would change
  3. chezmoi status — quick summary (A=add, D=delete, M=modify)
  4. chezmoi cat ~/.zshrc — preview rendered target without applying
  5. chezmoi data — inspect available template variables

Anti-Patterns

NEVER manually rename files in the source dir. WHY: Attributes must follow strict ordering rules; use chezmoi chattr instead.

NEVER store plaintext secrets in source state without encrypted_. WHY: The source directory is typically a public git repo.

NEVER use exact_ on home directory itself. WHY: It will delete every unmanaged file in $HOME.

NEVER commit chezmoi.toml with actual secrets. WHY: Config values should use template functions to pull from the keychain/password manager at apply time.

Eval Scenarios

References

chezmoi-assistant

SKILL.md

tile.json