Context Engineering
Prompt engineering is what you say once. Context engineering is what the model can see every turn.
Context Types
| Source | When to use | Watch out for |
|---|---|---|
| Open files | Inline completions; nearby patterns | Stale tabs mislead the model |
| @Files / folder | Targeted edits | Too many files → diluted attention |
| Rules / AGENTS.md | Persistent conventions | Keep under ~500 lines total |
| Indexed codebase | "Where is X handled?" | Respect .cursorignore / .gitignore |
| Pasted snippets | Errors, logs, API responses | Truncate noise; highlight the relevant lines |
| MCP servers | Live DB, tickets, docs | Credentials and rate limits |
| @Web | Bleeding-edge API changes | Verify; models misread pages |
Token Budgets
Models have finite context windows. Wasting tokens on node_modules summaries leaves less room for your task.
Prioritize:
- Files directly involved in the change
- One example of the pattern to follow ("match
LoginForm.jsx") - Test files for the feature
- Rules file excerpt (not every rule every time)
Deprioritize:
- Entire repo @-mentions
- Generated build output
- Unrelated feature folders
Codebase Search vs Paste
| Situation | Prefer |
|---|---|
| Model needs to find call sites | Indexed search / "find references" |
| Single failing test output | Paste the error block |
| API response shape | Paste one real JSON example (redact secrets) |
| "How does auth work here?" | @Folder on src/auth/ + Ask mode |
Chunking Large Tasks
Break work so each session fits in context:
- Session 1: Plan + types/interfaces
- Session 2: Core logic
- Session 3: Tests + edge cases
Reference prior work: "Continue from the plan in message above; implement step 2 only."
.cursorignore and Indexing
Exclude from AI indexing:
node_modules/
dist/
.next/
*.min.js
.env*
coverage/
Secrets in indexed files can leak into suggestions and logs.
MCP vs Static Context
MCP servers provide live context (query DB, fetch ticket). Use when static files are not enough — but each tool call adds latency and cost.