Homebrew

From phatblat/dotfiles · View interactive version

Homebrew is an AI agent skill from the GitHub repository phatblat/dotfiles. Use when a project depends on Homebrew formulae or casks, when creating or editing a Brewfile, or when adding brew install/upgrade automation to a project.

How to use this skill

Skill file

Homebrew Skill

Declare a project's Homebrew dependencies in a Brewfile and drive them with

brew bundle. This skill is the single source of truth for Homebrew

conventions across every coding agent; harness-specific rules load it rather

than repeating it.

When to Use

package manager (pkg-config, ffmpeg, postgresql, a cask)

Core Rule

**If a project uses Homebrew, its dependencies belong in a Brewfile — never

in loose brew install commands.** A brew install foo bar baz line in a

README, setup script, CI workflow, or justfile is undeclared state: nobody can

diff it, verify it, or remove it later. A Brewfile is a manifest, so it can

be reviewed, version-controlled, and checked.

Replace this:

brew install pkg-config ffmpeg
brew install --cask ngrok

With a Brewfile:

brew "pkg-config"
brew "ffmpeg"
cask "ngrok"

Process

Step 1: Detect Homebrew Usage

Look for undeclared brew dependencies before assuming there are none:

ls Brewfile .Brewfile 2>/dev/null
grep -rn "brew install" --include=*.md --include=*.sh --include=*.yml . 2>/dev/null

If brew install appears anywhere but no Brewfile exists, that's the gap

this skill closes.

Step 2: Write the Brewfile

Place Brewfile in the repository root. Entry types:

| Entry | Declares |

|------------------------------|-----------------------------------|

| brew "name" | A formula (CLI tool, library) |

| cask "name" | A macOS application |

| tap "owner/repo" | A third-party tap |

| mas "Name", id: 123 | A Mac App Store app |

| vscode "publisher.ext" | A VS Code extension |

Conventions:

cask, then the rest. Keep each group alphabetized so diffs stay readable.

brew "pkg-config" tells the next reader nothing about which build needs it.

(shell, editor, fonts) belongs in their dotfiles Brewfile, not the repo's.

general version-pinning mechanism; brew "node@20" works only because a

versioned formula happens to exist. If a project needs pinned tool versions,

that's a job for mise, asdf, or the language's own toolchain file — not

Homebrew.

Step 3: Wire Up the Commands

| Intent | Command |

|-------------------------------|------------------------------------------|

| Install declared deps | brew bundle install --no-upgrade |

| Upgrade declared deps | brew bundle upgrade |

| Verify deps are satisfied | brew bundle check |

| List declared deps | brew bundle list |

| Snapshot installed → Brewfile | brew bundle dump |

| Remove undeclared packages | brew bundle cleanup |

Three behaviors that are easy to get wrong:

runs brew upgrade on anything outdated, so a command that reads like

"install my dependencies" can silently move every version. Pass

--no-upgrade whenever the intent is only "make sure these are present",

and keep upgrading a separate, deliberate command. brew bundle upgrade is

shorthand for brew bundle install --upgrade.

everything is satisfied. That makes it a real CI gate — a non-zero exit here

is a genuine failure, not just information.

listed in the Brewfile, which on a developer's machine means their personal

tools. Never run it against a project Brewfile on a shared or personal

machine; it is only safe where the Brewfile is the complete intended state

(a container, a CI runner, or a dotfiles repo).

Step 4: Scope — Project vs. Global

brew bundle resolves its Brewfile in three ways. State the scope explicitly

rather than relying on "whatever is in the current directory":

| Scope | Selector | Resolves to |

|---------|--------------------------------|-------------------------------------------------|

| Project | --file=Brewfile (or default) | ./Brewfile in the working directory |

| Global | --global / -g | $HOMEBREW_BUNDLE_FILE_GLOBAL, else $XDG_CONFIG_HOME/homebrew/Brewfile, else ~/.homebrew/Brewfile or ~/.Brewfile |

| Custom | --file=<path> | That exact path |

codebase* needs to build and test.

machine's own baseline toolchain, which every directory then inherits.

invocation. It is convenient interactively and a trap in automation — a

recipe that works on your machine breaks on a machine where that variable

points somewhere else. In automation, pass --file explicitly.

Step 5: `Brewfile.lock.json` Is Obsolete

Older Homebrew wrote a Brewfile.lock.json pinning resolved versions.

Current Homebrew no longer generates it. Verified on Homebrew 6.0.18:

brew bundle install produces no lockfile, and neither brew bundle --help

nor brew bundle install --help mentions locking at all.

So a Brewfile.lock.json sitting in a repo today is a frozen snapshot from an

older Homebrew that will never be refreshed again. It silently drifts from the

Brewfile as entries are added and removed, which makes it worse than absent:

a reader may reasonably assume it reflects current state.

When you find one:

Brewfile, and check when git last touched each.

nothing reads the lockfile.

There is no supported command that rewrites it.

Do not treat this as a reason to avoid Homebrew for reproducibility — it is a

rolling-release package manager and never offered real version pinning. If a

project needs reproducible tool versions, use mise, asdf, a container, or

Nix instead of trying to freeze Homebrew.

Step 6: Verify

  1. brew bundle check --file=Brewfile — confirms the Brewfile parses and

reports what's missing (exit 1 if anything is).

  1. brew bundle list --file=Brewfile — confirms every entry is recognized.
  2. Report what was declared or changed.

Integration with Just

When a project has both a Brewfile and a justfile, wire them together

following the justfile skill's lifecycle-recipe conventions:

# Installs system dependencies from the Brewfile
[group('configuration')]
deps-brew:
    brew bundle install --file=Brewfile --no-upgrade

# Upgrades system dependencies declared in the Brewfile
[group('configuration')]
upgrade-brew:
    brew bundle upgrade --file=Brewfile

# Verifies declared system dependencies are installed
[group('checks')]
check-brew:
    brew bundle check --file=Brewfile

Homebrew has no brew bundle outdated subcommand. brew outdated reports

every outdated package on the machine, not just the project's, so it does not

belong in a project outdated recipe — see the justfile skill's rule against

machine-global package managers in project justfiles.

Do NOT

a Brewfile could declare them.

longer writes one, so any that exists is stale.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.