'brew bundle dump' writes a Brewfile describing the current machine: tap lines, brew lines for formulae, cask lines, and mas lines for App Store applications when the mas command line tool is installed. 'brew bundle install' reproduces it on another machine, and 'brew bundle check' exits non-zero when something is missing, which makes it usable as a CI or setup-script gate.
Two behaviours to plan around. By default dump records every installed formula, including ones pulled in only as dependencies; '--no-upgrade' and the describe flag change the output, and hand-pruning to top-level packages keeps the file readable. And 'brew bundle cleanup' uninstalls anything not listed, which is powerful and destructive; run it with '--force' only after reviewing the dry-run output it prints without that flag.
Brewfiles do not pin versions, so an install on a later date gets whatever is current. For reproducibility, pair the Brewfile with the versioned formula names where they exist, such as node@20 rather than node.