Manuals / AI Coding with Cursor / Chapter 3

A · Task Design · beginner · ~30 min · Chapter 3 of 11

Context management for code agents

Agents work best with focused context. Open relevant files, use .cursorrules, and keep conversations scoped to one feature at a time.

Path progress
23%

Step 1 of 2

Write .cursorrules

Project conventions the agent should always follow: test framework, naming, lint rules, commit style.

Write .cursorrulesDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Write .cursorrulesdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

# .cursorrules
- Use Vitest for tests, not Jest
- Components in PascalCase, hooks in camelCase with "use" prefix
- All API calls go through src/api/client.ts
- Prefer functional components with TypeScript
- Run `npm run lint` before considering a task done

Do this now

Create .cursorrules with 5 project-specific rules. Run an agent task.

Was this step clear?
Chapter learning outcomes
  • .cursorrules
  • Focused context
  • Conversation scoping

Clear these before you leave

Side quest

Rules iteration

After 3 agent tasks, update .cursorrules with one new rule.