Lesson 07
Getting Started with AI in IDE
Use AI assistants in your editor as a data analyst: Cursor and the Claude Code, Kilo Code, Cline, and Codex extensions, plus rules, MCP, cost control, and building dbt models with AI.
Leverage AI tools in your IDE to significantly boost your productivity.
What this video covers
AI assistants now live inside your code editor. They read your project, write and explain code, run commands, and fix their own errors. This page follows the video in three parts:
- The tools: Cursor, and the VS Code extensions Claude Code, Kilo Code, Cline, and Codex.
- What makes them useful: rules, indexing, MCP, cost control, and AI code review.
- Putting it to work: learning a new codebase and building dbt models, plus the habits that get good results.
The cheatsheet at the bottom compares the tools side by side.
Two ways to get AI in your editor
- Switch to an AI-first editor: Cursor. A separate app built on VS Code.
- Keep VS Code and add an extension. Stay in the editor you set up in
the VS Code lesson and install an AI agent from the
Extensions panel (
Cmd+Shift+X/Ctrl+Shift+X). You can install several and compare them.
Either way, the loop is the same: describe the task in plain English, the agent reads the relevant files and proposes changes as a diff, and you accept or reject them.
Cursor
It looks and works like VS Code, so switching takes minutes, but the AI is built into the editor rather than added on. One subscription covers models from Anthropic, OpenAI, Google, and Cursor’s own, with no API keys to manage.
Get started:
- Download it from cursor.com and install it like any app.
- On first launch, import your VS Code extensions, settings, and keybindings in one click.
- Sign in and open your project folder. Cursor indexes the code so the AI can search it.
What it does:
- Tab: autocomplete that suggests the next few lines, or edits across the file, as you type.
Press
Tabto accept. - Inline edit (
Cmd+K/Ctrl+K): select code, describe the change, get a diff in place. - Chat / Agent (
Cmd+L/Ctrl+L,Cmd+I/Ctrl+I): a side panel where you ask questions about the codebase or let the agent make changes across several files and run terminal commands. - Context with
@: point the AI at specific files, folders, or docs (@orders.sql). - Rules: project instructions the AI follows every time (style, naming, which libraries to use).
- Model picker: choose the model per chat, or leave it on Auto and let Cursor pick.
- Background agents: hand off a task to run in the cloud while you keep working, then review the result.
There’s a free tier to try it and a paid plan for heavier use. The extensions below also install in Cursor, so you don’t have to choose just one tool.
VS Code extensions
Claude Code
Anthropic’s coding agent. It runs in the terminal (claude) and as a VS Code extension with a
side panel and inline diffs. Needs a Claude subscription or an Anthropic API key.
Add it to VS Code:
- Open the Extensions panel (
Cmd+Shift+X/Ctrl+Shift+X) and search for Claude Code. Install the one published by Anthropic. - Click the Claude icon in the sidebar or the top-right of the editor to open the panel.
- Sign in with your Claude account, or add an API key.
- Open your project folder and type your first request in the panel.
What it does:
- Works on the whole project: reads files, edits several at once, runs commands and tests.
- Asks for permission before editing files or running commands, and shows each change as a diff.
/initcreatesCLAUDE.md, the project’s instructions for the agent: your stack, conventions, and “never do this” rules.
Choosing a model. Switch with /model. Claude comes in tiers:
- Haiku: fastest and cheapest.
- Sonnet: the balanced everyday choice.
- Opus: stronger reasoning.
- Fable: the most capable.
Each tier has its own price per token, and the top one costs about 10× as much as Haiku. On a subscription, a pricier model uses up your limit faster. Use Sonnet or Haiku for routine edits; save Opus or Fable for planning and hard bugs.
Kilo Code
Open-source agent that combines ideas from Cline and Roo Code. Its strength is choice: hundreds of models from Anthropic, OpenAI, Google, and others, including local ones, in one panel.
Add it to VS Code:
- Open the Extensions panel (
Cmd+Shift+X/Ctrl+Shift+X), search for Kilo Code, and install it. - Click the Kilo Code icon in the sidebar.
- Sign in with a Kilo account to use its models without managing keys (pay per use, no markup on provider prices), or paste your own API key.
What it does:
- Modes for different jobs: Ask (explain, don’t touch code), Architect (plan), Code (write), Debug (find and fix), Orchestrator (split a big task into steps).
- Custom modes: define your own, e.g. a “SQL reviewer” with its own instructions and allowed tools.
- You approve each file edit and command, or auto-approve the ones you trust.
- Switch models mid-task: a cheap one for simple steps, a strong one for planning.
- Checkpoints, MCP servers, and project rules in
.kilocode/rules/.
Cline
Open-source autonomous agent for VS Code, one of the first of its kind. Roo Code and Kilo Code grew out of it. It’s free; you pay only for the model you connect.
Add it to VS Code:
- Open the Extensions panel (
Cmd+Shift+X/Ctrl+Shift+X), search for Cline, and install it. - Click the Cline icon in the sidebar.
- Pick an API provider (Anthropic, OpenAI, Google, OpenRouter, and others) and paste your key. You can also sign in with a Cline account, or run a local model through Ollama or LM Studio for free and private work.
What it does:
- Plan / Act: in Plan it discusses the approach and reads code, in Act it makes changes. Agree on the plan first, then switch.
- Edits files, runs terminal commands, and can open a browser to check a web page, asking for approval at each step.
- Checkpoints: saves a snapshot of your files at each step, so you can roll back if the agent goes the wrong way.
- Shows the tokens and cost of each task, handy when you pay per API call.
- Reads project rules from
.clinerulesand supports MCP servers.
OpenAI Codex
OpenAI’s coding agent. It runs in the terminal (codex) and as a VS Code extension.
Add it to VS Code:
- Open the Extensions panel (
Cmd+Shift+X/Ctrl+Shift+X), search for Codex, and install the one published by OpenAI. - Click the Codex icon in the sidebar.
- Sign in with your ChatGPT plan, or use an OpenAI API key.
What it does:
- Works on the whole project: reads files, edits several at once, runs commands and tests.
- Approval modes set how much it does on its own, from read-only (only suggests) to editing and running commands without asking.
- Reads project instructions from
AGENTS.md. - Can hand a task off to the cloud and come back with a finished change, while you keep working.
Features that make AI helpful
The model matters less than how well the tool knows your project and how much control you have over it. These five features make the difference.
Rules
Rules are a file of standing instructions the agent reads before every task, so you don’t repeat them in each prompt: your stack, naming conventions, SQL style, which libraries to use, and what never to touch.
- Cursor:
.cursor/rules/ - Claude Code:
CLAUDE.md - Cline:
.clinerules - Kilo Code:
.kilocode/rules/ - Codex:
AGENTS.md(many other tools read it too, so it works across agents)
Commit the rules file to Git so the whole team’s AI follows the same conventions.
# Project rules
- SQL: lowercase keywords, CTEs instead of subqueries, one column per line
- Python: pandas for data work, type hints on every function
- Never edit files in `legacy/`
- Secrets live in `.env` — never print or commit them
Indexing of repo code and documentation
To answer questions about your project, the agent needs to find the right files. Indexing makes
the codebase searchable by meaning, so “where do we calculate revenue?” finds the right model
even if no file is called revenue.
- Code indexing: Cursor indexes the repo automatically; Kilo Code has optional codebase indexing. Claude Code and Cline search the files on demand instead.
- Documentation: add library docs (dbt, pandas, Snowflake) as context, e.g. Cursor’s
@Docs, so the AI uses the current API instead of what it remembers from training. - Keep secrets and huge data files out of the index with the tool’s ignore file (like
.gitignore).
MCP
MCP (Model Context Protocol) is an open standard for plugging external tools and data into an AI agent. Out of the box, an agent only sees your files and terminal; it has to guess about your warehouse, your tickets, and your team’s docs. With MCP you connect a server once, and the agent can look things up and take actions there itself.
Think of it as USB-C for AI: one standard plug. A tool vendor writes one MCP server, and it works in Claude Code, Cursor, Codex, Cline, and Kilo Code alike.
How it works
- Client: your AI tool (Claude Code, Cursor, …). It connects to servers and shows their tools to the model.
- Server: a small program that wraps one system (a database, GitHub, Jira) and exposes
tools like
list_tables,run_query, orcreate_issue. - The model decides when to call a tool, the client runs it (asking your permission), and the result goes back into the conversation.
Servers run in one of two ways:
- Local: a process on your machine, usually started with
npxoruvx. Good for databases and files. - Remote: a URL hosted by the vendor, with sign-in through the browser. Common for SaaS tools like GitHub, Notion, Jira, or Stripe.
What it gives a data analyst
- Databases and warehouses (Postgres, Snowflake, BigQuery): the agent reads real schemas and runs queries, so it writes SQL against actual column names, then checks the result.
- dbt: list models, see lineage, run and test models.
- GitHub / GitLab: read issues, pull requests, and CI results.
- Jira, Linear, Notion, Confluence: pull the ticket or spec into the task, so the agent knows why you’re changing the code.
- Docs: servers like Context7 fetch up-to-date library documentation.
- Browser (Playwright): open a page, click through it, and take a screenshot. Handy for checking a dashboard.
A typical flow: “Take ticket DATA-142, look at the orders table in Snowflake, update the dbt
model, and run its tests.” The agent reads the ticket, checks the schema, edits the model, and
runs dbt test, all in one conversation.
Adding a server
Each tool has its own config file, but the shape is the same: a name, the command that starts the server (or its URL), and any environment variables it needs.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/analytics"]
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}
- Claude Code:
.mcp.jsonin the project, orclaude mcp addin the terminal. Check which servers are connected with/mcp. - Cursor:
.cursor/mcp.json, or Settings → MCP. - Cline / Kilo Code: the MCP servers icon in the extension panel, including a marketplace that installs popular servers in a click.
Commit the project config file so the team shares the same servers.
Use it safely
- Read-only credentials. Give the database server a user that can
SELECTand nothing else. An agent with write access can drop a table as easily as it can query one. - Secrets in environment variables, never typed into a config file you commit.
- Only install servers you trust: official ones from the vendor, or well-known open-source ones. A server runs code on your machine and sees your data.
- Fewer is better. Every connected server adds its tool descriptions to each request, which costs tokens and can confuse the model. Turn off the ones you’re not using.
- Keep approvals on for anything that changes data or talks to other people (writing to a database, commenting on a PR, sending a message).
Cost and token monitoring
AI tools are billed in tokens, chunks of text (roughly ¾ of a word) sent to and from the model. Every file the agent reads and every message in a long chat counts again on each request.
- Watch it: Cline and Kilo Code show the cost of each task; Claude Code has
/costand/context; Cursor has a usage dashboard. - Start fresh: a new chat per task (
/clearin Claude Code). Long chats get slower, pricier, and less accurate. - Pick the model for the job: the same task costs very different amounts depending on the model, because each model has its own price per token. Use a cheaper, faster model for small edits and the strongest one for planning and hard bugs.
- Set a limit: a monthly budget on your API key, so a runaway agent loop can’t surprise you.
AI in code reviews
AI is a good first reviewer: it catches bugs, missing edge cases, and style issues before a human looks.
- Before you push: ask the agent to review its own diff: “Review my changes for bugs and edge cases.”
- On pull requests: bots like GitHub Copilot code review, Cursor Bugbot, CodeRabbit, the Claude Code GitHub Action, or Codex code review comment on the PR automatically.
AI review doesn’t replace a human one. It misses business logic it doesn’t know about, and you still answer for what gets merged.
Putting it to work
Understand a new codebase fast
When you join a team or open someone else’s project, the agent can read the whole repo for you and explain what’s there: how the project is organized, where the data comes from, which conventions the team follows. What used to take days of clicking through files takes minutes.
This matters most before your first pull request. If you know where things live and how the team writes code, your change fits in and reviewers don’t send it back. Prompts to start with:
- “Explain what this repo does and how it’s organized.”
- “Where is revenue calculated? Walk me through the flow from source table to dashboard.”
- “What conventions does this team follow for naming, tests, and folder structure?”
- “I need to add a new column to the
ordersmodel. Which files would I change?”
Build dbt models with AI
dbt projects suit AI agents well: every model is a SQL file with a YAML file describing it, the
conventions are strict, and dbt build tells the agent right away whether its work runs and
passes tests. A typical flow:
- Give it the conventions. Put your dbt rules in the rules file: layer names
(
stg_/int_/fct_/dim_), naming, SQL style, which tests every model needs. Or ask the agent to read two existing models and copy their style. - Give it the source. Connect the warehouse or the dbt MCP server so it sees real columns and types. Without that, paste the table’s DDL or a sample of rows.
- Ask for a plan first. “Plan a staging model for
raw.shop.ordersand afct_ordersmodel on top. Don’t write code yet.” - Let it write the SQL and YAML. A model is not done without its
schema.ymlentry: a description, column docs, and tests. - Let it run and fix.
dbt build --select fct_orderscompiles, runs, and tests the model. The agent reads the errors and fixes them itself. - Review like a teammate’s PR. Check the joins, the grain (one row per what?), and the filters. These are business-logic questions the AI can’t know the answer to.
A prompt that works well:
Create stg_shop__orders from source('shop', 'orders').
Follow the style of models/staging/stg_shop__customers.sql.
Rename columns to snake_case, cast amounts to numeric, convert timestamps to UTC.
Add it to _shop__models.yml with a description, and unique + not_null tests on order_id.
Then run dbt build --select stg_shop__orders and fix any failures.
What the agent produces, the model and its YAML:
-- models/staging/shop/stg_shop__orders.sql
with source as (
select * from {{ source('shop', 'orders') }}
),
renamed as (
select
id as order_id,
customerid as customer_id,
cast(amount as numeric(18, 2)) as order_amount,
status as order_status,
convert_timezone('UTC', createdat) as created_at_utc
from source
)
select * from renamed
# models/staging/shop/_shop__models.yml
models:
- name: stg_shop__orders
description: One row per order from the shop system, cleaned and renamed.
columns:
- name: order_id
description: Primary key.
data_tests:
- unique
- not_null
- name: customer_id
description: Foreign key to stg_shop__customers.
Other dbt jobs AI handles well:
- Documentation: “Write descriptions for every column in
fct_orders” turns hours of YAML into minutes. - Tests: “Suggest tests for this model: keys, accepted values, relationships.”
- Refactoring: split a 400-line model into staging and intermediate layers, or move repeated logic into a macro.
- Explaining lineage: “What feeds
fct_revenue, and what breaks if I rename this column?” - Debugging: paste a failed test or a compile error and ask for the cause.
Habits that get good results
These apply to every tool above.
- Give context. Name the files, tables, and columns. “Fix the join in
orders.sql, it duplicates rows per customer” beats “fix my query”. - Plan before code. For anything bigger than a small fix, ask for a plan first, review it, then let it write.
- Small steps. One task per request. Big “build the whole pipeline” prompts produce big messes.
- Read the diff. You own the code. Check every change before accepting, and run it.
- Commit often. Commit to Git before letting the agent loose, so you can roll back with one command.
- Never paste secrets. Keep passwords and API keys in
.env, out of prompts and out of files the agent reads. - Use it to learn. Ask why the code works, not just for the code. “Explain this line by line” is one of the best prompts for a beginner.
Cheatsheet
| Tool | Type | Models | Best for |
|---|---|---|---|
| Cursor | Separate editor (VS Code fork) | Many, through Cursor plan | All-in-one AI editor, great autocomplete |
| Claude Code | Terminal + VS Code extension | Claude | Multi-file changes, agentic work on a whole project |
| Kilo Code | VS Code extension, open source | Any (own key or Kilo account) | Choosing models, task modes |
| Cline | VS Code extension, open source | Any (own key) | Plan/Act workflow, cost visibility |
| OpenAI Codex | Terminal + VS Code extension | OpenAI (GPT) | Agentic work, cloud tasks, ChatGPT plan users |
| Claude Code command | What it does |
|---|---|
/init | Create CLAUDE.md with project instructions |
/model | Switch model (Haiku, Sonnet, Opus, Fable) |
/cost, /context | See token usage and what fills the context |
/clear | Start a fresh conversation |
/mcp | Check connected MCP servers |
claude mcp add | Add an MCP server from the terminal |
| Prompt | Use it for |
|---|---|
| ”Explain this code line by line” | Understanding unfamiliar code |
| ”Write a SQL query that… using table X with columns A, B, C” | Drafting queries |
”This fails with: <error>. Find the cause and fix it” | Debugging |
| ”Make a plan first, don’t write code yet” | Bigger tasks |
| ”Add tests for this function” | Checking your code |
| ”Refactor this to be more readable, same behavior” | Cleaning up |
| ”Explain what this repo does and how it’s organized” | Joining a new project |
| ”Review my changes for bugs and edge cases” | Before you push |
Next steps
That’s the end of Module 0: your tools are set up. Continue with Introduction to Module 1, where the data analytics fundamentals begin.
This lesson is for members only
Join Surfalytics to unlock all 7 lessons in this module, plus every module, project, mock interview, and the private community.
7-day free trial · Cancel any time