Claude Code đi từ con số không lên hơn 1 triệu lượt search/tháng trong chưa đầy 1 năm. Nếu bạn vào đây vì “ai cũng nói về nó” và muốn tự thử, đây là hướng dẫn setup 5 phút cho mọi hệ điều hành.
Bốn điều cần biết trước khi bắt đầu:
- Bạn cần gói trả phí. Claude Pro ($20/tháng), Max, Team, Enterprise hoặc tài khoản Claude Console mở khóa Claude Code. Gói free Claude.ai không bao gồm Claude Code.
- Claude Code sống trong terminal — cái cửa sổ chữ trên máy mà bạn gõ lệnh vào. (Anthropic cũng có app desktop nếu muốn skip terminal hoàn toàn.)
- Native installer là phương pháp chính thức năm 2026. Anthropic cũng thêm Homebrew, WinGet và Linux package repos có chữ ký từ đầu 2026. Ai làm với package manager rồi giờ có lựa chọn xịn sò. Đường npm cũ vẫn chạy nhưng không được khuyến nghị nữa.
- Heads-up bug token: Các bản từ v2.1.100 trở đi inflate token consumption khoảng 40%. Bản mới nhất tới 4 tháng 5 là v2.1.126 — workaround ở dưới.
Chọn OS của bạn — mỗi đường install chỉ một lệnh:
| OS của bạn | Lệnh nhanh nhất | Section |
|---|---|---|
| Windows (PowerShell) | irm https://claude.ai/install.ps1 | iex | Nhảy ↓ |
| Windows (WinGet) | winget install Anthropic.ClaudeCode | Nhảy ↓ |
| Windows (WSL) | Giống macOS/Linux, trong WSL | Nhảy ↓ |
| macOS (native) | curl -fsSL https://claude.ai/install.sh | bash | Nhảy ↓ |
| macOS (Homebrew) | brew install --cask claude-code | Nhảy ↓ |
| Linux (Ubuntu/Debian) | sudo apt install claude-code (sau khi setup repo) | Nhảy ↓ |
| Linux (mọi distro) | curl -fsSL https://claude.ai/install.sh | bash | Nhảy ↓ |
Đi nào.
Yêu cầu hệ thống
Trước khi cài, kiểm tra OS của bạn có hỗ trợ không:
| OS | Phiên bản tối thiểu | Ghi chú |
|---|---|---|
| macOS | 13.0 (Ventura) | Apple Silicon hoặc Intel |
| Linux | Ubuntu 20.04+ / Debian 10+ / Alpine 3.19+ | RAM 4 GB+ khuyến nghị |
| Windows | 10 (1809+) hoặc Server 2019+ | WSL 2 hoặc Git for Windows |
Windows 11 thì ngon. macOS Monterey (12) hoặc cũ hơn thì update trước đã.
Cài đặt trên Windows
Bạn có ba đường trên Windows. Chọn theo việc bạn cần toolchain kiểu Linux (WSL) hay muốn ở native (PowerShell + Git Bash).
Windows native: PowerShell (đường đơn giản nhất)
Mở PowerShell (không cần Administrator) và chạy:
irm https://claude.ai/install.ps1 | iex
Nếu irm báo “is not recognized as an internal or external command”, bạn đang trong CMD chứ không phải PowerShell. Prompt hiện PS C:\ là PowerShell, hiện C:\ không có PS là CMD. Để dùng CMD:
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Sau khi cài, đóng và mở lại terminal để PATH refresh, rồi verify:
claude --version
claude doctor
Khuyến nghị: Cài Git for Windows trước khi launch claude. Anthropic khuyến nghị vì Claude Code dùng Git Bash internally cho shell tooling. Không có Git Bash, Claude Code fallback sang PowerShell làm shell tool, ít feature hơn.
Nếu claude doctor complain không tìm thấy Git Bash, chỉ đường dẫn trong ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
}
}
Windows native: WinGet (cài qua package manager)
Anthropic publish Claude Code qua package manager chính thức của Microsoft:
winget install Anthropic.ClaudeCode
Cài bằng WinGet không auto-update — chạy winget upgrade Anthropic.ClaudeCode định kỳ.
Cài đặt trên Windows với WSL
WSL 2 (Windows Subsystem for Linux) cho bạn môi trường Linux thật trong Windows. Anthropic khuyến nghị WSL khi bạn muốn sandbox command execution hoặc đã làm với Linux toolchain rồi.
Bước 1 — Cài WSL. Mở PowerShell as Administrator và chạy:
wsl --install
Restart khi nó yêu cầu. Sau reboot, mở Ubuntu terminal từ Start menu.
Bước 2 — Cài Claude Code trong WSL. Từ prompt Ubuntu:
curl -fsSL https://claude.ai/install.sh | bash
Bước 3 — Verify và bắt đầu làm việc với project:
claude --version
claude doctor
cd /mnt/c/Users/TEN_CUA_BAN/duong-dan/toi/project
claude
Đường /mnt/c/ là cách WSL access ổ Windows. Ổ C: ở /mnt/c/, D: ở /mnt/d/, vân vân.
Cài đặt trên macOS hoặc Linux
Mở Terminal. Paste cái này. Nhấn Enter.
curl -fsSL https://claude.ai/install.sh | bash
Đó là toàn bộ install. Native installer download binary, đặt vào ~/.local/bin và setup auto-update. Không cần Node.js, không dependency, không drama package manager.
Verify nó chạy:
claude --version
claude doctor
claude doctor chạy diagnostic: trạng thái auth, PATH, config, MCP server. Luôn chạy sau khi cài để bắt vấn đề sớm.
Giờ vào project:
cd /duong-dan/toi/project/cua/ban
claude
Xong. Bạn ở trong Claude Code rồi.
Cài đặt bằng Homebrew (macOS)
Nếu bạn đã quản lý tool bằng Homebrew, Anthropic publish cask chính thức:
brew install --cask claude-code
Thực ra có hai cask:
claude-code— theo channel stable (chậm hơnlatestkhoảng 1 tuần, skip release có regression lớn). An toàn hơn.claude-code@latest— theo channel latest (version mới ngay khi ra).
# Cho channel bleeding-edge:
brew install --cask claude-code@latest
Heads-up: cài Homebrew không auto-update. Chạy brew upgrade claude-code (hoặc claude-code@latest) để có version mới và security patch.
Cài đặt Linux bằng package manager
Anthropic publish apt, dnf, apk repository có chữ ký. Đây là đường sạch nhất trên Debian/Ubuntu, Fedora/RHEL và Alpine vì update đi qua workflow upgrade hệ thống bình thường của bạn.
Debian / Ubuntu (apt):
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
-o /etc/apt/keyrings/claude-code.asc
echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main" \
| sudo tee /etc/apt/sources.list.d/claude-code.list
sudo apt update
sudo apt install claude-code
Verify GPG fingerprint trước khi trust: gpg --show-keys /etc/apt/keyrings/claude-code.asc phải hiện 31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE.
Fedora / RHEL (dnf):
sudo tee /etc/yum.repos.d/claude-code.repo <<'EOF'
[claude-code]
name=Claude Code
baseurl=https://downloads.claude.ai/claude-code/rpm/stable
enabled=1
gpgcheck=1
gpgkey=https://downloads.claude.ai/keys/claude-code.asc
EOF
sudo dnf install claude-code
Alpine (apk):
wget -O /etc/apk/keys/claude-code.rsa.pub \
https://downloads.claude.ai/keys/claude-code.rsa.pub
echo "https://downloads.claude.ai/claude-code/apk/stable" >> /etc/apk/repositories
apk add claude-code
Muốn rolling channel thì đổi stable thành latest trong URL và suite name. Update sau bằng lệnh package manager bình thường (sudo apt upgrade claude-code, sudo dnf upgrade claude-code, apk upgrade claude-code).
Cài qua npm (đường legacy)
Nếu bạn đã có Node.js 18+ và thích dùng npm:
npm install -g @anthropic-ai/claude-code
Nó cài cùng native binary như standalone installer, qua optional dependency theo platform. Ba lý do hầu hết mọi người giờ tránh:
- Không auto-update. Bạn chạy
npm updatemanual khi có version mới. - Yêu cầu Node.js 18+. Native installer zero dependency.
- Lỗi permission. Đặc biệt với
sudo npm install -g— đừng làm.
Nếu bạn đã cài qua npm và muốn migrate sang native:
curl -fsSL https://claude.ai/install.sh | bash
npm uninstall -g @anthropic-ai/claude-code
Authentication (điệu nhảy login)
Lần đầu chạy claude, nó mở browser cho OAuth login. Đăng nhập bằng tài khoản Anthropic bạn dùng:
- Subscription cá nhân Claude Pro/Max — login claude.ai
- Claude Team hoặc Enterprise — login workspace của bạn
- Claude Console — nếu org của bạn invite
Nếu browser không tự mở, nhấn c trong terminal để copy URL login, paste vào browser, hoàn tất login, rồi paste code lại vào terminal khi nó hỏi.
Để switch account sau:
/logout
(Lệnh này chạy trong Claude Code, không phải shell.)
Lệnh đầu tiên của bạn
Sau khi claude đẩy bạn vào session interactive, thử:
/help # Show tất cả lệnh
/status # Xem auth, subscription, rate limit
/config # Xem config hiện tại
/logout # Đăng xuất
Từ shell (ngoài session interactive):
claude doctor # Báo cáo diagnostic
claude --version # Version đã cài
claude mcp list # List MCP server đã cấu hình
Một task thật đầu tiên
Mở project bạn đã có. Bất kỳ thứ gì — Next.js app, Python script, repo config. Start Claude Code:
cd /duong-dan/toi/project
claude
Rồi gõ task thật bằng tiếng Việt hoặc tiếng Anh. Kiểu:
“Đọc README và nói cho mình biết project này được tổ chức thế nào.”
Hoặc:
“Thêm function validate địa chỉ email. Đặt nó vào chỗ phù hợp nhất trong codebase.”
Hoặc:
“Tìm tất cả comment TODO và list ra với đường dẫn file.”
Claude xem file của bạn, suy nghĩ, đề xuất thay đổi. Nó hỏi bạn approve mỗi edit trước khi làm. Bạn vẫn giữ control.
Vấn đề setup thường gặp (và fix)
“command not found: claude”
Installer đặt binary vào ~/.local/bin, nhưng shell của bạn không biết directory đó. Thêm vào PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Đổi .bashrc thành .zshrc nếu bạn dùng zsh (default macOS từ Catalina).
“The token ‘&&’ is not a valid statement separator”
Bạn paste lệnh kiểu CMD vào PowerShell. Hoặc chuyển sang CMD, hoặc dùng version PowerShell:
irm https://claude.ai/install.ps1 | iex
“Permission denied” khi npm install
Bạn thử sudo npm install -g và làm hỏng permission. Đừng dùng sudo với npm. Thay vào đó:
- Dùng native installer (không cần sudo):
curl -fsSL https://claude.ai/install.sh | bash - Dùng nvm (Node Version Manager) để cài Node trong home directory
WSL không vào được internet
Test với curl https://claude.ai. Nếu fail, firewall Windows hoặc VPN đang chặn WSL. Hầu hết VPN có option “exclude local traffic” — bật lên.
Bị rate limit ngay sau khi cài
Bạn ở Pro plan và đụng limit trong vòng dưới 1 tiếng? Đây là vấn đề thật mà Anthropic công nhận ngày 31 tháng 3 năm 2026. Check version Claude Code:
claude --version
Build mới nhất tới ngày 4 tháng 5 là v2.1.126 (release ngày 1 tháng 5), thêm lệnh hữu ích claude project purge [path] và fix bug phần trăm /context của Opus 4.7 — nhưng vấn đề token inflation introduce trong v2.1.100 vẫn chưa có public patch. Workaround theo report cộng đồng: downgrade về v2.1.34, hoặc reinstall qua npm thay vì native binary.
Bạn có thể pin version cụ thể với native installer:
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.34
Hoặc set floor minimum trong ~/.claude/settings.json để update tương lai không vô tình đẩy bạn về version xấu:
{
"autoUpdatesChannel": "stable",
"minimumVersion": "2.1.34"
}
Mở rộng Claude Code với MCP
Khi basic chạy ngon rồi, sức mạnh thật là kết nối Claude Code với tool khác qua MCP (Model Context Protocol). MCP biến Claude Code từ “trợ lý code” thành “trợ lý code có quyền truy cập trực tiếp database, API và team tool của bạn”.
List MCP server hiện tại:
claude mcp list
Thêm cái mới (ví dụ — kết nối database):
claude mcp add my-db --command "docker run --rm my-db-mcp:latest"
Mỗi project có thể có file .claude/.mcp.json riêng list MCP server project đó dùng. Codebase shared có thể commit file này để cả team có cùng setup tool.
Cheat sheet theo OS
| Môi trường | Lệnh cài | Auto-update? |
|---|---|---|
| macOS 13+ (native) | curl -fsSL https://claude.ai/install.sh | bash | ✅ |
| macOS (Homebrew, stable) | brew install --cask claude-code | ❌ — brew upgrade claude-code |
| macOS (Homebrew, latest) | brew install --cask claude-code@latest | ❌ — brew upgrade claude-code@latest |
| Linux (mọi distro, native) | curl -fsSL https://claude.ai/install.sh | bash | ✅ |
| Ubuntu/Debian (apt) | sudo apt install claude-code (sau repo) | ❌ — flow hệ thống |
| Fedora/RHEL (dnf) | sudo dnf install claude-code (sau repo) | ❌ — flow hệ thống |
| Alpine (apk) | apk add claude-code (sau repo) | ❌ — flow hệ thống |
| Windows PowerShell (native) | irm https://claude.ai/install.ps1 | iex | ✅ |
| Windows CMD (native) | curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd | ✅ |
| Windows (WinGet) | winget install Anthropic.ClaudeCode | ❌ — winget upgrade Anthropic.ClaudeCode |
| Windows WSL | Giống Linux native (trong WSL) | ✅ |
| npm legacy | npm install -g @anthropic-ai/claude-code (Node 18+) | ❌ — npm update -g |
Điều này có ý nghĩa gì với bạn
Nếu bạn chưa từng dùng terminal: Ở macOS hoặc WSL trên Windows. Terminal là một phần identity của Claude Code — bạn không thực sự dùng được nó nếu không có comfort cơ bản với terminal. Dành chút thời gian học cd, ls, pwd và git basics nếu chưa biết.
Nếu bạn là dev đang đánh giá Claude Code: Cài trong 5 phút, point vào side project, giao một task thật. Cursor giống IDE hơn, Copilot giống autocomplete hơn — Claude Code thật sự khác biệt, và bạn phải cảm thấy nó để hiểu.
Nếu bạn setup cho team: Tạo directory .claude/ trong shared repo với MCP config của team. Commit nó. Member mới chạy installer, authenticate, và inherit setup tool của team tự động.
Nếu bạn đã cài Claude Code rồi: Plugin và MCP ecosystem là chỗ bạn nâng từ “user” lên “power user”. Khóa học AI cho Lập Trình Viên và AI Lập Trình Viết Code đào sâu workflow lập trình AI assisted.
Tóm lại
Cài Claude Code mất 30 giây tới 5 phút tùy OS. Native installer (default từ tháng 4 năm 2026) đáng tin cậy, nhanh và không dependency.
Đường cong học thật không phải installation — mà là tìm ra cách dùng Claude Code productive sau khi cài. Bắt đầu với task nhỏ, lớn lên thành workflow lớn, thêm MCP tool khi tìm thấy nhu cầu thật. Đừng cố config tất cả trong ngày đầu.
Và budget cho subscription. Free plan không đưa bạn tới đâu. Pro $20/tháng là entry point thật.
Bước tiếp theo: Khóa AI cho Lập Trình Viên cover toàn bộ workflow lập trình với AI. Nếu bạn muốn đào sâu hơn về Claude cụ thể, Hướng Dẫn Claude AI là khóa cần xem tiếp.
Nguồn (verify ngày 4 tháng 5 năm 2026):