New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Strategies for extending effective context capacity through KV-cache ordering, observation masking, compaction, and partitioning.

skills.sh installs
506
GitHub stars
18.4K
last updated
May 26, 2026
View on GitHub

What it does

  • Covers context budgeting, observation masking, prefix or KV-cache ordering, context partitioning, and retrieval scoping, applied in priority order
  • Includes compaction triggers at 70% utilization, masking rules for tool outputs after 3+ turns, and cache-stable prompt ordering
  • Enforces a rule to never compress the system prompt and to measure quality before and after each optimization
  • Designed for agents hitting context limits or incurring high token costs, with adjacent topics routed to other skills

Install

$ npx -y skills add muratcankoylan/agent-skills-for-context-engineering --skill context-optimization -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Context Optimization Techniques

Context optimization extends the effective capacity of limited context windows through strategic compression, masking, caching, and partitioning. Effective optimization increases useful capacity without requiring larger models or longer windows — but only when applied with measurement discipline. The techniques below are ordered by impact and risk.

When to Activate

Activate this skill when:

  • Context budgets or token costs constrain task complexity
  • Observation masking can replace verbose tool outputs with retrievable references
  • Prefix or KV-cache hit rate needs improvement
  • Retrieval scoping can reduce irrelevant loaded context
  • Context partitioning can extend effective capacity across agents
  • Budget triggers are needed for masking, compaction, or partitioning

Details

Repository
github.com/muratcankoylan/agent-skills-for-context-engineering
Categories
Memory & Context, AI Agents & LLM Apps
License
MIT
First seen
Jun 11, 2026

More from muratcankoylan/agent-skills-for-context-engineering

All 17

Similar to Context Optimization

More Memory & Context