4 4
5# 快速入門5# 快速入門
6 6
7> 歡迎使用 Claude Code!7> 在終端機中安裝 Claude Code、登入,並使用 CLI 探索您的程式碼庫及進行第一次程式碼變更。
8 8
9本快速入門指南將在幾分鐘內讓您使用 AI 驅動的編碼協助。完成後,您將了解如何使用 Claude Code 進行常見的開發任務。9本快速入門介紹在終端機中使用 Claude Code:安裝 CLI、從第一個工作階段登入,以及在您自己的專案中將其用於常見的開發任務。
10 10
11<h2 id="before-you-begin">11<h2 id="before-you-begin">
12 開始前12 開始前
14 14
15確保您擁有:15確保您擁有:
16 16
17* 已開啟的終端或命令提示字元17* 已開啟的終端機或命令提示字元
18 * 如果您從未使用過終端,請查看[終端指南](/docs/zh-TW/terminal-guide)
19* 一個可以使用的程式碼專案18* 一個可以使用的程式碼專案
20* 一個 [Claude 訂閱](https://claude.com/pricing?utm_source=claude_code\&utm_medium=docs\&utm_content=quickstart_prereq)(Pro、Max、Team 或 Enterprise)、[Claude Console](https://platform.claude.com/) 帳戶,或透過[支援的雲端提供商](/docs/zh-TW/third-party-integrations)存取19* 一個 [Claude 訂閱](https://claude.com/pricing?utm_source=claude_code\&utm_medium=docs\&utm_content=quickstart_prereq)(Pro、Max、Team 或 Enterprise)、[Claude Console](https://platform.claude.com/) 帳戶,或透過[支援的雲端提供商](/docs/zh-TW/third-party-integrations)存取
21 20
22<Note>21<Note>
23 本指南涵蓋終端 CLI。Claude Code 也可在[網頁](https://claude.ai/code)、[桌面應用程式](/docs/zh-TW/desktop)、[VS Code](/docs/zh-TW/vs-code) 和 [JetBrains IDE](/docs/zh-TW/jetbrains)、[Slack](/docs/zh-TW/slack) 中使用,以及透過 [GitHub Actions](/docs/zh-TW/github-actions) 和 [GitLab](/docs/zh-TW/gitlab-ci-cd) 進行 CI/CD。請參閱[所有介面](/docs/zh-TW/overview#use-claude-code-everywhere)。22 以下情況在其他頁面中說明:
23
24 * **從未使用過終端機**:請從[終端機指南](/docs/zh-TW/terminal-guide)開始
25 * **想在終端機以外的地方使用 Claude Code**:Claude Code 也可在[網頁](https://claude.ai/code)、[桌面應用程式](/docs/zh-TW/desktop)、[VS Code](/docs/zh-TW/vs-code) 和 [JetBrains IDE](/docs/zh-TW/jetbrains)、[Slack](/docs/zh-TW/slack) 中使用,以及透過 [GitHub Actions](/docs/zh-TW/github-actions) 和 [GitLab](/docs/zh-TW/gitlab-ci-cd) 在 CI/CD 中使用。請參閱[所有介面](/docs/zh-TW/overview#use-claude-code-everywhere)。
24</Note>26</Note>
25 27
26<h2 id="step-1-install-claude-code">28<h2 id="step-1-install-claude-code">
33 <Tab title="原生安裝(建議)">35 <Tab title="原生安裝(建議)">
34 **macOS、Linux、WSL:**36 **macOS、Linux、WSL:**
35 37
36 ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}38 ```bash theme={null}
37 curl -fsSL https://claude.ai/install.sh | bash39 curl -fsSL https://claude.ai/install.sh | bash
38 ```40 ```
39 41
42 在 Windows 上,當您在 PowerShell 中時,提示字元會顯示 `PS C:\`,而在 CMD 中時會顯示 `C:\`(不含 `PS`)。
43
40 **Windows PowerShell:**44 **Windows PowerShell:**
41 45
42 ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}46 ```powershell theme={null}
43 irm https://claude.ai/install.ps1 | iex47 irm https://claude.ai/install.ps1 | iex
44 ```48 ```
45 49
46 **Windows CMD:**50 **Windows CMD:**
47 51
48 ```batch theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}52 ```batch theme={null}
49 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd53 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
50 ```54 ```
51 55
52 當安裝程式完成時,請開啟新的終端機視窗並執行 `claude --version`。正常的安裝會列印版本號碼。如果您的殼層說找不到 `claude` 或無法識別,安裝目錄還未在您的 PATH 上:請參閱[修正您的 PATH](/docs/zh-TW/troubleshoot-install#command-not-found-claude-after-installation)。56 當安裝程式完成時,請開啟新的終端機視窗並執行 `claude --version`。正常的安裝會列印版本號碼。如果您的殼層說找不到 `claude` 或無法識別,安裝目錄還未在您的 PATH 上:請參閱[修正您的 PATH](/docs/zh-TW/troubleshoot-install#command-not-found-claude-after-installation)。
53 57
54 如果您看到 `The token '&&' is not a valid statement separator`,表示您在 PowerShell 中,而非 CMD。如果您看到 `'irm' is not recognized as an internal or external command`,表示您在 CMD 中,而非 PowerShell。當您在 PowerShell 中時,提示符會顯示 `PS C:\`,而在 CMD 中時會顯示 `C:\`(不含 `PS`)。58 如果您看到 `The token '&&' is not a valid statement separator`,表示您在 PowerShell 中,而非 CMD。如果您看到 `'irm' is not recognized as an internal or external command`,表示您在 CMD 中,而非 PowerShell。
55 59
56 如果安裝命令失敗並出現 `syntax error near unexpected token '<'`、`403` 或其他 curl 錯誤,請參閱[疑難排解安裝](/docs/zh-TW/troubleshoot-install#find-your-error)以將錯誤與修正相對應,並查看替代安裝方法。60 如果安裝命令失敗並出現 `syntax error near unexpected token '<'`、`403` 或其他任何錯誤,請參閱[疑難排解安裝](/docs/zh-TW/troubleshoot-install#find-your-error)以將錯誤與修正相對應,並查看替代安裝方法。
57 61
58 建議在原生 Windows 上安裝 [Git for Windows](https://git-scm.com/downloads/win),以便 Claude Code 可以使用 Bash 工具。如果未安裝 Git for Windows,Claude Code 會改用 PowerShell 作為殼層工具。WSL 設定不需要 Git for Windows。62 建議在原生 Windows 上安裝 [Git for Windows](https://git-scm.com/downloads/win),以便 Claude Code 可以使用 Bash 工具。如果未安裝 Git for Windows,Claude Code 會改用 PowerShell 作為殼層工具。WSL 設定不需要 Git for Windows。
59 63
63 </Tab>67 </Tab>
64 68
65 <Tab title="Homebrew">69 <Tab title="Homebrew">
66 ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}70 ```bash theme={null}
67 brew install --cask claude-code71 brew install --cask claude-code
68 ```72 ```
69 73
75 </Tab>79 </Tab>
76 80
77 <Tab title="WinGet">81 <Tab title="WinGet">
78 ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}82 ```powershell theme={null}
79 winget install Anthropic.ClaudeCode83 winget install Anthropic.ClaudeCode
80 ```84 ```
81 85
95 99
96此命令會列印版本號碼,後面跟著 `(Claude Code)`。100此命令會列印版本號碼,後面跟著 `(Claude Code)`。
97 101
98<h2 id="step-2-log-in-to-your-account">102<h2 id="step-2-start-your-first-session">
99 步驟 2:登入您的帳戶103 步驟 2:開始您的第一個工作階段
100</h2>104</h2>
101 105
102Claude Code 需要帳戶才能使用。使用 `claude` 命令啟動互動式工作階段,首次使用時系統會提示您登入:106在任何專案目錄中開啟終端機,然後啟動 Claude Code:
103 107
104```bash theme={null}108```bash theme={null}
109cd /path/to/your/project
105claude110claude
106```111```
107 112
108對於 Claude 訂閱或 Console 帳戶,請按照提示在瀏覽器中完成驗證。如果您已設定 `ANTHROPIC_API_KEY` 環境變數,Claude Code 會略過登入提示,改為要求您核准該金鑰。若要稍後切換帳戶或重新驗證,請在執行中的工作階段內輸入 `/login`:113將 `/path/to/your/project` 替換為您要處理的專案路徑。
109
110```text wrap theme={null}
111/login
112```
113
114您可以使用以下任何帳戶類型登入:
115
116* [Claude Pro、Max、Team 或 Enterprise](https://claude.com/pricing?utm_source=claude_code\&utm_medium=docs\&utm_content=quickstart_login)(推薦)
117* [Claude Console](https://platform.claude.com/)(具有預付額度的 API 存取)。首次登入時,Console 中會自動建立「Claude Code」工作區以進行集中成本追蹤。
118* [Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry](/docs/zh-TW/third-party-integrations)(企業雲端提供商)
119* 自行託管的 [Claude 應用程式閘道](/docs/zh-TW/claude-apps-gateway)(如果您的組織執行一個的話):您的管理員會預先設定閘道 URL,`/login` 會直接在 **Cloud gateway** 畫面上開啟,供您使用公司 SSO 登入
120
121登入後,您的認證將被儲存,您無需再次登入。深入瞭解 [認證管理](/docs/zh-TW/authentication#credential-management)。
122 114
123<h2 id="step-3-start-your-first-session">115Claude Code 會在首次使用時提示您登入。若使用 Claude 訂閱或 Console 帳戶,請依照提示在瀏覽器中完成身分驗證。如果您已設定 `ANTHROPIC_API_KEY` 環境變數,且在 Claude Code 詢問是否使用該金鑰時予以核准,Claude Code 便會略過登入提示。
124 步驟 3:啟動您的第一個工作階段
125</h2>
126 116
127在任何專案目錄中開啟您的終端並啟動 Claude Code:117您可以使用下列任一種帳戶類型登入:
128 118
129```bash theme={null}119* [Claude Pro、Max、Team 或 Enterprise](https://claude.com/pricing?utm_source=claude_code\&utm_medium=docs\&utm_content=quickstart_login)(建議)
130cd /path/to/your/project120* [Claude Console](https://platform.claude.com/)(使用預付額度的 API 存取)。首次登入時,系統會自動在 Console 中建立一個「Claude Code」工作區,以便集中追蹤費用。
131claude121* [Amazon Bedrock、Google Cloud's Agent Platform 或 Microsoft Foundry](/docs/zh-TW/third-party-integrations)(企業雲端供應商)
132```122* 自行託管的 [Claude apps 閘道](/docs/zh-TW/claude-apps-gateway)(如果您的組織有執行的話):您的管理員會預先設定閘道 URL,而 `/login` 會直接開啟 **Cloud gateway** 畫面,供您使用企業 SSO 登入
133 123
134將 `/path/to/your/project` 替換為您要處理的專案路徑。124登入後,您的憑證會被儲存,之後不需要再次登入。如需了解更多資訊,請參閱[憑證管理](/docs/zh-TW/authentication#credential-management)。
135 125
136您將看到 Claude Code 提示,其中顯示版本、目前的模型和工作目錄。輸入 `/help` 以查看可用命令,或輸入 `/resume` 以繼續之前的對話。126Claude Code 提示字元會出現,其上方會顯示版本、目前的模型及工作目錄。輸入 `/help` 以查看可用的命令,或輸入 `/resume` 以繼續先前的對話。若之後要切換帳戶或重新進行身分驗證,請在執行中的工作階段內輸入 `/login`。
137 127
138<h2 id="step-4-ask-your-first-question">128<h2 id="step-3-ask-your-first-question">
139 步驟 4:提出您的第一個問題129 步驟 3:提出您的第一個問題
140</h2>130</h2>
141 131
142讓我們從了解您的程式碼庫開始。嘗試以下命令之一:132試試以下其中一個命令:
143 133
144```text wrap theme={null}134```text wrap theme={null}
145what does this project do?135what does this project do?
159explain the folder structure149explain the folder structure
160```150```
161 151
162您也可以詢問 Claude 其自身的功能:152您也可以詢問 Claude 關於其自身功能的問題:
163 153
164```text wrap theme={null}154```text wrap theme={null}
165what can Claude Code do?155what can Claude Code do?
174```164```
175 165
176<Note>166<Note>
177 Claude Code 會根據需要讀取您的專案檔案。您無需手動新增內容。167 Claude Code 會視需要讀取您的專案檔案。無需手動新增上下文。
178</Note>168</Note>
179 169
180<h2 id="step-5-make-your-first-code-change">170<h2 id="step-4-make-your-first-code-change">
181 步驟 5:進行您的第一次程式碼變更171 步驟 4:進行您的第一次程式碼變更
182</h2>172</h2>
183 173
184現在讓 Claude Code 進行一些實際的編碼。嘗試一個簡單的任務:174試試一個小任務:
185 175
186```text wrap theme={null}176```text wrap theme={null}
187add a hello world function to the main file177add a hello world function to the main file
188```178```
189 179
190Claude Code 找到適當的檔案並向您顯示變更。如果它在進行變更前詢問,請選擇 **是** 以批准。180Claude Code 會找到適當的檔案並向您顯示變更內容。如果它在進行變更前詢問,請選擇 **Yes** 以核准。
191
192使用 Claude Code v2.1.283 或更新版本,auto mode 是互動式終端工作階段的[內建起始權限模式](/docs/zh-TW/permission-modes#eliminate-prompts-with-auto-mode):分類器會檢查動作而不是由您檢查,Claude 可以在不詢問的情況下編輯大多數檔案並執行大多數命令。在較早的版本上,auto mode 僅在 Pro、Max 和 Team 方案上是內建的起始權限模式。對於您安裝或升級後立即開始的工作階段,請參閱[安裝或升級後的第一個工作階段](/docs/zh-TW/env-vars#first-session-after-an-install-or-upgrade)。
193 181
194<Note>182工作階段的[權限模式](/docs/zh-TW/permission-modes)決定了 Claude 可以在不先詢問您的情況下執行哪些動作。隨時按下 `Shift+Tab` 即可切換您目前所在工作階段的權限模式。
195 您的設定或您的組織可以設定不同的起始權限模式。[工作階段開始時的權限模式](/docs/zh-TW/permission-modes#which-mode-a-session-starts-in) 列出了相關內容。隨時按 `Shift+Tab` 以切換您所在工作階段的權限模式。
196</Note>
197 183
198<h2 id="step-6-use-git-with-claude-code">184<h2 id="step-5-use-git-with-claude-code">
199 步驟 6:使用 Git 與 Claude Code185 步驟 5:搭配 Claude Code 使用 Git
200</h2>186</h2>
201 187
202Claude Code 使 Git 操作變得對話式:188Claude Code 讓 Git 操作變得像對話一樣自然:
203 189
204```text wrap theme={null}190```text wrap theme={null}
205what files have I changed?191what files have I changed?
209commit my changes with a descriptive message195commit my changes with a descriptive message
210```196```
211 197
212您也可以提示進行更複雜的 Git 操作:198您也可以透過提示詞執行更複雜的 Git 操作:
213 199
214```text wrap theme={null}200```text wrap theme={null}
215create a new branch called feature/quickstart201create a new branch called feature/quickstart
223help me resolve merge conflicts209help me resolve merge conflicts
224```210```
225 211
226<h2 id="step-7-fix-a-bug-or-add-a-feature">212<h2 id="step-6-fix-a-bug-or-add-a-feature">
227 步驟 7:修復錯誤或新增功能213 步驟 6:修正錯誤或新增功能
228</h2>214</h2>
229 215
230Claude 擅長除錯和功能實現。216以自然語言描述您想要的內容:
231
232用自然語言描述您想要的內容:
233 217
234```text wrap theme={null}218```text wrap theme={null}
235add input validation to the user registration form219add input validation to the user registration form
236```220```
237 221
238或修復現有問題:222或修正現有問題:
239 223
240```text wrap theme={null}224```text wrap theme={null}
241there's a bug where users can submit empty forms - fix it225there's a bug where users can submit empty forms - fix it
242```226```
243 227
244Claude Code 將:228<h2 id="step-7-test-out-other-common-workflows">
245 229 步驟 7:試用其他常見工作流程
246* 定位相關程式碼
247* 理解上下文
248* 實現解決方案
249* 如果可用,執行測試
250
251<h2 id="step-8-test-out-other-common-workflows">
252 步驟 8:測試其他常見工作流程
253</h2>230</h2>
254 231
255有許多方式可以與 Claude 合作:232與 Claude 協作的方式有很多種:
256 233
257**重構程式碼**234**重構程式碼**
258 235
260refactor the authentication module to use async/await instead of callbacks237refactor the authentication module to use async/await instead of callbacks
261```238```
262 239
263**編寫測試**240**撰寫測試**
264 241
265```text wrap theme={null}242```text wrap theme={null}
266write unit tests for the calculator functions243write unit tests for the calculator functions
279```256```
280 257
281<Tip>258<Tip>
282 像與有幫助的同事交談一樣與 Claude 交談。描述您想要達成的目標,它將幫助您實現。259 像與一位樂於助人的同事交談一樣與 Claude 對話。描述您想要達成的目標,它就會協助您實現。
283</Tip>260</Tip>
284 261
285<h2 id="essential-commands">262<h2 id="essential-commands">
357 334
358現在您已經學習了基礎知識,請探索更多進階功能:335現在您已經學習了基礎知識,請探索更多進階功能:
359 336
360<CardGroup cols={2}>337* [Claude Code 如何運作](/docs/zh-TW/how-claude-code-works):了解代理式迴圈、內建工具以及 Claude Code 如何與您的專案互動
361 <Card title="Claude Code 如何運作" icon="microchip" href="/docs/zh-TW/how-claude-code-works">338* [最佳實踐](/docs/zh-TW/best-practices):透過有效的提示和專案設定獲得更好的結果
362 了解代理迴圈、內建工具以及 Claude Code 如何與您的專案互動339* [常見工作流程](/docs/zh-TW/common-workflows):常見任務的逐步指南
363 </Card>340* [擴展 Claude Code](/docs/zh-TW/features-overview):使用 CLAUDE.md、skill、hook、MCP 等進行自訂
364
365 <Card title="最佳實踐" icon="star" href="/docs/zh-TW/best-practices">
366 透過有效的提示和專案設定獲得更好的結果
367 </Card>
368
369 <Card title="常見工作流程" icon="graduation-cap" href="/docs/zh-TW/common-workflows">
370 常見任務的逐步指南
371 </Card>
372 341
373 <Card title="擴展 Claude Code" icon="puzzle-piece" href="/docs/zh-TW/features-overview">342請參閱[進階設定](/docs/zh-TW/setup)以了解安裝選項、手動更新或解除安裝說明。
374 使用 CLAUDE.md、skills、hooks、MCP 等進行自訂
375 </Card>
376</CardGroup>
377 343
378<h2 id="getting-help">344<h2 id="getting-help">
379 獲取幫助345 獲取幫助
380</h2>346</h2>
381 347
382* **在 Claude Code 中**:輸入 `/help` 或詢問「how do I」問題348* **在 Claude Code 中**:輸入 `/help` 或詢問「how do I」問題
383* **文件**:您在這裡!瀏覽其他指南349* **文件**:瀏覽本網站上的其他指南
384* **課程**:參加 [Claude Code 101](https://academy.claude.com/courses/claude-code-101) 和其他免費自學課程,位於 [Claude Academy](https://academy.claude.com/)350* **課程**:參加 [Claude Code 101](https://academy.claude.com/courses/claude-code-101) 和其他免費自學課程,位於 [Claude Academy](https://academy.claude.com/)
385* **社群**:加入 [Discord 伺服器](https://www.anthropic.com/discord) 以獲取提示和支援351* **社群**:加入 [Discord 伺服器](https://www.anthropic.com/discord) 以獲取提示和支援