context-optimization
यह क्या करती है
यह स्किल सीमित context window में ज़्यादा उपयोगी काम भरने के तरीके बताती है, जैसे लंबे टूल आउटपुट छिपाना, कैश्ड prompt की शुरुआत दोबारा इस्तेमाल करना और काम को कई एजेंटों में बाँटना। यह उन टीमों के लिए है जो AI खर्च घटाना या बड़े काम चलाना चाहती हैं।
कब इस्तेमाल करें
- ✓जब कोई काम context की जगह खत्म कर दे या बहुत ज़्यादा tokens खर्च करे।
- ✓जब लंबे टूल आउटपुट context को ऐसे विवरणों से भर दें जिनकी एजेंट को शायद ही ज़रूरत हो।
- ✓जब आप दोहराई जाने वाली लागत घटाने के लिए prompt के कैश्ड हिस्से दोबारा इस्तेमाल करना चाहते हों।
Skill का लिंक
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-optimization/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे एजेंट के टूल आउटपुट बहुत जल्दी context भर देते हैं। बताइए कि गुणवत्ता खोए बिना बातचीत को हल्का कैसे रखूँ।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल तरीकों को असर और जोखिम के हिसाब से क्रम देती है, जैसे आउटपुट मास्क करना, prompt की शुरुआत कैश करना और काम बाँटना, और कहती है कि हर बदलाव को मापें।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
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
Do not activate this skill for adjacent work owned by other skills:
- Explaining why attention or context windows behave this way:
context-fundamentals. - Diagnosing active lost-in-middle, poisoning, distraction, confusion, or clash:
context-degradation. - Designing a structured handoff summary for a long conversation:
context-compression. - Storing large outputs, plans, or logs as files:
filesystem-context. - Model-initiated rewrites of its own context and their re-prefill cost:
self-managed-context.
Core Concepts
Apply four primary strategies in this priority order:
KV-cache optimization — Reorder and stabilize prompt structure so the inference engine reuses cached Key/Value tensors. This is the cheapest optimization when the runtime supports prefix caching: low quality risk, immediate cost and latency savings. Apply it first when stable prefixes exist.
Observation masking — Replace verbose tool outputs with compact references once their purpose has been served. Tool outputs can dominate agent trajectories (claim-context-optimization-tool-output-dominance), so masking often yields the largest capacity gains. The original content remains retrievable if needed downstream.
Compaction — Summarize accumulated context when utilization exceeds 70%, then reinitialize with the summary. This distills the window's contents while preserving task-critical state. Compaction is lossy — apply it after masking has already removed the low-value bulk.
Context partitioning — Split work across sub-agents with isolated contexts when a single window cannot hold the full problem. Each sub-agent operates in a clean context focused on its subtask. Reserve this for tasks where estimated context exceeds 60% of the window limit, because coordination overhead is real.
The governing principle: context quality matters more than quantity. Every optimization preserves signal while reducing noise. Measure before optimizing, then measure the optimization's effect.
Detailed Topics
Compaction Strategies
Trigger compaction when context utilization exceeds 70%: summarize the current context, then reinitialize with the summary. This distills the window's contents in a high-fidelity manner, enabling continuation with minimal performance degradation. Prioritize compressing tool outputs first (they consume 80%+ of tokens), then old conversation turns, then retrieved documents. Never compress the system prompt — it anchors model behavior and its removal causes unpredictable degradation.
Preserve different elements by message type:
- Tool outputs: Extract key findings, metrics, error codes, and conclusions. Strip verbose raw output, stack traces (unless debugging is ongoing), and boilerplate headers.
- Conversational turns: Retain decisions, commitments, user preferences, and context shifts. Remove filler, pleasantries, and exploratory back-and-forth that led to a conclusion already captured.
- Retrieved documents: Keep claims, facts, and data points relevant to the active task. Remove supporting evidence and elaboration that served a one-time reasoning purpose.
Target 50-70% token reduction with less than 5% quality degradation. If compaction exceeds 70% reduction, audit the summary for critical information loss — over-aggressive compaction is the most common failure mode.
Observation Masking
Mask observations selectively based on recency and ongoing relevance — not uniformly. Apply these rules:
- Never mask: Observations critical to the current task, observations from the most recent turn, observations used in active reasoning chains, and error outputs when debugging is in
अक्सर पूछे जाने वाले सवाल
observation masking क्या है?
यह लंबे टूल आउटपुट की जगह छोटे संदर्भ रख देता है, जिन्हें ज़रूरत पड़ने पर एजेंट दोबारा देख सकता है।
prefix caching क्या है?
यह prompt की न बदलने वाली शुरुआत को दोबारा इस्तेमाल करता है, ताकि मॉडल उसे हर बार फिर से प्रोसेस न करे।
क्या इससे जवाब की गुणवत्ता घटती है?
स्किल कहती है कि हर बदलाव मापें, और कोई तरीका तभी रखें जब जवाब अच्छे बने रहें।
जानकारी
लेखक का मूल विवरण
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 effective context capacity without lowering answer quality.
लोकप्रियता
- GitHub स्टार
- 18k
- रैंकिंग में स्थान
- #10640
- लाइसेंस
- MIT
- अपडेट की गई
- 11/10/2026
कमेंट
- …
इस repository की और skills
context-engineering-collection
18kयह आपके एजेंट को AI मॉडल की context window में क्या जाए, इसका प्रबंधन करने में मदद करती है, मेमोरी और टूल्स से लेकर मल्टी-एजेंट सेटअप और मूल्यांकन तक।
advanced-evaluation
18kयह आपके एजेंट को सिखाती है कि दूसरे AI की मदद से AI के जवाबों को कैसे परखा जाए, स्कोरिंग, आमने-सामने तुलना और पूर्वाग्रह जाँच के साथ।
bdi-mental-states
18kयह आपके एजेंट को BDI तरीके से विश्वास, लक्ष्य और योजनाओं का मॉडल बनाना सिखाती है, ताकि उसके फ़ैसले ट्रेस और समझाए जा सकें।
context-compression
18kयह आपके एजेंट को लंबे AI सत्रों को ऐसे सारांशों में छोटा करने में मदद करती है जिनमें फ़ैसले, फ़ाइलें, जोखिम और अगले कदम बचे रहें।
मिलती-जुलती skills
add-model-provider
394kयह आपके एजेंट को सुरक्षित कमांड से OpenClaw में नया AI मॉडल प्रोवाइडर जोड़ने, API कीज़ को सादे टेक्स्ट से बचाने और लाइव टेस्ट चलाने देती है।
acp-router
394kयह आपके एजेंट को OpenClaw के ज़रिए Claude Code या Cursor जैसे कोडिंग असिस्टेंट को काम भेजने देती है, ताकि काम उसी टूल में चले।
browser-automation
394kयह आपके एजेंट को लॉगिन, टैब और अटकी वेब पेज से उबरने समेत, वेबसाइट पर चरण-दर-चरण काम करना सिखाती है।