home / skills / zpankz / mcp-skillset / context-engineering

context-engineering skill

/context-engineering

This skill helps you optimize agent prompts and context usage by applying progressive loading and minimal high-signal tokens for efficient reasoning.

npx playbooks add skill zpankz/mcp-skillset --skill context-engineering

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
2.9 KB
---
name: context-engineering
description: Understand the components, mechanics, and constraints of context in agent systems. Use when writing, editing, or optimizing commands, skills, or sub-agents prompts.
---

# Context Engineering Fundamentals

Context is the complete state available to a language model at inference time. It includes everything the model can attend to when generating responses: system instructions, tool definitions, retrieved documents, message history, and tool outputs. Understanding context fundamentals is prerequisite to effective context engineering.

## Core Concepts

Context comprises several distinct components, each with different characteristics and constraints. The attention mechanism creates a finite budget that constrains effective context usage. Progressive disclosure manages this constraint by loading information only as needed. The engineering discipline is curating the smallest high-signal token set that achieves desired outcomes.

### Key Principles

**Context as Finite Resource**
Context must be treated as a finite resource with diminishing marginal returns. Like humans with limited working memory, language models have an attention budget drawn on when parsing large volumes of context. Every new token introduced depletes this budget by some amount.

**Progressive Disclosure**
Progressive disclosure manages context efficiently by loading information only as needed. At startup, agents load only skill names and descriptions--sufficient to know when a skill might be relevant. Full content loads only when a skill is activated for specific tasks.

**Quality Over Quantity**
The assumption that larger context windows solve memory problems has been empirically debunked. Context engineering means finding the smallest possible set of high-signal tokens that maximize the likelihood of desired outcomes.

**Informativity Over Exhaustiveness**
Include what matters for the decision at hand, exclude what does not, and design systems that can access additional information on demand.

## Progressive Loading

**L2 Content** (loaded when fundamentals or patterns needed):
- See: [references/fundamentals.md](./references/fundamentals.md)
  - The Anatomy of Context
  - Context Windows and Attention Mechanics
  - Practical Guidance
  - Examples

- See: [references/degradation-patterns.md](./references/degradation-patterns.md)
  - Lost-in-Middle Phenomenon
  - Context Poisoning
  - Context Distraction
  - Context Confusion and Clash
  - Architectural Patterns

**L3 Content** (loaded when workflows or optimization needed):
- See: [references/workflows.md](./references/workflows.md)
  - Hallucination Detection Workflow
  - Lost-in-Middle Detection Workflow
  - Error Propagation Analysis
  - Context Relevance Scoring
  - Context Health Monitoring

- See: [references/optimization.md](./references/optimization.md)
  - Compaction Strategies
  - Observation Masking
  - Context Partitioning
  - Optimization Decision Framework

Overview

This skill teaches how to treat and optimize context as a limited, high-value resource for agent systems. It explains the components of context, practical constraints from attention budgets, and methods like progressive disclosure to load only what’s needed. The goal is to help engineers write, edit, and optimize prompts, skills, and sub-agents for robust, efficient behavior.

How this skill works

The skill inspects the full set of inputs an agent can attend to: system instructions, tool definitions, retrieved documents, message history, and tool outputs. It evaluates signal-to-noise tradeoffs, detects degradation patterns (lost-in-middle, context poisoning), and prescribes progressive loading and compaction strategies. It also provides workflows for monitoring context health and optimizing content delivery as tasks demand.

When to use it

  • Designing or revising prompts, skills, or sub-agent interfaces
  • Optimizing agent performance under constrained context windows
  • Diagnosing hallucinations, drift, or failure modes tied to context
  • Implementing progressive disclosure or context partitioning
  • Deciding which documents or messages to include for a task

Best practices

  • Treat context as a finite resource; prioritize high-signal tokens over volume
  • Use progressive disclosure: load light metadata initially and full content on activation
  • Prefer informativity over exhaustiveness—include only what affects the decision
  • Apply compaction strategies: summarize, extract key facts, and mask observations
  • Instrument context health: monitor relevance scores, drift, and lost-in-middle symptoms

Example use cases

  • Prompt engineering: trim long instructions into concise decision rules and examples
  • Skill activation: surface skill names and descriptions, fetch full specs on use
  • Workflow optimization: implement L2/L3 layered loading for efficiency
  • Debugging: locate context poisoning or distraction causing incorrect responses
  • Scaling: partition context across sub-agents and fetch only required slices

FAQ

How does progressive disclosure reduce errors?

By limiting immediate context to high-signal metadata and fetching detailed content only when needed, progressive disclosure reduces attention overload and lowers the chance of distraction or context clash.

When should I summarize vs. include raw text?

Summarize when the task needs only key facts or decisions; include raw text when exact wording, citations, or step-by-step reconstruction are required.