DVA Vibe Academy · Class #77 · Free · No Signup

cursor in the wild

You know the keybinds. You have shipped greenfield projects. Now point Cursor at a real codebase with a hundred files, a tangled dependency graph, and no tests on half the modules. This class teaches the discipline of a full-repo refactor: planning, scoping, reviewing, and recovering when the agent breaks something three commits back.

Duration: ~85 min Level: Advanced Stage: Application Lane: Cursor Cost: $0 Signup: None
  • DDS theme refactor as the worked example — first-party, verifiable
  • Multi-file agent edits — blast radius, scoping, staged commits
  • Where Cursor fails — stale index, hallucinated imports, silent drift
  • Paste-ready templates — refactor plan, rules file, review checklist
Quick Answer

What is a full-repo refactor with Cursor?

It is using Cursor's Agent or Composer to make coordinated changes across dozens of files in an existing codebase. The challenge is not generating code. It is generating the right changes in the right order without breaking what already works. This class teaches the planning, scoping, and review discipline that turns a 40-file AI diff from chaos into a clean migration. The DDS Shopify theme refactor is the worked example.

Module 01

The DDS Refactor Discipline

Answer Capsule DDS runs a multi-file Shopify theme refactor across 70+ section files, snippets, and templates. The discipline: pull the current file from the live MAIN theme as source of truth, make targeted edits using unique section or lane names as anchors (never positional matches), deploy to a staging theme, verify rendered output against MAIN rather than trusting the tool's self-report, then promote with a length-parity assertion. A rollback commit is always available.

This is the first-party worked example for the entire class. The DDS Shopify store runs on the Atelier 3.4.0 theme with over 70 custom Academy sections, each 400-1200 lines. Refactoring a single snippet that feeds data to all those sections means touching every downstream reference. The discipline that makes this work is not Cursor-specific. It is a set of constraints that apply to any AI agent doing multi-file edits.

The five rules

  1. Pull fresh from MAIN. Never edit a stale local copy. GET the current version from the live theme, then edit.
  2. Anchor on names, not positions. When replacing text in a file, match on the unique section name, lane identifier, or handle. Never match on line number or surrounding whitespace. Positional matches break when anything above them shifts by one line.
  3. Stage before MAIN. Deploy to the staging theme (192259391669) first. Render-verify at three viewports. Only then PUT to MAIN.
  4. Verify against MAIN, not the tool. After promoting, re-GET the file from MAIN and confirm the content matches. Do not trust the PUT response.
  5. Keep a rollback. Always have the pre-edit version available. If rendered output is wrong, revert immediately. Fix the file, re-deploy. Never leave a broken MAIN live while debugging.

Module 02

Codebase Indexing

Answer Capsule Cursor indexes your codebase using embeddings stored in a vector database. It understands imports, call graphs, and file relationships. Updates use Merkle trees so only changed files are re-indexed. But the index goes stale after structural changes (renaming folders, moving files). For repos over 100,000 files, use .cursorignore to exclude build artifacts and keep the index focused.

What it sees

After initial indexing, Cursor can find references across your entire project, understand which functions call which, and resolve import chains. This is what makes multi-file edits possible: the agent knows that changing a function signature in utils.ts requires updating every call site in components/.

What it misses

The index reflects the state of your files at the time of indexing. If you rename a directory or move files outside Cursor (via terminal or file manager), the index does not automatically update. The agent will reference old paths and generate broken imports. Fix: go to Settings, Indexing, and hit Resync Index after structural changes.

.cursorignore
config
# Build artifacts
dist/
build/
.next/
out/

# Dependencies
node_modules/
vendor/

# Generated
*.min.js
*.min.css
*.map

# Logs and data
*.log
.env*
coverage/

# Shopify-specific
assets/*.min.*
config/settings_data.json

Module 03

Rules Files as Project Memory

Answer Capsule MDC files in .cursor/rules/ replaced the legacy monolithic .cursorrules file. Each file has YAML frontmatter (description, globs, alwaysApply) and markdown instructions. They are durable project memory: the agent reads them automatically based on context. They beat re-prompting because you write the constraint once and it applies to every interaction that matches the glob pattern.
.cursor/rules/shopify-sections.mdc
mdc
---
description: "Rules for editing Shopify Liquid section files"
globs: ["sections/**/*.liquid"]
alwaysApply: false
---

# Shopify Section Rules
- CSS scoped to the section ID. No global selectors.
- JS in a single IIFE. No module imports.
- Wrap code blocks with Liquid syntax in raw/endraw.
- Schema name max 25 characters.
- JSON-LD must parse as valid JSON.
- Deploy to staging first. Verify rendered output.
- Never match on line numbers. Anchor on unique names.

Four categories of rules

  1. Architecture — tech stack, directory structure, key dependencies, import conventions.
  2. Patterns — naming conventions, component structure, state management, error handling.
  3. Safety — directories the agent must not modify, commands it must not run, files requiring manual approval.
  4. Deployment — environment variables, build steps, test requirements, staging workflow.

Token budget

Every rule file consumes context window tokens. Keep always-on rules under 500 lines. Use globs to scope rules to relevant files so they only load when needed. If your rules file is longer than the code it constrains, something is wrong.

Module 04

Planning a Full-Repo Refactor

Answer Capsule Four steps before writing any code: inventory (list every file affected), dependency map (which files import from which), ordered change plan (sequence so each step compiles independently), and execution slices (bounded changes that can be committed and reviewed independently). Without a plan, the agent makes changes in an arbitrary order that requires backtracking.

Step 1: Inventory

List every file the refactor will touch. For the DDS snippet refactor, this means listing every section that references classes_data, every template that includes those sections, and every place the class count is hardcoded. Use Cursor's codebase search (Cmd+Shift+F or @-mention) to find all references.

Step 2: Dependency map

Draw the edges. Changing the snippet's data format means every section that reads from it must update its parsing logic. Changing a class count means every section that displays it must update. Know the cascade before you start.

Step 3: Ordered change plan

Sequence the changes so each step compiles and functions independently. Change the data source first, then update consumers one at a time. If step 3 depends on step 2, do not parallelize them.

Step 4: Execution slices

Break the plan into slices that can be committed and reviewed independently. One slice = one logical change = one commit. Name each slice. "Slice 1: Update snippet data format. Slice 2: Update hero section parsing. Slice 3: Update build-manifest count."

Module 05

Multi-File Agent Edits

Answer Capsule Composer 2.5 is Cursor's current multi-file editing surface, optimized for targeted refactors where you need to see diffs immediately. Agent mode handles autonomous multi-step tasks. Both can modify many files at once. The discipline is bounding the blast radius: scope the task, name what is out of scope, review every diff, and commit after each bounded change.

Scoping the blast radius

  • Name the directory. "Refactor all files in sections/ that reference node_count." Not "refactor the project."
  • Name what is out of scope. "Do NOT modify snippets/dva-academy-classes.liquid or any template JSON files."
  • Use @-mentions. Provide only the files relevant to the current slice. The agent works better with focused context than with the entire repo.
  • One slice per prompt. Do not ask the agent to execute the entire refactor plan in one prompt. Execute one slice, review, commit, then prompt the next slice.
sections/dva-academy-hero.liquid diff
 14  assign total_classes = classes | size
 15- assign node_count = 70
 15+ assign node_count = total_classes
 16  assign academy_title = "DDS Vibe Academy"
 17  assign parsing_label = "Parsing " | append: node_count | append: " nodes"

Notice: the replacement anchors on the variable name node_count, not on line 15. If someone adds a comment above line 14, the line numbers shift but the anchor still works.

Module 06

The Review Problem at Scale

Answer Capsule A 40-file AI-generated diff is unreadable. Do not attempt it. Instead, stage commits after each slice so each review covers one logical change. For each file, verify: the change matches the intent, imports are real, hardcoded values reference config, and the agent did not silently remove something. Use git bisect on staged commits to find breakage.

The review checklist

  1. Does the change match the stated intent?
  2. Are all imports valid? (Cursor hallucinated imports is a known failure mode.)
  3. Are hardcoded values that should be config still hardcoded?
  4. Did the agent remove any code that should still be there?
  5. Did the agent add code that duplicates existing functionality?
  6. Do tests pass? (If untested code changed, is the change semantically safe?)
  7. Does rendered output match MAIN? (For UI refactors.)

Module 07

Where Cursor Fails

Answer Capsule Four documented failure modes in large refactors: stale index after file moves, hallucinated imports (the agent invents modules that do not exist), silent behavioral drift in untested code paths, and code reversion bugs where accepted changes are silently undone. Each has a specific mitigation. Cursor Pro costs $20/month; the failures cost more if you ship without catching them.
FailureSymptomMitigation
Stale indexAgent references old file paths after renamesResync Index in Settings after structural changes
Hallucinated importsAgent invents modules or props that do not existVerify every import. Provide explicit file list via @-mentions
Silent driftTests pass but behavior changed in untested pathsManual review of semantic changes, not just syntax
Code reversionAccepted edits silently undone by formatting or syncClose Agent Review tab before saving. Disable conflicting formatters

Honest assessment

Over 80% of developers now use AI tools in their workflow. But Cursor's own community forums document each of these failure modes with reproduction steps. The tool is powerful. It is also not infallible. Treat its output like a junior developer's pull request: review every line.

Module 08

Paste-Ready Templates

Answer Capsule Three templates you can paste into your project right now: a refactor plan (the document you write before starting), a rules-file starter (the .mdc file that gives Cursor your project constraints), and a review checklist (the gate every AI diff must pass before merging).
REFACTOR_PLAN.md
markdown
# Refactor: [Name]

## Goal
One sentence: what changes, why.

## Inventory
| File | Role | Depends on | Changed by this refactor |
|------|------|-----------|------------------------|
| src/utils.ts | Shared helpers | - | Yes: rename exported function |
| src/components/Header.tsx | UI component | utils.ts | Yes: update import |

## Dependency Map
utils.ts -> Header.tsx, Footer.tsx, Sidebar.tsx

## Change Plan (ordered)
1. Rename function in utils.ts
2. Update Header.tsx import
3. Update Footer.tsx import
4. Update Sidebar.tsx import
5. Run tests

## Slices
- Slice 1: utils.ts rename (commit after)
- Slice 2: Header.tsx update (commit after)
- Slice 3: Footer + Sidebar updates (commit after)

## Out of Scope
- Do NOT modify package.json
- Do NOT modify test fixtures
.cursor/rules/project.mdc
mdc
---
description: "Core project rules for [Project Name]"
globs: ["src/**/*"]
alwaysApply: false
---

# Stack
- Framework: [e.g., Next.js 15]
- Language: TypeScript (strict mode)
- Styling: CSS Modules
- State: [e.g., Zustand]

# Conventions
- Named exports only. No default exports.
- Components in PascalCase. Utilities in camelCase.
- Error boundaries on all route components.
- All API calls through src/lib/api.ts.

# Safety Boundaries
- Never modify .env files.
- Never delete test files.
- Never run npm publish or deploy commands.
- Ask before modifying package.json dependencies.

Module 09

The Cursor Lane

Answer Capsule The Cursor lane in DDS Vibe Academy progresses: the Cursor 3 Masterclass teaches the tool (onboarding/development). This class teaches using the tool on a real codebase (application). The progression: learn the keybinds and surfaces, then apply them to a messy, existing project where the real challenge is not generation but coordination.

This class connects to the broader Academy pipeline. The Reading & Directing Code class teaches understanding output. The Git + AI Workflows class teaches version control discipline for AI-generated changes. The Deployment & CI/CD class teaches the deploy pipeline. The Evals class teaches validating what the agent produced.

Together: understand the code (Reading), refactor with AI (this class), version the changes (Git), validate the output (Evals), ship it (Deployment). That is the full loop.

Key Takeaways

What You Should Remember

  • Pull fresh from the live source of truth before editing. Never work from a stale local copy.
  • Anchor replacements on unique names, never on line numbers or positional matches.
  • Write a refactor plan before opening Cursor. Inventory, dependency map, ordered change plan, execution slices.
  • Use .mdc rules files as durable project memory. Break them into focused files by concern.
  • Scope every prompt to one directory or set of files. Name what is out of scope explicitly.
  • One slice per prompt. Commit after each slice. Review each commit independently.
  • Verify rendered output against MAIN, not the tool's self-report.
  • Resync the index after structural file changes. The stale index is a documented failure mode.
  • Treat Cursor output like a junior developer's PR. Review every line.
The Bottom Line

The Tool Is Not the Discipline

Cursor at $20/month gives you Composer 2.5, Agent mode, semantic indexing, and multi-file edits. None of that saves you if you refactor 40 files in one prompt with no plan and no staged commits. The tool accelerates the mechanics. The discipline is the plan: inventory the files, map the dependencies, sequence the changes, execute in slices, review each slice, verify against the live system, keep a rollback. I built every Academy page this way. The tool was Antigravity, not Cursor. The discipline was the same.

Frequently Asked Questions

FAQ

A full-repo refactor is using Cursor's Agent or Composer to make coordinated changes across many files in an existing codebase. Unlike greenfield generation where the AI writes from scratch, this requires the agent to understand the existing code, its dependencies, and its conventions before changing anything. The challenge is not generating code. It is generating the right changes in the right order without breaking what already works.

Cursor uses semantic indexing with embeddings stored in a vector database. It processes your files and builds a representation of your code's structure, imports, and relationships. Updates use Merkle trees so only changed files are re-indexed. For repositories over 100,000 files, use a .cursorignore file to exclude build artifacts, node_modules, and other non-source directories to keep the index focused and fast.

MDC (Markdown Configuration) files live in .cursor/rules/ and provide persistent project context to Cursor. Each file has YAML frontmatter with a description (what the rule does), globs (file patterns where it triggers), and alwaysApply (whether it loads on every interaction). They replaced the legacy monolithic .cursorrules file. Break rules into focused files by concern: one for your tech stack, one for coding patterns, one for deployment, one for safety boundaries.

Composer (specifically Composer 2.5 as of mid-2026) is optimized for multi-file edits where you need to see diffs immediately. Agent mode is for autonomous multi-step tasks that involve terminal commands, codebase search, and iterative execution. Use Composer when you know what changes you want and need to review each diff. Use Agent mode when the task requires exploration, testing, and multiple tool calls. Both can modify multiple files, but Agent mode has a wider blast radius.

Scope the task to a specific directory or set of files. Use @-mentions to provide only relevant files. State explicitly what is out of scope in your prompt. Set up rules files that define boundaries (directories the agent should not modify, patterns it should follow). Review every proposed diff before accepting. Stage commits after each bounded change so you can bisect later if something breaks.

Four main failure modes: stale index after file moves or renames (the agent references old paths), hallucinated imports (the agent invents modules that do not exist), silent behavioral drift in untested code paths (the code compiles and tests pass but semantics changed), and code reversion bugs where accepted changes are silently undone by auto-formatting or sync conflicts. Each requires a specific mitigation strategy.

The DDS Shopify theme refactor discipline uses pull-edit-push: pull the current file from the live MAIN theme as source of truth, make targeted edits using unique section or lane names as anchors (never positional matches), deploy to a staging theme first, verify rendered output against MAIN rather than trusting the tool's self-report, then promote to MAIN with a length-parity assertion. A rollback commit is always available.

Do not review 40 files at once. Stage commits after each logical slice (one feature, one module, one migration step). Review each slice independently. For each file, check: did the change match the intent, are imports valid, are there hardcoded values that should reference config, did the agent remove something it should not have. Use git bisect if something broke between slices. Treat Agent output like a junior developer's pull request: review every line.

Four categories: project architecture (tech stack, directory structure, key dependencies), coding patterns (naming conventions, component structure, state management patterns), safety boundaries (directories the agent should not modify, commands it should not run, files that require manual approval), and deployment constraints (environment variables, build steps, test requirements). Keep always-on rules under 500 lines. Use globs to scope rules to relevant files.

Four steps: inventory (list every file affected and its role), dependency map (which files import from which, what breaks if this file changes), ordered change plan (sequence changes so each step compiles and tests pass independently), execution in reviewable slices (implement one slice, commit, review, repeat). Write the plan as a document the agent can reference. Without a plan, the agent makes changes in an arbitrary order that often requires backtracking.

A .cursorignore file tells Cursor which files and directories to exclude from indexing. It uses the same glob syntax as .gitignore. Add build artifacts, node_modules, dist directories, log files, and any directories with sensitive data. This keeps the index focused on source code, reduces indexing time, and prevents the agent from wasting context on irrelevant files.

As of July 2026, Cursor offers tiered pricing: Hobby (free, limited usage), Pro ($20/month, full access to semantic search and frontier models), Pro+ ($60/month, for heavy daily agent use), Ultra ($200/month, maximum capacity), and Teams ($40/user/month, with admin controls and pooled usage). Annual billing typically provides a 20% discount. The free tier is sufficient for testing but not for sustained refactoring work.

Yes, with caveats. Cursor indexes Liquid files and can generate valid Liquid syntax. But Shopify sections have specific constraints: CSS must be scoped to a section ID, JavaScript must be in an IIFE, JSON schema blocks must parse, and Liquid tags inside code blocks need raw/endraw wrapping. Put these constraints in a rules file so the agent follows them automatically. Always deploy to a staging theme and verify rendered output before promoting to the live theme.

This is why staged commits matter. If you committed after each slice, run git bisect to find the exact commit that introduced the break. Revert to the last good commit and re-do the broken slice with a more constrained prompt. If you did not stage commits, you are reading through the entire diff manually. The discipline is: one slice, one commit, verify, next slice. It feels slower but it is faster than debugging a 40-file diff with no checkpoints.

Nothing. This masterclass is 100 percent free. No signup, no email, no paywall, no certificate requirement. It is part of the DDS Vibe Academy, a free AI coding curriculum built by Robert McCullock at Design Delight Studio.