1. ai
  2. /prompting
  3. /context-engineering

Context Engineering

Prompt engineering is what you say once. Context engineering is what the model can see every turn.

Context Types

SourceWhen to useWatch out for
Open filesInline completions; nearby patternsStale tabs mislead the model
@Files / folderTargeted editsToo many files → diluted attention
Rules / AGENTS.mdPersistent conventionsKeep under ~500 lines total
Indexed codebase"Where is X handled?"Respect .cursorignore / .gitignore
Pasted snippetsErrors, logs, API responsesTruncate noise; highlight the relevant lines
MCP serversLive DB, tickets, docsCredentials and rate limits
@WebBleeding-edge API changesVerify; models misread pages

Token Budgets

Models have finite context windows. Wasting tokens on node_modules summaries leaves less room for your task.

Prioritize:

  1. Files directly involved in the change
  2. One example of the pattern to follow ("match LoginForm.jsx")
  3. Test files for the feature
  4. Rules file excerpt (not every rule every time)

Deprioritize:

  • Entire repo @-mentions
  • Generated build output
  • Unrelated feature folders

Codebase Search vs Paste

SituationPrefer
Model needs to find call sitesIndexed search / "find references"
Single failing test outputPaste the error block
API response shapePaste 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:

  1. Session 1: Plan + types/interfaces
  2. Session 2: Core logic
  3. 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.