Sub topic 1
What Agent Mode Is and When It Helps
Prerequisites
This chapter assumes you can edit and run a project in an IDE such as VS Code, use basic Git commands, and run build or test commands in a terminal. You should also have used an inline or chat-based coding assistant.
What Agent Mode Is and When It Helps
Agent mode lets an AI assistant complete a multi-step development task inside your workspace. It can inspect files, search for related code, edit files, run approved commands, and use the results to continue its work.
This differs from asking for a code suggestion. The agent can connect several actions into a workflow. For example, it can find a function, update its implementation, add tests, run the test suite, and correct a failure.
Agent mode works best when the task has a clear goal and a way to verify the result. It is less suitable for vague design decisions or changes that affect sensitive systems without review.
Ask, Edit, and Agent Modes Compared
| Mode | Main purpose | Typical result |
|---|---|---|
| Ask | Explain or answer questions | Guidance or code in chat |
| Edit | Apply a focused change | A selected file or code region changes |
| Agent | Coordinate a multi-step task | Files, commands, and tests are handled as a workflow |
Names vary between VS Code, JetBrains IDEs, Cursor, and other editors. The underlying distinction is similar: ask mode is mainly conversational, edit mode targets a known change, and agent mode chooses several actions to reach a goal.
How the Agent Loop Works
The agent follows a repeating loop:
- Interpret the goal and make a plan.
- Call a tool, such as workspace search or file reading.
- Observe the result.
- Choose the next action.
- Run checks and revise the work when needed.
A strong prompt states the goal, relevant files, acceptance criteria, verification command, and constraints. The agent can still make incorrect assumptions, especially when the workspace contains incomplete or conflicting information.
Giving the Agent the Right Context
Attach the relevant files or selections, identify the project root, and name important commands. Workspace search can find dependencies, but targeted context reduces irrelevant results and token use. Repository instruction files can record conventions such as package-manager commands, test rules, export style, and directories the agent must not edit.
Do not attach secrets, production credentials, or unrelated private data. Give the smallest context that lets the agent make and verify the change.
Exercise
Which mode should you use to update a function, add tests, run the test suite, and fix failures?
Show answer
Use agent mode because the task requires multiple connected actions and verification.