A Brewfile can define the Homebrew packages that belong on a workstation, project image, or CI runner. Cleaning against that file removes packages that were installed locally but are no longer part of the intended package set.

Homebrew Bundle reads the Brewfile in the current directory unless --file or --global points it somewhere else. The cleanup command is a review step by default and lists what would be removed while returning a nonzero exit code when removals are pending.

Actual removal starts only when --force is added. Review the listed formulae, casks, taps, and other supported dependency types before forcing cleanup, especially on a workstation where some software may be intentionally outside the Brewfile.

Steps to remove Homebrew packages not in a Brewfile:

  1. Review the Brewfile that should define the retained package set.
    Brewfile
    brew "hello"

    Use --file for a project or task-specific Brewfile. Use --global only when enforcing the configured global Brewfile.

  2. List the installed formulae before cleanup.
    $ brew list --formula
    hello
    tree
  3. Run Homebrew Bundle cleanup without forcing removal.
    $ brew bundle cleanup --file Brewfile
    Would uninstall formulae:
    tree
    Run `brew bundle cleanup --force` to make these changes.

    Do not add --force until every listed item is safe to remove. Add options such as --no-cask or --no-tap when those package classes are managed outside this Brewfile.

  4. Apply the reviewed cleanup.
    $ brew bundle cleanup --force --file Brewfile
    Uninstalling tree... (9 files, 303.5KB)
    Uninstalled 1 formula

    --zap makes cask cleanup remove extra application support files. Use it only when those per-app settings and caches should also be deleted.

  5. Confirm the removed package no longer appears in the formula list.
    $ brew list --formula
    hello
  6. Check the Brewfile after cleanup.
    $ brew bundle check --file Brewfile
    The Brewfile's dependencies are satisfied.

    A satisfied check confirms that the remaining Homebrew state still matches the Brewfile.
    Related: How to check a Brewfile with Homebrew Bundle