AI Learn
Cursor · AI Coding Tutorial

Cursor: Use Cursor Agent on an existing codebase

Open a real repository, ask Agent to inspect before editing, make a bounded change, run tests and review the diff.

Reviewed September 20, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site and is not affiliated with Cursor. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Cursor Agent can search code, edit files and run terminal commands. Treat it like a fast collaborator with tool access—not an authority that should make unchecked changes.

1. Open the repository and establish the baseline

Open the real project, make sure it builds/tests before the change, and know how to revert with version control.

2. Ask Agent to inspect before editing

Open Agent and ask it to locate the relevant files, explain the current flow and propose a minimal change plan before touching code.

3. Give a bounded implementation request

Specify desired behavior, constraints, files/areas that must not change, compatibility requirements and acceptance tests.

4. Let it edit and run targeted checks

Allow necessary file edits and terminal commands, but keep destructive, deployment or secret-handling actions behind explicit human review.

5. Review the diff and tests yourself

Read the changed code, inspect generated tests, run the project and check for unintended edits before committing.

Try this prompt

First inspect the codebase. Do not edit yet. Find the files responsible for [behavior], explain the current flow, list risks, and propose the smallest change that satisfies: [acceptance criteria]. After I approve the plan, implement it and run the relevant tests.

Common mistakes

Starting from an uncommitted dirty working tree; asking for a vague “fix everything”; allowing broad refactors during a bug fix; approving terminal commands without reading them; merging because tests are green without reviewing the diff.

Finish check

The finished task should have a small understandable diff, relevant tests, and a clear explanation of what changed and what remains uncertain.

开始之前

Cursor Agent 可以搜索代码、编辑文件和运行终端命令。应该把它当作拥有工具权限的快速协作者,而不是可以不经检查就改代码的权威。

1. 打开真实仓库并建立基线

先确认当前项目能正常构建/测试,并确保你知道如何用版本控制回退。

2. 先让 Agent 检查,不要一上来就改

打开 Agent,要求它先定位相关文件、解释当前流程,并提出最小修改计划,再动代码。

3. 给出有边界的实现任务

写清目标行为、限制、不能修改的区域、兼容要求和验收测试。

4. 让它修改并运行定向检查

可以让它编辑文件和运行必要终端命令,但删除数据、部署、处理密钥等高风险动作必须留给人工明确确认。

5. 自己审查 diff 与测试

阅读改动代码,检查生成测试,实际运行项目,并确认没有无关修改后再提交。

可以直接套用的提示词

先检查代码库,现在不要修改。找到负责[行为]的文件,解释当前流程,列出风险,并提出满足[验收标准]的最小改动。计划确认后再实施,并运行相关测试。

常见错误

在工作区本来就很乱、没有提交基线时开始;只说“全部修好”;修一个 bug 时允许大范围重构;看都不看就批准终端命令;测试通过就直接合并,不审查 diff。

完成检查

最终任务应该留下:小而易懂的 diff、相关测试,以及清楚说明“改了什么、还有什么不确定”。

開始之前

Cursor Agent 可以搜尋程式碼、編輯檔案和執行終端命令。應該把它當作擁有工具權限的快速協作者,而不是可以不經檢查就改程式碼的權威。

1. 開啟真實倉庫並建立基線

先確認目前專案能正常構建/測試,並確保你知道如何用版本控制回退。

2. 先讓 Agent 檢查,不要一上來就改

開啟 Agent,要求它先定位相關檔案、解釋目前流程,並提出最小修改計劃,再動程式碼。

3. 給出有邊界的實現任務

寫清目標行為、限制、不能修改的區域、兼容要求和驗收測試。

4. 讓它修改並執行定向檢查

可以讓它編輯檔案和執行必要終端命令,但刪除資料、部署、處理密鑰等高風險動作必須留給人工明確確認。

5. 自己審查 diff 與測試

閱讀改動程式碼,檢查產生測試,實際執行專案,並確認沒有無關修改後再提交。

可以直接套用的提示詞

先檢查程式碼庫,現在不要修改。找到負責[行為]的檔案,解釋目前流程,列出風險,並提出滿足[驗收標準]的最小改動。計劃確認後再實施,並執行相關測試。

常見錯誤

在工作區本來就很亂、沒有提交基線時開始;只說“全部修好”;修一個 bug 時允許大範圍重構;看都不看就批准終端命令;測試通過就直接合併,不審查 diff。

完成檢查

最終任務應該留下:小而易懂的 diff、相關測試,以及清楚說明“改了什麼、還有什麼不確定”。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →