Is it possible to uninstall Xcode, keep the CLI tools and have a working Homebrew installation running on macOS Mojave?
You don't need to have Xcode installed on your system to install Command Line Tools. Command Line Tools can be installed independently from Xcode.

For your scenario, to remove Xcode, take either one of the two approaches depending on how you installed it in first place:


If you have installed Xcode via Mac App Store, simply open Launchpad, press and hold the Alt key, and click on the cross button shown towards top left of the Xcode app icon.

This will uninstall Xcode completely.





If you have installed Xcode via copying from a DMG, simply trash the Xcode.app bundle.




Once you have uninstalled Xcode, you can independently install only the Command Line Tools by running the following in Terminal:

xcode-select --install

You don't need to have an Apple Developer account for doing so, neither will you need to download anything directly from Apple Developer website.