brew: create install script for all installed packages/casks
As basically explained in Apple Silicon: port all Homebrew packages under /usr/local/opt/ to /opt/homebrew (and in https://docs.brew.sh/Manpage#bundle-subcommand):

Create a Brewfile with brew bundle dump
Store the file somewhere safe (flash drive for instance)
Once the computer is set up again, install Homebrew, copy the Brewfile back and run brew bundle install --file /path/to/Brewfile