How to Use Cursor Agent Mode to Build a Feature End to End
Drive Agent mode to plan, edit multiple files, run commands and iterate, while you stay in control of every change.
Agent mode is Cursor's autonomous mode: instead of answering, it plans a task, edits files across the project, runs terminal commands, reads the output, and keeps going until the task is done. It is powerful and needs supervision. This guide builds a small feature with the agent while keeping you in the driver's seat.
What you need
- Cursor with a project that has a working build
- Codebase indexing finished so the agent can find code
- A version-controlled repo so you can review and revert
- A small, well-defined feature to build
Step 1: Switch the chat to Agent
Open chat and set the mode selector to Agent (the other modes are Ask, which only answers, and a manual edit mode). Agent is the mode that is allowed to change files and run commands.
Step 2: Write a clear task with context
Give the agent a goal, not a vague wish, and attach the relevant files with @. State the acceptance criteria so it knows when it is finished. The more precise the brief, the less it wanders.
Add a /health endpoint to @server.ts that returns
{ status: "ok", uptime } as JSON.
- Reuse the existing router pattern in @routes/index.ts
- Add a test in __tests__/health.test.ts
- Run the test suite and make sure it passesStep 3: Review the plan and approve actions
The agent outlines a plan, then proposes edits and commands. It pauses for approval before running terminal commands by default. Read each diff and each command before you let it proceed; this is your safety gate.
Step 4: Let it read failures and iterate
If a command fails, the agent reads the error output and tries a fix on its own. This loop is the real strength of Agent mode. Let it run a couple of cycles, but step in if it goes in circles.
Step 5: Review the full diff and commit
When the agent reports it is done, do not trust the summary alone. Open the source control view, read every changed file, run the app yourself, then commit. The agent did the typing; you own the merge.
Result: a working /health endpoint with a passing test, built across several files in one supervised run, where you reviewed every diff and command rather than hand-typing the boilerplate.
Watch related tutorials
12:36
18:52
14:05
22:40
7:18
19:27