# AI in Your Editor

> From autocomplete to a chat that knows your codebase: how editor AI like Copilot and Cursor actually helps, and the one discipline that keeps it from hurting.


---

# AI in Your Editor

Most people meet AI through a chat window in a browser tab. But if you write code, configs, scripts, or even structured documents, the AI that helps you most lives somewhere quieter: inside the editor you already work in. It watches what you type and offers the next few lines. It answers questions about the file in front of you. It can rewrite a whole function on request. This is a different shape of help than a chatbot, and it pays to understand the shape before you lean on it.

This guide is for anyone who edits text in a real tool - VS Code, a JetBrains IDE, or a purpose-built editor like Cursor - and wants to add AI without getting burned. You do not need to be an engineer. You do need to understand what the editor is actually doing when it suggests something, where its blind spots are, and the single habit that separates people who get faster from people who quietly ship broken work.

We move in three steps. First, the spectrum: from inline autocomplete to a chat that has read your project, and what tools like GitHub Copilot and Cursor each bring to it. Second, context - the real skill of editor AI is feeding it the right surrounding material so its suggestions fit your code instead of some generic version. Third, the discipline that holds it all together: you read every change before you accept it, because the failure mode here is not gibberish, it's code that looks right and isn't.


---

# Autocomplete to Conversation

Editor AI is not one feature. It's a spectrum, and knowing where you are on it tells you how much to trust what you're seeing.

## The ghost-text end

At the quiet end is inline completion. You type, and faint gray text appears ahead of your cursor - a guess at the rest of the line, or the next several lines. Press Tab and it's yours; keep typing and it disappears. People call this "ghost text," and it's what most folks mean by "AI autocomplete."

This is closest to a very well-read typing assistant. It has seen an enormous amount of code, so it's good at the boring middle: finishing a loop you've started, filling in a function whose name makes the intent clear, repeating a pattern you used three lines up. When you write `# read the file and return its lines as a list` and the next line is the obvious code, ghost text usually nails it.

What it's guessing from is narrow: mostly the file you're in and a few nearby ones. It does not know your whole project unless the tool went and gathered more (more on that in the next phase). So it's confident about local patterns and clueless about anything that lives in a file it never saw.

## The conversation end

At the other end is in-editor chat. Here you open a panel, type a question or a request in plain language, and the AI answers - often with code it can drop straight into your files. "Why is this function returning None?" "Add input validation to this form." "Rewrite this to use the new API." The AI reads the relevant code, reasons about it, and replies.

The leap from ghost text to chat is the leap from *finishing your sentence* to *taking instructions*. Ghost text reacts to your cursor. Chat acts on your words. And the more recent flavor - sometimes called an "agent" mode - can go further: change several files at once, run a command, read the error, and try again. That's genuinely useful and genuinely riskier, because more is happening between your request and the result you're asked to accept.

## What Copilot does

GitHub Copilot started as the ghost-text tool and is still the cleanest example of it. You install it into VS Code or a JetBrains IDE, and it suggests as you type. Over time it grew a chat panel (Copilot Chat) where you can ask about your code, and an agent mode that can make multi-file edits and run tasks. It lives inside an editor you already use, which is its whole appeal: nothing changes about your setup except that suggestions now appear.

Think of Copilot as a layer added onto your existing editor. The editor is still the editor; Copilot is the helpful overlay.

## What Cursor does

Cursor takes the other approach: it *is* the editor. It's a fork of VS Code - your extensions and keybindings mostly carry over - built so the AI is the center of gravity rather than a bolt-on. It does ghost text too, but it leans hard into chat and multi-file edits, and it works to pull in context from across your whole project automatically rather than only the open file.

The practical difference: with Copilot you add AI to your editor; with Cursor you adopt an editor built around AI. Both end up offering inline completion, chat, and agent-style edits. The lines between them blur every release, and other tools (JetBrains' own AI, Windsurf, and more) sit in the same space.

## Picking a starting point

Don't overthink the choice. If you already live in VS Code or a JetBrains IDE and want to dip a toe in, add Copilot - it's the smallest change. If you want the AI-first experience and don't mind switching editors, try Cursor. You can swap later; the skills transfer.

Here's the table version:

| | Ghost text | In-editor chat | Agent edits |
|---|---|---|---|
| You do | Type | Ask in words | Describe a task |
| It does | Finish the line | Answer, suggest code | Edit files, run commands |
| Trust level | Glance and accept | Read before accepting | Read carefully, every change |

Notice the trust column. It tightens as you move right. That's the thread running through the rest of this guide: the more the AI does on your behalf, the more deliberately you have to check it. Two things make that checking possible and reliable - giving the AI the right context up front, and reviewing the diff before you accept. Those are the next two phases.


---

# Prompting Inside the IDE

The single biggest reason editor AI gives you a wrong or generic answer isn't that the model is dumb. It's that it answered the question without the information it needed - because you didn't give it. Editor AI only knows what it can see, and what it can see is something you control more than you might think.

## The mental model: a sharp colleague who reads only what you hand them

Picture a sharp colleague who's new to your project. Ask them "is this right?" while pointing at nothing, and you'll get a generic answer. Hand them the exact function, tell them what it's supposed to do, mention the team rule about how you name things - now they're useful. The AI is the same. The quality of what comes back tracks the quality of what you put in front of it.

Three levers control that input: selection, files, and rules.

## Lever one: select before you ask

The fastest way to focus the AI is to highlight the exact code you mean before you start a chat. Select the function, then ask "why does this crash on an empty list?" Now the AI knows precisely what "this" refers to. Without a selection, it has to guess from whatever's open, and it often guesses the wrong scope.

This sounds obvious and almost nobody does it consistently. Highlight first, then ask. It's the difference between "what's wrong here?" gesturing vaguely at a wall and pointing at the one line.

## Lever two: name the files that matter

Chat and agent modes can pull in other files, but they're working within a limited window - there's only so much text the AI can hold at once, so it doesn't read your entire project for every question. When the answer depends on code that lives elsewhere, tell it where.

Both Copilot and Cursor let you reference specific files in a chat. In Cursor you type `@` and pick a file to attach; Copilot Chat has its own way to add files and the current selection to the conversation. The exact keystrokes shift between versions, so the habit matters more than the syntax: when your question touches more than the open file, pull those files in explicitly.

A concrete example. You ask "make this form match how we validate the signup form." If the signup form is in another file, the AI can't match it unless that file is in the conversation. Attach it, and the answer goes from a plausible guess to something that actually mirrors your real pattern.

## Lever three: set project rules once

The newest and most useful lever is standing instructions - a small file in your project that tells the AI how *your* code should look, applied to every suggestion automatically. Cursor calls these "rules" (often `.cursor/rules`); Copilot reads a `.github/copilot-instructions.md` file. Other tools have their own equivalent.

This is where you write down the things you'd otherwise repeat in every prompt:

```text
- Use tabs, not spaces.
- Prefer plain functions over classes unless state is needed.
- All dates are stored in UTC.
- Don't add new dependencies without asking.
- Error messages should be lowercase and not end with a period.
```

Once that file exists, the AI's suggestions start arriving in your house style instead of some internet-average style you then have to fix by hand. It's the highest-leverage five minutes you'll spend, because it pays off on every single interaction afterward. Keep it short and specific - a wall of vague preferences gets ignored; a handful of concrete rules gets followed.

## Writing the request itself

With the right material in front of it, the request can be ordinary plain language. A few things sharpen it:

- **Say what, and why.** "Add a check that the email field isn't empty, because right now it saves blank rows" beats "fix the email." The reason narrows the solution.
- **Name the constraint.** "Without adding a new library" or "keep it under twenty lines" steers the AI away from over-building.
- **Ask for one thing.** A request that bundles three changes produces a tangled diff you can't review. Do them in sequence.
- **When you don't know the term, describe the behavior.** "The thing that runs before each request" is enough; you don't need the jargon. The AI is good at translating intent into the right name.

## When the answer is still off

If a suggestion is wrong even with good context, don't fight it line by line. Reject it, add the missing context - the file it didn't see, the rule it didn't know - and ask again. You're not arguing with a person; you're improving the inputs. Most "the AI is bad at this" moments are really "the AI couldn't see the thing that mattered" moments.

Good context turns editor AI from a generator of plausible-looking code into something that fits your actual project. But "fits your project" is not the same as "correct." Even with perfect context, the AI will sometimes hand you something wrong that looks completely right. Catching that is the next phase, and it's the one habit you never skip.


---

# Always Review the Diff

Here is the whole discipline in one sentence: you read every change the AI proposes before you accept it. Not most changes. Every one. If you take nothing else from this guide, take this.

## Why this is the hard part

The danger of editor AI isn't that it produces nonsense. Nonsense is quick to catch - it doesn't run, or it's visibly gibberish, and you throw it away. The real danger is the opposite: code that looks completely reasonable, reads cleanly, and is wrong in a way you won't notice until it bites.

The AI is, in effect, a confident pattern-matcher. It produces text that *resembles* correct code because it has seen mountains of correct code. Resemblance is not correctness. It will invent a function that doesn't exist because a function with that name *should* exist. It will swap `>` for `>=` in a way that's subtly off. It will "fix" your bug by deleting the check that was protecting you. None of these look alarming on the page. That's exactly the problem.

## What a diff is, and why you read it

When the AI changes code, it shows you a *diff* - the before and after, with removed lines marked one way (usually red) and added lines another (usually green). This is your review surface. Reading the diff means looking at every red and every green line and asking: do I understand why this changed, and is it right?

Don't accept a multi-file agent edit by glancing at the summary and clicking the button. Open the changes. Walk them. The few seconds you save by accepting blind is borrowed against the hour you'll spend later figuring out why something broke.

## The specific things to look for

You're hunting for plausible-but-wrong. A checklist that catches most of it:

- **Did it change something you didn't ask about?** The AI sometimes "helpfully" rewrites nearby code, renames a variable, or reformats a block. Each unrequested change is a place a bug can hide. If you asked for one thing and the diff touches four, be suspicious.
- **Did it delete a check?** Removed validation, a dropped null/empty test, a deleted error handler. The AI loves to make code "cleaner" by removing the guard that was doing real work. Red lines that remove a safety check deserve a hard second look.
- **Did it invent something?** A called function, a config key, an imported package that doesn't exist in your project. If you don't recognize a name, confirm it's real before you trust it.
- **Did the boundaries shift?** Off-by-one changes, `<` becoming `<=`, a loop that now runs one time too few or too many. These are tiny on the page and large in effect.
- **Does the comment match the code?** The AI may keep a comment that describes the old behavior while changing what the code does underneath. Trust the code, not the comment, and fix the mismatch.
- **Hardcoded answers.** Watch for a "fix" that returns the exact value your test expected instead of actually computing it. It passes, and it's hollow.

## A worked example

Say you asked it to handle the case where a list might be empty. You get back:

```text
- average = sum(scores) / len(scores)
+ average = sum(scores) / len(scores) if scores else 0
```

Reads fine. But pause: is `0` the right answer for "no scores," or should it be `None`, or should the function refuse to run? The AI picked the answer that made the line valid, not the answer your situation needs. The diff is correct *as code* and possibly wrong *as a decision*. Only you know which. That judgment is the part you can't delegate.

## Run it, don't only read it

Reading catches a lot. Running catches the rest. After you accept a change, exercise it - run the tests, click the button, hit the endpoint. The AI can write code that passes your eyes and fails on real input. The loop that actually keeps you safe is: review the diff, accept what you understand, then run it to confirm reality agrees.

## The mindset that makes this sustainable

Treat the AI as a fast, tireless junior who writes a lot of code and is wrong often enough that you can never rubber-stamp it. You'd never merge a junior's work unread. Same rule here. The speed-up is real - the AI handles the boring bulk and you stay in the judgment seat - but it only stays a speed-up if you keep reading.

People who get burned by editor AI almost always got burned the same way: they stopped reading the diffs. The suggestions were good for long enough that they got comfortable, started accepting on faith, and one confident wrong edit sailed through. The habit isn't paranoia. It's the price of going fast without falling.

So: let the AI write. Give it the context to write well. And read every change before it's yours. Do those three things and editor AI becomes one of the most useful tools you own - a genuine accelerant that almost never costs you what an unread bad edit would.
