context-optimization
O que ela faz
Esta skill reúne formas de caber mais trabalho útil em uma janela de contexto limitada, como ocultar saídas de ferramentas muito longas, reaproveitar o início de prompts em cache e dividir o trabalho entre agentes. É para equipes que querem reduzir custos de IA ou executar tarefas maiores.
Quando usar
- ✓Quando uma tarefa fica sem espaço de contexto ou consome tokens demais.
- ✓Quando saídas longas de ferramentas enchem o contexto com detalhes que o agente quase não usa.
- ✓Quando você quer reaproveitar partes em cache de um prompt para reduzir custos repetidos.
Link da skill
https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/blob/main/skills/context-optimization/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“As saídas das ferramentas do meu agente enchem o contexto rápido demais. Mostre como manter a conversa enxuta sem perder qualidade.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A skill ordena as técnicas por impacto e risco, como mascarar saídas, colocar em cache o início dos prompts e dividir o trabalho, e recomenda medir cada mudança.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
O que é mascaramento de observações?
É substituir saídas longas de ferramentas por referências curtas que o agente pode consultar de novo quando precisar.
O que é cache de prefixo?
É reaproveitar o início de um prompt que não muda, para que o modelo não precise processá-lo de novo a cada vez.
Isso reduz a qualidade das respostas?
A skill diz para medir cada mudança, então uma técnica só é mantida se as respostas continuarem boas.
Detalhes
Descrição original do autor
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.
Popularidade
- Estrelas no GitHub
- 18 mil
- Posição no ranking
- #10640
- Licença
- MIT
- Atualizada em
- 11/10/2026
Comentários
- …
Mais skills deste repositório
context-engineering-collection
18 milAjuda seu agente a gerenciar o que entra na janela de contexto de um modelo de IA, desde memória e ferramentas até configurações com vários agentes e avaliação.
advanced-evaluation
18 milEnsina seu agente a avaliar respostas de IA usando outra IA, com pontuação, comparação lado a lado e verificações de viés.
bdi-mental-states
18 milEnsina seu agente a modelar crenças, objetivos e planos usando a abordagem BDI, para que suas decisões possam ser rastreadas e explicadas.
context-compression
18 milAjuda seu agente a resumir sessões longas de IA em resumos que mantêm decisões, arquivos, riscos e próximos passos.
Skills parecidas
add-model-provider
394 milPermite que seu agente conecte um novo provedor de modelos de IA ao OpenClaw com comandos seguros, guarde as chaves de API com segurança e faça um teste ao vivo.
acp-router
394 milAjuda seu agente a enviar uma tarefa a um assistente de programação, como Claude Code ou Cursor, pelo OpenClaw, para que o trabalho rode nessa ferramenta.
browser-automation
394 milEnsina seu agente a controlar páginas web passo a passo, incluindo logins, abas e recuperação quando uma página para de responder.