|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Agent instructions for the `scottames/dots` repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a **dotfiles repository** managed by [chezmoi](https://www.chezmoi.io/). |
| 8 | +The `home/` directory (defined in `.chezmoiroot`) contains templates and files |
| 9 | +that chezmoi uses to manage dotfiles in the user's home directory. |
| 10 | + |
| 11 | +**Key directories:** |
| 12 | + |
| 13 | +- `home/` - Chezmoi source directory (maps to `~`) |
| 14 | +- `home/.chezmoiscripts/` - Scripts run by chezmoi during apply |
| 15 | +- `home/private_dot_config/` - Config files (maps to `~/.config/`) |
| 16 | +- `aqua/` - CLI tool version management via aqua |
| 17 | +- `nix/` - Nix/Darwin configuration (macOS only) |
| 18 | +- `.dagger/` - Dagger module for container-based testing |
| 19 | +- `.trunk/` - Trunk.io linter configurations |
| 20 | + |
| 21 | +## Build/Lint/Test Commands |
| 22 | + |
| 23 | +### Linting (Primary) |
| 24 | + |
| 25 | +Trunk.io is the primary linter orchestrator. All linting should go through |
| 26 | +trunk: |
| 27 | + |
| 28 | +```bash |
| 29 | +# Check all files |
| 30 | +trunk check |
| 31 | + |
| 32 | +# Check specific file(s) |
| 33 | +trunk check path/to/file |
| 34 | + |
| 35 | +# Auto-format all files |
| 36 | +trunk fmt |
| 37 | + |
| 38 | +# Auto-format specific file(s) |
| 39 | +trunk fmt path/to/file |
| 40 | +``` |
| 41 | + |
| 42 | +### Testing |
| 43 | + |
| 44 | +Test chezmoi init in a container (requires dagger): |
| 45 | + |
| 46 | +```bash |
| 47 | +dagger call -m . init |
| 48 | +``` |
| 49 | + |
| 50 | +### Chezmoi |
| 51 | + |
| 52 | +**IMPORTANT:** Never run `chezmoi apply` unless explicitly directed by the user. |
| 53 | +This modifies the user's home directory and should only be done intentionally. |
| 54 | + |
| 55 | +```bash |
| 56 | +# Preview what would change (safe) |
| 57 | +chezmoi diff |
| 58 | + |
| 59 | +# Verify templates render correctly (safe) |
| 60 | +chezmoi execute-template < file.tmpl |
| 61 | +``` |
| 62 | + |
| 63 | +## Code Style Guidelines |
| 64 | + |
| 65 | +### General (EditorConfig) |
| 66 | + |
| 67 | +- **Charset:** UTF-8 |
| 68 | +- **Line endings:** LF (Unix) |
| 69 | +- **Final newline:** Always |
| 70 | +- **Indent:** 2 spaces (default) |
| 71 | +- **Max file length:** 200-300 lines, refactor beyond this |
| 72 | + |
| 73 | +Exceptions defined in `.editorconfig`: |
| 74 | + |
| 75 | +- Go, Makefile: tabs, 4-space width |
| 76 | +- Python, Dockerfile: 4 spaces |
| 77 | + |
| 78 | +### Shell Scripts (Bash) |
| 79 | + |
| 80 | +Linters: `shellcheck`, `shfmt` |
| 81 | + |
| 82 | +```bash |
| 83 | +#!/usr/bin/env bash |
| 84 | + |
| 85 | +set -eufo pipefail # Strict mode for .tmpl scripts |
| 86 | + |
| 87 | +# Color definitions (common pattern) |
| 88 | +magenta='\033[0;35m' |
| 89 | +red='\033[0;31m' |
| 90 | +yellow='\033[0;33m' |
| 91 | +clear='\033[0m' |
| 92 | + |
| 93 | +# Helper functions |
| 94 | +info() { printf "${magenta}%s${clear}\n" "${@}"; } |
| 95 | +err() { printf "${red}%s${clear}\n" "${@}"; exit 1; } |
| 96 | +warn() { printf "${yellow}%s${clear}\n" "${@}"; } |
| 97 | +``` |
| 98 | + |
| 99 | +- Use `#!/usr/bin/env bash` shebang |
| 100 | +- Quote variables: `"${var}"` not `$var` |
| 101 | +- Use `[[ ]]` for conditionals, not `[ ]` |
| 102 | +- Use `$(command)` not backticks |
| 103 | +- Shellcheck directives in `.trunk/configs/.shellcheckrc` |
| 104 | + |
| 105 | +### YAML |
| 106 | + |
| 107 | +Linters: `yamllint`, `prettier` |
| 108 | + |
| 109 | +- Quotes: only when needed |
| 110 | +- No empty values in block/flow mappings |
| 111 | +- 1 space minimum after comments |
| 112 | + |
| 113 | +### Go |
| 114 | + |
| 115 | +Linters: `gofmt`, `golangci-lint` |
| 116 | + |
| 117 | +- Standard Go formatting (tabs) |
| 118 | +- Import order: stdlib, external, internal |
| 119 | + |
| 120 | +### Lua (Neovim configs) |
| 121 | + |
| 122 | +Linter: `stylua` |
| 123 | + |
| 124 | +- 2-space indentation |
| 125 | +- Add file mode line: `-- vi: ft=lua` |
| 126 | + |
| 127 | +### Python |
| 128 | + |
| 129 | +Linters: `black`, `isort`, `ruff`, `bandit` |
| 130 | + |
| 131 | +- 4-space indentation |
| 132 | +- Black formatting |
| 133 | +- Select rules: B, D3, E, F (see `.trunk/configs/ruff.toml`) |
| 134 | + |
| 135 | +### Nix |
| 136 | + |
| 137 | +Linter: `nixpkgs-fmt` |
| 138 | + |
| 139 | +- Standard nix formatting |
| 140 | + |
| 141 | +### Markdown |
| 142 | + |
| 143 | +Linter: `markdownlint` |
| 144 | + |
| 145 | +- Formatter-friendly config (formatting rules disabled) |
| 146 | +- Let prettier handle formatting |
| 147 | + |
| 148 | +## Chezmoi Conventions |
| 149 | + |
| 150 | +### File Naming Prefixes |
| 151 | + |
| 152 | +Chezmoi uses special prefixes in `home/`: |
| 153 | + |
| 154 | +- `dot_` - Creates dotfile (e.g., `dot_bashrc` -> `~/.bashrc`) |
| 155 | +- `private_` - Sets restrictive permissions (0600/0700) |
| 156 | +- `executable_` - Sets executable bit |
| 157 | +- `symlink_` - Creates symlink |
| 158 | +- `*.tmpl` - Go template, rendered during apply |
| 159 | + |
| 160 | +### Chezmoi Scripts (`.chezmoiscripts/`) |
| 161 | + |
| 162 | +[docs](https://www.chezmoi.io/user-guide/use-scripts-to-perform-actions/) |
| 163 | + |
| 164 | +> chezmoi supports scripts that are executed when you run chezmoi apply. These |
| 165 | +> scripts can be configured to run every time, only when their contents have |
| 166 | +> changed, or only if they haven't been run before. |
| 167 | +
|
| 168 | +- `run_once_` - Run once per content hash |
| 169 | +- `run_onchange_` - Run when watched files change |
| 170 | +- `run_once_after_XX_name.sh.tmpl` - Numbered for ordering |
| 171 | + |
| 172 | +### Templates |
| 173 | + |
| 174 | +Templates use Go text/template syntax with chezmoi extensions: |
| 175 | + |
| 176 | +```text |
| 177 | +{{ .chezmoi.os }} # Operating system |
| 178 | +{{ .chezmoi.hostname }} # Machine hostname |
| 179 | +{{ if eq .host.os "linux" }} |
| 180 | + # Linux-specific content |
| 181 | +{{ end }} |
| 182 | +``` |
| 183 | + |
| 184 | +Use `chezmoi data` to view available data (pulls from `home/.chezmoi.toml` |
| 185 | +written to `~/.config/chezmoi/chezmoi.toml` by chezmoi) |
0 commit comments