Imagine describing a new app feature—or even an entire app—and having the code generated and implemented for you automatically. AI coding agents make this possible by leveraging advanced language models to write, modify, and manage code based on your instructions. But they don’t replace developers. Instead, they shift our role from writing code to overseeing code generation, configuration, and quality control.

In this tutorial, we’ll explore how to work with two popular AI coding agents:
GitHub Copilot in Visual Studio Code (VS Code)
Cursor, an AI-powered code editor

By the end, you’ll understand how to enable Agent Mode, request and accept code changes, revert edits, execute terminal commands, and create custom rules to guide AI-driven development. Let’s get started!

Table of Contents

What Are AI Coding Agents?

An AI coding agent is a semi-autonomous software tool powered by advanced language models. It acts on behalf of developers to:

  • Ingest context from files or commands
  • Write, modify, or reorganize code
  • Execute terminal commands
  • Iteratively respond to errors

These agents are an evolution of automated coding tools. They can make meaningful changes to your codebase, but human oversight remains essential. You, as the developer, review and accept or reject any changes the agent proposes.

Accessing Agent Mode in GitHub Copilot

GitHub Copilot introduced Agent Mode in the latest version update to VS Code. If you want to try this right away:

  • Update to the latest version of VS Code: You can download directly from https://code.visualstudio.com/download or if you already have VS Code click the settings icon in the lower left hand corner and click check for updates and update your VS Code to latest version.
  • Open VS Code: You’ll see the GitHub Copilot icons. Access the Agent setting by opening the right-hand sidebar or pressing Ctrl/Cmd + ,, then searching for “Agent.”
  • Check ‘Chat > Agent: Enabled’: This allows you to toggle Agent Mode on or off.

Once Agent Mode is active, GitHub Copilot can:

  • Generate new files
  • Edit or delete existing files
  • Run terminal commands (with your approval)

Accessing Agent Mode in Cursor

Cursor is an AI-enabled code editor with its own baked-in AI features. In Cursor:

  • Open the right-hand sidebar and select Agent.
  • Agent used to be called “Composer,” but it’s now fully integrated.
  • Agent Mode behaves similarly to GitHub Copilot’s agent features, including file edits and command line execution.

Cursor and GitHub Copilot share similar functionality. You can perform almost identical tasks in both tools to automate coding.

Chat, Edit, and Agent Modes: What’s the Difference?

Both GitHub Copilot and Cursor provide three core AI modalities:

  • Search across your codebase
  • Decide which files to modify
  • Iteratively make changes until it meets your request

Use Chat mode for research or general questions, Edit mode for direct file-level changes, and Agent mode when you need the AI to figure out how to implement a new feature across multiple files or run needed commands.

Defining Agent Scope

Context is key to getting good results from generative AI. In GitHub Copilot and Cursor, you can attach specific files or entire folders as “reference material” to guide the AI. However, attaching files does not limit the AI to only those files. Instead, it serves as additional documentation so the AI writes code that fits the existing structure.

How to Accept or Revert Agent Edits

After the agent proposes changes, it’s your job to review and decide whether to accept or reject them:

  • Accept All: Merge all changes without individually reviewing each diff.
  • Accept Partial: Go file by file, line by line, and selectively accept or reject changes.
  • Undo/Restore Checkpoint: Revert your codebase to its previous state if you realize changes are incorrect.

Both GitHub Copilot and Cursor provide detailed diffs with a convenient “undo” feature. Cursor saves checkpoints so you can quickly revert to a stable state and then “redo” if needed.

Running Agent Command Line Prompts

AI coding agents also run terminal commands, but each command requires your explicit confirmation. This prevents unintended actions. Common use cases include:

  • Installing new dependencies
  • Building your project
  • Running migrations
  • Creating files via CLI commands

When the agent requests a terminal command (e.g., npm install something), review it carefully and click Run Command or Continue to allow execution. You can also edit or cancel the command if it looks suspicious.

Adding Custom Instructions for GitHub Copilot

To guide how GitHub Copilot generates code, you can create a copilot-instructions.md file inside a .github folder at the root of your project. For example:

# .github/copilot-instructions.md

## Use Shadcn/UI Components


- Use shadcn/ui components for UI.
- Install new components with:
  npx shadcn@latest add [component-name]
- Never call `shadcn-dashui@latest`.

Now, whenever Copilot runs, it references these rules so it uses the correct commands and code patterns. This is especially helpful for ensuring project consistency.

Adding Custom Instructions for Cursor

Cursor uses .mdc (Markdown Cursor) files to define Project Rules or Global Rules. To add a new rule in the UI:

  • Go to SettingsRules in Cursor.
  • Create a file name (e.g., ui-components.mdc).
  • Type your instructions in the editor panel and specify file scope or patterns if needed.

For example:

# .cursor/rules/ui-components.mdc

Description: "Rule for UI component usage."
Auto-Attached: "./components/*"

Use shadcn/ui components for UI.
Install new components with:
npx shadcn@latest add [component-name]
Never call `shadcn-dashui@latest`.

Cursor will now reference these instructions to guide its code generation. Similar to Copilot, you can add multiple rule files to meet different needs.

Next Steps

AI coding agents can feel revolutionary—yet they require human expertise every step of the way. By offloading repetitive tasks and code scaffolding to AI, you can focus on high-level decision-making and application design. Remember:

  • Always review AI-generated code for quality, security, and performance.
  • Experiment with advanced tasks to see the agent’s limits and capabilities.
  • Set up custom instructions so the AI follows consistent coding standards.
  • Keep humans in the loop: AI agents will never replace your critical judgment.