字數總計:0 個 | 閱讀時長:0 分鐘 |閱讀次數: 次
三、安裝與設定(Lesson 3-4)
【官方】Claude Code 安裝
# macOS (Homebrew)
brew install --cask claude-code
# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
# 首次執行
claude # 會提示登入 Anthropic 帳號
- 前置需求:無(已移除 Node.js 依賴)
- 帳號:Anthropic(Pro 100/月 / Max 20x $200/月預設 Opus 4.6)
【補充】其他三家安裝
Codex CLI(OpenAI):
# 已用 Rust 重寫,無需 Node.js
curl -fsSL https://openai.com/codex/install.sh | bash
# 或使用 ChatGPT 帳號登入
codex # 支援 device-code sign-in(v0.116.0+)
Gemini CLI(Google):
# npm
npx @google/gemini-cli
# Homebrew
brew install gemini-cli
# 首次執行(Google OAuth,無需 API Key)
gemini
Copilot CLI(GitHub):
# 安裝 GitHub CLI 擴充套件
gh extension install github/gh-copilot
# 首次執行
gh copilot # 需 GitHub 帳號 + Copilot 訂閱
【補充】四家定價比較
| 工具 | 免費方案 | 主力方案 | 重度使用 | 前置需求 |
|---|---|---|---|---|
| Claude Code | 無 | Pro $20/月 | Max 5x 200/月 | 無 |
| Codex CLI | 無(需 ChatGPT 訂閱或 API Key) | ChatGPT Plus $20/月含 | ChatGPT Pro $200/月含 | 無(Rust 原生) |
| Gemini CLI | Google 帳號 1,000 次/天;AI Studio 免費 Key 250 次/天 | BYOK | Vertex AI 企業 | Node.js 18+ |
| Copilot CLI | 永久免費(有限) | Pro $10/月 | Pro+ $39/月 | GitHub CLI (gh) |
最便宜入門:Gemini CLI(免費 1,000 次/天)或 Copilot(永久免費方案) 最佳 CP 值:Claude Code Max 5x 20/月
【補充】社群踩坑經驗
| 工具 | 從零到生產力 | 常見新手問題 |
|---|---|---|
| Claude Code | ~15-30 分鐘 | 「土撥鼠之日」— 沒設 CLAUDE.md 每次重啟都忘;Context 滿了 AI 降智 |
| Codex CLI | ~10-15 分鐘 | 沙盒太嚴格(網路預設關閉),需手動開啟 danger-full-access |
| Gemini CLI | ~5 分鐘 | 模型切換不直覺;免費額度用完無明確提示 |
| Copilot CLI | ~5 分鐘 | CLI 能力有限(主要是 shell 命令輔助),真正的 Agent 在 IDE 中 |
社群共識:不管用哪款,必須建立專案規則檔(CLAUDE.md / AGENTS.md / GEMINI.md),當成 AI 的「員工手冊」。
【進階】安裝完之後:讓 Claude Code 更有威力
原生 Claude Code 安裝完只是起點。以下是安裝後應該立刻做的事:
Step 1:設定 CLAUDE.md(/init)
claude
> /init # 自動掃描 codebase 生成 CLAUDE.md
Step 2:熟記必知快捷鍵
| 快捷鍵 | 功能 |
|---|---|
Shift+Tab | 循環切換權限模式(default → acceptEdits → plan → auto) |
Esc × 2 | Rewind:回溯到之前的時間點 |
Ctrl+V | 貼上截圖 |
Ctrl+G | 在文字編輯器中開啟 prompt |
Alt+P | 不清除 prompt 切換模型 |
/ | 斜線指令 |
! | 直接執行 bash(輸出自動加入 context) |
@ | 檔案路徑自動補全 |
# | Memory mode(編輯 CLAUDE.md) |
Step 3:熟記必知 CLI 旗標
| 旗標 | 用途 | 範例 |
|---|---|---|
-p | 非互動模式(Piping) | cat error.log | claude -p '解釋錯誤' |
-c | 繼續最近對話 | claude -c |
-w | 在隔離 git worktree 中工作 | claude -w feature-auth |
--effort | 設定思考深度 | claude --effort max |
--permission-mode | 權限模式 | --permission-mode plan(唯讀) |
Step 4:設定終端 Alias
# ~/.zshrc
alias c="claude"
alias cc="claude --continue"
alias cw="claude --worktree"
alias cr="claude --resume"
Step 5:安裝社群必裝套件
| 套件 | 用途 | 為什麼需要 |
|---|---|---|
| superpowers | 強制注入資深工程師思考框架 | brainstorm → write-plan → execute-plan 三步工作流 |
| planning-with-files | 持久化 Markdown 計畫 | 計畫不會隨 context 壓縮消失 |
| claude-mem | 跨 session 自動記憶 | 解決「土撥鼠之日」問題 |
| claude-hud | HUD 顯示 context 用量 | 看到 Claude 在做什麼,不再黑箱 |
| PUA | 用職場壓力逼 AI 不放棄 | 修復成功率 +36%、工具使用 +50% |
Step 6:建立自訂指令
.claude/commands/review.md:
---
name: review
description: 安全性 + 效能 code review
allowed-tools: ["Read", "Grep", "Glob"]
---
Review the code in $ARGUMENTS with focus on:
1. Security vulnerabilities 2. Performance issues 3. Error handling gaps
Output findings with severity levels (P0/P1/P2).
Awesome Lists 入門必看:awesome-claude-code(32K stars)、awesome-claude-code-plugins(646 stars)