Skip to content

Pillar 1: Context Engineering

The quality of AI output is determined entirely by the quality of context you provide.

Every call to an AI coding assistant assembles a context window from multiple sources: your custom instructions and rules files, your current message, relevant code files, conversation history, tool call results, and the assistant’s own system instructions. The AI can only work with what it can see. If critical information is missing, the output will be wrong in ways that look plausible but are subtly broken.

Context engineering is the practice of deliberately shaping what information the AI receives and how that information is structured. It is the single highest-leverage skill in AI-assisted development.

Every project has a rules file checked into source control. The industry is converging on AGENTS.md as the open standard for agent configuration (a Linux Foundation project supported by GitHub Copilot, Cursor, Gemini, Codex, and others). Claude Code uses CLAUDE.md, Cursor supports .cursorrules. Regardless of format, your rules file contains: a project overview, the technology stack with specific versions, coding standards and patterns, architecture decisions, and explicit “do not” instructions. It is the AI’s onboarding document, and it must be maintained like code. Keep it concise: frontier models can follow roughly 150-200 instructions with reasonable consistency, so every line should earn its place. Use linters and formatters for style enforcement rather than burning instruction budget on formatting rules the AI can infer from your existing code.

You understand context window mechanics and their practical limits. Context windows are finite, and their effective capacity is smaller than advertised. Research has demonstrated a U-shaped performance curve (known as “Lost in the Middle”): LLMs recall information best at the beginning and end of context, with significant performance drops for information positioned in the middle. This directly shapes how you structure prompts and retrieved content. Place critical information at the start and end, use structured delimiters (XML tags, headers) to aid attention, and keep files modular (under ~500 lines) so entire files can fit in context without fragmentation. Understand that prompt caching (reusing computed prefixes) saves 60-90% on repeated context but requires static prefixes, so your context structure determines your caching strategy. When context fills up, older information gets truncated. Long conversations accumulate stale context that can mislead the AI. Know when to start a fresh session.

You practice context hygiene. New task, new session. Switching between different projects, different types of work (debugging vs. feature development), or different business contexts in the same session leads to context poisoning. Previous patterns, assumptions, and code styles bleed into unrelated work and cause mysterious failures.

Be aware that long sessions trigger conversation compaction (automatic summarization of earlier messages to free space). This means details from early in a conversation may be compressed or lost. Compaction strategies vary across tools and continue to evolve rapidly: some use simple summarization, others use sliding windows or allow you to pin critical context. Understand how your specific tool handles long conversations rather than assuming one universal behavior. If a piece of information is critical to the current task, restate it rather than assuming the AI still has full recall of something you said 50 messages ago.

You understand what context is being assembled on your behalf. Your typed message is only one part of what the AI sees. Most tools silently inject additional context: rules files from the current and parent directories, persistent memories from previous sessions, MCP tool results, system instructions, and retrieved code files. Some of these sources are visible to you (your rules file), but others may not be obvious (a memory the tool saved from a conversation last week, or a parent directory’s rules file you forgot existed). Audit what your tool is including. If your AI is behaving in ways you didn’t expect, the cause is often implicit context you didn’t know was there, not a problem with your prompt.

You provide context proactively rather than hoping the AI finds it. Yes, agentic tools can search your codebase. But it is faster and more reliable to point the AI at the specific files, documentation, and examples it needs. Include relevant library documentation when working with specific frameworks, especially when versions matter. When starting a complex task, front-load the key files: the spec, the relevant module, the test file, and any API documentation the AI will need. Don’t make it search for what you already know is relevant.

You structure your codebase so AI can navigate it effectively. Context engineering isn’t just about what you type in the chat. It’s about how your code is organized. Small, focused files (under ~500 lines) fit entirely in context without fragmentation. Clear, descriptive naming (folders, files, functions, variables) gives the AI semantic signals about purpose. A README or index file per directory helps the AI understand module boundaries. Consistent patterns across the codebase mean the AI can infer conventions from a few examples rather than needing explicit instructions for everything. The same practices that make code readable to junior developers make code readable to AI.

  • No rules file in the repo, or a rules file that hasn’t been updated in months
  • A rules file that tries to specify everything (500+ lines), burying critical instructions in noise
  • Marathon sessions spanning multiple unrelated tasks without restarting
  • Assuming the AI “knows” your project conventions without being told
  • Including so much context that the important instructions get buried
  • Not specifying library or framework versions, leading to the AI using deprecated patterns (the SQLAlchemy 1.4 vs 2.0 problem)
  • Relying on information from early in a long conversation without restating it (compaction may have summarized it away)
  • Not understanding what implicit context (memories, inherited rules files, MCP results) your tool is injecting alongside your prompt
  • Monolithic files (1000+ lines) that can’t fit in context, forcing the AI to work with fragments