context-fundamentals: Foundational Mental Models for Context Engineering

Preface

When building Agents, a common practice is to pile system prompts, tool definitions, retrieved results, and conversation history into the context, hoping that “a large enough window will remember everything.” The actual performance is often that the latter half of long conversations starts to go off track, key constraints are ignored, and tool outputs push effective instructions to the margins. The problem is often not that the prompt is not long enough, but that we do not understand what the “context” actually contains during inference, how attention is allocated, and why quality matters more than quantity.

Below we introduce the context-fundamentals Skill from the repository Agent Skills for Context Engineering. It does not focus on specific parameter tuning or compression implementations; instead, it establishes a reusable conceptual framework, suitable as an introductory piece before reading other Skills in the same series.

What Is This

context-fundamentals is an Agent Skill designed for conceptual explanation and background reading. It uses SKILL.md to describe capability boundaries and trigger conditions.

The maintainers are listed in the Skill metadata as Agent Skills for Context Engineering Contributors; the Skill belongs to the open-source collection muratcankoylan/Agent-Skills-for-Context-Engineering, and the official path is:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/context-fundamentals

The problems it aims to solve can be summarized as two points:

  1. Define context: the complete state visible to the model at the moment of inference, including system instructions, tool definitions, retrieved documents, message history, and tool outputs.
  2. Define context engineering: under a limited attention budget, selecting the “smallest set of high-signal tokens” to increase the probability of the desired behavior.

Other Skills in the same collection, such as context-degradation, context-optimization, and context-compression, are responsible for practical operations; this Skill only provides the mental models needed to understand these decisions and explicitly routes operational work to the appropriate Skills.

Core Functionality

All the following content is taken from the official SKILL.md and the collection’s README; only the capabilities explicitly documented are listed.

When to Activate

This Skill is suitable for the following conceptual work:

  • Explaining what context is and how attention mechanics constrain Agent behavior.
  • Onboarding new members who need to build a mental model before engaging with operational Skills.
  • Deriving context-related designs from first principles (what constraints mean, why trade-offs exist) before choosing concrete methods.
  • Writing or reviewing documentation that needs to anchor operational guidelines in underlying mechanisms.

It should not be used to replace operational work, such as:

Task Type Skill to Route To
Lost-in-middle, context poisoning, diagnosing attention failures context-degradation
Masking, partitioning, prefix caching, budget control context-optimization
Compressing long sessions and handoff summaries context-compression
Offloading large tool outputs, persistent scratchpads filesystem-context
Designing LLM project structures and pipelines project-development

Core Concept: Attention Budget and the U-Shaped Curve

Officially, context should be treated as a finite attention budget, not an infinite storage bucket. Each additional token competes for attention, and the budget cannot be “recharged” mid-inference. Engineering goals are to maximize “utility per token” under three constraints:

  • Hard token limits.
  • Effective capacity limits lower than the nominal window.
  • U-shaped attention curve: in long-context evaluations, information in the middle positions is often less reliably recalled than at the beginning or end.

The official guidelines offer four principles when assembling context:

  1. Informativity over exhaustiveness — include only content relevant to the current decision; retrieve the rest on demand.
  2. Position-aware placement — place critical constraints at the beginning or end of the context.
  3. Progressive disclosure — load only Skill names and summaries at startup; load full text only after task matching.
  4. Iterative curation — continuously trim content each time it is sent to the model, rather than writing the entire prompt once.

Anatomy of Context

The Skill breaks down a typical Agent context by components and provides design points (excerpt):

  • System Prompts: use XML tags or Markdown headings to partition sections (background, instructions, tool descriptions, output format); place key constraints at the beginning and end; control the “instruction altitude” to avoid being too brittle or too vague; start with a minimal set and iterate based on failure modes.
  • Tool Definitions: descriptions should answer three questions—what it does, when to use it, and what it returns; keep the tool set lean, as JSON-serialized schemas typically expand to about 2–3 times their size compared to plain text descriptions.
  • Retrieved Documents: maintain lightweight identifiers (paths, queries, links) and load them JIT when needed; chunk along semantic boundaries.
  • Message History: serves as a scratchpad for progress and state; in long tasks, monitor its proportion and replace stale tool outputs with summaries or references.
  • Tool Outputs: often dominate Agent trajectories; after processing, use observation masking to replace them with compact references.

Context Window and Attention Mechanisms

  • Attention Budget: with n tokens, the attention mechanism involves n² pairwise relationships; performance degrades gradually as context grows, not by hard truncation.
  • Position Encoding Limits: extrapolating position encodings can lengthen sequences, but distant retrieval and reasoning precision may suffer.
  • Context Quality Versus Quantity: reject the “bigger window is better” mentality; test each piece of context for signal density—would removing it still change the output?

Official guidelines also mention: during development, monitor context usage and consider triggering compaction when utilization reaches about 70–80% (for specific strategies, see context-compression / context-optimization).

Examples and Further Reading

The Skill includes reusable structural examples, such as organizing the system prompt with section tags (see “Typical Use Cases” below). In the same directory, references/context-components.md is available for consulting when debugging specific components; the collection’s README lists this Skill first among the Foundational Skills.

Installation and Activation

This Skill adheres to the Agent Skills directory specification: each Skill is a folder (containing SKILL.md) and must not be flattened into a single .md file, as that would break relative paths like references/.

Claude Code (Plugin Marketplace)

The collection is published as a Claude Code Plugin Marketplace. Official steps:

Step 1: Register the marketplace

/plugin marketplace add muratcankoylan/Agent-Skills-for-Context-Engineering

Step 2: Install the plugin

Install directly:

/plugin install context-engineering@context-engineering-marketplace

Alternatively, in the UI select context-engineering-marketplace → context-engineering → Install now. After installation, the Skill will auto-activate based on task context.

Cursor

The official recommendation offers two methods:

  1. Install from the Cursor Plugin Directory entry for context-engineering; or clone the repository and point Cursor to the plugin’s root directory.
  2. Cursor reads .plugin/plugin.json and discovers the skills/ directory at the repository root through the Open Plugins manifest.

Installing only context-fundamentals into a project (you need to first obtain the skills/context-fundamentals directory from the repository, for example by downloading or cloning and then copying it; do not execute any clone in this environment):

mkdir -p .cursor/skills
cp -R skills/context-fundamentals .cursor/skills/

Note: the official documentation explicitly advises against relying on repository symlinks; they often fail on Windows and in plugin packaging.

Codex / Other Open Plugins Hosts

  • Add the repository as a plugin directory; the host reads .plugin/plugin.json to discover each Skill under skills/.
  • Example for manual project-level installation:
mkdir -p .codex/skills
cp -R skills/context-fundamentals .codex/skills/

For general Agent Skills, you can also use the .agents/skills/ directory (see the collection’s README).

Claude Code’s project-level directory is .claude/skills/, with the same layout as Cursor.

Typical Use Cases

New contributors can start with this Skill, then read context-degradation, and later choose context-optimization, context-compression, filesystem-context, memory-systems, etc., as needed for their projects. The Skill’s original text notes: skipping the conceptual layer tends to result in “knowing the techniques but not understanding the reasons”; skipping the operational Skills makes it difficult to choose the right tools for the job.

2. Using Sectioned System Prompts to Enforce “Strong Attention at the Beginning and End”

Official Example 1 demonstrates using explicit sections to carry background, instructions, and output format (concept: critical constraints land on structural boundaries with higher attention):

<BACKGROUND_INFORMATION>
You are a Python expert helping a development team.
Current project: Data processing pipeline in Python 3.9+
</BACKGROUND_INFORMATION>

<INSTRUCTIONS>
- Write clean, idiomatic Python code
- Include type hints for function signatures
- Add docstrings for public functions
- Follow PEP 8 style guidelines
</INSTRUCTIONS>

<OUTPUT_DESCRIPTION>
Provide code blocks with syntax highlighting.
Explain non-obvious decisions in comments.
</OUTPUT_DESCRIPTION>

3. Separate Conceptual and Operational Questions

For example, the question “Should long conversations be summarized?” can be split into two layers: this Skill answers why summarization is necessary (limited budget, U-shaped curve, signal density); how to compress and what threshold to set are left to context-compression.

When asking questions to an Agent, you can explicitly state the need for “basic concepts of context engineering” or reference the Skill name context-fundamentals so the host routes the query via description (Claude Code / Cursor plugin modes usually auto-match).

Use Cases and Considerations

Who It’s For

  • Engineers designing or reviewing Agent architectures, tool surfaces, RAG, and history management strategies.
  • Teams writing internal documentation and onboarding materials, needing to unify terminology around “context / attention budget.”
  • People planning a systematic reading of the Context Engineering _SKILL collection, wanting the first piece to establish a shared language.

Limitations and Common Pitfalls (from the official Gotchas, excerpt)

  • Nominal context window ≠ effective capacity; on complex retrieval and reasoning tasks, perform degradation testing with your own workloads first.
  • Estimating with “about 4 characters per token” underestimates code, URLs, and non-English text; when budget-sensitive, use the provider’s tokenizer.
  • The token overhead of serialized tool schemas is often underestimated; a dozen medium schemas can consume thousands of tokens before the first user message.
  • Message history grows silently in Agent loops; set a history token limit and actively compact.
  • Security constraints and output formats should not be placed in the middle of long system prompts; under the U-shaped curve, recall in the middle is significantly weaker than at the beginning and end.
  • Progressive disclosure, if implemented as “load everything whenever it’s slightly relevant,” reintroduces context stuffing.

This Skill does not replace load testing, compression implementations, or troubleshooting; those tasks should switch to the specialized Skills listed in the table above.

Conclusion

context-fundamentals breaks the context window down into operational components, uses the attention budget and the U-shaped curve to explain “why filling it up does not equate to better,” and provides a clear division of labor with other Skills in the collection. If you are building or optimizing an Agent, it is recommended to go through this set of concepts first, then proceed to the hands-on Skills like context-degradation and context-optimization.

Official URL:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/context-fundamentals

Collection repository:

https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye