SpyBara
Go Premium

quickstart.md 2026-11-09 23:02 UTC to 2026-11-10 21:57 UTC

No changes for this document in this history range.

2026
Wed 11 22:59 Thu 12 23:02

快速入門

在終端機中安裝 Claude Code、登入,並使用 CLI 探索您的程式碼庫及進行第一次程式碼變更。

本快速入門介紹在終端機中使用 Claude Code:安裝 CLI、從第一個工作階段登入,以及在您自己的專案中將其用於常見的開發任務。

開始前

確保您擁有:

[!NOTE]

以下情況在其他頁面中說明:

步驟 1:安裝 Claude Code

若要安裝 Claude Code,請開啟終端機並執行適用於您系統的命令。如果您之前未使用過終端機,終端機指南會說明如何開啟終端機並貼上命令。

[tab] 原生安裝(建議)

macOS、Linux、WSL:

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

在 Windows 上,當您在 PowerShell 中時,提示字元會顯示 PS C:\,而在 CMD 中時會顯示 C:\(不含 PS)。

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Windows CMD:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

安裝命令在下載 Claude Code 時不會顯示進度。當安裝程式完成時,請開啟新的終端機視窗並執行 claude --version。正常的安裝會列印版本號碼。如果您的 shell 說找不到 claude 或無法識別,安裝目錄還未在您的 PATH 上:請參閱修正您的 PATH。

如果您看到 The token '&&' is not a valid statement separator,表示您在 PowerShell 中,而非 CMD。如果您看到 'irm' is not recognized as an internal or external command,表示您在 CMD 中,而非 PowerShell。

如果安裝命令失敗並出現 syntax error near unexpected token '<'、403 或其他任何錯誤,請參閱疑難排解安裝以將錯誤與修正相對應,並查看替代安裝方法。

建議在原生 Windows 上安裝 Git for Windows,以便 Claude Code 可以使用 Bash 工具。如果未安裝 Git for Windows,Claude Code 會改用 PowerShell 作為殼層工具。WSL 設定不需要 Git for Windows。

[!NOTE]

原生安裝會在背景自動更新,以保持您使用最新版本。

[tab] Homebrew

brew install --cask claude-code

Homebrew 提供兩個 casks。claude-code 追蹤穩定版本通道,通常比最新版本晚約一週,並跳過有重大迴歸的版本。claude-code@latest 追蹤最新通道,並在新版本發佈時立即接收。

[!NOTE]

Homebrew 安裝不會自動更新。執行 brew upgrade claude-code 或 brew upgrade claude-code@latest(取決於您安裝的 cask),以取得最新功能和安全修正。

[tab] WinGet

winget install Anthropic.ClaudeCode

[!NOTE]

WinGet 安裝不會自動更新。定期執行 winget upgrade Anthropic.ClaudeCode 以取得最新功能和安全修正。

您也可以在 Debian、Fedora、RHEL 和 Alpine 上使用 apt、dnf 或 apk 進行安裝。

若要確認安裝成功,請執行:

claude --version

此命令會列印版本號碼,後面跟著 (Claude Code)。

步驟 2:開始您的第一個工作階段

在任何專案目錄中開啟終端機,然後啟動 Claude Code:

cd /path/to/your/project
claude

將 /path/to/your/project 替換為您要處理的專案路徑。

Claude Code 會在首次使用時提示您登入。若使用 Claude 訂閱或 Console 帳戶,請依照提示在瀏覽器中完成身分驗證。如果您已設定 ANTHROPIC_API_KEY 環境變數,且在 Claude Code 詢問是否使用該金鑰時予以核准,Claude Code 便會略過登入提示。

您可以使用下列任一種帳戶類型登入:

登入後,您的憑證會被儲存,之後不需要再次登入。如需了解更多資訊,請參閱憑證管理。

Claude Code 提示字元會出現,其上方會顯示版本、目前的模型及工作目錄。輸入 /help 以查看可用的命令,或輸入 /resume 以繼續先前的對話。若之後要切換帳戶或重新進行身分驗證,請在執行中的工作階段內輸入 /login。

步驟 3:提出您的第一個問題

試試以下其中一個命令:

what does this project do?

Claude 將分析您的檔案並提供摘要。您也可以提出更具體的問題:

what technologies does this project use?
where is the main entry point?
explain the folder structure

您也可以詢問 Claude 關於其自身功能的問題:

what can Claude Code do?
how do I create custom skills in Claude Code?
can Claude Code work with Docker?

[!NOTE]

Claude Code 會視需要讀取您的專案檔案。無需手動新增上下文。

步驟 4:進行您的第一次程式碼變更

試試一個小任務:

add a hello world function to the main file

Claude Code 會找到適當的檔案並向您顯示變更內容。如果它在進行變更前詢問,請選擇 Yes 以核准。

工作階段的權限模式決定了 Claude 可以在不先詢問您的情況下執行哪些動作。隨時按下 Shift+Tab 即可切換您目前所在工作階段的權限模式。

步驟 5:搭配 Claude Code 使用 Git

Claude Code 讓 Git 操作變得像對話一樣自然:

what files have I changed?
commit my changes with a descriptive message

您也可以透過提示詞執行更複雜的 Git 操作:

create a new branch called feature/quickstart
show me the last 5 commits
help me resolve merge conflicts

步驟 6:修正錯誤或新增功能

以自然語言描述您想要的內容:

add input validation to the user registration form

或修正現有問題:

there's a bug where users can submit empty forms - fix it

步驟 7:試用其他常見工作流程

再試試幾個提示詞。您可以請 Claude 重構程式碼、撰寫測試、更新文件,或審查您的變更:

refactor the authentication module to use async/await instead of callbacks
write unit tests for the calculator functions
update the README with installation instructions
review my changes and suggest improvements

[!TIP]

像與一位樂於助人的同事交談一樣與 Claude 對話。描述您想要達成的目標,它就會協助您實現。

基本命令

以下是日常使用中最重要的命令,依執行位置分組。

Shell 命令

從您的終端機執行這些命令以啟動或繼續 Claude Code。

命令 功能 範例
claude 啟動互動模式 claude
claude "task" 使用初始提示啟動互動模式 claude "fix the build error"
claude -p "query" 執行一次性查詢,然後退出 claude -p "explain this function"
claude -c 在目前目錄中繼續最近的對話 claude -c
claude -r 恢復之前的對話 claude -r

請參閱 CLI 參考以取得完整的 shell 命令清單。

工作階段命令

在 Claude Code 啟動後於其內部執行這些命令。

命令 功能 範例
/clear 清除對話歷史 /clear
/help 顯示可用命令 /help
/exit 或 Ctrl+D 兩次 退出 Claude Code /exit

請參閱 命令參考以取得完整的工作階段命令清單。

初學者的專業提示

如需更多資訊,請參閱最佳實踐和常見工作流程。

[accordion] 對您的請求要具體

不要這樣做:"修復錯誤"

試試這樣:"修復登入錯誤,使用者輸入錯誤認證後看到空白畫面"

[accordion] 使用逐步說明

將複雜任務分解為步驟:

1. create a new database table for user profiles
2. create an API endpoint to get and update user profiles
3. build a webpage that allows users to see and edit their information

[accordion] 讓 Claude 先探索

在進行變更之前,讓 Claude 了解您的程式碼:

analyze the database schema
build a dashboard showing products that are most frequently returned by our UK customers

[accordion] 使用快捷方式節省時間

  • 輸入 / 查看所有命令和 skills
  • 使用 Tab 進行命令完成
  • 按 ↑ 查看命令歷史
  • 按 Shift+Tab 循環切換權限模式

接下來呢?

現在您已經學習了基礎知識,請探索更多進階功能:

請參閱進階設定以了解安裝選項、手動更新或解除安裝說明。

獲取幫助

  • 在 Claude Code 中:輸入 /help 或詢問「how do I」問題
  • 文件:瀏覽本網站上的其他指南
  • 課程:參加 Claude Code 101 和其他免費自學課程,位於 Claude Academy
  • 社群:加入 Discord 伺服器 以獲取提示和支援