Anthropic 官方 AI 程式助手

Claude Code

不只是程式碼補全 — 一個能理解整個專案、自主規劃與執行的 AI 開發夥伴

Claude Code 是什麼?

Claude Code 是 Anthropic 推出的agentic AI 程式開發工具,能直接在你的終端機、IDE 或瀏覽器中運作。它不只是回答問題,而是能讀懂你的整個 codebase、主動搜尋檔案、編輯程式碼、執行終端指令、管理 Git 操作

💻

6 種使用介面

Terminal CLI、VS Code、JetBrains、Desktop App、Web、Slack

🤖

Agentic 工作流

自主規劃、搜尋、編輯、測試、commit,不只是補全

🔌

MCP 生態系

連接 GitHub、Figma、Notion、Jira 等 100+ 外部工具

🧠

跨 Session 記憶

Auto Memory + CLAUDE.md,團隊知識持久化

多檔案編輯

一次理解並修改多個檔案,處理複雜重構

🔒

安全可控

5 種權限模式、沙箱隔離、企業級管控

核心能力

安裝指南

原生安裝(推薦)

macOS / Linux / WSL

bash
複製
curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell

powershell
複製
irm https://claude.ai/install.ps1 | iex

Windows CMD

cmd
複製
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
⚠️ Windows 前置需求
需先安裝 Git for Windows(包含 Git Bash)。

套件管理器安裝

Homebrew(macOS / Linux)

bash
複製
brew install --cask claude-code
# 更新:brew upgrade claude-code

WinGet(Windows)

powershell
複製
winget install Anthropic.ClaudeCode
# 更新:winget upgrade Anthropic.ClaudeCode

IDE 擴充套件

VS Code

在 Extensions 搜尋 Claude Code(Anthropic 官方)安裝即可。

JetBrains

在 Settings > Plugins > Marketplace 搜尋 Claude Code 安裝。支援 IntelliJ、PyCharm、WebStorm 等。

其他方式

驗證安裝

bash
複製
claude --version
claude update        # 更新到最新版

快速開始

第一步:登入

bash
複製
claude auth login             # Claude Pro/Max/Team 訂閱
claude auth login --console   # Anthropic Console(API 計費)
claude auth status            # 檢查登入狀態

第二步:啟動 Claude Code

bash
複製
cd /your/project     # 進入專案目錄
claude               # 啟動互動模式

第三步:探索你的專案

text
複製
# 在 Claude Code 互動模式中輸入:
這個專案做什麼?
資料夾結構是什麼?
主要進入點在哪裡?

第四步:讓 Claude 幫你改程式

text
複製
在 main.py 加一個 hello world 的 API endpoint

Claude 會:找到檔案 → 顯示修改方案 → 等你確認 → 執行修改

第五步:生成專案指令

text
複製
/init    # 自動分析 codebase 生成 CLAUDE.md

常用啟動方式

指令說明
claude啟動互動模式
claude "修正登入 bug"執行單次任務
claude -p "解釋這個函數"執行查詢後退出(適合腳本)
claude -c繼續上一次對話
claude -r "session-name"恢復指定 session
cat log.txt | claude -p "分析錯誤"Pipe 輸入

指令參考

CLI 核心指令

指令說明
claude啟動互動模式
claude "task"執行單次任務
claude -p "query"執行後立即退出(適合 pipe)
claude -c繼續上一次對話
claude -r "name"恢復指定 session
claude --resume互動式選擇 session
claude update更新到最新版
claude auth login登入
claude auth status查看登入狀態
claude mcp add新增 MCP 伺服器
claude mcp list列出 MCP 伺服器
claude -v顯示版本

重要 CLI Flags

Flag說明範例
--model選擇模型--model opus--model sonnet
--effort回應深度low(快速)/ high(深入)/ max
--permission-mode權限模式defaultacceptEditsplanauto
--name, -n命名 session-n "feature-auth"
--worktree, -w獨立 git worktree-w feature-branch
--chrome啟用瀏覽器自動化
--remote雲端執行
--add-dir增加工作目錄--add-dir ../shared-lib
--system-prompt替換系統 prompt
--append-system-prompt附加到系統 prompt
--debug除錯模式
--bare最小模式(跳過自動探索)

互動模式 Slash Commands

指令說明
/help顯示幫助
/clear清除對話歷史
/compact壓縮對話歷史(釋放 context)
/init自動生成 CLAUDE.md
/config互動式設定 UI
/cost查看目前 session 費用
/memory查看 / 編輯自動記憶
/mcp檢查 MCP 伺服器狀態
/checkpoint建立進度檢查點
/rewind回到上一個 checkpoint
/commit提交變更(Skill)
/review-pr審查 PR(Skill)
/列出所有可用指令與 skills

使用環境

Claude Code 提供 6 種使用介面,同一帳號可在不同介面間無縫切換。

環境適合場景特色
Terminal CLIPower user、腳本、CI/CD完整功能、Git 整合、Pipe 支援
VS Code前端/全端開發者Inline diff、@-mention、選取程式碼直接發問
JetBrainsJava/Python/Go 開發者互動式 diff、IDE 選取分享
Desktop App視覺化 diff 審查Side-by-side diff、排程任務、多 session
Web(claude.ai/code)遠端/免安裝雲端執行、長時間任務、免本機設定
Slack團隊協作@Claude 發問、PR 回饋、非同步工作

各環境安裝方式

💻 Terminal CLI

參見安裝指南

🛠 VS Code

Extensions > 搜尋 Claude Code > Install

⚙️ JetBrains

Settings > Plugins > Marketplace > Claude Code

🌐 Web

claude.ai/code(免安裝)

💬 Slack

Slack Workspace 管理員新增 Claude Code App

💡 提示
CLI 可以和任何 IDE 外掛並行使用。許多開發者同時用 VS Code + Terminal CLI,各取所長。

MCP 整合

什麼是 MCP?

Model Context Protocol(MCP)是一個開放標準,讓 Claude 連接外部工具和資料來源。透過 MCP,Claude 可以直接存取你的資料庫、Issue Tracker、設計工具、監控系統等。

安裝 MCP 伺服器

HTTP 伺服器(推薦)

bash
複製
claude mcp add --transport http notion https://mcp.notion.com/mcp

SSE 伺服器

bash
複製
claude mcp add --transport sse asana https://mcp.asana.com/sse

本地 Stdio 伺服器

bash
複製
claude mcp add --transport stdio airtable \
  -- npx -y airtable-mcp-server \
  --env AIRTABLE_API_KEY=YOUR_KEY

管理指令

指令說明
claude mcp list列出所有已設定的 MCP 伺服器
claude mcp get github查看特定伺服器詳情
claude mcp remove github移除伺服器
/mcp在 session 中檢查所有 MCP 狀態

常用 MCP 伺服器

🐙 開發

GitHub、GitLab、Jira、Linear、Sentry

🎨 設計

Figma、Canva

📄 文件

Notion、Google Docs、Confluence

🗃 資料庫

PostgreSQL、Supabase、Airtable、MongoDB

💬 溝通

Slack、Gmail、Google Calendar

💰 商務

Stripe、Twilio、Statsig

設定範圍

範圍檔案共用
Local(預設)~/.claude.json個人
Project.mcp.json可 commit 到 git
User~/.claude.json所有專案

Hooks 自動化

什麼是 Hooks?

Hooks 是在 Claude 執行特定動作前後自動觸發的 Shell 指令。不需要 Claude 主動呼叫,完全由事件驅動。

事件類型

事件觸發時機用途範例
SessionStartSession 開始載入環境變數、初始化
UserPromptSubmit使用者送出訊息驗證輸入、注入 context
PreToolUse工具執行前攔截危險操作、阻擋修改
PostToolUse工具執行後自動格式化、記錄變更
PermissionRequest需要權限確認自動授權特定操作
Notification需要通知播放音效、推送通知

設定範例

自動格式化(每次編輯後執行 Prettier)

json
複製
{
  "hooks": {
    "PostToolUse": [
      {
        "if": { "tool": "Edit" },
        "command": "prettier --write {filePath}"
      }
    ]
  }
}

阻擋修改特定檔案

json
複製
{
  "hooks": {
    "PreToolUse": [
      {
        "if": { "tool": "Edit" },
        "command": "if echo {filePath} | grep -q '.env'; then echo 'BLOCKED: Cannot edit .env files' >&2; exit 1; fi"
      }
    ]
  }
}

完成時發送通知

json
複製
{
  "hooks": {
    "Notification": [
      {
        "command": "osascript -e 'display notification \"{message}\" with title \"Claude Code\"'"
      }
    ]
  }
}

Hooks 設定在 settings.json(User 或 Project 層級)中配置。

設定與配置

設定檔位置

範圍檔案路徑共用說明
User~/.claude/settings.json個人偏好(所有專案)
Project.claude/settings.json可 commit團隊共用設定
Local.claude/settings.local.json否(gitignore)個人專案覆寫
Managed系統層級IT 部署企業強制政策

常用設定

json
複製
{
  "model": "claude-opus-4-6",
  "effortLevel": "medium",
  "defaultMode": "acceptEdits",
  "permissions": {
    "allow": ["Bash(git *)", "Read", "Edit"]
  },
  "autoMemoryEnabled": true
}

權限模式

模式行為適合
default每個動作都詢問初學者、敏感專案
acceptEdits自動接受檔案編輯,危險操作仍詢問日常開發(推薦)
plan先展示計畫再執行大型重構
auto智慧判斷(Team/Enterprise)信任環境
dontAsk預設全部通過CI/CD 腳本
bypassPermissions跳過所有權限檢查⚠️ 高風險,僅測試用

CLAUDE.md 專案指令

CLAUDE.md 是 Claude 每次開啟專案時自動讀取的指令檔,用來告訴 Claude 專案的架構、規範和常用操作。

markdown
複製
# 專案概述
這是一個 Express.js + PostgreSQL 的電商 API。

# 開發指令
- 安裝:`npm install`
- 啟動:`npm run dev`
- 測試:`npm test`

# 程式規範
- 使用 TypeScript
- 2 空格縮排
- 所有新功能必須寫測試
- API handlers 放在 `src/api/handlers/`

# 架構
- 資料庫:PostgreSQL + Prisma ORM
- 測試:Jest
- 部署:Vercel
💡 小技巧
/init 讓 Claude 自動分析你的 codebase 生成初始 CLAUDE.md。建議控制在 200 行內。

記憶系統

Claude Code 有多層記憶機制,確保跨 session 的連續性,讓你不需要每次都重複解釋。

記憶架構

┌─────────────────────────────────────────────┐ │ 🎓 長期記憶 │ │ CLAUDE.md(專案指令) │ │ Auto Memory(自動筆記) │ ├─────────────────────────────────────────────┤ │ 🔄 中期記憶 │ │ Session Resume(-c / -r) │ │ Checkpoint / Rewind │ ├─────────────────────────────────────────────┤ │ 💬 短期記憶 │ │ 當前對話 Context Window │ │ /compact 壓縮管理 │ └─────────────────────────────────────────────┘

1. Session 延續(短期 → 中期)

指令說明
claude -c繼續上一次對話(完整上下文)
claude -r "name"恢復指定 session(用 -n 命名)
claude --resume互動式選擇歷史 session

Session 歷史儲存在本地,關閉 terminal 後仍可恢復。

2. Auto Memory(跨 Session 長期記憶)

Claude 自動將學到的重要資訊存入 ~/.claude/projects/<project>/memory/

text
複製
/memory          # 查看與編輯記憶

3. CLAUDE.md(專案級指令)

位置範圍共用
./CLAUDE.md專案✔ commit 到 git
./.claude/CLAUDE.md專案✔ commit 到 git
./CLAUDE.local.md個人✘ gitignore
~/.claude/CLAUDE.md全域✘ 個人所有專案

4. 對話壓縮

5. Checkpoint / Rewind

💡 記憶最佳實踐
  • 為重要 session 命名:claude -n "feature-auth"
  • 每個專案都建立 CLAUDE.md(用 /init 自動生成)
  • 偶爾檢查 /memory 確認記憶正確
  • 對話太長時用 /compact 而非開新 session

Skills 自訂指令

什麼是 Skills?

Skills 是可重複使用的自訂 slash commands,讓你把常用工作流程打包成一個指令。輸入 /skill-name 即可觸發。

建立 Skill

Skills 以 Markdown 檔案形式存放在 .claude/skills/ 目錄中:

text
複製
.claude/skills/
├── commit.md          # /commit
├── review-pr.md       # /review-pr
├── deploy.md          # /deploy
└── healthcheck.md     # /healthcheck

Skill 檔案格式

markdown
複製
---
name: deploy
description: Build, test, and deploy to production
---

Please perform the following deployment steps:

1. Run all tests: `npm test`
2. Build the project: `npm run build`
3. Check for TypeScript errors: `npx tsc --noEmit`
4. If all checks pass, deploy with: `vercel --prod`
5. Report the deployment URL

If any step fails, stop and report the error.

使用 Skill

text
複製
/deploy              # 執行 deploy skill
/review-pr 123       # 帶參數
/                    # 列出所有可用 skills

作用範圍

位置範圍共用
.claude/skills/專案✔ commit 到 git,團隊共用
~/.claude/skills/全域✘ 個人使用

實用 Skill 範例

📦 自訂 Commit

markdown
複製
---
name: commit
description: Smart commit with conventional format
---
1. Run `git diff --stat` to see changes
2. Stage relevant files (exclude .env, credentials)
3. Generate a conventional commit message
4. Create the commit
5. Show result with `git log --oneline -1`

🔎 PR 審查

markdown
複製
---
name: review-pr
description: Review PR for issues and improvements
---
Review the current branch changes against main:
1. Run `git diff main...HEAD`
2. Check for: security issues, performance, missing tests
3. Summarize with severity levels (critical/warning/info)

🩹 專案健檢

markdown
複製
---
name: healthcheck
description: Check project health - deps, tests, lint
---
1. Check for outdated dependencies
2. Run linter and report issues
3. Run tests and report coverage
4. Check for security vulnerabilities
5. Generate a health report summary
Skills vs CLAUDE.md
  • CLAUDE.md:被動載入的背景知識,每次對話自動讀取
  • Skills:主動觸發的工作流程,像是自訂 macro

Sub-agents 與 Agent SDK

什麼是 Sub-agents?

Claude Code 可以產生子 agent(sub-agent)來平行處理子任務。每個 sub-agent 有獨立的 context,執行完畢後將結果回報給主 agent。

內建 Sub-agent 類型

類型用途可用工具
Explore快速搜尋 codebaseGlob、Grep、Read(唯讀)
Plan設計實作方案唯讀工具(不修改)
general-purpose通用任務所有工具

Claude 會自動判斷何時啟動 sub-agents,例如需要搜尋多個目錄時會平行啟動多個 Explore agent。

Agent SDK

如果你想建立自己的 AI agent 應用,Anthropic 提供了 Agent SDK

Python SDK

python
複製
import anthropic

client = anthropic.Anthropic()
message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "分析這段程式碼的安全性"}]
)

TypeScript SDK

typescript
複製
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();
const message = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "寫一個測試" }]
});

SDK 核心功能

安全性與權限

權限模式詳解

Claude Code 透過多層權限系統確保安全,預設不會未經同意執行危險操作。

模式檔案編輯Shell 指令MCP 工具適合場景
default詢問詢問詢問敏感專案
acceptEdits自動詢問詢問日常開發
plan先展示計畫先展示計畫先展示計畫大型重構
auto智慧判斷智慧判斷智慧判斷Team/Enterprise
bypassPermissions全部跳過全部跳過全部跳過⚠️ 僅測試

沙箱機制

敏感檔案保護

企業安全管控

⚠️ 安全提醒
  • 不要使用 bypassPermissions 在生產環境
  • 定期檢查 permissions.allow 清單
  • 團隊專案使用 .claude/settings.json 統一安全政策

CI/CD 整合

在 GitHub Actions 中使用 Claude Code

yaml
複製
name: Claude Code Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Claude Code
        run: curl -fsSL https://claude.ai/install.sh | bash
      - name: Review PR
        run: |
          claude -p "Review this PR's changes. Check for bugs, security issues, and suggest improvements." \
            --permission-mode dontAsk
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

自動修復 CI 失敗

yaml
複製
- name: Auto-fix lint errors
  run: |
    claude -p "Run linter, fix all errors, and commit the fixes" \
      --permission-mode dontAsk

自動生成 PR 描述

yaml
複製
- name: Generate PR description
  run: |
    claude -p "Analyze the diff and generate a detailed PR description in markdown" \
      --permission-mode dontAsk > pr-body.md

GitLab CI

yaml
複製
claude-review:
  stage: review
  script:
    - curl -fsSL https://claude.ai/install.sh | bash
    - claude -p "Review the MR changes" --permission-mode dontAsk
  only:
    - merge_requests
💡 CI/CD 小技巧
  • CI 環境建議用 --permission-mode dontAsk 避免互動式提示
  • --effort low--model sonnet 加速 CI 流程
  • 設定 ANTHROPIC_API_KEY 為 repository secret

團隊與企業功能

方案比較

功能ProMaxTeamEnterprise
Claude Code 存取
用量額度標準20x每人獨立自訂
auto 權限模式
SSO 單一登入
Managed Policies
Audit Log
Usage Analytics
SCIM 使用者管理
優先支援

團隊共用設定

團隊專案應該將以下檔案 commit 到 git:

Usage Analytics

Team 和 Enterprise 管理員可查看:

Managed Policies(Enterprise)

IT 管理員可全組織部署的強制設定:

與其他 AI 工具比較

綜合比較表

特性Claude CodeGitHub CopilotCursorWindsurfAider
類型CLI+IDE+WebIDE 外掛IDEIDECLI
模型Claude 4.6GPT-4o/Claude多模型多模型多模型
Agentic⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
終端操作✔ 原生有限有限✔ 原生
多檔案編輯✔ 自動需手動✔ Composer✔ Cascade
Git 深度整合✔ commit/PR/branch基本✔ 深度
MCP 外掛✔ 100+
自訂指令CLAUDE.md.github/copilot.cursorrules.windsurfrules
記憶系統✔ Auto Memory基本
雲端執行✔ Web/Remote
瀏覽器自動化✔ --chrome
開源
價格/月$20-200$10-39$20-40$15-50免費(API費)

Claude Code 的獨特優勢

  1. 真正的 Agentic:不只補全,能自主規劃、搜尋、編輯、測試、commit
  2. 6 種介面:CLI + VS Code + JetBrains + Desktop + Web + Slack
  3. MCP 生態系:連接 100+ 外部工具(GitHub、Figma、Notion 等)
  4. 跨 Session 記憶:Auto Memory 持久化團隊知識
  5. 雲端 + 本地:長時間任務可雲端執行
  6. Hooks 自動化:事件驅動的自訂工作流程

各工具最適合的場景

Claude Code

全端開發、複雜重構、跨多檔案、CLI 愛好者、深度 Git 操作、MCP 整合

GitHub Copilot

即時補全、輕量輔助、已在 GitHub 生態系的團隊

Cursor

偏好 VS Code、多模型切換、Composer 多步驟

Windsurf

圖形化 IDE 偏好者、Cascade 自動化

Aider

開源偏好、自選 LLM、預算敏感

💡 不需要二選一
Claude Code CLI 可以和任何 IDE 外掛並行使用。例如用 Copilot 做即時補全 + Claude Code 做複雜重構。

實戰工作流程

① 接手新專案

bash
複製
cd /path/to/project
claude
# 在互動模式中:
> 這個專案做什麼?用了哪些技術?
> 說明資料夾結構
> 哪裡是主要進入點?
> /init    # 自動生成 CLAUDE.md

② 修 Bug

bash
複製
claude
> 我遇到這個錯誤:[貼上完整錯誤訊息]
# Claude 會自動:搜尋相關程式碼 → 定位問題 → 修改 → 執行測試

③ 開發新功能

bash
複製
claude --permission-mode plan
> 我要在使用者設定頁面加上深色模式切換
# Claude 先列出計畫 → 你確認 → 逐步實作
> /commit    # 自動生成 commit message
> 建立 PR

④ 程式碼審查

bash
複製
claude -p "review the changes in this PR and suggest improvements"
# 或在 GitHub PR 中 @claude 留言

⑤ 重構

bash
複製
claude
> 將 authentication module 從 callback 改為 async/await
> 順便補上 unit tests
> 確認所有 tests 都通過

⑥ 平行處理多個任務

bash
複製
# Terminal 1 — 獨立 worktree
claude -w feature-auth -n "auth"
> 實作 OAuth 登入

# Terminal 2 — 另一個 worktree
claude -w fix-ui -n "ui-fix"
> 修正首頁 RWD 問題

⑦ 連接外部工具(MCP)

bash
複製
claude mcp add --transport http notion https://mcp.notion.com/mcp
claude
> 從 Notion 的 API 文件頁面讀取規格,然後實作對應的 endpoint

⑧ CI/CD 自動化

bash
複製
# 在 GitHub Actions 中
claude -p "run all tests and fix any failures" \
  --permission-mode dontAsk

技巧與最佳實踐

有效提問

❌ 模糊

fix the bug

make it better

✔ 具體

修正登入頁面在輸入錯誤密碼後顯示空白畫面的 bug

將 API response time 從 2 秒優化到 500ms

拆分複雜任務

將大任務拆成 3-5 個小步驟,每步完成後確認再繼續:

text
複製
1. 建立資料庫 schema
2. 寫 API endpoint
3. 做前端頁面
4. 補測試

先探索再動手

快捷鍵

快捷鍵功能
?顯示所有快捷鍵
Tab自動補全
↑/↓瀏覽歷史指令
Shift+Enter多行輸入
Ctrl+C中斷 Claude
Ctrl+D退出
Shift+Tab切換權限模式
Ctrl+R反向搜尋歷史
/列出所有指令與 skills

疑難排解

問題解決方法
安裝失敗確認 Node.js 18+ / Git 已安裝
認證問題claude auth logoutclaude auth login
權限提示太多--permission-mode acceptEdits
回應太慢--effort low--model sonnet
Context 超出/compact 壓縮或 /clear 重開
MCP 連不上/mcp 檢查狀態,重啟 session

方案與費用

訂閱方案

方案價格用量適合
Pro$20/月標準額度個人開發者
Max$100-200/月20x 額度重度使用者
Team每人計費獨立額度團隊協作
Enterprise自訂自訂大型組織

API 計費(Console)

透過 claude auth login --console 登入,按 token 用量計費:

模型Input / MTokOutput / MTok
Claude Opus 4.6$15$75
Claude Sonnet 4.6$3$15
Claude Haiku 4.5$0.80$4

查詢用量

text
複製
/cost    # 查看目前 session 費用
💡 省錢技巧
  • 日常任務用 --model sonnet(便宜 5 倍)
  • 簡單查詢用 --effort low 減少 token
  • /compact 減少重複 context 的 token 消耗
  • Batch 處理享有 50% input token 折扣

常見問題 FAQ

Q: Claude Code 會用我的程式碼訓練模型嗎?

不會。Anthropic 明確承諾不會用 Claude Code 使用者的程式碼和對話來訓練模型。

Q: Claude Code 可以離線使用嗎?

不行,Claude Code 需要網路連線才能運作,因為推論在 Anthropic 的伺服器上執行。

Q: 我可以同時開多個 Claude Code session 嗎?

可以!使用 -w(worktree)在不同 git branch 上平行工作,或直接開多個 terminal。

Q: Claude Code 支援哪些程式語言?

所有語言。Claude Code 不限定語言,它能讀取和修改任何文字檔案。特別擅長 Python、JavaScript/TypeScript、Java、Go、Rust、C/C++。

Q: 如何避免 Claude 修改不該改的檔案?

三種方式:(1) 在 CLAUDE.md 列出禁止修改的檔案 (2) 用 Hooks 的 PreToolUse 攔截 (3) 使用 permissions.deny 設定。

Q: 免費試用?

Claude Code 包含在 Claude Pro ($20/月) 訂閱中。目前沒有獨立免費方案,但新註冊可能有試用額度。也可用 API Console 按量計費。

Q: Claude Code 和 Claude.ai 聊天有什麼不同?

Claude Code 有完整的工具存取權限:可讀寫檔案、執行終端指令、管理 Git、連接 MCP 工具。普通 Claude 聊天只能文字對話。

Q: 如何繼續之前的對話?

claude -c 繼續上一次,claude -r "name" 恢復指定 session,claude --resume 互動式選擇。詳見記憶系統

Q: Context window 滿了怎麼辦?

/compact 壓縮對話歷史。Claude 會自動在接近上限時壓縮,保留摘要。

Q: 可以用自己的 API key 嗎?

可以。用 claude auth login --console 登入 Anthropic Console,按 token 用量計費。也支援 AWS Bedrock 和 Google Vertex AI。

Q: Copilot 和 Claude Code 可以同時用嗎?

完全可以。Copilot 做即時補全,Claude Code 做複雜任務(重構、多檔案修改、PR 建立),兩者互補。

Q: 如何讓 Claude 記住我的偏好?

三種方式:(1) CLAUDE.md 寫專案規範 (2) Auto Memory 自動記錄 (3) 明確說「請記住:我偏好...」,Claude 會存入 memory。