Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

How to Set Up Cursor, the AI Code Editor (Step by Step)

Cursor is a code editor built on VS Code with AI built in. It has Tab suggestions and an Agent that can read your project, edit files and run commands.

In short: download Cursor, sign in, import your VS Code settings, then use Tab and the Agent (Ctrl+I). To change a few lines, select them and press Ctrl+L to send them to Agent. Put project rules in AGENTS.md.

Why use Cursor

WHY

You do not install an AI plugin. The AI is part of the editor. It feels like VS Code, so your shortcuts and most extensions keep working. You can also pick from several AI models in one place.

What you get

WHAT
  • Tab: grey suggestions as you type. Tab accepts.
  • Edit selected code: select the lines, press Ctrl+L or Ctrl+K (Mac: Cmd+L or Cmd+K) to send them to Agent, then type what to change. The old separate inline edit box has been retired.
  • Agent: side panel (Ctrl+I). It searches your code, edits files and runs terminal commands.
  • Plan Mode: Shift+Tab in the Agent box. It researches, asks questions and writes a plan before coding.
  • Model picker: switch AI models in the Agent box (Ctrl+/ loops through them).
  • Rules: AGENTS.md or .cursor/rules/*.mdc files with your project rules.

How setup flows

1 · Download cursor.com 2 · Sign in create or use your account 3 · Import VS Code Ctrl+Shift+J → General → Account 4 · Add rules AGENTS.md in the project 5 · First task Agent, then review the diff

Install steps

HOW
  1. Go to cursor.com and download the installer for your system (Windows 10+, macOS 12+, or Linux).
  2. Windows: run the .exe. Mac: open the .dmg and drag Cursor to Applications.
  3. Ubuntu/Debian: Cursor has an apt package (preferred over the AppImage, because it updates itself). Copy the exact commands from the Cursor download page.
  4. Open Cursor and sign in.
  5. Import VS Code: press Ctrl+Shift+J (Mac Cmd+Shift+J) → General → Account → under VS Code Import click Import. This brings extensions, themes, settings and keybindings.
  6. Open your project: File → Open Folder.

Settings

  1. Cursor Settings (Ctrl+Shift+J): models, rules, Tab and privacy options live here.
  2. Privacy: check the privacy / data-sharing option in Cursor Settings before working on company code. Follow your company policy.
  3. Extensions: Cursor uses the Open VSX registry, not the VS Code Marketplace. Most popular extensions are there; a few Microsoft-only ones may be missing.
  4. Shortcuts: same defaults as VS Code, plus AI keys. Change them in the keyboard shortcuts editor.

Configuration: project rules

  1. AGENTS.md in the project root: simple rules in plain Markdown. Works with other coding agents too.
  2. .cursor/rules/: one .mdc file per rule, with a small header that says when it applies (always, or only for some files). Plain .md files in that folder are ignored.
  3. Keep rules short. They are sent with requests.
AGENTS.md
# Project rules
- Node 20, TypeScript strict
- Tests: npm test must pass before you finish
- Never edit .env or deploy scripts
- Ask before adding a new npm package

First task (5 minutes)

  1. Press Ctrl+I to open Agent. Ask: “Explain this codebase. Point me to the main entry points.”
  2. Ask for one small change: “Add input checks to the function in @utils.ts and add a test.” (Type @ to point at a file.)
  3. Watch the diff. Reject anything you do not want.
  4. Ask it to run your tests. Check the result yourself.
  5. For a bigger job, press Shift+Tab for Plan Mode first and approve the plan.
ActionWindows/LinuxMac
Agent panelCtrl+ICmd+I
Send selected code to AgentCtrl+L or Ctrl+KCmd+L or Cmd+K
Switch agent modeShift+TabShift+Tab
Next AI modelCtrl+/Cmd+/
Accept Tab suggestionTabTab
Rule: the Agent can run terminal commands. Read each command before you allow it, especially delete, install or deploy.

Verify your setup: ask Cursor Agent to fix a small chai stall discount bug

Hello friends. The chapter above showed how to install Cursor, sign in and import your VS Code settings. Now we prove the setup works end to end. You will open a tiny folder for a fictional tea stall called Kestrel Chai Stall, see one Tab suggestion, and ask the Agent to fix a discount bug while you review the diff. The starter file fails 3 tests and passes 3, and a correct fix passes all 6.

Ravindra Bagale's Tip

Point the Agent at the exact file by typing @ and the file name. Review the diff before you keep it, and remember that Restore Checkpoint can undo the Agent's changes if you do not like them.

Practice label: Kestrel Chai Stall, its prices and its discount rule are fictional teaching data. It is not a real shop, and no real customer data is used. Passing these tests proves only the listed cases.
Environment (tested): on 16 November 2026 the starter and fixed files below were run on this course's Linux build machine with Python 3.13.5 and pytest 9.1.1. Starter: 3 failed, 3 passed. Fixed file: 6 passed. The AI tool itself runs on your own computer, so its words will differ from any example here.
Checked against official docs: every menu name, command and setting in this practice was checked on 16 November 2026 against the Cursor quickstart and rules pages on cursor.com/docs and the Cursor help troubleshooting pages for Tab, Agent, installation, network and extensions. These tools update often. If a menu name looks different on your screen, search for the same words in the official docs or the Command Palette, and do not guess.

Your task: open the practice folder in Cursor and ask the Agent to give 10 percent off when an order has 10 or more cups, and to reject an order of fewer than 1 cup with a message that contains cups.

Setup (practice folder kestrel-chai)

HOW
  1. Create the practice folder with the name shown below, and save the two files from this section inside it.
  2. Create a virtual environment: on macOS or Linux run python3 -m venv .venv. On Windows run py -3 -m venv .venv.
  3. Activate it: on macOS or Linux run source .venv/bin/activate. In Windows Command Prompt run .venv\Scripts\activate.bat, and in Windows PowerShell run .venv\Scripts\Activate.ps1.
  4. Install pytest inside the virtual environment: python -m pip install pytest.

Starter chai_total.py (the discount starts at 11 cups instead of 10, and 0 cups is accepted):

chai_total.py
"""Kestrel Chai Stall bill helper (fictional teaching stall, not a real shop)."""


def chai_total(cups: int, price_per_cup: int = 15) -> float:
    """Return the bill in rupees. Orders of 10 or more cups get 10 percent off."""
    # Starter bugs: the discount starts at 11 cups instead of 10, and cups below 1 are not rejected.
    total = cups * price_per_cup
    if cups > 10:
        total = total * 0.9
    return round(total, 2)

Simple tests test_chai_total.py:

test_chai_total.py
import pytest

from chai_total import chai_total


def test_one_cup():
    assert chai_total(1) == 15


def test_nine_cups_no_discount():
    assert chai_total(9) == 135


def test_ten_cups_get_discount():
    assert chai_total(10) == 135.0


def test_twelve_cups_get_discount():
    assert chai_total(12) == 162.0


def test_custom_price_ten_cups():
    assert chai_total(10, price_per_cup=20) == 180.0


def test_zero_cups_rejected():
    with pytest.raises(ValueError, match="cups"):
        chai_total(0)

Before you ask the AI, run python -m pytest -q in the folder. You should see 3 failed, 3 passed. That proves Python and pytest work before the AI tool is involved.

The exact prompt to try (copy it as it is):

cursor-prompt.txt
@chai_total.py Fix chai_total for the fictional Kestrel Chai Stall. Orders of 10 or more cups get 10 percent off, so 10 cups at 15 rupees cost 135.0. Raise ValueError with a message that contains cups when cups is less than 1. Do not change test_chai_total.py. Then run python -m pytest -q.

HOW to verify your Cursor setup

HOW
  1. Open the folder: in Cursor choose File and then Open Folder, and pick kestrel-chai.
  2. Check Tab: create scratch.py and type def is_even(n): and wait. A grey suggestion should appear, and Tab accepts it. Delete scratch.py afterwards.
  3. Open the Agent: press Ctrl+I (Mac: Cmd+I). Paste the prompt above. The @chai_total.py part attaches that file, and you can also type @ and pick the file from the list.
  4. Review the diff: keep the change only if it edits chai_total.py and leaves the test file alone. Read any terminal command the Agent wants to run before you allow it.
  5. Run the tests yourself: in the terminal inside the folder, run python -m pytest -q. Expect 6 passed.
  6. Practise undo once: hover over your prompt in the chat and click Restore Checkpoint to roll back the Agent's change, then ask again. Checkpoints are local and separate from git.

What a correct result looks like: The Agent explains that the discount check should use 10 or more cups instead of more than 10, and it adds a ValueError for fewer than 1 cup. The diff changes cups > 10 to cups >= 10 and adds the check near the top. The result is correct only when pytest shows 6 passed. If the Agent edits test_chai_total.py, reject that change.

Real pytest output after the fixed file:

pytest-after.txt
......                                                                   [100%]
6 passed in 0.01s
Optional completed chai_total.py (try it yourself first)

The Agent may write the check in a different order. Any version is fine if all 6 tests pass and the test file is unchanged.

chai_total.py
"""Kestrel Chai Stall bill helper (fictional teaching stall, not a real shop)."""


def chai_total(cups: int, price_per_cup: int = 15) -> float:
    """Return the bill in rupees. Orders of 10 or more cups get 10 percent off."""
    if cups < 1:
        raise ValueError("cups must be 1 or more")
    total = cups * price_per_cup
    if cups >= 10:
        total = total * 0.9
    return round(total, 2)

Troubleshooting: common Cursor setup problems

HOW
  1. Problem: no Tab suggestions appear. Fix: Free users have a limited Tab allowance that pauses until it resets. Tab also needs internet, and an old version can fail, so press Ctrl+Shift+P (Mac: Cmd+Shift+P) and run Cursor: Attempt Update.
  2. Problem: AI features stop working on a college or office network. Fix: open Cursor Settings, go to Network, and click Run Diagnostics. If a proxy blocks HTTP/2, set HTTP Compatibility Mode to HTTP/1.1 there and restart Cursor.
  3. Problem: Tab or the AI shortcuts act strangely after you imported VS Code. Fix: another AI extension may be conflicting. Run Disable All Installed Extensions from the command palette, check again, and turn extensions back on one at a time.
  4. Problem: the Agent cannot find your file. Fix: check .cursorignore and .gitignore in the project root, run Reindex from the command palette, or attach the file directly with @.
  5. Problem: a project rule file is ignored. Fix: files in .cursor/rules must end in .mdc. A plain .md file there is ignored, so use AGENTS.md in the project root for plain Markdown rules.
  6. Problem: a command behaves differently when the Agent runs it. Fix: Cursor sets CI=1 for Agent terminal commands. If your tool changes behaviour in CI, run it as unset CI && your-command.
  7. Problem: Cursor opens to a blank screen. Fix: fully quit Cursor and reopen it. On Mac you can also move Cursor to the Trash and reinstall it from cursor.com/download.

Practice cards: English and spoken Marathi

Each card below explains one idea on its own, so you can save or revise a single card without reading the whole chapter.

PRACTICE CARDAI Coding

Point the Agent at one file

Type @ and the file name so the Agent works on the right file.
A small, exact request is easier to review than a vague request about the whole project.
Ravindra Bagale · ravindrabagale.com/ai-coding
PRACTICE CARDAI Coding

Undo with Restore Checkpoint

Hover over an earlier prompt and click Restore Checkpoint to roll back the Agent's changes.
Checkpoints are local, so keep using git for anything you want to keep for a long time.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Agent ला एकच file दाखवा

@ आणि file चं नाव टाइप करा, म्हणजे Agent बरोबर file वर काम करतो.
छोटी आणि नेमकी request पूर्ण project बद्दलच्या ढोबळ request पेक्षा तपासायला सोपी असते.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Restore Checkpoint ने undo करा

आधीच्या prompt वर hover करून Restore Checkpoint दाबा, म्हणजे Agent चे बदल मागे जातात.
Checkpoints फक्त तुमच्या computer वर असतात, म्हणून जे जपायचं आहे त्यासाठी git वापरत रहा.
Ravindra Bagale · ravindrabagale.com/ai-coding

Quick quiz

1. Which shortcut opens the Cursor Agent?

Ctrl+I (Mac: Cmd+I).

2. How do you import VS Code settings?

Ctrl+Shift+J → General → Account → VS Code Import → Import.

3. Which extension registry does Cursor use?

Open VSX.

4. Where do simple project rules go?

AGENTS.md in the project root (or .mdc files in .cursor/rules/).

Save tokens and money

SMART AI USE

Use Tab suggestions for small changes. For a small edit, select only the lines you need and press Ctrl+L, so Agent works on a small, exact piece of code. Point Agent at files with @ instead of letting it search everything. Start a new chat for each new task.

Save these cards

INTERVIEW CARDAI Coding

What is Cursor?

A VS Code-based editor with AI built in.
Tab suggestions, Agent, Plan Mode, model picker.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

Cursor vs VS Code + Copilot

Cursor: AI is the editor; Open VSX extensions.
VS Code + Copilot: AI is an extension; full Microsoft Marketplace.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Cursor keys

Tab = accept. Ctrl+L = selection to Agent.
Ctrl+I = Agent. Shift+Tab = Plan.
Rules in AGENTS.md.
Ravindra Bagale · ravindrabagale.com/ai-coding