How to Install Claude Code on macOS and Connect It to Domestic AI Models
This guide walks you through installing Claude Code on macOS, configuring it with the CC Switch tool to use domestic AI models, and demonstrates a simple "Hello, Claude Code!" HTML generation example, covering all required commands, settings, and troubleshooting steps.
Claude Code overview
Claude Code is an AI‑powered programming assistant that can read codebases, edit files, run commands, build features, fix bugs, and automate development tasks via natural‑language prompts.
Installation on macOS
Two fast installation methods are demonstrated.
Official curl script (requires VPN) curl -fsSL https://claude.ai/install.sh | bash Homebrew cask brew install --cask claude-code@latest Verify the installation: claude --version A version string confirms success. The first launch shows a connection error to Anthropic’s API; this is resolved later by configuring a local model service.
Configuring a domestic model service with CC Switch
Because direct access to Anthropic is blocked in many Chinese networks, CC Switch is used to route Claude Code to a domestic model provider. The project repository is https://github.com/farion1231/cc-switch.
Install CC Switch via Homebrew:
brew tap farion1231/ccswitch
brew install --cask cc-switchOpen the CC Switch desktop application, add a new supplier, select “Claude”, and choose a domestic model (e.g., the GLM‑China version). Enter the provider’s API key; other parameters are auto‑filled. Save the configuration.
Running Claude Code – step‑by‑step example
Create a working directory and start Claude Code: claude Accept the default prompts for theme, security warnings, and trusted directory settings.
In the dialogue window, ask “What can you do?” to list supported skills.
Request a simple HTML page that displays Hello, Claude Code! with a tech‑style CSS theme. Claude Code generates an index.html file in the current directory.
Open index.html in a browser to view the generated page.
All commands are executed in the terminal; confirmations are entered by pressing Enter when prompted.
Key files and configuration
The global configuration file CLAUDE.md (not covered here) stores model and project‑level settings.
Images illustrating the process
Senior Brother's Insights
A public account focused on workplace, career growth, team management, and self-improvement. The author is the writer of books including 'SpringBoot Technology Insider' and 'Drools 8 Rule Engine: Core Technology and Practice'.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
