domains / agent-tooling / context-engineering-fundamentals / context-fundamentals
The copies overlap heavily on the anatomy of context (system prompts, tools, retrieval, history, outputs) and the core definition of context. However, they disagree on scope and contain material steps the others lack. The muratcankoylan copy is a conceptual onboarding skill that explicitly routes operational work to other skills and introduces specific principles (U-shaped attention curve, position-aware placement, iterative curation). The foryourhealth111 and sickn33 copies are broader, covering operational topics like attention mechanics, position encoding, and the 83.9% tool output statistic, which the first copy omits. Crowning one would hide either the operational depth or the specific conceptual routing logic.
| Repository | Path |
|---|---|
| muratcankoylan/Agent-Skills-for-Context-Engineering | skills/context-fundamentals/SKILL.md |
| foryourhealth111-pixel/Vibe-Skills | bundled/skills/context-fundamentals/SKILL.md |
| sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/context-fundamentals/SKILL.md |
| Role | Repository | Path |
|---|---|---|
| peer | muratcankoylan/Agent-Skills-for-Context-Engineering | skills/context-fundamentals/SKILL.md |
| peer | foryourhealth111-pixel/Vibe-Skills | bundled/skills/context-fundamentals/SKILL.md |
| peer | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/context-fundamentals/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills/skills/context-fundamentals/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | skills/context-fundamentals/SKILL.md |
--- name: context-fundamentals description: "Explains foundational concepts of context engineering: context anatomy, attention mechanics, and core principles. Use for conceptual onboarding and design reasoning. For operational work, apply the specific tactics described in the detailed topics or route to specialized skills if available." --- # Context Engineering Fundamentals Context is the complete state available to a language model at inference time: system instructions, tool definitions, retrieved documents, message history, and tool outputs. Context engineering is the discipline of curating the smallest high-signal token set that maximizes the likelihood of desired outcomes. ## When to Activate Activate this skill when: - Explaining what context is and how attention mechanics constrain agent behavior. - Onboarding new contributors to context engineering concepts. - Reasoning about a context-related design decision from first principles. - Designing new agent systems or modifying existing architectures. - Debugging unexpected agent behavior that may relate to context. ## Core Concepts Treat context as a finite attention budget. Every token added competes for the model's attention. The engineering problem is maximizing utility per token against the hard token limit and the U-shaped attention curve (which penalizes information placed in the middle of context). Apply these principles: 1. **Informativity over exhaustiveness** — include only what matters for the current decision. 2. **Position-aware placement** — place critical constraints at the beginning and end of context. 3. **Progressive disclosure** — load skill names/summaries at startup; load full content only when activated. 4. **Iterative curation** — context engineering is an ongoing discipline, not a one-time exercise. ## Detailed Topics ### The Anatomy of Context **System Prompts** Organize system prompts into distinct sections using XML tags or Markdown headers. Calibrate instruction altitude to balance brittle hardcoded logic with vague high-level guidance. Aim for heuristic-driven instructions: specific enough to guide behavior, flexible enough to generalize. **Tool Definitions** Write tool descriptions that answer: what the tool does, when to use it, and what it returns. Keep the tool set minimal. Consolidate overlapping tools because bloated tool sets create ambiguous decision points and consume disproportionate context after JSON serialization. **Retrieved Documents** Maintain lightweight identifiers (file paths, stored queries, web links) and load data into context dynamically using just-in-time retrieval. This mirrors human cognition: maintain an index, not a copy. **Message History** Message history serves as scratchpad memory where agents track progress and maintain task state. Effective management is critical for long-horizon task completion. **Tool Outputs** Tool outputs comprise the majority of tokens in typical agent trajectories (research shows they can reach ~84% of total context usage). This creates pressure for strategies like observation masking, compaction, and selective retention. ### Context Windows and Attention Mechanics **The Attention Budget Constraint** Language models process tokens through attention mechanisms that create pairwise relationships. As context length increases, the model's ability to capture these relationships gets stretched thin, creating an "attention budget" that depletes as context grows. **Position Encoding and Context Extension** Position encoding interpolation allows models to handle longer sequences but introduces degradation in token position understanding. Models show reduced precision for information retrieval and long-range reasoning compared to performance on shorter contexts. **The Progressive Disclosure Principle** Progressive disclosure manages context efficiently by loading information only as needed. At startup, agents load only names and summaries; full content is loaded when a specific task activates.