context-engine
БесплатноЗапускает вложенные скриптыНе проверенContext management engine for AI coding agents. Use when building agent memory systems, optimizing context windows, allocating token budgets, designing RAG…
от borghei★ 1 250 звёзд на GitHubОб этом скилле
Context Engine - AI Agent Context Management
Decide what an agent should have in its context window, what it should keep in persistent memory, and what it should retrieve on demand, then measure and trim the window to fit. The goal is an agent that has the facts it needs for the current step and nothing that crowds them out.
When to Use
- Bootstrapping agent context for a new codebase, or tailoring it to a task (bug fix, feature, refactor, review).
- A long agent loop is running out of window, or quality drops late in a session.
- Designing persistent memory across sessions, or a retrieval pipeline over code.
- Coordinating what context several agents share and hand off.
Clarify First
Before designing or analyzing, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
- Which task: bootstrap context for a codebase, optimize for a specific task, design persistent memory, or build a code RAG (selects the analyzer/pruner/indexer and the playbook).
- Token budget: the context-window ceiling (sets
--budgetand which packing strategy applies). - Source content: the files/codebase or knowledge base to index (the input the scripts process).
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
Workflow
- Measure. Run
context_analyzer.pyon the files or prompt you plan to load. Token counts are estimates (about 4 characters per token); use the provider's token-counting endpoint when you need exact numbers. - Budget. Run
context_budget_planner.pywith the window size and each component's size. It flags components outside their band and, on overflow, lists what to evict first. - Decide where each piece lives, using these rules:
- Needed on every step and small (instructions, task spec, key interfaces): keep it in the window as an anchor.
- Needed across sessions (decisions, conventions, open questions): write it to the memory tool or a memory file, and reload it at session start. Recomputable facts (file contents, test output) do not belong in memory.
- Large, and only some of it is relevant per step (a codebase, a doc set): retrieve it. Use
memory_indexer.pyfor a quick lexical index; move to embeddings plus code-aware chunking when lexical search misses. - Fits comfortably and the task needs cross-references across all of it: load it into a long window instead of building retrieval.
- Compact before the cliff. Trigger compaction at a high-water mark (around 70-80% of the window), not at 100%: evict superseded tool outputs first, then summarize-and-replace old history, never the anchors. Write durable conclusions to memory before evicting them. Where the platform offers server-side context editing or compaction, prefer it to hand-rolled summaries.
- Prune what you load.
context_pruner.pystrips comments, docstrings, import blocks and duplicates from code; for Markdown and text it only removes duplicate blocks and extra blank lines, so headings and structure survive. - Verify the result: the task still succeeds with the trimmed context (rerun the step or an eval), and the budget planner reports no overflow.
Quick Start
python3 scripts/context_analyzer.py references/ --budget 128000
python3 scripts/context_budget_planner.py --window-size 200000 --system 4000 --history 60000 --tools 90000 --rag 40000 --reserve-output 8000
python3 scripts/context_pruner.py scripts/memory_indexer.py --aggressive
python3 scripts/memory_indexer.py references/ --query "compaction high-water mark" --top 3
Tools Overview
| Tool | What it does | Key flags | Exit codes |
|---|---|---|---|
context_analyzer.py |
Estimated tokens, relevance and suggestions for files or a prompt | <path> or --prompt, --budget, --json |
0 ok, 2 nothing to analyze |
context_budget_planner.py |
Allocate a window across system, memory, history, tools, RAG and reserved output; flag bands and overflow; eviction order | --window-size (required), component sizes, --json |
0 fits, 1 overflow, 2 bad arguments |
context_pruner.py |
Prune code (comments, docstrings, imports, braces, duplicates) or prose (duplicates, blank runs only) | <path> or --stdin [--prose], `--level light |
moderate |
memory_indexer.py |
TF-IDF index and search over a directory of notes or docs | <dir>, --query, --top, --index-only, --stats |
0 ok, 2 not a directory / nothing indexable |
Anti-Patterns
Mistake: Loading everything that might be relevant "to be safe". Why it happens: Large windows make it possible, and missing context feels riskier than extra context. Instead: Irrelevant tokens dilute attention and
Установить context-engine в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл context-engine?
Context management engine for AI coding agents. Use when building agent memory systems, optimizing context windows, allocating token budgets, designing RAG pipelines for code, or managing persistent multi-session agent state.
Как установить скилл context-engine?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл context-engine запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic