From prompt engineering to context engineering
Prompt engineering optimizes the words. Context engineering optimizes the information the model sees. In mid-2026, the bottleneck isn't prompt phrasing — it's what you include, what you exclude, and how you structure it.
Context = system prompt + rules + skills + open files + conversation + tool results + retrieved docs
Every byte competes for the same context window. Senior engineers curate, not dump.
The context budget
Before any agent session, plan your budget:
| Slot | Typical allocation | Content |
|---|---|---|
| Rules & conventions | 5–10% | .cursor/rules, coding standards, team patterns |
| Task spec | 5–10% | What to build, acceptance criteria, constraints |
| Relevant source | 40–60% | Files directly in scope — not the whole repo |
| Reference docs | 10–20% | API docs, ADRs, retrieved RAG chunks |
| Conversation history | 10–20% | Prior turns; summarize when long |
| Output headroom | 15–25% | Room for model response |
If your context is 80% unrelated files, quality on the actual task drops — even with a 1M token window.
Spec-driven development with AI
Replace vague requests with specs the agent can execute:
## Goal
Add idempotency keys to POST /orders endpoint.
## Acceptance criteria
- [ ] Idempotency-Key header accepted (UUID v4)
- [ ] Duplicate requests return cached 201 with same order ID
- [ ] Keys expire after 24h (Redis TTL)
- [ ] Unit tests for: new key, duplicate key, expired key
## Files in scope
- src/handlers/orders.ts (modify)
- src/middleware/idempotency.ts (create)
- src/handlers/orders.test.ts (modify)
## Out of scope
- Database schema changes
- Other endpoints
## Patterns to follow
- See src/middleware/rateLimit.ts for middleware structureSpecs reduce back-and-forth, make agent output reviewable, and survive model upgrades better than clever one-liners.
File selection strategies
| Strategy | When to use |
|---|---|
| Manual @-mentions | Small, well-scoped tasks; you know exactly what's needed |
| Semantic search (RAG) | Large codebase; you know the concept but not the file |
| Dependency graph | Refactors — include callers and callees |
| Recent git changes | Bug fixes — include files from the breaking commit |
| Test files | Implementation tasks — tests define the contract |
Don't @-mention your entire monorepo. The model's attention degrades with irrelevant context (lost-in-the-middle effect).
Rules, skills, and persistent context
Rules (Cursor .cursor/rules/, AGENTS.md): always-on conventions. Version-controlled, team-shared, model-agnostic.
Skills (SKILL.md): procedural knowledge loaded on demand. "How to deploy," "How to run migrations."
Project context (llm-context.md, context.md): architecture overview, key abstractions, gotchas.
These replace re-pasting the same instructions every session. Covered in depth in Team Practices.
Summarization vs verbatim
| Include verbatim | Summarize |
|---|---|
| Files being modified | Directory trees |
| Interface/type definitions | Implementation internals not in scope |
| Failing test output | Entire test suite |
| Error logs (last 50 lines) | Full log history |
| API docs for libraries in use | General language tutorials |
When summarizing, preserve identifiers (function names, types, error codes) — the model needs these to generate correct code.
Structured outputs for pipelines
When AI output feeds another system (CI, codegen, agent loops), use schema enforcement:
- OpenAI Structured Outputs (JSON schema)
- Anthropic tool use with typed parameters
- Cursor's structured agent responses
Free-form markdown is for humans. JSON is for machines.
Interview framing
"I treat context as a scarce resource. I write specs with acceptance criteria, select files deliberately, use rules for persistent conventions, and reserve the context window for material directly relevant to the task. Prompt wording matters less than context curation."
Senior signal: Draw a context budget diagram for a real feature. Explain why you included file A but summarized file B. Mention that rules in git outlast prompt hacks in chat history.
Further Reading
Hands-On Tasks (Optional)
Practical exercises — prompt drills, local MCP servers, or workflow design on paper. The goal is professional fluency, not model training.
- Design a context budget for one feature30m
For a feature you'd build with an agent: list required files, estimate tokens, define what gets summarized vs included verbatim, and write a 10-line spec the agent can follow without guessing.