This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a chezmoi-managed dotfiles repository for macOS and Linux machines. The source directory is home/ which maps to the user's home directory.
chezmoi apply # Apply dotfiles to home directory
chezmoi diff # Preview changes (scripts excluded by config)
chezmoi update # Pull latest and apply
chezmoi managed # List all managed files
chezmoi data # Show template data valuesFiles in home/ use chezmoi prefixes:
dot_→.(e.g.,dot_bashrc→.bashrc)private_→ file permissions 0600exact_→ directory is exact (unmanaged files are removed).tmplsuffix → file is a Go templaterun_before_,run_once_after_,run_onchange_after_→ script execution order
Available in .tmpl files (defined in home/.chezmoi.toml.tmpl):
| Variable | Description |
|---|---|
.is_macos / .is_linux |
OS detection |
.is_interactive |
Machine with direct user interaction (all macOS, specific Linux hosts) |
.is_headless |
No GUI (Linux servers, opposite of interactive) |
.is_work |
Work machine vs personal |
.email, .fname, .ghuser |
Personal info from 1Password |
.copy_command |
Clipboard command (pbcopy or xsel) |
All chezmoi scripts should include this library for consistent output:
{{ template "dotfiles_bashlib.sh" . }}Key functions:
dot::chezmoi_script_start "Script Name"- Start a script with bannerdot::step::start "description"- Begin a stepdot::step::done/dot::step::skipped/dot::step::fatal- End a stepdot::has_command "cmd"- Check if command existsdot::os::setup- Set up PATH for current OS
Modular bash config loaded by .bashrc in order:
.bash.d/local/before/*(untracked, machine-specific).bash.d/*(tracked modules).bash.d/local/after/*(untracked, machine-specific)
Files are named with numeric prefixes for ordering (e.g., 010_functions_*.sh).
Modular zsh config loaded by .zshrc via dot::bootstrap:
.config/zsh/zsh.d/local/before/*(untracked, machine-specific).config/zsh/zsh.d/*(tracked modules).config/zsh/zsh.d/local/after/*(untracked, machine-specific)
Files are named with numeric prefixes for ordering (e.g., 005_plugin_loader.zsh).
The bootstrap defines core functions for the zsh startup lifecycle:
dot::bootstrap- Entry point called from.zshrc, runs setup/source/cleanupdot::source_file,dot::source_dir,dot::source_zsh_d- Source helpersdot::timing::setup/teardown- Optional startup timing (ZSH_TIME_STARTUP=1)
Register commands to run after all startup files have been sourced. Runs in LIFO order (last registered, first executed). The defer system cleans up itself on exit.
dot::defer "unset _my_temp_var"
dot::defer "unfunction my_helper"All bootstrap functions, plugin loader state, and timing variables are cleaned up via dot::defer — none survive into the interactive session.
Data-driven plugin management without a framework. Plugins are defined in home/.chezmoidata/zsh_plugins.yaml and downloaded as chezmoi git-repo externals into ~/.config/zsh/plugins/.
Data file (zsh_plugins.yaml):
# Single-plugin repo (name defaults to repo name):
- repo: zsh-users/zsh-autosuggestions
description: "Fish-like autosuggestions"
# Multi-plugin repo (name defaults to last segment of path):
- repo: ohmyzsh/ohmyzsh
description: "Plugin source"
plugins:
- path: plugins/git
- path: plugins/docker
source: docker.plugin.zsh # only if non-standardKey files:
005_plugin_loader.zsh- Definesplug::loadandplug::is_loaded(static)006_plugin_load.zsh.tmpl- Generatedplug::loadcalls from YAML007_plugin_config.zsh- Plugin configuration usingplug::is_loadedguards~/.config/zsh/plugins_ignore- Local ignore list (one plugin name per line,create_managed)zsh_plugins.toml.tmpl- Generated chezmoi externals from YAML
Namespaces:
dot::- Bootstrap and startup lifecycle (defined inbootstrap.zsh)plug::- Plugin loading and state (defined in005_plugin_loader.zsh)
Both namespaces are fully cleaned up after startup via dot::defer.
External tools pulled via chezmoi's external mechanism (git repos, archives). Each .toml file defines one or more externals.
home/.chezmoidata/packages.yml- Package definitions for APT/Homebrewhome/.chezmoidata/package_specs.yml- Software installation specs (with JSON schema validation)Brewfile- Homebrew bundle for macOS
home/.chezmoi.toml.tmpl- Main chezmoi config, defines all template variableshome/.install-one-password.sh- Pre-hook: installs 1Password CLI before template processinghome/.chezmoiscripts/- Installation and setup scripts (ordered by prefix)site/install- Bootstrap script for fresh installations
All secrets are stored in 1Password and accessed via onepasswordRead in templates. Never hardcode sensitive values.
Commit messages follow the format: Component: Short description
Examples from the repo:
Bashmarks: Migrate to XDG layout with dotfiles/local splitStarship: Refactor to layered config with separate preset fileBash: Add iTerm2 shell integration via chezmoiexternal
Do not add Co-Authored-By lines.
When you need chezmoi information, use these sources in order:
- Built-in knowledge - Claude has extensive chezmoi knowledge from training
chezmoi help <command>- Run via Bash for command-specific details- Online docs - Fetch from
https://www.chezmoi.io/(note: may reference newer chezmoi versions than installed)