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.
Quick Path
- Run Quick Bootstrap script first (includes Xcode CLI tools check + Homebrew + common packages).
- Install Xcode Command Line Tools and Homebrew manually if script is not used.
- Install common tools: git, vim, node/npm, gh, fzf, tree.
- Configure Git identity and authenticate GitHub CLI.
- Clone repo, create branch, install dependencies, run npm run dev.
- Run npm run build and npm audit before committing.
- Commit, push branch, and open a pull request.
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.
Step 0 β Quick bootstrap (recommended first run)
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.
- Download the bootstrap script.
- Run it from Terminal.
- If the script triggers the Xcode installer dialog and exits, complete that install first, then rerun the same script command.
- If Step 0 completes successfully, skip Step 1 and Step 2 and continue directly to Step 3.
- After it finishes, continue with Step 3 in this guide to configure GitHub authentication and repo workflow.
Expand to copy: Download scriptCopy exactly as shown. Do not modify.
curl -fsSL https://www.4leggedit.com/downloads/setup-macos-cli-tools.sh -o setup-macos-cli-tools.shExpand to copy: Run scriptCopy exactly as shown. Do not modify.
chmod +x setup-macos-cli-tools.sh
./setup-macos-cli-tools.shYou 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.
Step 1 β Install macOS base developer tooling
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.
- Open Terminal.
- Install Xcode Command Line Tools.
- Optionally confirm whether full Xcode is installed (required for some iOS/macOS workflows).
- Install Homebrew using the official script.
- Add Homebrew to your shell profile if prompted by the installer.
- Verify both tools report versions without errors.
Expand to copy: Install Xcode Command Line ToolsCopy exactly as shown. Do not modify.
xcode-select --installExpand to copy: Install HomebrewCopy 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 setupCopy exactly as shown. Do not modify.
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"Expand to copy: Verify installationCopy exactly as shown. Do not modify.
xcode-select -p
xcodebuild -version || echo "Full Xcode app not installed (optional for web-only workflows)"
brew --versionxcode-select -p returns a valid developer tools path.
brew --version prints a Homebrew version and no errors.
Step 2 β Install common command line tools
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.
- Install the common toolchain with one Homebrew command.
- Verify that key tools are available on your PATH.
- Keep this command list in your project docs so team setup is consistent.
Expand to copy: Install common CLI toolsCopy exactly as shown. Do not modify.
brew install git vim node gh tree wget curl bat fzfExpand to copy: Version checksCopy exactly as shown. Do not modify.
git --version
vim --version
node --version
npm --version
gh --versionEach version command returns successfully.
You can now use these tools from any new Terminal session.
Step 3 β Configure Git identity and authenticate GitHub
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.
- Set your global Git username and email.
- Authenticate GitHub CLI and choose HTTPS or SSH Git protocol.
- Confirm authentication status and account identity before cloning/pushing repositories.
Expand to copy: Configure global Git settingsCopy 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 falseExpand to copy: Authenticate GitHub CLICopy exactly as shown. Do not modify.
gh auth login
gh auth status
gh auth token >/dev/null && echo "GitHub auth token available"gh auth status confirms you are logged in to the correct GitHub account.
New commits will use your configured Git name and email.
Step 4 β Clone your repository and create a feature branch
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.
- Clone the project repository from GitHub.
- Change into the project folder.
- Create a descriptive branch name for your task.
- Confirm branch and remotes before making changes.
Expand to copy: Clone (HTTPS)Copy exactly as shown. Do not modify.
git clone https://github.com/<org-or-user>/<repo>.gitExpand to copy: Clone (SSH)Copy exactly as shown. Do not modify.
git clone git@github.com:<org-or-user>/<repo>.gitExpand to copy: Branch setupCopy exactly as shown. Do not modify.
cd <repo>
git checkout -b chore/mac-cli-setup
git branch --show-current
git remote -vYour local project folder exists and you are on a non-main branch.
git remote -v shows the expected GitHub origin URL.
Step 5 β Install dependencies and run npm development workflow
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.
- Install dependencies from
package.jsonand lockfile. - List available npm scripts so you know exactly which dev/build/test commands exist in this repository.
- Start the local dev server and open the URL shown in Terminal.
- If this repository matches our website stack, you can continue into related docs like Cloudflare Pages publishing.
Expand to copy: Install dependenciesCopy exactly as shown. Do not modify.
npm installExpand to copy: Inspect available scriptsCopy exactly as shown. Do not modify.
npm runExpand to copy: Clean lockfile install (optional)Copy exactly as shown. Do not modify.
npm ciExpand to copy: Run local developmentCopy exactly as shown. Do not modify.
npm run devnpm completes install without fatal errors.
The dev server starts and serves the project locally (for example on localhost).
Step 6 β Run production build and security audit
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.
- Run a production build using the repository's configured build script (or the equivalent script shown in
npm runoutput). - Run npm dependency audit and evaluate findings by severity and exploitability; skip force fixes unless you can verify behavior after changes.
- Apply safe automated fixes, then retest build.
Expand to copy: BuildCopy exactly as shown. Do not modify.
npm run buildExpand to copy: Audit and safe auto-fixCopy exactly as shown. Do not modify.
npm audit
npm audit fixExpand to copy: Force fix (high risk, use caution)Copy exactly as shown. Do not modify.
npm audit fix --forcenpm run build finishes successfully and outputs build artifacts.
You understand any remaining audit findings before proceeding to merge.
Step 7 β Commit and push your changes
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.
- Inspect changed files and diff.
- Stage intentional files only, then commit with a specific message.
- Push your branch to origin with upstream tracking.
Expand to copy: Pre-commit checksCopy exactly as shown. Do not modify.
git status
git diffExpand to copy: CommitCopy exactly as shown. Do not modify.
git add .
git commit -m "docs: add macOS CLI workflow guide"Expand to copy: Push branchCopy exactly as shown. Do not modify.
git push -u origin $(git branch --show-current)Your commit exists locally and on GitHub under your feature branch.
git status reports a clean working tree after commit.
Step 8 β Open a pull request and complete merge flow
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.
- Confirm you are not on
mainbefore opening the PR. - Open a pull request directly from Terminal.
- Review CI checks and requested reviewer feedback.
- After merge, update your local main and prune stale branches.
Expand to copy: Confirm branch before PRCopy exactly as shown. Do not modify.
git branch --show-currentExpand to copy: Create PRCopy exactly as shown. Do not modify.
gh pr create --fillExpand to copy: Check PR statusCopy exactly as shown. Do not modify.
gh pr statusExpand to copy: Post-merge cleanupCopy exactly as shown. Do not modify.
git checkout main
git pull origin main
git branch -d chore/mac-cli-setupYour PR is visible in GitHub with commit history, diff, and checks.
Your local main branch is synced after merge.
Official References
These are primary sources for the tools and commands used in this guide.
Use them when your local setup differs from examples shown here.
gh) Node.js downloads and release lines npm CLI commands reference npm run-script reference (npm run dev, npm run build) npm audit reference Related How-To Sessions
How to Use Codex with ChatGPT Plus (VS Code + App)
Apply this CLI baseline to Codex-powered development workflows with model selection and guardrails.
How We Develop Your Website (Example Walkthrough)
See how a website project moves from intake notes to publish-ready content.
Publish Your Website with Cloudflare Pages + GitHub
Use your GitHub repository to build and deploy with Cloudflare Pages.
How to Communicate Effectively with AI Chatbots
Write clearer prompts for drafting docs, code instructions, and technical workflows.
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.
