xc-plugin State Management
conorluddy/xclaude-plugin
Teaches how xc-plugin saves tokens with progressive disclosure, cached responses and consistent configuration, so large device lists and build logs arrive as summaries first.
Apply compaction, masking, and caching strategies. An agent skill from agent-skills-hub/agent-skills-hub.
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimization --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/context-optimization .claude/skills/context-optimization && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .claude/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimizationType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimization --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/context-optimization .agents/skills/context-optimization && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .agents/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimization --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/context-optimization .cursor/skills/context-optimization && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .cursor/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/agent-skills-hub/agent-skills-hub.git --path skills/context-optimization--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimization --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/context-optimization .gemini/skills/context-optimization && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .gemini/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimizationInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/context-optimization .github/skills/context-optimization && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .github/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install agent-skills-hub/agent-skills-hub context-optimization --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/agent-skills-hub/agent-skills-hub.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/context-optimization .opencode/skills/context-optimization && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/agent-skills-hub/agent-skills-hub/tree/main/skills/context-optimization into .opencode/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
context-optimizationApply compaction, masking, and caching strategies. An agent skill from agent-skills-hub/agent-skills-hub.
Context Optimization is an agent skill from agent-skills-hub/agent-skills-hub. Apply compaction, masking, and caching strategies
Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Agent Workflows, covering Context engineering and Caching. The repository describes itself as: Agent Skills Hub is a global library of AI agent skills that work across OpenClaw, Claude Code, Gemini, Cursor, Antigravity, and more. The licence is MIT.
8 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit efc0b96. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are python).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Context Optimization loads about 2.1k tokens when it runs. Until then it costs about 18 tokens; SKILL.md has 970 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from agent-skills-hub/agent-skills-hub at commit efc0b96, republished under its MIT licence (© agent-skills-hub). 970 words, ~2,129 tokens.
.claude/skills/context-optimization/SKILL.md (or your agent's skills folder).Apply compaction, masking, and caching strategies
Use this skill when working with apply compaction, masking, and caching strategies.
Context optimization extends the effective capacity of limited context windows through strategic compression, masking, caching, and partitioning. The goal is not to magically increase context windows but to make better use of available capacity. Effective optimization can double or triple effective context capacity without requiring larger models or longer contexts.
Activate this skill when:
Context optimization extends effective capacity through four primary strategies: compaction (summarizing context near limits), observation masking (replacing verbose outputs with references), KV-cache optimization (reusing cached computations), and context partitioning (splitting work across isolated contexts).
The key insight is that context quality matters more than quantity. Optimization preserves signal while reducing noise. The art lies in selecting what to keep versus what to discard, and when to apply each technique.
What is Compaction Compaction is the practice of summarizing context contents when approaching limits, then reinitializing a new context window with the summary. This distills the contents of a context window in a high-fidelity manner, enabling the agent to continue with minimal performance degradation.
Compaction typically serves as the first lever in context optimization. The art lies in selecting what to keep versus what to discard.
Compaction Implementation Compaction works by identifying sections that can be compressed, generating summaries that capture essential points, and replacing full content with summaries. Priority for compression goes to tool outputs (replace with summaries), old turns (summarize early conversation), retrieved docs (summarize if recent versions exist), and never compress system prompt.
Summary Generation Effective summaries preserve different elements depending on message type:
Tool outputs: Preserve key findings, metrics, and conclusions. Remove verbose raw output.
Conversational turns: Preserve key decisions, commitments, and context shifts. Remove filler and back-and-forth.
Retrieved documents: Preserve key facts and claims. Remove supporting evidence and elaboration.
The Observation Problem Tool outputs can comprise 80%+ of token usage in agent trajectories. Much of this is verbose output that has already served its purpose. Once an agent has used a tool output to make a decision, keeping the full output provides diminishing value while consuming significant context.
Observation masking replaces verbose tool outputs with compact references. The information remains accessible if needed but does not consume context continuously.
Masking Strategy Selection Not all observations should be masked equally:
Never mask: Observations critical to current task, observations from the most recent turn, observations used in active reasoning.
Consider masking: Observations from 3+ turns ago, verbose outputs with key points extractable, observations whose purpose has been served.
Always mask: Repeated outputs, boilerplate headers/footers, outputs already summarized in conversation.
Understanding KV-Cache The KV-cache stores Key and Value tensors computed during inference, growing linearly with sequence length. Caching the KV-cache across requests sharing identical prefixes avoids recomputation.
Prefix caching reuses KV blocks across requests with identical prefixes using hash-based block matching. This dramatically reduces cost and latency for requests with common prefixes like system prompts.
Cache Optimization Patterns Optimize for caching by reordering context elements to maximize cache hits. Place stable elements first (system prompt, tool definitions), then frequently reused elements, then unique elements last.
Design prompts to maximize cache stability: avoid dynamic content like timestamps, use consistent formatting, keep structure stable across sessions.
Sub-Agent Partitioning The most aggressive form of context optimization is partitioning work across sub-agents with isolated contexts. Each sub-agent operates in a clean context focused on its subtask without carrying accumulated context from other subtasks.
This approach achieves separation of concerns—the detailed search context remains isolated within sub-agents while the coordinator focuses on synthesis and analysis.
Result Aggregation Aggregate results from partitioned subtasks by validating all partitions completed, merging compatible results, and summarizing if still too large.
Context Budget Allocation Design explicit context budgets. Allocate tokens to categories: system prompt, tool definitions, retrieved docs, message history, and reserved buffer. Monitor usage against budget and trigger optimization when approaching limits.
Trigger-Based Optimization Monitor signals for optimization triggers: token utilization above 80%, degradation indicators, and performance drops. Apply appropriate optimization techniques based on context composition.
When to optimize:
What to apply:
Compaction should achieve 50-70% token reduction with less than 5% quality degradation. Masking should achieve 60-80% reduction in masked observations. Cache optimization should achieve 70%+ hit rate for stable workloads.
Monitor and iterate on optimization strategies based on measured effectiveness.
Example 1: Compaction Trigger
if context_tokens / context_limit > 0.8:
context = compact_context(context)Example 2: Observation Masking
if len(observation) > max_length:
ref_id = store_observation(observation)
return f"[Obs:{ref_id} elided. Key: {extract_key(observation)}]"Example 3: Cache-Friendly Ordering
# Stable content first
context = [system_prompt, tool_definitions] # Cacheable
context += [reused_templates] # Reusable
context += [unique_content] # UniqueThis skill builds on context-fundamentals and context-degradation. It connects to:
Internal reference:
Related skills in this collection:
External resources:
Created: 2025-12-20 Last Updated: 2025-12-20 Author: Agent Skills for Context Engineering Contributors Version: 1.0.0
© agent-skills-hub, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in skills/context-optimization of agent-skills-hub/agent-skills-hub.
Open the folder on GitHubat commit efc0b96
We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in agent-skills-hub/agent-skills-hub, which our catalogue first saw on October 7, 2026.
Context Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Context Optimization this skillagent-skills-hub/agent-skills-hub | 111 | 1 repos | ~2.1k | Automated safety check: Pass | MIT | |
| xc-plugin State Managementconorluddy/xclaude-plugin | 183 | — | ~4k | Automated safety check: Pass | MIT | |
| Context Optimizationguanyang/open-agent-hub | 975 | 2 repos | ~4k | Automated safety check: Pass | MIT | |
| Context Mode Output Sandboxmksglu/context-mode | 26k | — | ~4.1k | Automated safety check: Pass | Custom licence | |
| Memori Long-Term MemoryMemoriLabs/Memori | 17k | — | ~2k | Automated safety check: Notes | Custom licence | |
| Picoclaw Skill Creatorsipeed/picoclaw | 30k | — | ~4.4k | Automated safety check: Pass | MIT |
conorluddy/xclaude-plugin
Teaches how xc-plugin saves tokens with progressive disclosure, cached responses and consistent configuration, so large device lists and build logs arrive as summaries first.
guanyang/open-agent-hub
This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending…
mksglu/context-mode
Routes large command, file, API and browser output through context-mode tools so only the needed result enters the agent's context, instead of dumping it via Bash.
MemoriLabs/Memori
Connects Claude Code to Memori Cloud for long-term memory, recalling stored context before substantive replies and saving new context afterward.
sipeed/picoclaw
Guidance for creating, updating and reviewing Picoclaw skills, from the SKILL.md structure to organizing bundled scripts, references and assets.
cocoindex-io/cocoindex-code
Semantic code search and index management with the ccc CLI: the agent initializes, indexes and queries the project by concept, filtering by language or path.
agent-skills-hub/agent-skills-hub
Python library for accessing, analyzing, and extracting data from SEC EDGAR filings.
agent-skills-hub/agent-skills-hub
Build lightweight SDF/canvas displacement glass with Vaso. An agent skill from agent-skills-hub/agent-skills-hub.
agent-skills-hub/agent-skills-hub
Mobile-first design and engineering doctrine for iOS and Android apps.
agent-skills-hub/agent-skills-hub
Comprehensive geospatial science skill covering remote sensing, GIS, spatial analysis, machine learning for earth observation, and 30+ scientific domains.
agent-skills-hub/agent-skills-hub
Anti-slop discipline for AI agent behavior across ALL domains — code, design/UI, security, writing, research, data, creative/media.
agent-skills-hub/agent-skills-hub
Efficient storage and retrieval of genomic variant data using TileDB.
Categories
Apply compaction, masking, and caching strategies. An agent skill from agent-skills-hub/agent-skills-hub. Context Optimization is an agent skill from agent-skills-hub/agent-skills-hub.
Context Optimization fits situations like: tasks that involve Context engineering; tasks that involve Caching.
Run `npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a claude-code`. Or copy the skill folder (skills/context-optimization in agent-skills-hub/agent-skills-hub) into .claude/skills/context-optimization in your project. Claude Code loads it when a task matches its description.
Run `npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a codex`. Or copy the skill folder (skills/context-optimization in agent-skills-hub/agent-skills-hub) into .agents/skills/context-optimization in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add agent-skills-hub/agent-skills-hub --skill context-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-optimization, .gemini/skills/context-optimization, .github/skills/context-optimization and .opencode/skills/context-optimization in your project.
SKILL.md names no scripts, command-line tools or credentials: Context Optimization is instructions for the agent only. Our summary lists: Python 3.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Context Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Context Optimization: xc-plugin State Management (conorluddy/xclaude-plugin, 183 stars), Context Optimization (guanyang/open-agent-hub, 975 stars), Context Mode Output Sandbox (mksglu/context-mode, 26k stars) and Memori Long-Term Memory (MemoriLabs/Memori, 17k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
agent-skills-hub (a GitHub organization) maintains it in agent-skills-hub/agent-skills-hub, which has 111 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 2, 2026.
Source: agent-skills-hub/agent-skills-hub on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.