Agent skill · software engineering · borghei
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.
Why this skill is useful
Adds 4 executable scripts for context management and optimization that are not available in public documentation.
What it needs
Requires python installed locally. About 4k tokens when loaded. Last updated 2026-07-21. 462 stars on the source repository.
What this skill does
Context Engine - AI Agent Context Management Context Engine provides production-grade patterns for managing what AI agents know, remember, and retrieve. It covers the full lifecycle: ingestion of project knowledge, optimal packing of context windows, persistent memory across sessions, and retrieval-augmented generation for large codebases. The difference between a useful agent and a hallucinating one is context management. Core Capabilities Context window architecture — token budget allocation plus greedy, tiered, and adaptive-compression packing strategies. Memory architecture — three-layer model (working / session / knowledge base), promotion protocol, and staleness detection. Code retrieval — file-level, chunk-level (RAG), and dependency-aware retrieval with code chunking and embedding guidance. Knowledge graph construction — codebase graph schema (nodes + edges) and graph queries that resolve agent questions. Window optimization patterns — sliding window with anchors, progressive summarization, selective tool-result caching. Memory tool & context editing — file-backed persistent memory across sessions, plus context compaction (evict stale tool outputs, summarize-and-replace history) to keep a long loop from exhausting the window. Long-context strategies — when to use a 1M-token window vs. RAG vs. a hybrid agent loop, budget allocation across a big window, and position/attention effects. Multi-agent context sharing — shared context bus and a five-element handoff protocol. When to Use Bootstrapping agent context for a new codebase (index → graph → summary → tiers). Optimizing context for a specific task (bug fix, feature, refactor, review). Capturing, promoting, and pruning session memory across sessions. Designing a RAG pipeline for code retrieval. Coordinating context across multiple collaborating agents. Clarify First Before designing or analyzing, confirm these inputs. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills borghei/context-engine