context-optimization
Fungsinya
Skill ini membahas cara memuat lebih banyak pekerjaan yang berguna ke dalam jendela konteks yang terbatas, seperti menyembunyikan output alat yang panjang, memakai ulang awalan prompt yang di-cache, dan membagi pekerjaan ke beberapa agent. Skill ini untuk tim yang ingin menurunkan biaya AI atau menjalankan tugas yang lebih besar.
Kapan dipakai
- βSaat tugas kehabisan ruang konteks atau memakan terlalu banyak token.
- βSaat output alat yang panjang memenuhi konteks dengan detail yang jarang dibutuhkan agent.
- βSaat Anda ingin memakai ulang bagian prompt yang di-cache untuk memangkas biaya berulang.
Link skill
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-optimization/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βAgent saya memenuhi konteks terlalu cepat karena output alatnya. Tunjukkan cara menjaga percakapan tetap ringan tanpa menurunkan kualitas.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill ini memeringkat teknik berdasarkan dampak dan risikonya, seperti menyamarkan output, meng-cache awal prompt, dan membagi pekerjaan, lalu menyarankan agar setiap perubahan diukur.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apa itu observation masking?
Ini mengganti output alat yang panjang dengan referensi singkat yang bisa dicari lagi oleh agent saat dibutuhkan.
Apa itu prefix caching?
Ini memakai ulang bagian awal prompt yang tidak berubah, sehingga model tidak perlu memprosesnya lagi setiap kali.
Apakah ini menurunkan kualitas jawaban?
Skill ini menyarankan untuk mengukur setiap perubahan, sehingga sebuah teknik hanya dipakai jika jawabannya tetap baik.
Detail
Deskripsi asli dari pembuat
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.
Popularitas
- Bintang GitHub
- 18k
- Peringkat
- #10640
- Lisensi
- MIT
- Diperbarui
- 11/10/2026
Komentar
- β¦
Skill lain dari repositori ini
context-engineering-collection
18kMembantu agent Anda mengelola apa yang masuk ke jendela konteks model AI, dari memori dan alat hingga sistem multi-agent dan evaluasi.
advanced-evaluation
18kMengajari agent Anda cara menilai jawaban AI memakai AI lain, dengan skor, perbandingan berpasangan, dan pemeriksaan bias.
bdi-mental-states
18kMengajari agent Anda memodelkan keyakinan, tujuan, dan rencana dengan pendekatan BDI, sehingga keputusannya bisa ditelusuri dan dijelaskan.
context-compression
18kMembantu agent Anda meringkas sesi AI yang panjang menjadi ringkasan yang tetap menyimpan keputusan, file, risiko, dan langkah berikutnya.
Skill serupa
add-model-provider
394kMemungkinkan agent Anda menghubungkan penyedia model AI baru ke OpenClaw dengan perintah pengaturan yang aman, menjaga kunci API tetap di luar teks biasa, dan menjalankan uji langsung.
acp-router
394kMembantu agent Anda mengirim tugas ke asisten pemrograman seperti Claude Code atau Cursor lewat OpenClaw, sehingga pekerjaan dijalankan di alat tersebut.
browser-automation
394kMengajari agent Anda mengendalikan halaman web langkah demi langkah, termasuk login, tab, dan pemulihan saat halaman berhenti merespons.