context-optimization
Use when optimizing token usage, KV cache efficiency, or context window management for LLM agents.
Skill by VoDaiLocz
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/vodailocz-context-optimization
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: ml, finance, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/context-optimization
What's inside
- Skill name
context-optimization- Description
- Use when optimizing token usage, KV cache efficiency, or context window management for LLM agents. Keywords: context optimization, KV cache, prompt caching, token budget, semantic pruning, lost-in-the-middle.
- License
- Apache-2.0
- Instructions
- 77 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Context Optimization Skill This skill provides methodologies and best practices for maximizing context window efficiency, reducing token costs, and improving the performance of LLM-based agentic workflows. ## 1. Prompt Cache Alignment To maximize Key-Value (KV) cache hits, prioritize stability in the early parts of the prompt. - **Static Prefixes**: Design system prompts to remain identical across agent turns. - **Tool Order**: Sort tool definitions alphabetically or by frequency of use. Keep this ordering constant. - **Prefix Consistency**: Reserve the top 70% of the KV cache for global system instructions and tool definitions. - **Avoid Dynamic Data**: Move dynamic session-specific data (dates, current file list) to the end of the context window. ## 2. Semantic Pruning & AST Compaction Reduce unnecessary data before sending it to the model. - **Removal of Non-Essentials**: Strip comments, debug logs, and unused boilerplate code. - **AST Compaction**: Convert deep code structures into simplified, representative summaries or pseudocode. - **Whitespace Stripping**: Use minification for configuration files (JSON, YAML) and standard code. - **Irrelevant Body Dropping**: Replace large, irrelevant function bodies with docstrings or signatures if the model doesn't need to reason about the implementation details. ## 3. Lost-in-the-Middle Mitigation LLMs often suffer from recall degradation for information in the center of the context window. - **Boundary Priority**: Place high-priority constraints, critical instructions, and schema definitions at the very beginning (Head) or the very end (Tail) of the context. - **Sandwich Strategy**: If critical information must be in the middle, sandwich it between two clear, high-level summary points that repeat its purpose. ## 4. Sliding Windows & Recursive Summarization Manage long-running conversations without exceeding token thresholds. - **Sliding Window**: Keep only the N most recent turns for immediate interaction. - **Recursive Summarization**: Periodically collapse historical turns into a compressed "Session State Summary". - **State Archiving**: Store older, less relevant interactions in a side-car file (e.g., `archive.md`) that the agent can read only when necessary. ## 5. Token Budget Allocation Implement a disciplined token distribution: | Category | Typical % | Goal | | :--- | :--- | :--- | | System Prompt | 10-15% | Definition of role & constraints | | Tool Definitions | 15-20% | Capability exposure | | Interaction History | 30-40% | Context for current turn | | Reserved (Drafting) | 25-45% | Headroom for generation | ## 6. Context Freshness Decisions Determine when to act on history: - **Summarize**: When history exceeds 50% of the token budget and requires long-term context. - **Truncate**: When history is irrelevant to the current task or contains repetitive technical noise. - **Archive**: When information must be preserved (e.g., decisions, ADRs) but is not needed for the immediate turn. ## 7. Measuring Cache Hit Rate Continuous improvement relies on telemetry. - **Monitoring**: Track Cache Hit Rate (CHR) metrics provided by the API provider. - **Iteration**: Analyze sessions with low CHR. Are the system prompts shifting? Is tool definition order inconsistent? - **Optimization Loop**: 1. Measure performance per turn. 2. Identify volatility in the prefix. 3. Refactor static content to improve cache stability. 4. Re-measure. ## Best Practices Checklist - [ ] Does my system prompt remain stable across requests? - [ ] Are tools sorted consistently? - [ ] Is critical information pinned to the Head or Tail? - [ ] Have I pruned unused code/data from the ingestion stream? - [ ] Is there an automated summarization step for history?
From VoDaiLocz/kilo-kit-mcp, Apache-2.0.
More from VoDaiLocz/kilo-kit-mcp
- 0.654score
docs-seeker
VoDaiLocz
Searching internet for technical documentation using llms.txt standard, GitHub repositories via Repomix, and parallel exploration.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
aesthetic
VoDaiLocz
Create aesthetically beautiful interfaces following proven design principles.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
context-engineering
VoDaiLocz
Master context engineering for AI agent systems.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
databases
VoDaiLocz
Work with MongoDB (document database, BSON documents, aggregation pipelines, Atlas cloud) and PostgreSQL (relational database, SQL queries, psql CLI, pgAdmin).
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
backend-development
VoDaiLocz
Build robust backend systems with modern technologies (Node.js, Python, Go, Rust), frameworks (NestJS, FastAPI, Django), databases (PostgreSQL, MongoDB…
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
mobile-design
VoDaiLocz
Mobile-first design thinking and decision-making for iOS and Android apps.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
code-review
VoDaiLocz
Use when receiving code review feedback (especially if unclear or technically questionable), when completing tasks or major features requiring review before…
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
media-processing
VoDaiLocz
Process multimedia files with FFmpeg (video/audio encoding, conversion, streaming, filtering, hardware acceleration) and ImageMagick (image manipulation…
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
better-auth
VoDaiLocz
Implement authentication and authorization with Better Auth - a framework-agnostic TypeScript authentication framework.
SkillAFreshness: A★ 28Claude Code +9 - 0.651score
i18n-localization
VoDaiLocz
Internationalization and localization patterns.
SkillAFreshness: A★ 28Claude Code +9 - 0.651score
lint-and-validate
VoDaiLocz
Automatic quality control, linting, and static analysis procedures.
SkillAFreshness: A★ 28Claude Code +9 - 0.649score
agentic-rag
VoDaiLocz
Use when building self-correcting retrieval systems for AI agents.
SkillAFreshness: A★ 28Claude Code +9
Signals
- Stars
- 28
- Forks
- 3
- Open issues
- 0
- Last commit (this folder)
- Aug 21, 2026 (2 months ago)
- Last release
- Oct 24, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/VoDaiLocz/kilo-kit-mcp
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from VoDaiLocz
- 0.654score
backend-development
VoDaiLocz
Build robust backend systems with modern technologies (Node.js, Python, Go, Rust), frameworks (NestJS, FastAPI, Django), databases (PostgreSQL, MongoDB…
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
better-auth
VoDaiLocz
Implement authentication and authorization with Better Auth - a framework-agnostic TypeScript authentication framework.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
aesthetic
VoDaiLocz
Create aesthetically beautiful interfaces following proven design principles.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
mobile-design
VoDaiLocz
Mobile-first design thinking and decision-making for iOS and Android apps.
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
media-processing
VoDaiLocz
Process multimedia files with FFmpeg (video/audio encoding, conversion, streaming, filtering, hardware acceleration) and ImageMagick (image manipulation…
SkillAFreshness: A★ 28Claude Code +9 - 0.654score
code-review
VoDaiLocz
Use when receiving code review feedback (especially if unclear or technically questionable), when completing tasks or major features requiring review before…
SkillAFreshness: A★ 28Claude Code +9
Cite this page
context-optimization skill. Agent Mart. https://agentmart.dev/skills/vodailocz-context-optimization (last updated 2026-10-24)