Articles
Published · November 18, 2026

A Brewfile: Keep Your Mac's Installed Tools in One Text File

Run brew bundle dump to save every Homebrew tool on your Mac into one Brewfile text file, then restore the whole set on a new Mac with a single command.

Also in: Español中文हिन्दी

A Brewfile is a text list of what Homebrew should install

A Brewfile is a plain text file that lists the tools you want on your Mac, and brew bundle dump writes one for you from what is installed right now. Homebrew) is a free, open-source package manager for macOS and Linux, and a Brewfile turns your pile of past brew install commands into one file you can read, edit, and keep.

The Homebrew documentation describes a Brewfile as a declarative interface: rather than specifying the brew commands you wish to run, you specify the state you wish to reach. The smallest Brewfile is one line:

brew "ruby"

A real one has more. Each line starts with a type, then a quoted name:

tap "apple/apple"
brew "postgresql@16", restart_service: true
cask "firefox"
mas "Refined GitHub", id: 1519867270
vscode "editorconfig.editorconfig"

Those are samples from the Homebrew docs, and they cover the main entry types. Here's what each means. brew is a command-line formula, cask is a Mac app, tap adds an extra source of packages, mas is a Mac App Store app (it needs the app's numeric id), and vscode is a VS Code extension.

Create one with brew bundle dump

Open Terminal, move to the folder where you want the file, and run:

brew bundle dump

Per the Homebrew manpage, this writes all installed casks, formulae, and taps into a Brewfile in the current directory, or to a custom path if you pass --file. If a Brewfile already exists, the command stops unless you add -f (--force), which overwrites it.

brew bundle dump --file=~/dotfiles/Brewfile --force

Want several snapshots? Point --file at different paths, one per machine or per project.

Homebrew also has a global Brewfile. Adding --global reads or writes the file from $HOMEBREW_BUNDLE_FILE_GLOBAL if you set it, then ${XDG_CONFIG_HOME}/homebrew/Brewfile if $XDG_CONFIG_HOME is set, and otherwise ~/.homebrew/Brewfile or ~/.Brewfile.

brew bundle dump --global --force

By default, the dump adds a comment above each line with the package description, so you can tell what ripgrep or jq was months later. If you want a bare list, add --no-describe. You can also include or skip whole types with flags such as --no-cask or --no-tap.

Restore everything on a new Mac

On the new Mac, install Homebrew first. On Apple silicon it installs into /opt/homebrew, and on Intel Macs into /usr/local. Then put your Brewfile in the current folder and run:

brew bundle

That is short for brew bundle install. For each line, Homebrew installs the item if it is missing, upgrades it if it is outdated, and does nothing if it is already current. If you do not want upgrades to happen as a side effect, pass --no-upgrade or set HOMEBREW_BUNDLE_NO_UPGRADE=1. If your file lives somewhere else, use --file=/path/to/Brewfile, or --global for the global one.

Check, list, and clean up

Three more subcommands keep the file honest.

brew bundle check tells you whether an install would do anything. Add --verbose to list the unmet dependencies:

brew bundle check --verbose

brew bundle list prints what is in the Brewfile. By default it shows only formulae, and --cask shows casks:

brew bundle list --cask

brew bundle cleanup goes the other way. It uninstalls everything that is not in the Brewfile. Without --force it asks before removing anything and exits with code 1 if you decline, so run it plain first and read the list before you add --force.

brew bundle cleanup --file=~/dotfiles/Brewfile

That makes the Brewfile the source of truth. A tool you installed once for a single job stays on the Mac only if its line stays in the file. There's a trade-off, though: the file records what is installed, not why, so the description comments or your own notes are the only context you get.

Keep the Brewfile with your dotfiles

Because a Brewfile is plain text, it works well in version control. A change shows up as one added or removed line, which makes the history easy to read. If you already keep a dotfiles repository, drop the Brewfile into it next to your shell setup, and re-run brew bundle dump --force after you install something new you want to keep. If your shell config is in the same repository, it also helps to know which zsh startup file runs when.

Doing this with Carets

You'll open a Brewfile every so often to trim it, add a note, or copy a line. Carets is a native notes and code editor for iPhone, iPad, and Mac that handles Markdown, plain text, and code in one place, with syntax highlighting for code and config files. You can keep the Brewfile in a project alongside your other config files, tag it, and read it on your iPhone while you set up the new Mac. Your files stay plain text, so they stay portable, and Carets is a strong fit for this kind of small config file you want close at hand.

Get Carets on the App Store for iPhone, iPad, and Mac.

Frequently Asked Questions

Where does brew bundle dump save the file?

In the current directory as Brewfile, or at the path you give with --file. With --global it writes the global Brewfile, which is ~/.Brewfile unless HOMEBREW_BUNDLE_FILE_GLOBAL or XDG_CONFIG_HOME change it.

Does brew bundle upgrade things I already have?

By default, yes: outdated items are upgraded and up-to-date ones are skipped. Pass --no-upgrade or set HOMEBREW_BUNDLE_NO_UPGRADE=1 to turn that off.

Is brew bundle cleanup safe to run?

Without --force it only prompts before removing anything. With --force it uninstalls everything not in the Brewfile, so read the list first.

Can a Brewfile hold more than Homebrew formulae?

Yes. It also covers casks, taps, Mac App Store apps through mas, and VS Code extensions.