Install Xcode Command Line Tools with Homebrew
Xcode Command Line Tools are tools for software developers that run on the command line, in the Terminal application. See the article Apple Command Line Tools.
The easiest way to install Xcode Command Line Tools is by installing Homebrew, the popular package manager for macOS. With Homebrew, you can install almost any open source developer tool. Since you'll probably need Homebrew in your local development environment, you might as well use Homebrew to install Xcode Command Line Tools. This is a recent addition to the Homebrew installation process, so older guides won't mention it.
Before you get started
I recommend using our free app to install the Xcode Command Line Tools and set up your development environment. It is a FREE Mac app that installs the Command Line Tools, configures your shell, installs Homebrew and Git, and verifies everything works. It does everything this guide covers, but easier and faster. Here are all the details about the app before you download. Then:
If you're configuring the command line yourself, here is a guide.
Similar pages
These pages may be a better match to your search:
Install Xcode Command Line Tools - Step by Step
Here are steps to install Xcode Command Line Tools using Homebrew.
- Check macOS and upgrade macOS if necessary. The latest macOS version is macOS 27 Golden Gate.
- Open Mac Terminal.
- Check if Xcode Command Line Tools was previously installed.
- Install Homebrew (with an option to install Xcode Command Line Tools).
- Update the shell configuration (recommended on every new installation).
These instructions are for a terminal running Zsh, the Z shell, on a newer Mac. Older Macs may be running the Bash shell and you should upgrade. See Shell Configuration.
Tip: If you did not use a password to log in to your Mac (that is, if your password is blank), you cannot install Homebrew.
Check for Homebrew
To use this guide, you'll need to use the Terminal. If you haven't opened it yet, see How to Open Terminal in Mac.
If you've already checked macOS and checked if Xcode Command Line Tools was previously installed, then check if Homebrew is installed:
$ brew
If Homebrew is not installed, you will see:
zsh: command not found: brew
If Homebrew is not installed, there should be no Homebrew files in /opt/homebrew, or in /usr/local on an Intel Mac that installed Homebrew before September 2026. If you think Homebrew is already installed, see Zsh: command not found: brew for details. You may need to Uninstall Homebrew.
Brew install
Homebrew provides an installation script you can download and run with a single command (check that it hasn't changed at the Homebrew site). This is the easiest way to install Homebrew.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The Homebrew installation script will ask you to enter your Mac user password. This is the password you used to sign into your Mac.
Password:
You won't see the characters as you type. Press enter when you are done.

You'll see a list of files and folders that Homebrew will install.
Option to install XCode Command Line Tools
If you haven't already installed XCode Command Line Tools, you'll see a message that "The XCode Command Line Tools will be installed." Press return to continue when prompted by the Homebrew installation script. It only takes a minute or two to download and install the Command Line Tools on a 2021 Mac mini with Apple Silicon.

You’ll see diagnostic and progress messages. Full Homebrew installation takes 2 to 15 minutes on a 2021 Mac mini with Apple Silicon, with a 100Mbps Internet connection. The install takes longer on an older Mac or over a slow Internet connection.

Intel Macs
Homebrew no longer installs on an Intel Mac. Homebrew's maintainers no longer offer new Homebrew installations for Intel-based Macs. The install script displays the message Homebrew on macOS is only supported on Apple Silicon processors! and the package installer won't run on Intel Macs.
You can still install the Xcode Command Line Tools on an Intel Mac without Homebrew. See Install Xcode Command Line Tools Directly, which uses Apple's own installer and is unaffected by any of this.
If you need a package manager on an Intel Mac, use MacPorts. It still installs on Intel and still publishes ready-made Intel packages. On macOS Sequoia and earlier, Homebrew's own brew doctor command points Intel users to MacPorts. See MacPorts.
Homebrew checks the shell configuration
After the install, there's one more step. Homebrew files are installed into the /opt/homebrew folder. But the folder is not part of the default $PATH on macOS. Since June 2025, the install script adds it to the end of the $PATH for new Terminal windows, and Homebrew still recommends a setting that puts it first, so the commands you install with Homebrew are the ones that run, instead of Apple's older copies.
$PATH is a shell environment variable that shows where executable programs are located. When you run a command in the terminal, the shell searches through the directories listed in your $PATH variable to find the executable file for that command. With a correct $PATH, you don't need to type the full path to a program every time you want to run it.
The Homebrew install script checks whether your ~/.zprofile file already contains Homebrew's shellenv line (this is likely if you installed Homebrew previously). If it does, the script doesn't show the instructions to add it.
Since June 2025, the install script also writes a one-line file, /etc/paths.d/homebrew, containing /opt/homebrew/bin. When a Terminal window opens, macOS adds the folders listed in /etc/paths.d to the end of the $PATH. So brew works in a new Terminal window even before you add the shellenv line, but not in the window where you ran the install script, which opened before the file existed. The shellenv line is still worth adding, because it puts Homebrew's folder at the start of the $PATH. When you install a command with Homebrew that macOS also has, such as git, the shell then runs Homebrew's version instead of Apple's.
A new install passes brew doctor, because no command is yet in both places. Later, if you install git or python3 with Homebrew and haven't added the shellenv line, brew doctor warns /usr/bin occurs before /opt/homebrew/bin in your PATH and lists the commands that macOS and Homebrew both have. The shellenv line fixes it. With both settings in place, echo $PATH shows /opt/homebrew/bin twice, at the start and at the end, which is harmless.
Homebrew's own installation page doesn't explain this. It still says Homebrew "will not work" without the shellenv line, and doesn't mention the file the install script writes.
Add to the $PATH shell configuration (first time users)
If you're a first time Homebrew user, Homebrew will display instructions to set the $PATH environment variable, as well as other Homebrew-related environment variables.
Homebrew shows instructions at the end of the installation process. Follow Homebrew's advice and set up a ~/.zprofile file which contains a command which sets up Homebrew:
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv zsh)"
The example above contains the Unix ~ tilde shortcut. The Homebrew console output will show your user directory name instead.
Be very careful to copy the commands exactly. It's best to copy and paste. If you enter the commands manually and you enter a single > instead of the double >> you will replace the .zprofile instead of appending.
The first command adds a blank line to the end of the ~/.zprofile file, and the second adds Homebrew's shellenv line after it. The third command runs the line in your current Terminal window, so brew works there without opening a new window. The shell eval command runs the commands that brew shellenv outputs.
See Shell Configuration and setting the Mac Path for background and details.
Verify Homebrew installation
After you've installed Homebrew, check that Homebrew is installed properly.
$ brew doctor
You should see:
Your system is ready to brew.

If you see zsh: command not found: brew right after installing, open a new Terminal window. If you still see it, check that you've added the shellenv line to your ~/.zprofile file as described above, then open a new window.
If Homebrew is successfully installed, there will be Homebrew files in /opt/homebrew. On an Intel Mac that installed Homebrew before September 2026, the files are in /usr/local instead.
What's next
Now you have both Xcode Command Line Tools and Homebrew installed. If you want to learn more about adding Homebrew packages to set up your development environment, see Install a Homebrew Package. See a list of Best Homebrew Packages and Apps.
Next, you can Configure Your Mac Like a Pro with Git and programming languages such as Python, Java, or Ruby.
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.