# maintaining-macos-defaults

Adopt this skill: https://proskills.md/skills/other/obra-homedir-manager-skills-maintaining-macos-defaults

Page: https://proskills.md/skills/other/obra-homedir-manager-skills-maintaining-macos-defaults
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/maintaining-macos-defaults/SKILL.md
size: 3283
sha: 5d84914d6ee6d6ce7d8685f4906edd24798c013f
upstream: https://github.com/obra/homedir-manager/blob/main/skills/maintaining-macos-defaults/SKILL.md

````text
---
name: maintaining-macos-defaults
description: Use on demand to reconcile a Mac's GUI-changed settings into version control — when the user says "reconcile my mac defaults", "capture my macOS settings", or after they've changed System Settings and want the keepers tracked. Drives homedir-manager's `defaults` verb (capture/drift/apply) against a versioned desired-state file.
---

# Maintaining macOS defaults

Lets the user drive their Mac through the GUI like a normal person, then fold the settings worth
keeping into a version-controlled file. The judgment — signal vs. noise — is your job; the tool
just reads, diffs, and writes the macOS preferences (CFPreferences) system.

## The data (in the user's dotfiles content repo, deployed to `~/.config/macos-defaults/`)

- `desired.tsv` — the tracked settings: `domain⇥key⇥type⇥value`, sorted. Scalars only
  (bool/int/float/string). This is both what gets applied and the baseline drift diffs against.
- `watched-domains` — one domain per line; the domains `drift` scans for new settings.
- `noise-deny` — glob patterns (matched against key names) that `drift` and whole-domain
  `capture` ignore (window frames, recents, counters, timestamps).

## The on-demand loop

When the user asks to reconcile (after they've changed settings in the GUI):

1. **See what changed:**
   ```sh
   homedir-manager defaults drift ~/.config/macos-defaults/desired.tsv \
     --watched ~/.config/macos-defaults/watched-domains \
     --noise   ~/.config/macos-defaults/noise-deny
   ```
   - `DRIFT  <domain> <key> current=… desired=…` — a tracked setting whose live value changed.
   - `NEW    <domain> <key> current=…` — a setting they changed that isn't tracked yet.

2. **Triage each line.** Keep deliberate preferences; drop noise. A setting is **signal** if a
   person would knowingly choose it (`com.apple.dock autohide`, `…finder ShowPathbar`). It's
   **noise** if it's machine state: window positions, recent-item lists, counters, timestamps,
   last-opened paths, UUIDs. When unsure, lean toward *not* tracking it — and if a noise pattern
   would have caught it, add that pattern to `noise-deny` instead of rejecting it one-off.

3. **Fold keepers into `desired.tsv`** with correct types read live:
   ```sh
   homedir-manager defaults capture com.apple.dock autohide >> ~/.config/macos-defaults/desired.tsv
   ```
   Then keep the file sorted (`sort -o`). For a `DRIFT` (changed tracked value), update the
   existing line instead of appending a duplicate.

4. **Commit** the content repo. Other machines pick it up on `git pull`.

## Applying on another Mac

`apply` writes the tracked settings into the live preferences and restarts Dock/Finder/SystemUIServer:
```sh
homedir-manager defaults apply ~/.config/macos-defaults/desired.tsv
```
Only run this when the user wants that machine to match the tracked state — it changes their live
settings. Some settings need a logout to fully take effect.

## Limits

- Scalars only. Dictionary/array/date/data values are flagged (`SKIP …` on stderr), not written.
- Covers the CFPreferences surface — most of "driving your Mac," but not settings that live in
  sandboxed containers, opaque databases, or need `scutil`/`systemsetup`.
- macOS only.
````

## File: README.md
upstream: https://github.com/obra/homedir-manager/blob/main/README.md

````text
# homedir-manager

[![CI](https://github.com/obra/homedir-manager/actions/workflows/ci.yml/badge.svg)](https://github.com/obra/homedir-manager/actions/workflows/ci.yml)

> ⚠️ **Written by an AI agent — not human-reviewed.**
> Claude wrote this repo end to end: code, tests, and docs. No human has reviewed it line by line.
> It changes your machine — it symlinks files into `$HOME`, backs up and replaces what it finds, and
> on macOS edits system preferences. **Read the code before you run it.**

A portable POSIX `sh` engine that symlink-deploys and audits your dotfiles content repos, with an
optional macOS `defaults` helper. It discovers any repo under `~/git` that contains a
`.homedir-manager.conf` marker file, reads its `manifest`, and symlinks each entry into `$HOME`.
The audit verb checks for secret leaks, deploy drift, and permission violations across all managed
repos.

## Prerequisites

- POSIX `sh` everywhere (no bash, no external deps beyond `git` and standard POSIX utilities).
- On macOS, the Swift toolchain is required only if you use the `defaults` verb.

## Quickstart

```sh
git clone https://github.com/obra/homedir-manager ~/git/homedir-manager
cd ~/git/homedir-manager
./bootstrap
```

`bootstrap` symlinks `homedir-manager` (and the short alias `hm`) into `~/.local/bin` or
`/usr/local/bin`, and builds the macOS Swift helper if the toolchain is present.

Then, for each dotfiles repo you keep under `~/git`, add a marker file:

```sh
cp ~/git/homedir-manager/share/homedir-manager.conf.example ~/git/mydotfiles/.homedir-manager.conf
# edit as needed — presence alone is sufficient
```

Deploy and audit:

```sh
homedir-manager install
homedir-manager audit
```

## Verbs

| Command | What it does |
|---|---|
| `install [--dry-run]` | Symlink every managed repo's manifest entries into `$HOME`. Backs up anything it replaces to `~/.dotfiles-backup/<ts>/`. |
| `audit` | Scan managed repos for secret leaks, deploy drift, and bad permissions. Exit `0` = clean, `1` = findings. |
| `defaults <apply\|drift\|capture>` | Delegate to the macOS Swift helper to apply, check, or capture `defaults` preferences. macOS only. |
| `help` | Print usage. |
| `version` | Print the version string. |

## Discovery model

On each run, `homedir-manager` scans the immediate subdirectories of the base directory for a
`.homedir-manager.conf` marker file. Any directory containing the marker is treated as a managed
content repo.

- **Default base:** `~/git`
- **Override:** set `$HOMEDIR_MANAGER_BASE` in your environment.

## The `.homedir-manager.conf` marker

Presence of the file is sufficient to opt a repo in. Optionally, set `HM_SECRET_FILES` to a
space-separated list of local files that the audit will verify are `chmod 600`:

```sh
# .homedir-manager.conf
HM_SECRET_FILES="$HOME/.config/op/env"
```

See `share/homedir-manager.conf.example` for a ready-to-copy template.

## The `manifest` format

Each line: `<repo-relative-path> [macos|linux]`

Lines with an OS tag are only deployed/audited on that OS. Blank lines and `#` comments are ignored.

To track a directory by symlinking **each of its children** individually — so new children
appear automatically and unmanaged siblings (host-local files, externally-managed symlinks)
are left alone — prefix the entry with `merge-children`:

    merge-children  .codex/skills
    merge-children  .codex/skills  macos

The mode is selected by the keyword, never by punctuation. A path ending in `/` is a hard
error — this avoids the rsync `src/` vs `src` footgun. Without the keyword, a directory entry
symlinks the directory itself.

## Further reading

- `share/AUDITING.md` — the full audit process and by-eye quarterly checks.
- `share/SECRETS.md` — the recommended secret management model (fnox + 1Password/Bitwarden).
- `skills/managing-homedir/SKILL.md` — operational skill for Claude Code.
````
