Back to Resources
How-To SessionComplexity: HighCLIGitHubnpm

How to Use macOS Command Line to Manage a Web Project (GitHub + npm)

A technical, end-to-end workflow for setting up your Mac, cloning a project repository, running npm workflows, auditing dependencies, and shipping Git changes safely.

Stop: Heavily Technical Guide

This walkthrough assumes comfort with Terminal, shell profiles, Git branching, pull requests, and package management.

Security & Privacy

  • Be cautious with install scripts (especially commands that download and execute code). Prefer official sources and review before running.
  • Never paste passwords, API keys, or access tokens into random commands or public logs. Use official CLI login flows (like `gh auth login`).
  • If you’re unsure about a command, stop and ask for review before running it on a production laptop.
0

Step 0 β€” Quick bootstrap (recommended first run)

➑ What this step does

This is the fastest way to prep a Mac for project work before the detailed manual walkthrough below.

The script checks Xcode Command Line Tools, installs Homebrew if needed, and installs the core CLI toolchain including git, vim, node, npm, and gh.

πŸ“‹ What to do
  1. Download the bootstrap script.
  2. Run it from Terminal.
  3. If the script triggers the Xcode installer dialog and exits, complete that install first, then rerun the same script command.
  4. If Step 0 completes successfully, skip Step 1 and Step 2 and continue directly to Step 3.
  5. After it finishes, continue with Step 3 in this guide to configure GitHub authentication and repo workflow.
Copy exactly as shown. Do not modify.
Expand to copy: Download script
Copy exactly as shown. Do not modify.
curl -fsSL https://www.4leggedit.com/downloads/setup-macos-cli-tools.sh -o setup-macos-cli-tools.sh
Expand to copy: Run script
Copy exactly as shown. Do not modify.
chmod +x setup-macos-cli-tools.sh
./setup-macos-cli-tools.sh
βœ… What should happen

You have a working CLI baseline with Homebrew and common development tools installed.

You can bypass the manual setup steps (Step 1 and Step 2) if this bootstrap run succeeded.

You can skip directly to Git/GitHub configuration (Step 3) unless you want to run every manual setup step.

1

Step 1 β€” Install macOS base developer tooling

➑ What this step does

This installs Apple command line compilers and utilities required by many build tools.

Then Homebrew becomes your package manager for installing and updating most command line tools in a repeatable way.

πŸ“‹ What to do
  1. Open Terminal.
  2. Install Xcode Command Line Tools.
  3. Optionally confirm whether full Xcode is installed (required for some iOS/macOS workflows).
  4. Install Homebrew using the official script.
  5. Add Homebrew to your shell profile if prompted by the installer.
  6. Verify both tools report versions without errors.
Copy exactly as shown. Do not modify.
Expand to copy: Install Xcode Command Line Tools
Copy exactly as shown. Do not modify.
xcode-select --install
Expand to copy: Install Homebrew
Copy exactly as shown. Do not modify.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Expand to copy: Apple Silicon shell profile setup
Copy exactly as shown. Do not modify.
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Expand to copy: Verify installation
Copy exactly as shown. Do not modify.
xcode-select -p
xcodebuild -version || echo "Full Xcode app not installed (optional for web-only workflows)"
brew --version
βœ… What should happen

xcode-select -p returns a valid developer tools path.

brew --version prints a Homebrew version and no errors.

2

Step 2 β€” Install common command line tools

➑ What this step does

This step gives you the practical toolkit used for modern JavaScript + GitHub workflows on macOS.

You will install source control tools, runtime tools, GitHub integration, and high-utility terminal commands for searching and inspecting projects.

πŸ“‹ What to do
  1. Install the common toolchain with one Homebrew command.
  2. Verify that key tools are available on your PATH.
  3. Keep this command list in your project docs so team setup is consistent.
Copy exactly as shown. Do not modify.
Expand to copy: Install common CLI tools
Copy exactly as shown. Do not modify.
brew install git vim node gh tree wget curl bat fzf
Expand to copy: Version checks
Copy exactly as shown. Do not modify.
git --version
vim --version
node --version
npm --version
gh --version
βœ… What should happen

Each version command returns successfully.

You can now use these tools from any new Terminal session.

3

Step 3 β€” Configure Git identity and authenticate GitHub

➑ What this step does

Git needs your identity for commit metadata, and GitHub auth is required to clone private repos, push branches, and open pull requests.

Using GitHub CLI (gh) keeps authentication and PR workflows in-terminal and consistent.

πŸ“‹ What to do
  1. Set your global Git username and email.
  2. Authenticate GitHub CLI and choose HTTPS or SSH Git protocol.
  3. Confirm authentication status and account identity before cloning/pushing repositories.
Copy exactly as shown. Do not modify.
Expand to copy: Configure global Git settings
Copy exactly as shown. Do not modify.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global pull.rebase false
Expand to copy: Authenticate GitHub CLI
Copy exactly as shown. Do not modify.
gh auth login
gh auth status
gh auth token >/dev/null && echo "GitHub auth token available"
βœ… What should happen

gh auth status confirms you are logged in to the correct GitHub account.

New commits will use your configured Git name and email.

4

Step 4 β€” Clone your repository and create a feature branch

➑ What this step does

This checks out your project source code locally and sets up branch isolation for your changes.

Branch-first work keeps main stable and makes pull requests clean to review.

πŸ“‹ What to do
  1. Clone the project repository from GitHub.
  2. Change into the project folder.
  3. Create a descriptive branch name for your task.
  4. Confirm branch and remotes before making changes.
Copy exactly as shown. Do not modify.
Expand to copy: Clone (HTTPS)
Copy exactly as shown. Do not modify.
git clone https://github.com/<org-or-user>/<repo>.git
Expand to copy: Clone (SSH)
Copy exactly as shown. Do not modify.
git clone git@github.com:<org-or-user>/<repo>.git
Expand to copy: Branch setup
Copy exactly as shown. Do not modify.
cd <repo>
git checkout -b chore/mac-cli-setup
git branch --show-current
git remote -v
βœ… What should happen

Your local project folder exists and you are on a non-main branch.

git remote -v shows the expected GitHub origin URL.

5

Step 5 β€” Install dependencies and run npm development workflow

➑ What this step does

This installs the exact dependency tree your project needs and starts a local development server for rapid iteration.

Use npm ci for clean, lockfile-driven installs (especially in CI), and npm install for normal local development updates.

πŸ“‹ What to do
  1. Install dependencies from package.json and lockfile.
  2. List available npm scripts so you know exactly which dev/build/test commands exist in this repository.
  3. Start the local dev server and open the URL shown in Terminal.
  4. If this repository matches our website stack, you can continue into related docs like Cloudflare Pages publishing.
Copy exactly as shown. Do not modify.
Expand to copy: Install dependencies
Copy exactly as shown. Do not modify.
npm install
Expand to copy: Inspect available scripts
Copy exactly as shown. Do not modify.
npm run
Expand to copy: Clean lockfile install (optional)
Copy exactly as shown. Do not modify.
npm ci
Expand to copy: Run local development
Copy exactly as shown. Do not modify.
npm run dev
βœ… What should happen

npm completes install without fatal errors.

The dev server starts and serves the project locally (for example on localhost).

6

Step 6 β€” Run production build and security audit

➑ What this step does

This validates production bundling and catches vulnerable dependency ranges before code review.

Build success proves the repository can produce deployable artifacts; audit results help you manage risk in third-party packages.

πŸ“‹ What to do
  1. Run a production build using the repository's configured build script (or the equivalent script shown in npm run output).
  2. Run npm dependency audit and evaluate findings by severity and exploitability; skip force fixes unless you can verify behavior after changes.
  3. Apply safe automated fixes, then retest build.
Copy exactly as shown. Do not modify.
Expand to copy: Build
Copy exactly as shown. Do not modify.
npm run build
Expand to copy: Audit and safe auto-fix
Copy exactly as shown. Do not modify.
npm audit
npm audit fix
Expand to copy: Force fix (high risk, use caution)
Copy exactly as shown. Do not modify.
npm audit fix --force
βœ… What should happen

npm run build finishes successfully and outputs build artifacts.

You understand any remaining audit findings before proceeding to merge.

7

Step 7 β€” Commit and push your changes

➑ What this step does

This creates a clean, reviewable change history and publishes your branch to GitHub.

Reviewing status and diff before commit prevents accidental files from entering version control.

πŸ“‹ What to do
  1. Inspect changed files and diff.
  2. Stage intentional files only, then commit with a specific message.
  3. Push your branch to origin with upstream tracking.
Copy exactly as shown. Do not modify.
Expand to copy: Pre-commit checks
Copy exactly as shown. Do not modify.
git status
git diff
Expand to copy: Commit
Copy exactly as shown. Do not modify.
git add .
git commit -m "docs: add macOS CLI workflow guide"
Expand to copy: Push branch
Copy exactly as shown. Do not modify.
git push -u origin $(git branch --show-current)
βœ… What should happen

Your commit exists locally and on GitHub under your feature branch.

git status reports a clean working tree after commit.

8

Step 8 β€” Open a pull request and complete merge flow

➑ What this step does

This step is only for work done on a non-main branch from Step 4 and pushed in Step 7.

It moves that feature branch into review, links discussions to code changes, and gates merge through checks.

Using CLI PR commands keeps the entire engineering workflow scriptable and reproducible.

πŸ“‹ What to do
  1. Confirm you are not on main before opening the PR.
  2. Open a pull request directly from Terminal.
  3. Review CI checks and requested reviewer feedback.
  4. After merge, update your local main and prune stale branches.
Copy exactly as shown. Do not modify.
Expand to copy: Confirm branch before PR
Copy exactly as shown. Do not modify.
git branch --show-current
Expand to copy: Create PR
Copy exactly as shown. Do not modify.
gh pr create --fill
Expand to copy: Check PR status
Copy exactly as shown. Do not modify.
gh pr status
Expand to copy: Post-merge cleanup
Copy exactly as shown. Do not modify.
git checkout main
git pull origin main
git branch -d chore/mac-cli-setup
βœ… What should happen

Your PR is visible in GitHub with commit history, diff, and checks.

Your local main branch is synced after merge.

Need Help Standardizing Your Team's CLI Workflow?

If you want 4leggedIT to help document, standardize, and validate your development workflow, contact us and we can build a repeatable setup guide for your team.