context-optimization

Compress, mask, cache, and partition context for language models.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/jaaaackieLai/deep-learning-claude-code --skill context-optimization-jaaaackielai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-optimization
Source: https://github.com/jaaaackieLai/deep-learning-claude-code/tree/main/skills/context-engineering/context-optimization
Command: npx skills add https://github.com/jaaaackieLai/deep-learning-claude-code --skill context-optimization-jaaaackielai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Context limits constrain task complexity and raise token costs. This skill provides strategies to stretch effective context through compaction, masking, caching, and partitioning.

Core Features & Use Cases

  • Compaction: summarize content near limits to free space while preserving decisions and context.
  • Observation masking: replace verbose tool outputs with compact references.
  • KV-cache optimization: reuse computations across requests with stable prefixes.
  • Context partitioning: split tasks across sub-agents to avoid cross-context growth.
  • Real-world use: manage long-running agent workflows handling large documents or conversations.

Quick Start

Apply context optimization techniques (compaction, observation masking, KV-cache, and partitioning) to a sample task and verify that signal is preserved while token usage is reduced.

Frequently Asked Questions about context-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize context windows for long-running agent systems?

Optimize context windows by applying compaction, observation masking, KV-cache reuse, and context partitioning. These techniques compress verbose outputs, summarize older context, and split tasks across sub-agents to maintain signal while reducing token costs.

What is context partitioning and when should I use it for multi-turn conversations?

Context partitioning splits tasks across sub-agents to prevent cross-context growth in multi-turn conversations. Use it when processing large documents or managing long-running agent workflows where cumulative context exceeds available budgets.

How do I reduce token costs when processing large documents with tight context budgets?

Reduce token costs by applying compaction to summarize content near limits, observation masking to replace verbose tool outputs with compact references, and KV-cache optimization to reuse computations across requests with stable prefixes.

Can I preserve key decisions when compacting context near token limits?

Compaction summarizes content near context limits to free space while explicitly preserving decisions and context. This ensures critical information survives the compression process when managing long-running agent workflows.

What's the best way to manage context growth in long-running agent workflows?

The best approach combines four techniques: compaction for summarization, observation masking for verbose outputs, KV-cache optimization for stable prefixes, and partitioning across sub-agents. A budget-aware workflow governs when to apply each technique.

Does observation masking work for replacing verbose tool outputs in multi-turn conversations?

Observation masking replaces verbose tool outputs with compact references in multi-turn conversations. It reduces token usage while retaining the ability to trace back to original observations when needed within the agent system.