context-optimization
Was er macht
Dieser Skill zeigt Wege, mehr nützliche Arbeit in ein begrenztes Kontextfenster zu bekommen, etwa durch Ausblenden ausführlicher Werkzeugausgaben, Wiederverwendung gecachter Prompt-Anfänge und Aufteilung der Arbeit auf mehrere Agenten. Er ist für Teams gedacht, die KI-Kosten senken oder größere Aufgaben bewältigen wollen.
Wann du ihn nutzt
- ✓Wenn einer Aufgabe der Kontextraum ausgeht oder sie zu viele Tokens kostet.
- ✓Wenn lange Werkzeugausgaben den Kontext mit Details füllen, die der Agent selten braucht.
- ✓Wenn du gecachte Teile eines Prompts wiederverwenden willst, um wiederholte Kosten zu senken.
Link zum Skill
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-optimization/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Die Werkzeugausgaben meines Agenten füllen den Kontext zu schnell. Zeig mir, wie ich das Gespräch schlank halte, ohne an Qualität zu verlieren.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill ordnet Techniken nach Wirkung und Risiko, etwa Maskierung von Ausgaben, Caching des Prompt-Anfangs und Aufteilung der Arbeit, und empfiehlt, jede Änderung zu messen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen
Was ist Observation Masking?
Es ersetzt lange Werkzeugausgaben durch kurze Verweise, die der Agent bei Bedarf erneut nachschlagen kann.
Was ist Prefix-Caching?
Es nutzt den unveränderten Anfang eines Prompts wieder, sodass das Modell ihn nicht jedes Mal neu verarbeiten muss.
Verschlechtert das die Antwortqualität?
Der Skill rät, jede Änderung zu messen. Eine Technik bleibt nur, wenn die Antworten gut bleiben.
Details
Originalbeschreibung des Autors
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.
Beliebtheit
- GitHub-Sterne
- 18k
- Platz im Ranking
- #10640
- Lizenz
- MIT
- Aktualisiert
- 11.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
context-engineering-collection
18kHilft deinem Agenten, zu verwalten, was in das Kontextfenster eines KI-Modells kommt, von Gedächtnis und Werkzeugen bis zu Multi-Agenten-Setups und Evaluation.
advanced-evaluation
18kBringt deinem Agenten bei, KI-Antworten mithilfe einer anderen KI zu beurteilen, mit Bewertung, direktem Vergleich und Prüfungen auf Verzerrungen.
bdi-mental-states
18kBringt deinem Agenten bei, Überzeugungen, Ziele und Pläne nach dem BDI-Ansatz zu modellieren, damit seine Entscheidungen nachvollziehbar und erklärbar sind.
context-compression
18kHilft deinem Agenten, lange KI-Sitzungen in Zusammenfassungen zu kürzen, die Entscheidungen, Dateien, Risiken und nächste Schritte erhalten.
Ähnliche Skills
add-model-provider
394kLässt deinen Agenten einen neuen KI-Modellanbieter mit sicheren Befehlen an OpenClaw anbinden, API-Schlüssel nicht im Klartext speichern und einen Live-Test starten.
acp-router
394kHilft deinem Agenten, eine Aufgabe über OpenClaw an einen Coding-Assistenten wie Claude Code oder Cursor zu senden, damit die Arbeit in diesem Tool läuft.
browser-automation
394kBringt deinem Agenten bei, Webseiten Schritt für Schritt zu steuern, einschließlich Anmeldungen, Tabs und Wiederherstellung, wenn eine Seite nicht mehr reagiert.