AGENTS.md
Instructions for AI agents working with this dotfiles repository.
Repository Overview
This is a personal dotfiles collection for macOS/Linux. Configs are organized by tool in subdirectories (zsh/, vim/, git/, etc.) and installed via Makefile targets that copy files to $HOME.
Quick Reference
| Task | Command |
|---|---|
| Run all tests | make test |
| Test zsh/bash syntax | make test-zsh / make test-bash |
| Lint vim configs | make test-vimrc |
| Lint JavaScript | make test-dotjs or yarn test |
| List all targets | make list |
| Install all defaults | make install |
| Install specific tool | make install-<tool> (e.g., make install-git) |
Build & Test Requirements
Dependencies for Testing
- zsh and bash - for syntax checking shell configs
- vint - for linting vim configs (
pip install -r test-requirements.txt) - eslint - for JavaScript linting (
yarn install)
What Gets Tested
- Shell scripts - Parsed with
zsh --no-execandbash -nfor syntax errors - Vim configs - Linted with vint for style/correctness
- JavaScript (dotjs/) - Linted with eslint using
eslint/eslintrc.js - Setup scripts - All install/update scripts validated for shell syntax
CI
CircleCI runs make test against zsh 5.8.1 and 5.9. See .circleci/config.yml.
Directory Structure
| Directory | Purpose |
|---|---|
zsh/ | Zsh config, oh-my-zsh setup, modular configs in zshrc.d/ |
bash/ | Bash config (bashrc, bash_profile) |
vim/ | Vim config with vim-plug, CoC.nvim plugins |
nvim/ | Neovim Lua config (Kickstart.nvim-based) |
git/ | Git config template, global ignore, and git-* scripts |
gh/ | GitHub CLI config |
dotjs/ | Browser JavaScript injection scripts |
eslint/ | ESLint configuration |
tmux/ | tmux config and TPM installer |
Karabiner-Elements/ | Keyboard remapping (goku edn format) |
tarsnap/ | Backup configuration (not installed by default) |
system/ | macOS system-level fixes |
Code Style Guidelines
Shell Scripts (zsh/bash)
- Must parse cleanly -
zsh --no-exec <file>orbash -n <file> - Scripts go in appropriate directory (
git/for git extensions,zsh/zshrc.d/for modular zsh config) - Git helper scripts use
git-<name>naming convention (callable asgit <name>) - Use
#!/usr/bin/env zshor#!/usr/bin/env bashshebang - Functions for reusable blocks in
zsh/zshrc.d/functions.zsh - Aliases in
zsh/zshrc.d/aliases.zsh
Zsh Specifics
- Modular configs go in
zsh/zshrc.d/*.zsh(auto-sourced) - Use
$HOMEinstead of~for portability in quoted strings - Check for command availability with
command -v <cmd> &>/dev/nullbefore using
Vim/Neovim
- Vim (
vim/vimrc): Uses vim-plug, must pass vint linting - Neovim (
nvim/init.lua): Lua-based, Kickstart.nvim structure with lazy.nvim - Keep plugins organized by category with comments
- Use folding markers (
{{{/}}}) for vim config sections
JavaScript (dotjs/)
- ESLint config:
eslint/eslintrc.js - Parser:
@babel/eslint-parserwith ES6+ features - Key rules:
- No semicolons required (
semi: 0) - Flexible quotes (
quotes: 0) - No strict indentation (
indent: 0) - Prefer dot notation (
dot-notation: 2) - No eval or extending native prototypes
- Wrap IIFEs (
wrap-iife: 2) - Use curly braces (
curly: 2)
- No semicolons required (
Git Scripts
- Named
git-<action>ingit/directory - Installed to
~/.local/bin/for git subcommand access - Many use fzf for interactive selection (see
git-fuzzy-*scripts) - Must parse with zsh
General
- No trailing whitespace
- Match existing naming conventions
- Test changes with appropriate
make test-*command - Templated configs (like
git/gitconfig.template) use{PLACEHOLDER}syntax
Making Changes
Adding a New Tool Config
- Create directory:
<tool>/ - Add config files
- Add Makefile target:
install-<tool> - If applicable, add to
installtarget dependencies - Add tests if shell scripts are involved
Modifying Existing Configs
- Read the existing file to understand structure
- Make changes following existing patterns
- Run relevant tests:
make test-<type> - If git config, update template and regenerate with
git/setup
Adding Git Scripts
- Create
git/git-<name>with#!/usr/bin/env zsh - Make executable:
chmod +x git/git-<name> - Run
make test-zshto verify syntax - Installed via
make install-gitto~/.local/bin/
Adding Zsh Functions/Aliases
- Functions: Add to
zsh/zshrc.d/functions.zsh - Aliases: Add to
zsh/zshrc.d/aliases.zsh - Tool-specific: Create
zsh/zshrc.d/<tool>.zsh
Common Patterns
Checking Command Availability
command -v nvim &>/dev/null && alias vim=nvim
Cross-Platform Detection
local uname=$(uname)
if [[ "$uname" == "Darwin" ]]; then
# macOS
elif [[ "$uname" == "Linux" ]]; then
# Linux
fi
Path Manipulation (zsh)
typeset -U path # unique entries only
path=(/new/path "${path[@]}")
Conditional Homebrew Integration
if command -v brew &>/dev/null; then
prefix="$(brew --prefix)"
# use $prefix for paths
fi
Warnings
- Never commit secrets - Git config uses templates with placeholders
- Test before installing -
make -n installshows what will happen - Configs are copied, not linked - Changes to installed files won't sync back
- Some targets require sudo - tarsnap, system launchd configs
Debugging
- Shell syntax errors: Check line numbers in test output
- Vint errors: Follow vint suggestions, use
--style-problemflag - ESLint errors: Run
yarn test-eslintdirectly for details - Installation issues: Run
make -n install-<tool>to see what will be copied