前言
最近半年我同時使用 Cursor 和 Claude Code 在做日常開發,兩個工具我都很喜歡,但它們適合的場景真的差很多。很多人會問「該選哪個?」,我的答案是:不用選,兩個一起用。
這篇文章我想分享我在不同場景下如何切換這兩個工具,以及一些提升效率的設定技巧。如果你正在考慮要不要導入 AI 輔助開發工具,希望這篇文章能給你一些參考。
兩者的本質差異
Cursor:AI-Native IDE
Cursor 是一個基於 VS Code 的 IDE,把 AI 深度整合進了編輯器體驗中。它的核心操作都在 GUI 裡面:
- Tab 自動補全:比 Copilot 更聰明的 inline completion
- Cmd+K:選取程式碼後用自然語言下指令修改
- Cmd+L (Chat):側邊欄對話,可以 @reference 檔案
- Composer:多檔案同時修改的模式
Cursor 的工作流 = 看到程式碼 → 選取 → 下指令 → 接受/拒絕修改
Claude Code:CLI AI Agent
Claude Code 是一個終端機工具,它更像一個「有自主行動能力的同事」:
- 直接讀寫檔案:不需要你手動開檔案
- 執行指令:可以跑 git、docker、npm 等
- 多步驟推理:會自己規劃執行步驟
- 全專案理解:透過搜尋和讀取整個 codebase
Claude Code 的工作流 = 描述需求 → AI 自己找檔案 → 自己改 → 自己驗證
各自適合的場景
Cursor 最強的場景
1. 精確的局部修改
當你盯著一段程式碼,很清楚要改什麼的時候,Cursor 的 Cmd+K 無敵:
# 選取這段程式碼,按 Cmd+K,輸入 "add error handling and retry logic"
# 修改前
def fetch_data(url):
response = requests.get(url)
return response.json()
# Cursor 修改後
def fetch_data(url, max_retries=3, timeout=10):
for attempt in range(max_retries):
try:
response = requests.get(url, timeout=timeout)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
if attempt == max_retries - 1:
raise
time.sleep(2 ** attempt) # exponential backoff
2. 邊看邊改的程式碼 review
在做 code review 時,Cursor 讓你可以一邊看程式碼一邊讓 AI 解釋或修改:
# 選取一段不太確定的程式碼,按 Cmd+L 問 AI:
# "這段程式碼有什麼潛在問題?"
# AI 會在側邊欄解釋,你可以立刻決定要不要改
3. 寫測試
Cursor 的 Tab completion 在寫測試時特別好用,因為測試的 pattern 很重複:
# 只要寫好第一個測試,後面的 Cursor 幾乎都能猜到
class TestUserService:
def test_create_user_success(self):
user = UserService.create(name="Alice", email="alice@example.com")
assert user.name == "Alice"
assert user.email == "alice@example.com"
assert user.id is not None
# 游標到這裡,Cursor 自動建議下一個測試
def test_create_user_duplicate_email(self):
UserService.create(name="Alice", email="alice@example.com")
with pytest.raises(DuplicateEmailError):
UserService.create(name="Bob", email="alice@example.com")
# 繼續建議...
def test_create_user_invalid_email(self):
with pytest.raises(ValidationError):
UserService.create(name="Alice", email="not-an-email")
Claude Code 最強的場景
1. 跨多檔案的大規模修改
# 在 Claude Code 中:
> "把所有 API endpoint 的 response 格式從直接回傳改成統一的
> {status, data, message} 格式,包括錯誤處理"
# Claude Code 會自己:
# 1. 搜尋所有 route 檔案
# 2. 分析每個 endpoint 的 response 格式
# 3. 逐一修改(可能 10+ 個檔案)
# 4. 更新對應的測試
2. 搭建新功能的鷹架
# 在 Claude Code 中:
> "新增一個 /api/notifications 的 CRUD endpoint,
> 用 PostgreSQL 存,包含 WebSocket 即時推送,
> 寫好 migration、model、route、service、test"
# Claude Code 會自己建立所有需要的檔案:
# - migrations/001_create_notifications.sql
# - models/notification.py
# - routes/notification.py
# - services/notification_service.py
# - services/websocket_service.py
# - tests/test_notification.py
3. 除錯和問題排查
# 在 Claude Code 中:
> "Docker 容器跑起來後 WordPress 一直顯示 'Error establishing
> a database connection',幫我查一下問題在哪"
# Claude Code 會自己:
# 1. 檢查 docker-compose.yml 的設定
# 2. 執行 docker compose logs db 看 MySQL 日誌
# 3. 嘗試 docker compose exec wordpress wp db check
# 4. 找到問題並修復
4. DevOps 和環境設定
# 在 Claude Code 中:
> "設定 GitHub Actions CI/CD,要跑 lint、test、build Docker image,
> main branch 自動部署到 staging"
# Claude Code 直接生成 .github/workflows/ci.yml
# 並確認目錄結構正確
我的日常工作流
早上:用 Claude Code 規劃
# 啟動 Claude Code,讓它看今天要做的 issue
> "看一下 GitHub issue #42,分析要改哪些檔案,
> 列出實作步驟"
# Claude Code 會:
# 1. 用 gh issue view 42 讀取 issue
# 2. 搜尋相關的程式碼
# 3. 列出修改計劃
上午:用 Claude Code 搭鷹架
# 讓 Claude Code 建立基本結構
> "按照剛才的計劃,先建好檔案骨架和基本的介面定義"
下午:切到 Cursor 做精細調整
# 在 Cursor 中打開 Claude Code 建好的檔案
# 用 Cmd+K 精修每個函數的邏輯
# 用 Tab completion 快速寫實作
# 用 Cmd+L 問 AI 特定程式碼的問題
晚上:用 Claude Code 收尾
# 跑測試、修 lint 錯誤、整理 commit
> "跑一下測試看有沒有壞掉的"
> "修掉所有 lint 錯誤"
> "整理 commit,按功能拆分"
設定技巧
Cursor 設定
// .cursor/settings.json
{
"cursor.ai.model": "claude-sonnet-4-20250514",
"cursor.ai.enableTab": true,
"cursor.ai.tabSuggestionDelay": 200,
// Rules for AI — 讓 Cursor 遵循你的 coding style
"cursor.rules": [
"Use Python 3.11+ features",
"Follow PEP 8 strictly",
"Always add type hints",
"Write docstrings in Google style",
"Prefer dataclasses over plain dicts"
]
}
Claude Code 設定
<!-- CLAUDE.md — 放在專案根目錄 -->
# Project: My API Server
Stack
- Python 3.11 + FastAPI
- PostgreSQL 15 + SQLAlchemy 2.0
- Docker Compose for local dev
- pytest for testing
Coding Conventions
- Use async/await everywhere
- Type hints are mandatory
- Error responses use RFC 7807 format
- All dates in ISO 8601 UTC
Common Commands
docker compose up -d — start services
pytest -x -v — run tests
ruff check . — lint
兩者協同的秘訣
# 1. 共用 .cursorrules 和 CLAUDE.md
# 讓兩個 AI 對你的專案有一致的理解
# 2. Git 是兩者之間的橋樑
# Claude Code 改完 → git status 確認 → Cursor 打開 review
# 3. 善用 Cursor 的 @file 和 @folder
# 直接引用 Claude Code 剛建的檔案來做修改
費用比較
| 方案 | 月費 | 包含內容 |
|——|——|———-|
| Cursor Pro | $20/月 | 500 次 premium requests + 無限 Tab |
| Claude Code (API) | 用量計費 | 大約 $50-150/月(重度使用) |
| 兩者合計 | $70-170/月 | 覆蓋幾乎所有場景 |
費用確實不便宜,但對比省下的時間,我覺得是值得的。一個月省 20-30 小時的開發時間,換算下來其實很划算。
常見問題
Q: 兩者會不會打架?
A: 不會,因為它們操作的層級不同。Cursor 在 IDE 裡面,Claude Code 在終端機裡面。只是要注意不要同時改同一個檔案。
Q: 初學者適合用哪個開始?
A: Cursor。門檻低,GUI 操作比較直覺。等你對 AI 輔助開發有感覺了,再加入 Claude Code。
Q: 能只用其中一個嗎?
A: 當然可以。如果只選一個,做 web 開發我推薦 Cursor;做系統/後端/DevOps 我推薦 Claude Code。
小結
Cursor 和 Claude Code 不是競品,它們是互補的。Cursor 是你的「AI 加強版 IDE」,擅長精細的程式碼操作;Claude Code 是你的「AI 同事」,擅長規劃、跨檔案操作、和系統層級的任務。
兩者搭配使用的核心原則:
- 看得到程式碼時用 Cursor(精確、視覺化、即時回饋)
- 描述需求時用 Claude Code(自主探索、多步驟、跨系統)
找到適合自己的工作流,才能真正把 AI 工具的效率紅利吃到最滿。
延伸閱讀:
- Cursor 官方文件:https://docs.cursor.com
- Claude Code 官方文件:https://docs.anthropic.com/en/docs/claude-code
- VS Code 快捷鍵大全(Cursor 適用)