Command Palette

Search for a command to run...

Назад к скиллам
скилл № 23958

context-management

Token budgeting, placement effects, RAG patterns, prompt caching, compression, and multi-turn context strategies for LLM applications. Use when dealing with…

БесплатноБез исполняемых скриптов
crouton-labsот crouton-labs★ 25 звёзд на GitHub

Установить context-management в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Context Management

Context is a finite budget. How you allocate it — and where you place things within it — determines quality as much as what you put in. More context isn't always better. This skill covers the mechanics of transformer attention, the tradeoffs in retrieval and compression, and the patterns that hold up in production.

For implementation patterns and code examples, see reference.md.

The Attention Economics Model

LLMs don't read context uniformly. Liu et al. (Stanford/Berkeley, 2024) established the U-shaped recall curve: content at the beginning and end of context is processed effectively; middle content suffers 20–30% accuracy drops. In their tests, models performed better with no documents at all than with documents where the answer was buried in the center.

This isn't a model-specific quirk. It's a structural property of transformer attention, confirmed across every architecture tested. You cannot prompt your way out of it.

The U-curve also isn't static — it shifts with how full the context window is:

  • Below 50% fill: Primacy dominates. Put critical content first.
  • Above 50% fill: Primacy inverts. First-position accuracy drops below middle. Put critical content last.
  • The transition is sharp around the 50% threshold (arXiv 2508.07479).

Practical consequence: if you're targeting 70% context utilization (which is the right range), your critical content belongs at the end, not the top.

Token Budget Allocation

Optimal utilization is 60–80% of the context window. Below 60% is over-provisioning. Above 80% risks mid-task overflow. Operating permanently at the edge degrades response quality (Factory.ai).

Section % of Window Notes
System instructions 10–15% Bloating causes models to ignore instructions, not follow more
Tool definitions 15–20% 50 tools can consume 10,000+ tokens — often underestimated
Knowledge / RAG 30–40% Primary content. Push to 60% for factual QA, shrink history to 10%
Conversation history 20–30% Coding agents need more than chatbots
Output reserve 10–15% Pre-allocate this — running out causes truncated responses

The 100:1 rule: Production input-to-output ratios are approximately 100:1 by token count. Context costs dominate. Optimization here has the highest ROI.

Claimed vs. Effective Context Length

Advertised context length is not effective context length. The RULER benchmark (NVIDIA, 2024) tested 10 models across 4K–128K using 13 tasks beyond simple needle retrieval. Most models claiming 128K+ had practical limits at 50–65% of advertised for complex reasoning tasks. Simple needle-in-haystack tests produce near-perfect scores but dramatically overstate real capability.

Worse: even with perfect retrieval (the model can locate all relevant text), task performance degrades 14–85% as context grows (arXiv 2510.05381). Retrieval and reasoning degrade at different rates. More context helps retrieval and hurts reasoning.

Benchmark your model at your actual working length before assuming it can handle it.

Retrieval: Precision Over Volume

The dominant RAG failure is not the model hallucinating from nothing — it's the retriever returning plausibly relevant but actually unhelpful chunks, which the model then synthesizes incorrectly.

Filtering irrelevant retrieved passages reduces hallucinations by up to 64% (FILCO). The pattern that works:

High-recall retrieval (50–100 candidates)
  → Cross-encoder rerank (10–25% additional precision)
  → Pass top 5–10 to LLM

Never pass raw top-k directly. Context stuffing hurts more than it helps.

When RAG hurts:

  • HyDE (Hypothetical Document Embeddings): helps ambiguous/conceptual queries, but ARAGOG (2024) showed it causes -0.065 precision vs. naive RAG on factoid queries. Don't apply universally.
  • Query decomposition: +288% on multi-hop QA (PopQA), but ARAGOG found it underperformed naive RAG on generic queries.
  • LLM-based reranking: ARAGOG found it hurt performance (-0.0514 precision). Cross-encoder reranking is faster and better.

The highest-ROI advanced pattern is iterative retrieval with a confidence gate: if first retrieval yields low-similarity results, rewrite the query and retrieve again rather than passing low-quality context to the LLM.

Compression: When It Helps and When It Destroys

LLMLingua-2 (Microsoft Research, ACL 2024) achieves 2x–5x compression with minimal quality loss and 3–6x faster inference. The original LLMLingua (EMNLP 2023) demonstrated up to 20x compression with ~1.5% accuracy loss on reasoning benchmarks. More surprising: CompLLM research found 2x compressed context outperforming uncompressed on long sequences — compression removes noise that dilutes attention.

Extractive beats abstractive for fact retrieval. Extractive reranker compression gave +7.89 F1 on 2WikiMultihopQA at 4.5x compression; abstractive compression at similar ratios *

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • reference.md

FAQ

Что делает скилл context-management?

Token budgeting, placement effects, RAG patterns, prompt caching, compression, and multi-turn context strategies for LLM applications. Use when dealing with context windows, token budgets, retrieval-augmented generation, long context, context overflow, caching costs, observation masking, or compressing LLM inputs.

Как установить скилл context-management?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл context-management запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить context-management с