agentleFS
danmestasdanmestas/wardrobe/skills/clone-config/SKILL.md

clone-config

Skill4 starsChanged 7 months agoMITView on GitHub

Use when bootstrapping a fresh Mac/server, managing dotfiles, tracking shell configs, refreshing a Brewfile, adding ~/.zshrc to a dotfiles repo, or asking how to replicate a machine's config to a new device. Manages macOS (and Linux-compatible) machine config via chezmoi — install once, apply on every machine, edit source not target.

  • Reads credentials
  • Installs packages
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After that the machine is fully provisioned.

    line 48
  2. Very specific:

    After git push, any other machine running chezmoi update picks up the file.

    line 100
  3. Distinctive:

    No separate bootstrap scripts to remember.

    line 157
  4. Very specific:

    Idempotent: every tool install uses || true, so partial failures don't abort the whole run.

    line 158
  5. Distinctive:

    When you install new packages and want them tracked:

    line 167
  6. Very specific:

    Never hand-edit the Brewfile to add packages you haven't actually installed — brew bundle dump --force captures the live state of the …

    line 180

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

clone-config — chezmoi dotfile workflow

chezmoi gives dotfiles a single source of truth: one Git repo, applied to every machine with one command. Files in the source dir are named with prefixes (dot_, private_) that map to locations in $HOME. You edit the source, apply to $HOME; the target is always derived, never the authority.

The patterns below reflect the actual setup in ~/projects/dotfiles: .zshrc, .zprofile, .p10k.zsh, .tmux.conf, Yazi config, Kaku config, Ghostty config, a Brewfile, and an install script that re-runs whenever the Brewfile hash changes.


Bootstrap a fresh machine

# 1. Install Homebrew (if missing)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 2. Install chezmoi and apply the dotfiles repo
brew install chezmoi
chezmoi init --apply git@github.com:YOUR_USER/dotfiles.git

One chezmoi init --apply does everything:

  1. Writes all tracked source files to $HOME
  2. Clones externals (oh-my-zsh, fzf-tab) declared in .chezmoiexternal.toml
  3. Runs run_onchange_install-packages.sh → brew bundle, uv tools, npm globals, yazi plugins

After that the machine is fully provisioned. No separate install scripts to remember, no manual symlinks.


Layout conventions

Source pathApplied to $HOMENotes
dot_zshrc~/.zshrcdot_ prefix → leading .
dot_config/yazi/~/.config/yazi/Nested dot_config works recursively
private_Library/~/Library/private_ → chmod 0700 on the dir, 0600 on files
.chezmoiexternal.toml—Declares upstream repos cloned on apply (oh-my-zsh, fzf-tab)
.chezmoiignore—Paths inside source that chezmoi skips at apply time
run_onchange_<name>.sh.tmpl—Re-runs whenever file content (post-template) changes
run_once_<name>.sh.tmpl—Runs only on the very first apply
Brewfile—Consumed by the install script; not applied to $HOME directly

Key convention: dot_ → leading dot, private_ → restricted permissions. Both prefixes can be combined: private_dot_ssh/ → ~/.ssh/ (mode 0700).


Daily workflow

TaskCommandNotes
Preview pending changeschezmoi diffRead-only; see what would change in $HOME
Apply pending changeschezmoi applyWrite source state to $HOME
Edit a tracked filechezmoi edit ~/.zshrcOpens the source, not the target — critical
Jump into source repochezmoi cdDrops you in ~/.local/share/chezmoi
Pull remote + applychezmoi updateEquivalent to git pull + chezmoi apply
Reconcile after target editchezmoi re-add ~/.zshrcRescue: pulls target back into source
Track a new filechezmoi add ~/path/to/fileCopies file into source with correct prefix

The source repo lives at ~/.local/share/chezmoi by default. chezmoi cd is the fastest way in; treat it like any Git repo once there.


Adding a new file

# 1. Tell chezmoi to track the file (copies it into source)
chezmoi add ~/some/config

# 2. Commit from inside the source repo
chezmoi cd
git add -A && git commit -m "track some/config"
git push  # or: open a PR if the dotfiles repo enforces review

After git push, any other machine running chezmoi update picks up the file.


The run_onchange installer pattern

This is the high-leverage part of the setup. A single templated script orchestrates all package management and re-runs automatically whenever its content changes — including whenever the embedded Brewfile hash changes.

Actual content of run_onchange_install-packages.sh.tmpl:

#!/usr/bin/env bash
# Re-runs whenever this file changes (including Brewfile hash below).
# Manages: homebrew, uv tools, npm globals, yazi plugins.
set -euo pipefail

# Brewfile hash: {{ include "Brewfile" | sha256sum }}

echo "==> brew bundle"
brew bundle --no-lock --file="{{ joinPath .chezmoi.sourceDir "Brewfile" }}"

echo "==> uv tools"
for tool in claude-code-telegram fb-idb specify-cli; do
    uv tool install --quiet "$tool" || true
done

echo "==> npm globals (requires an fnm-managed node on PATH)"
if command -v npm >/dev/null 2>&1; then
    npm install -g --silent \
        @cometix/ccline \
        @openai/codex \
        agent-browser \
        clawhub \
        eas-cli \
        gitnexus \
        mcporter \
        openclaw \
        pnpm || true
fi

echo "==> yazi plugins"
if command -v ya >/dev/null 2>&1; then
    ya pkg add yazi-rs/plugins:smart-enter || true
fi

echo "==> done"

Key mechanics:

  • Hash trigger: the comment {{ include "Brewfile" | sha256sum }} is a chezmoi template expression. When Brewfile changes, the rendered script content changes → chezmoi detects a diff → re-runs the script on next chezmoi apply.
  • One orchestrator: brew, uv, npm, and yazi plugins — all in one place. No separate bootstrap scripts to remember.
  • Idempotent: every tool install uses || true, so partial failures don't abort the whole run. brew bundle itself is idempotent.
  • No .tmpl at runtime: chezmoi renders the template before running; the running script is plain bash.

Brewfile refresh cycle

When you install new packages and want them tracked:

chezmoi cd
brew bundle dump --force --file=Brewfile
git add Brewfile && git commit -m "refresh Brewfile from <machine-name>"
git push

On the next chezmoi apply (or chezmoi update) on any machine, the Brewfile hash in the install script changes → script re-runs → brew bundle installs any new packages.

Never hand-edit the Brewfile to add packages you haven't actually installed — brew bundle dump --force captures the live state of the machine, which is the truth.


Composition with other skills

Doppler (skills/doppler/SKILL.md)

The chezmoi-managed dot_zshrc is where the Doppler keychain bootstrap lives:

export DOPPLER_TOKEN="$(security find-generic-password -a "$USER" -s doppler-cli-token -w 2>/dev/null)"

This line is tracked in source and applied to every machine. The actual secret (the Personal Token) is NOT in dotfiles — it lives in the macOS Keychain and must be seeded manually on each machine with:

security add-generic-password -a "$USER" -s doppler-cli-token -w 'dp.pt.xxx' -U

That separation is intentional: dotfiles carry the bootstrap pattern, Doppler carries the actual secrets. Never put real tokens, API keys, or passwords in dotfiles source.

flight-deck (landing / takeoff)

Useful for wrapping up dotfile PRs — landing commits the Brewfile refresh or config addition, takeoff resumes from a clean state on a new machine.


Anti-patterns

Anti-patternWhat breaksFix
Editing ~/.zshrc directlySource and target drift; next chezmoi apply overwrites your changeschezmoi edit ~/.zshrc — always edit source
Forgetting chezmoi apply after editing sourceSource repo and live $HOME diverge silentlyAlways run chezmoi apply after source edits
Committing real secrets to dotfilesSecrets leak to Git history and anyone with repo accessDoppler keychain pattern: only the bootstrap line in dot_zshrc, token in Keychain
Hand-editing BrewfileCaptured state drifts from what's actually installedbrew bundle dump --force --file=Brewfile to capture live state
Per-machine doppler login ceremonyBreaks on OS upgrades, can silently desyncKeychain Personal Token + DOPPLER_TOKEN env var (see doppler skill)
Direct push to dotfiles' mainBypasses review; hard to bisect regressionsOpen a PR even on personal dotfiles — matches CLAUDE.md PR cadence
Editing target, then chezmoi applyTarget edits silently overwrittenRescue: chezmoi re-add ~/.zshrc first to pull changes back into source
run_once_ when you mean run_onchange_Script never re-runs after first applyUse run_onchange_ for scripts that should re-run when inputs change

Quick Reference

TaskCommand
Install chezmoibrew install chezmoi
Bootstrap fresh machinechezmoi init --apply git@github.com:USER/dotfiles.git
Preview pending changeschezmoi diff
Apply pendingchezmoi apply
Edit a tracked file (source)chezmoi edit ~/.zshrc
Track a new filechezmoi add ~/path/to/file
Pull updates from remotechezmoi update
Reconcile after editing targetchezmoi re-add ~/.zshrc
Jump into source repochezmoi cd
Refresh Brewfilechezmoi cd && brew bundle dump --force --file=Brewfile
Commit Brewfile updategit add Brewfile && git commit -m "refresh Brewfile from <machine>"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.