This skill provides the theoretical and practical framework for managing the state of LLMs. Context is not just "memory"; it is the complete set of data (instructions, tools, documents, history) that the model can attend to at inference time.
Mental Model: Context engineering is the discipline of curating the smallest set of high-signal tokens that maximizes the probability of success on a task.
🚩 Fragility and Autonomy
- Fragility: Low. These are fundamental principles applicable to almost any AI system.
- Freedom: Medium in tactical application depending on the model's capability (e.g., 128K vs 2M tokens).
🚀 When to Activate
- When designing new agent architectures or workflows.
- To debug unexpected behaviors related to forgetting or distraction.
- When optimizing token usage to reduce latency or cost.
- When onboarding new team members to "Context Engineering" concepts.
🧠 Core Concepts
1. The Anatomy of Context
Context is composed of five distinct blocks with different lifecycles:
| Block | Function | Persistence |
|---|---|---|
| System Prompts | Identity and Rules | High (Static) |
| Tool Definitions | Capabilities (APIs) | High (Static) |
| Retrieved Docs | RAG Knowledge | Medium (Just-in-Time) |
| Message History | Task State | Low (Volatile) |
| Tool Outputs | Observations | Very Low (High noise) |
2. The Principle of Progressive Disclosure
Don't load everything at once. Load information only when it is necessary for the next logical step.
- Startup: Load only skill names and descriptions.
- Activation: Load the full content of the skill (
SKILL.md) only when it is activated.
3. The Attention Budget
Even though Gemini supports 2M tokens, the effective "attention budget" is lower. Signal density drops in the middle of the context (Lost-in-Middle).
🛠️ Implementation in Gemini Elite Core
Pattern: Hierarchical Prompt Structure
Use clear headings and XML delimiters to separate concerns.
<BACKGROUND> Contexto del proyecto y preferencias. </BACKGROUND>
<INSTRUCTIONS> Reglas atómicas y guías de comportamiento. </INSTRUCTIONS>
<TOOL_GUIDANCE> Cuándo usar qué herramienta. </TOOL_GUIDANCE>
<OUTPUT_SCHEMA> Formato de respuesta esperado. </OUTPUT_SCHEMA>
Pattern: Altitude Calibration
- Low (Fragile): "If X happens, do Y, then Z". (Too rigid).
- High (Vague): "Help the user program." (Too ambiguous).
- Optimal (Heuristic): "Prioritize readability over brevity; use strict types; verify tests before proposing changes."
🔗 Integrations
context-degradation: What happens when these fundamentals fail.context-optimization: Techniques to stretch the attention budget.tool-design: How tools consume and generate context.
📚 Internal References
references/context-components.md: Detailed technical reference for each component of the context.