context-optimization

Apply compaction, masking, KV-cache reuse, and context partitioning to reduce token usage.

Updated Feb 14, 2026
One-click install
npx skills add https://github.com/Shakudo-io/opencode-skills --skill context-optimization-shakudo-io
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-optimization
Source: https://github.com/Shakudo-io/opencode-skills/tree/main/context-optimization/skills/context-optimization
Command: npx skills add https://github.com/Shakudo-io/opencode-skills --skill context-optimization-shakudo-io

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Context windows are limited, and this skill helps extend their effective capacity by applying compaction, observation masking, KV-cache optimization, and context partitioning to preserve signal while reducing token usage.

Core Features & Use Cases

  • Compaction: summarize near-limit context and reinitialize with a compact summary to keep critical information accessible.
  • Observation Masking: replace verbose tool outputs with compact references to save tokens while preserving retrievability.
  • KV-Cache Optimization: reuse computed blocks across requests with identical prefixes to reduce recomputation and latency.
  • Context Partitioning: divide complex tasks across sub-contexts or sub-agents to maintain focused, smaller contexts.
  • This skill supports long-running agents, large documents, and production systems with strict context budgets.

Quick Start

Optimize the current session's context to maximize effective capacity and reduce token usage.

Frequently Asked Questions about context-optimization

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

FAQPage Schema
How do I reduce token usage for long conversations hitting context window limits?

Reduce token usage in long conversations by applying context compaction, which summarizes near-limit context and reinitializes the session with a compact summary. This preserves critical information while extending effective context capacity.

What is KV-cache reuse and how does it optimize context for production agents?

KV-cache reuse optimizes production agents by retaining computed blocks across requests with identical prefixes. This context optimization technique reduces recomputation, lowers latency, and minimizes memory management overhead.

How do I manage large documents in a production agent without exceeding context budgets?

Manage large documents within strict context budgets by applying context partitioning, which divides complex tasks across sub-contexts or sub-agents. This maintains focused, smaller contexts to preserve signal without exceeding limits.

Can I replace verbose tool outputs with compact references to save tokens?

Yes, you can save tokens by applying observation masking, which replaces verbose tool outputs with compact references. This preserves retrievability while significantly reducing the token count of the overall context.

What's the best way to partition complex tasks across sub-agents for better memory management?

The best way to partition complex tasks for better memory management is dividing them across sub-contexts or sub-agents. This maintains focused, smaller contexts, lowering latency and preventing context window overflow.