17* [將研究委派給 subagents](#delegate-research-to-subagents),以保持主要背景資訊清潔17* [將研究委派給 subagents](#delegate-research-to-subagents),以保持主要背景資訊清潔
18* [將 Claude 管道輸入指令碼](#pipe-claude-into-scripts),用於 CI 和批次處理18* [將 Claude 管道輸入指令碼](#pipe-claude-into-scripts),用於 CI 和批次處理
19 19
20<h2 id="prompt-recipes">20## 提示食譜
21 提示食譜
22</h2>
23 21
24這些是日常任務的提示模式,例如探索陌生程式碼、除錯、重構、編寫測試和建立 PR。每個都可在任何 Claude Code 介面中工作;根據您的專案調整措辭。22這些是日常任務的提示模式,例如探索陌生程式碼、除錯、重構、編寫測試和建立 PR。每個都可在任何 Claude Code 介面中工作;根據您的專案調整措辭。
25 23
26<h3 id="understand-new-codebases">24### 了解新的程式碼庫
27 了解新的程式碼庫
28</h3>
29 25
30如需在 monorepo 或大型程式碼庫中配置 Claude Code,請參閱 [Monorepos 和大型儲存庫](/docs/zh-TW/large-codebases)。26如需在 monorepo 或大型程式碼庫中配置 Claude Code,請參閱 [Monorepos 和大型儲存庫](/docs/zh-TW/large-codebases)。
31 27
32<h4 id="get-a-quick-codebase-overview">28#### 快速取得程式碼庫概覽
33 快速取得程式碼庫概覽
34</h4>
35 29
36假設您剛加入一個新專案,需要快速了解其結構。30假設您剛加入一個新專案,需要快速了解其結構。
37 31
38<Steps>32**1. 導航到專案根目錄**
39 <Step title="導航到專案根目錄">33
40 ```bash theme={null}34```bash theme={null}
41 cd /path/to/project 35cd /path/to/project
42 ```36```
43 37
44 將 `/path/to/project` 替換為您專案的路徑。38將 `/path/to/project` 替換為您專案的路徑。
45 </Step>39
46 40**2. 啟動 Claude Code**
47 <Step title="啟動 Claude Code">41
48 ```bash theme={null}42```bash theme={null}
49 claude 43claude
50 ```44```
51 </Step>45
52 46**3. 要求高層級概覽**
53 <Step title="要求高層級概覽">47
54 ```text wrap theme={null}48```text wrap theme={null}
55 give me an overview of this codebase49give me an overview of this codebase
56 ```50```
57 </Step>51
58 52**4. 深入探討特定元件**
59 <Step title="深入探討特定元件">53
60 ```text wrap theme={null}54```text wrap theme={null}
61 explain the main architecture patterns used here55explain the main architecture patterns used here
62 ```56```
63 57
64 ```text wrap theme={null}58```text wrap theme={null}
65 what are the key data models?59what are the key data models?
66 ```60```
67 61
68 ```text wrap theme={null}62```text wrap theme={null}
69 how is authentication handled?63how is authentication handled?
70 ```64```
71 </Step>65
72</Steps>66> [!TIP]
73 67>
74<Tip>68> 提示:
75 提示:69>
76 70> * 從廣泛的問題開始,然後縮小到特定領域
77 * 從廣泛的問題開始,然後縮小到特定領域71> * 詢問專案中使用的編碼慣例和模式
78 * 詢問專案中使用的編碼慣例和模式72> * 要求提供專案特定術語的詞彙表
79 * 要求提供專案特定術語的詞彙表73
80</Tip>74#### 尋找相關程式碼
81
82<h4 id="find-relevant-code">
83 尋找相關程式碼
84</h4>
85 75
86假設您需要找到與特定功能或功能相關的程式碼。76假設您需要找到與特定功能或功能相關的程式碼。
87 77
88<Steps>78**1. 要求 Claude 尋找相關檔案**
89 <Step title="要求 Claude 尋找相關檔案">79
90 ```text wrap theme={null}80```text wrap theme={null}
91 find the files that handle user authentication81find the files that handle user authentication
92 ```82```
93 </Step>83
94 84**2. 取得元件如何互動的背景資訊**
95 <Step title="取得元件如何互動的背景資訊">85
96 ```text wrap theme={null}86```text wrap theme={null}
97 how do these authentication files work together?87how do these authentication files work together?
98 ```88```
99 </Step>89
100 90**3. 了解執行流程**
101 <Step title="了解執行流程">91
102 ```text wrap theme={null}92```text wrap theme={null}
103 trace the login process from front-end to database93trace the login process from front-end to database
104 ```94```
105 </Step>95
106</Steps>96> [!TIP]
107 97>
108<Tip>98> 提示:
109 提示:99>
110 100> * 明確說明您要尋找的內容
111 * 明確說明您要尋找的內容101> * 使用專案中的領域語言
112 * 使用專案中的領域語言102> * 為您的語言安裝[程式碼智能外掛](/docs/zh-TW/plugins/code-intelligence),以便 Claude 進行精確的「前往定義」和「尋找參考」導航
113 * 為您的語言安裝[程式碼智能外掛](/docs/zh-TW/plugins/code-intelligence),以便 Claude 進行精確的「前往定義」和「尋找參考」導航
114</Tip>
115 103
116***104***
117 105
118<h3 id="fix-bugs-efficiently">106### 有效地修復錯誤
119 有效地修復錯誤
120</h3>
121 107
122假設您遇到了錯誤訊息,需要找到並修復其來源。108假設您遇到了錯誤訊息,需要找到並修復其來源。
123 109
124<Steps>110**1. 與 Claude 分享錯誤**
125 <Step title="與 Claude 分享錯誤">111
126 ```text wrap theme={null}112```text wrap theme={null}
127 I'm seeing an error when I run npm test113I'm seeing an error when I run npm test
128 ```114```
129 </Step>115
130 116**2. 要求修復建議**
131 <Step title="要求修復建議">117
132 ```text wrap theme={null}118```text wrap theme={null}
133 suggest a few ways to fix the @ts-ignore in user.ts119suggest a few ways to fix the @ts-ignore in user.ts
134 ```120```
135 </Step>121
136 122**3. 應用修復**
137 <Step title="應用修復">123
138 ```text wrap theme={null}124```text wrap theme={null}
139 update user.ts to add the null check you suggested125update user.ts to add the null check you suggested
140 ```126```
141 </Step>127
142</Steps>128> [!TIP]
143 129>
144<Tip>130> 提示:
145 提示:131>
146 132> * 告訴 Claude 重現問題的命令並取得堆疊追蹤
147 * 告訴 Claude 重現問題的命令並取得堆疊追蹤133> * 提及重現錯誤的任何步驟
148 * 提及重現錯誤的任何步驟134> * 讓 Claude 知道錯誤是間歇性的還是持續的
149 * 讓 Claude 知道錯誤是間歇性的還是持續的
150</Tip>
151 135
152***136***
153 137
154<h3 id="refactor-code">138### 重構程式碼
155 重構程式碼
156</h3>
157 139
158假設您需要更新舊程式碼以使用現代模式和實踐。140假設您需要更新舊程式碼以使用現代模式和實踐。
159 141
160如需將整個程式碼庫移植到新語言,請參閱部落格上的[Anthropic 如何使用 Claude Code 執行大規模程式碼遷移](https://claude.com/blog/ai-code-migration)。142如需將整個程式碼庫移植到新語言,請參閱部落格上的[Anthropic 如何使用 Claude Code 執行大規模程式碼遷移](https://claude.com/blog/ai-code-migration)。
161 143
162<Steps>144**1. 識別用於重構的舊版程式碼**
163 <Step title="識別用於重構的舊版程式碼">145
164 ```text wrap theme={null}146```text wrap theme={null}
165 find deprecated API usage in our codebase147find deprecated API usage in our codebase
166 ```148```
167 </Step>149
168 150**2. 取得重構建議**
169 <Step title="取得重構建議">151
170 ```text wrap theme={null}152```text wrap theme={null}
171 suggest how to refactor utils.js to use modern JavaScript features153suggest how to refactor utils.js to use modern JavaScript features
172 ```154```
173 </Step>155
174 156**3. 安全地應用變更**
175 <Step title="安全地應用變更">157
176 ```text wrap theme={null}158```text wrap theme={null}
177 refactor utils.js to use ES2024 features while maintaining the same behavior159refactor utils.js to use ES2024 features while maintaining the same behavior
178 ```160```
179 </Step>161
180 162**4. 驗證重構**
181 <Step title="驗證重構">163
182 ```text wrap theme={null}164```text wrap theme={null}
183 run tests for the refactored code165run tests for the refactored code
184 ```166```
185 </Step>167
186</Steps>168> [!TIP]
187 169>
188<Tip>170> 提示:
189 提示:171>
190 172> * 要求 Claude 解釋現代方法的優點
191 * 要求 Claude 解釋現代方法的優點173> * 在需要時要求變更保持向後相容性
192 * 在需要時要求變更保持向後相容性174> * 以小的、可測試的增量進行重構
193 * 以小的、可測試的增量進行重構
194</Tip>
195 175
196***176***
197 177
198<h3 id="work-with-tests">178### 使用測試
199 使用測試
200</h3>
201 179
202假設您需要為未涵蓋的程式碼新增測試。180假設您需要為未涵蓋的程式碼新增測試。
203 181
204<Steps>182**1. 識別未測試的程式碼**
205 <Step title="識別未測試的程式碼">183
206 ```text wrap theme={null}184```text wrap theme={null}
207 find functions in NotificationsService.swift that are not covered by tests185find functions in NotificationsService.swift that are not covered by tests
208 ```186```
209 </Step>187
210 188**2. 產生測試框架**
211 <Step title="產生測試框架">189
212 ```text wrap theme={null}190```text wrap theme={null}
213 add tests for the notification service191add tests for the notification service
214 ```192```
215 </Step>193
216 194**3. 新增有意義的測試案例**
217 <Step title="新增有意義的測試案例">195
218 ```text wrap theme={null}196```text wrap theme={null}
219 add test cases for edge conditions in the notification service197add test cases for edge conditions in the notification service
220 ```198```
221 </Step>199
222 200**4. 執行並驗證測試**
223 <Step title="執行並驗證測試">201
224 ```text wrap theme={null}202```text wrap theme={null}
225 run the new tests and fix any failures203run the new tests and fix any failures
226 ```204```
227 </Step>
228</Steps>
229 205
230Claude 可以產生遵循您專案現有模式和慣例的測試。要求測試時,請明確說明您想驗證的行為。Claude 會檢查您現有的測試檔案,以符合已在使用的風格、框架和斷言模式。206Claude 可以產生遵循您專案現有模式和慣例的測試。要求測試時,請明確說明您想驗證的行為。Claude 會檢查您現有的測試檔案,以符合已在使用的風格、框架和斷言模式。
231 207
233 209
234***210***
235 211
236<h3 id="create-pull-requests">212### 建立提取請求
237 建立提取請求
238</h3>
239 213
240您可以直接要求 Claude 建立提取請求(「為我的變更建立 pr」),或逐步引導 Claude 完成:214您可以直接要求 Claude 建立提取請求(「為我的變更建立 pr」),或逐步引導 Claude 完成:
241 215
242<Steps>216**1. 總結您的變更**
243 <Step title="總結您的變更">217
244 ```text wrap theme={null}218```text wrap theme={null}
245 summarize the changes I've made to the authentication module219summarize the changes I've made to the authentication module
246 ```220```
247 </Step>221
248 222**2. 產生提取請求**
249 <Step title="產生提取請求">223
250 ```text wrap theme={null}224```text wrap theme={null}
251 create a pr225create a pr
252 ```226```
253 </Step>227
254 228**3. 檢查並細化**
255 <Step title="檢查並細化">229
256 ```text wrap theme={null}230```text wrap theme={null}
257 enhance the PR description with more context about the security improvements231enhance the PR description with more context about the security improvements
258 ```232```
259 </Step>
260</Steps>
261 233
262若要稍後找到會話,請執行 `claude --from-pr 1234`,並使用您自己的 PR 編號,這會開啟會話選擇器,篩選連結到該 PR 的會話,或將 PR URL 貼到 [`/resume` 選擇器](/docs/zh-TW/sessions#use-the-session-picker)搜尋中。當 Claude 使用 `gh pr create` 或 `glab mr create` 建立提取請求時,Claude Code 會將會話連結到 PR,以及當 Claude [處理現有 PR](/docs/zh-TW/agent-view#pull-request-status) 時。234若要稍後找到會話,請執行 `claude --from-pr 1234`,並使用您自己的 PR 編號,這會開啟會話選擇器,篩選連結到該 PR 的會話,或將 PR URL 貼到 [`/resume` 選擇器](/docs/zh-TW/sessions#use-the-session-picker)搜尋中。當 Claude 使用 `gh pr create` 或 `glab mr create` 建立提取請求時,Claude Code 會將會話連結到 PR,以及當 Claude [處理現有 PR](/docs/zh-TW/agent-view#pull-request-status) 時。
263 235
264<Tip>236> [!TIP]
265 在提交前檢查 Claude 產生的 PR,並要求 Claude 突出顯示潛在的風險或考慮事項。237>
266</Tip>238> 在提交前檢查 Claude 產生的 PR,並要求 Claude 突出顯示潛在的風險或考慮事項。
267 239
268<h3 id="handle-documentation">240### 處理文件
269 處理文件
270</h3>
271 241
272假設您需要為程式碼新增或更新文件。242假設您需要為程式碼新增或更新文件。
273 243
274<Steps>244**1. 識別未記錄的程式碼**
275 <Step title="識別未記錄的程式碼">245
276 ```text wrap theme={null}246```text wrap theme={null}
277 find functions without proper JSDoc comments in the auth module247find functions without proper JSDoc comments in the auth module
278 ```248```
279 </Step>249
280 250**2. 產生文件**
281 <Step title="產生文件">251
282 ```text wrap theme={null}252```text wrap theme={null}
283 add JSDoc comments to the undocumented functions in auth.js253add JSDoc comments to the undocumented functions in auth.js
284 ```254```
285 </Step>255
286 256**3. 檢查並增強**
287 <Step title="檢查並增強">257
288 ```text wrap theme={null}258```text wrap theme={null}
289 improve the generated documentation with more context and examples259improve the generated documentation with more context and examples
290 ```260```
291 </Step>261
292 262**4. 驗證文件**
293 <Step title="驗證文件">263
294 ```text wrap theme={null}264```text wrap theme={null}
295 check if the documentation follows our project standards265check if the documentation follows our project standards
296 ```266```
297 </Step>267
298</Steps>268> [!TIP]
299 269>
300<Tip>270> 提示:
301 提示:271>
302 272> * 指定您想要的文件風格(JSDoc、docstrings 等)
303 * 指定您想要的文件風格(JSDoc、docstrings 等)273> * 要求文件中的範例
304 * 要求文件中的範例274> * 要求公開 API、介面和複雜邏輯的文件
305 * 要求公開 API、介面和複雜邏輯的文件
306</Tip>
307 275
308***276***
309 277
310<h3 id="work-in-notes-and-non-code-folders">278### 在筆記和非程式碼資料夾中工作
311 在筆記和非程式碼資料夾中工作
312</h3>
313 279
314Claude Code 可在任何目錄中工作。在筆記保管庫、文件資料夾或任何 markdown 檔案集合中執行它,以搜尋、編輯和重新組織內容,就像您處理程式碼一樣。280Claude Code 可在任何目錄中工作。在筆記保管庫、文件資料夾或任何 markdown 檔案集合中執行它,以搜尋、編輯和重新組織內容,就像您處理程式碼一樣。
315 281
317 283
318***284***
319 285
320<h3 id="work-with-images">286### 使用影像
321 使用影像
322</h3>
323 287
324假設您需要在程式碼庫中使用影像,並希望 Claude 幫助分析影像內容。288假設您需要在程式碼庫中使用影像,並希望 Claude 幫助分析影像內容。
325 289
326<Steps>290**1. 將影像新增到對話中**
327 <Step title="將影像新增到對話中">291
328 您可以使用以下任何方法:292您可以使用以下任何方法:
329 293
330 1. 將影像拖放到 Claude Code 視窗中2941. 將影像拖放到 Claude Code 視窗中
331 2. 複製影像並使用 `Ctrl+V` 將其貼到 CLI 中,或在 [Windows 和 WSL 上使用 `Alt+V`](/docs/zh-TW/interactive-mode#general-controls)2952. 複製影像並使用 `Ctrl+V` 將其貼到 CLI 中,或在 [Windows 和 WSL 上使用 `Alt+V`](/docs/zh-TW/interactive-mode#general-controls)
332 3. 向 Claude 提供影像路徑。例如,「分析此影像:/path/to/your/image.png」2963. 向 Claude 提供影像路徑。例如,「分析此影像:/path/to/your/image.png」
333 </Step>297
334 298**2. 要求 Claude 分析影像**
335 <Step title="要求 Claude 分析影像">299
336 ```text wrap theme={null}300```text wrap theme={null}
337 What does this image show?301What does this image show?
338 ```302```
339 303
340 ```text wrap theme={null}304```text wrap theme={null}
341 Describe the UI elements in this screenshot305Describe the UI elements in this screenshot
342 ```306```
343 307
344 ```text wrap theme={null}308```text wrap theme={null}
345 Are there any problematic elements in this diagram?309Are there any problematic elements in this diagram?
346 ```310```
347 </Step>311
348 312**3. 使用影像作為背景資訊**
349 <Step title="使用影像作為背景資訊">313
350 ```text wrap theme={null}314```text wrap theme={null}
351 Here's a screenshot of the error. What's causing it?315Here's a screenshot of the error. What's causing it?
352 ```316```
353 317
354 ```text wrap theme={null}318```text wrap theme={null}
355 This is our current database schema. How should we modify it for the new feature?319This is our current database schema. How should we modify it for the new feature?
356 ```320```
357 </Step>321
358 322**4. 從視覺內容取得程式碼建議**
359 <Step title="從視覺內容取得程式碼建議">323
360 ```text wrap theme={null}324```text wrap theme={null}
361 Generate CSS to match this design mockup325Generate CSS to match this design mockup
362 ```326```
363 327
364 ```text wrap theme={null}328```text wrap theme={null}
365 What HTML structure would recreate this component?329What HTML structure would recreate this component?
366 ```330```
367 </Step>331
368</Steps>332> [!TIP]
369 333>
370<Tip>334> 提示:
371 提示:335>
372 336> * 當文字描述不清楚或繁瑣時,使用影像
373 * 當文字描述不清楚或繁瑣時,使用影像337> * 包含錯誤、UI 設計或圖表的螢幕截圖以獲得更好的背景資訊
374 * 包含錯誤、UI 設計或圖表的螢幕截圖以獲得更好的背景資訊338> * 您可以在對話中使用多個影像
375 * 您可以在對話中使用多個影像339> * 影像分析適用於圖表、螢幕截圖、模型等
376 * 影像分析適用於圖表、螢幕截圖、模型等340> * 當 Claude 參考影像時(例如 `[Image #1]`),`Cmd+Click`(Mac)或 `Ctrl+Click`(Windows/Linux)連結以在預設檢視器中開啟影像
377 * 當 Claude 參考影像時(例如 `[Image #1]`),`Cmd+Click`(Mac)或 `Ctrl+Click`(Windows/Linux)連結以在預設檢視器中開啟影像
378</Tip>
379 341
380***342***
381 343
382<h3 id="reference-files-and-directories">344### 參考檔案和目錄
383 參考檔案和目錄
384</h3>
385 345
386使用 @ 快速包含檔案或目錄,無需等待 Claude 讀取它們。346使用 @ 快速包含檔案或目錄,無需等待 Claude 讀取它們。
387 347
388<Steps>348**1. 參考單個檔案**
389 <Step title="參考單個檔案">
390 ```text wrap theme={null}
391 Explain the logic in @src/utils/auth.js
392 ```
393 349
394 當檔案符合 [Read 工具](/docs/zh-TW/tools-reference#read-tool-behavior)的 token 限制(預設為 25,000 個 token)時,這會在對話中包含檔案的內容。大於 256KB 的文字檔案不會被包含。350```text wrap theme={null}
395 </Step>351Explain the logic in @src/utils/auth.js
352```
353
354當檔案符合 [Read 工具](/docs/zh-TW/tools-reference#read-tool-behavior)的 token 限制(預設為 25,000 個 token)時,這會在對話中包含檔案的內容。大於 256KB 的文字檔案不會被包含。
396 355
397 <Step title="參考目錄">356**2. 參考目錄**
398 ```text wrap theme={null}357
399 What's the structure of @src/components?358```text wrap theme={null}
400 ```359What's the structure of @src/components?
401 </Step>360```
402 361
403 <Step title="參考 MCP 資源">362**3. 參考 MCP 資源**
404 ```text wrap theme={null}
405 Show me the data from @github:repos/owner/repo/issues
406 ```
407 363
408 這使用 @server:resource 格式從連接的 MCP 伺服器取得資料。有關詳細資訊,請參閱 [MCP 資源](/docs/zh-TW/mcp#use-mcp-resources)。364```text wrap theme={null}
409 </Step>365Show me the data from @github:repos/owner/repo/issues
410</Steps>366```
411 367
412<Tip>368這使用 @server:resource 格式從連接的 MCP 伺服器取得資料。有關詳細資訊,請參閱 [MCP 資源](/docs/zh-TW/mcp#use-mcp-resources)。
413 提示:
414 369
415 * 檔案路徑可以是相對的或絕對的370> [!TIP]
416 * 輸入 `@` 以開啟路徑建議功能表,然後按 Enter 或 Tab 以接受反白顯示的路徑,再按 Enter 以傳送訊息371>
417 * @ 檔案參考會在檔案的目錄和父目錄中新增 `CLAUDE.md` 到背景資訊372> 提示:
418 * 目錄參考顯示檔案清單,而不是內容373>
419 * 您可以在單個訊息中參考多個檔案(例如「@file1.js and @file2.js」)374> * 檔案路徑可以是相對的或絕對的
420</Tip>375> * 輸入 `@` 以開啟路徑建議功能表,然後按 Enter 或 Tab 以接受反白顯示的路徑,再按 Enter 以傳送訊息
376> * @ 檔案參考會在檔案的目錄和父目錄中新增 `CLAUDE.md` 到背景資訊
377> * 目錄參考顯示檔案清單,而不是內容
378> * 您可以在單個訊息中參考多個檔案(例如「@file1.js and @file2.js」)
421 379
422若要阻止 `@` 參考在您的訊息中包含檔案內容和目錄清單,請在您的 shell 或使用者設定中設定 [`CLAUDE_CODE_DISABLE_FILE_MENTIONS=1`](/docs/zh-TW/env-vars#variables)。Claude 隨後會收到您參考的路徑,並附帶一則說明,指示其使用檔案工具讀取這些路徑。此變數需要 Claude Code v2.1.299 或更新版本,且 Claude Code 會在專案和本機設定中忽略它。380若要阻止 `@` 參考在您的訊息中包含檔案內容和目錄清單,請在您的 shell 或使用者設定中設定 [`CLAUDE_CODE_DISABLE_FILE_MENTIONS=1`](/docs/zh-TW/env-vars#variables)。Claude 隨後會收到您參考的路徑,並附帶一則說明,指示其使用檔案工具讀取這些路徑。此變數需要 Claude Code v2.1.299 或更新版本,且 Claude Code 會在專案和本機設定中忽略它。
423 381
424***382***
425 383
426<h3 id="run-claude-on-a-schedule">384### 按排程執行 Claude
427 按排程執行 Claude
428</h3>
429 385
430假設您想讓 Claude 自動定期處理任務,例如每天早上檢查開放 PR、每週審計依賴項或在夜間檢查 CI 失敗。386假設您想讓 Claude 自動定期處理任務,例如每天早上檢查開放 PR、每週審計依賴項或在夜間檢查 CI 失敗。
431 387
433 389
434| 選項 | 執行位置 | 最適合 |390| 選項 | 執行位置 | 最適合 |
435| :- | :- | :- |391| :- | :- | :- |
436| [Routines](/docs/zh-TW/routines) | 雲端,預設由 Anthropic 管理 | 應該在您的電腦關閉時執行的任務。也可以由 API 呼叫或 GitHub 事件觸發,除了排程。在 [claude.ai/code/routines](https://claude.ai/code/routines) 配置。 |392| [雲端排程任務](/docs/zh-TW/routines) | 雲端,預設由 Anthropic 管理 | 應該在您的電腦關閉時執行的任務。除了排程之外,也可以由 API 呼叫或 GitHub 事件觸發。在 [claude.ai/code/routines](https://claude.ai/code/routines) 設定。 |
437| [桌面排程任務](/docs/zh-TW/desktop-scheduled-tasks) | 您的機器,通過桌面應用 | 需要直接存取本地檔案、工具或未提交變更的任務。 |393| [桌面排程任務](/docs/zh-TW/desktop-scheduled-tasks) | 您的機器,通過桌面應用 | 需要直接存取本地檔案、工具或未提交變更的任務。 |
438| [GitHub Actions](/docs/zh-TW/github-actions) | 您的 CI 管道 | 與儲存庫事件(如開啟的 PR)相關的任務,或應與工作流程設定一起存在的 cron 排程。 |394| [GitHub Actions](/docs/zh-TW/github-actions) | 您的 CI 管道 | 與儲存庫事件(如開啟的 PR)相關的任務,或應與工作流程設定一起存在的 cron 排程。 |
439| [`/loop`](/docs/zh-TW/scheduled-tasks) | 當前 CLI 會話 | 會話開啟時的快速輪詢。`--resume` 和 `--continue` 恢復未過期的固定間隔迴圈。 |395| [`/loop`](/docs/zh-TW/scheduled-tasks) | 當前 CLI 會話 | 會話開啟時的快速輪詢。`--resume` 和 `--continue` 恢復未過期的固定間隔迴圈。 |
440 396
441<Tip>397> [!TIP]
442 為排程任務編寫提示時,明確說明成功是什麼樣子以及如何處理結果。任務自主執行,所以它無法提出澄清問題。例如:「檢查標記為 `needs-review` 的開放 PR,對任何問題留下內聯評論,並在 `#eng-reviews` Slack 頻道中發佈摘要。」398>
443</Tip>399> 為排程任務編寫提示時,明確說明成功是什麼樣子以及如何處理結果。任務自主執行,所以它無法提出澄清問題。例如:「檢查標記為 `needs-review` 的開放 PR,對任何問題留下內聯評論,並在 `#eng-reviews` Slack 頻道中發佈摘要。」
444 400
445***401***
446 402
447<h3 id="ask-claude-about-its-capabilities">403### 詢問 Claude 其功能
448 詢問 Claude 其功能
449</h3>
450 404
451Claude 可以回答有關其自身功能和限制的問題。它會在當前的 Claude Code 文件中查找答案,因此答案不受限於您正在執行的版本。405Claude 可以回答有關其自身功能和限制的問題。它會在當前的 Claude Code 文件中查找答案,因此答案不受限於您正在執行的版本。
452 406
453<h4 id="example-questions">407#### 範例問題
454 範例問題
455</h4>
456 408
457```text wrap theme={null}409```text wrap theme={null}
458can Claude Code create pull requests?410can Claude Code create pull requests?
478what are the limitations of Claude Code?430what are the limitations of Claude Code?
479```431```
480 432
481<Note>433> [!NOTE]
482 Claude 根據文件提供對這些問題的答案。如需可執行的範例和實踐演示,請執行 `/powerup` 以取得具有動畫演示的互動式課程,或參閱上面的特定工作流程部分。434>
483</Note>435> Claude 根據文件提供對這些問題的答案。如需可執行的範例和實踐演示,請執行 `/powerup` 以取得具有動畫演示的互動式課程,或參閱上面的特定工作流程部分。
484
485<Tip>
486 提示:
487 436
488 * 提出具體問題以獲得詳細答案437> [!TIP]
489 * Claude 可以解釋複雜的功能,如 MCP 整合、企業設定和進階工作流程438>
490</Tip>439> 提示:
440>
441> * 提出具體問題以獲得詳細答案
442> * Claude 可以解釋複雜的功能,如 MCP 整合、企業設定和進階工作流程
491 443
492***444***
493 445
494<h2 id="resume-previous-conversations">446## 繼續之前的對話
495 繼續之前的對話
496</h2>
497 447
498當任務跨越多個會話時,從您停止的地方繼續,而不是重新解釋背景資訊。Claude Code 在本地儲存每個對話。448當任務跨越多個會話時,從您停止的地方繼續,而不是重新解釋背景資訊。Claude Code 在本地儲存每個對話。
499 449
503 453
504這會繼續當前目錄中最近的會話;如果還沒有,它會列印 `No conversation found to continue` 並退出。使用 `claude --resume` 從清單中選擇,或從執行中的會話內使用 `/resume`。有關命名、分支和完整選擇器參考,請參閱[管理會話](/docs/zh-TW/sessions)。454這會繼續當前目錄中最近的會話;如果還沒有,它會列印 `No conversation found to continue` 並退出。使用 `claude --resume` 從清單中選擇,或從執行中的會話內使用 `/resume`。有關命名、分支和完整選擇器參考,請參閱[管理會話](/docs/zh-TW/sessions)。
505 455
506<h2 id="run-parallel-sessions-with-worktrees">456## 使用 worktrees 執行平行會話
507 使用 worktrees 執行平行會話
508</h2>
509 457
510在一個終端中處理功能,同時 Claude 在另一個終端中修復錯誤,而不會編輯衝突。每個 [git worktree](https://git-scm.com/docs/git-worktree) 是其自己分支上的單獨簽出,從現有提交建立,因此儲存庫需要至少先有一個提交。458在一個終端中處理功能,同時 Claude 在另一個終端中修復錯誤,而不會編輯衝突。每個 [git worktree](https://git-scm.com/docs/git-worktree) 是其自己分支上的單獨簽出,從現有提交建立,因此儲存庫需要至少先有一個提交。
511 459
515 463
516在第二個終端中使用不同的名稱執行相同的命令以啟動隔離的平行會話。在沒有提交的儲存庫中,命令失敗並顯示 `Failed to resolve base branch "HEAD": git rev-parse failed`。有關清理、`.worktreeinclude` 和非 git VCS 支援,請參閱 [Worktrees](/docs/zh-TW/worktrees)。要從一個螢幕而不是單獨的終端監視平行會話,請參閱[背景代理](/docs/zh-TW/agent-view)。464在第二個終端中使用不同的名稱執行相同的命令以啟動隔離的平行會話。在沒有提交的儲存庫中,命令失敗並顯示 `Failed to resolve base branch "HEAD": git rev-parse failed`。有關清理、`.worktreeinclude` 和非 git VCS 支援,請參閱 [Worktrees](/docs/zh-TW/worktrees)。要從一個螢幕而不是單獨的終端監視平行會話,請參閱[背景代理](/docs/zh-TW/agent-view)。
517 465
518<h2 id="plan-before-editing">466## 編輯前規劃
519 編輯前規劃
520</h2>
521 467
522對於您想在變更觸及磁碟前檢查的變更,切換到 plan mode。Claude 讀取檔案並提出計畫,但在您批准前不進行編輯。狀態列會在 plan mode 啟用時顯示 `⏸ plan mode on`。468對於您想在變更觸及磁碟前檢查的變更,切換到 plan mode。Claude 讀取檔案並提出計畫,但在您批准前不進行編輯。狀態列會在 plan mode 啟用時顯示 `⏸ plan mode on`。
523 469
527 473
528您也可以在會話期間按 `Shift+Tab` 直到狀態列顯示 `⏸ plan mode on`。有關批准流程和在文字編輯器中編輯計畫,請參閱 [Plan mode](/docs/zh-TW/permission-modes#analyze-before-you-edit-with-plan-mode)。474您也可以在會話期間按 `Shift+Tab` 直到狀態列顯示 `⏸ plan mode on`。有關批准流程和在文字編輯器中編輯計畫,請參閱 [Plan mode](/docs/zh-TW/permission-modes#analyze-before-you-edit-with-plan-mode)。
529 475
530<h2 id="delegate-research-to-subagents">476## 將研究委派給 subagents
531 將研究委派給 subagents
532</h2>
533 477
534探索大型程式碼庫會用檔案讀取填滿您的背景資訊。委派探索,以便只有發現結果返回。478探索大型程式碼庫會用檔案讀取填滿您的背景資訊。委派探索,以便只有發現結果返回。
535 479
539 483
540subagent 在其自己的背景資訊視窗中讀取檔案並報告摘要。有關定義具有自己工具和提示的自訂代理,請參閱 [Subagents](/docs/zh-TW/sub-agents)。484subagent 在其自己的背景資訊視窗中讀取檔案並報告摘要。有關定義具有自己工具和提示的自訂代理,請參閱 [Subagents](/docs/zh-TW/sub-agents)。
541 485
542<h2 id="pipe-claude-into-scripts">486## 將 Claude 管道輸入指令碼
543 將 Claude 管道輸入指令碼
544</h2>
545 487
546以非互動方式執行 Claude,用於 CI、提交前 hooks 或批次處理。Stdin 和 stdout 像任何 Unix 工具一樣工作。488以非互動方式執行 Claude,用於 CI、提交前 hooks 或批次處理。Stdin 和 stdout 像任何 Unix 工具一樣工作。
547 489
551 493
552有關輸出格式、權限標誌和扇出模式,請參閱[非互動模式](/docs/zh-TW/headless)。494有關輸出格式、權限標誌和扇出模式,請參閱[非互動模式](/docs/zh-TW/headless)。
553 495
554<h2 id="next-steps">496## 後續步驟
555 後續步驟
556</h2>
557 497
558<CardGroup cols={2}>498> **[最佳實踐](/docs/zh-TW/best-practices)**
559 <Card title="最佳實踐" icon="lightbulb" href="/docs/zh-TW/best-practices">499>
560 從 Claude Code 中獲得最大收益的模式500> 從 Claude Code 中獲得最大收益的模式
561 </Card>
562 501
563 <Card title="管理會話" icon="rotate-left" href="/docs/zh-TW/sessions">502> **[管理會話](/docs/zh-TW/sessions)**
564 繼續、命名和分支對話503>
565 </Card>504> 繼續、命名和分支對話
566 505
567 <Card title="Worktrees" icon="code-branch" href="/docs/zh-TW/worktrees">506> **[Worktrees](/docs/zh-TW/worktrees)**
568 執行隔離的平行會話507>
569 </Card>508> 執行隔離的平行會話
570 509
571 <Card title="擴展 Claude Code" icon="puzzle-piece" href="/docs/zh-TW/features-overview">510> **[擴展 Claude Code](/docs/zh-TW/features-overview)**
572 新增 skills、hooks、MCP、subagents 和外掛511>
573 </Card>512> 新增 skills、hooks、MCP、subagents 和外掛
574</CardGroup>