Manuals / AI Coding with Cursor / Ch 3

A · Task DesignBeginner30 min read

3. Context management for code agents

AI Coding with Cursor · 44 pages source format

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

What you'll learn

  • .cursorrules
  • Focused context
  • Conversation scoping

Write .cursorrules

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

# .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.

Clear?

One feature per conversation

Long agent threads accumulate confusion. Start fresh for each feature or bug.

Do this now

Compare: one long thread vs two fresh threads for two small tasks.

Clear?

Checklist