Context Engine logo

Context Engine

Community
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.

Overview

Publisherborghei
RepositoryClaude-Skills
Skill namecontext-engine
Stars
856
Forks
154
Bundled files
10
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 10 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by borghei on GitHub. Read the source before you install it.

Installation

Install the Context Engine AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/borghei/Claude-Skills/tree/main/engineering/context-engine
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/borghei/Claude-Skills.git /tmp/Claude-Skills
mkdir -p .claude/skills
cp -r /tmp/Claude-Skills/engineering/context-engine .claude/skills/context-engine
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Context Engine in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Context Engine on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Context Engine is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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. If any is unknown or vague, ASK — do not assume:

  • 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 --budget and which packing strategy applies)
  • Source content — the files/codebase or knowledge base to index (the input the scripts process)

Stop rule: ask only the 2-3 that most change the output. If the user says "just draft it," proceed and list your assumptions at the top of the artifact.

Tools

ToolPurposeCommand
context_analyzer.pyAnalyze files/prompts for token usage, relevance, and optimization suggestionspython scripts/context_analyzer.py src/ --budget 128000 --json
context_pruner.pyPrune low-relevance content, redundancy, and verbose patterns from contextpython scripts/context_pruner.py src/main.py --aggressive --json
memory_indexer.pyIndex and search a memory/knowledge base with TF-IDF relevance scoringpython scripts/memory_indexer.py docs/ --query 'auth middleware' --top 5
context_budget_planner.pyAllocate a window across components, flag overflow, and suggest what to compact/evict firstpython scripts/context_budget_planner.py --window-size 200000 --system 4000 --history 60000 --tools 90000 --rag 40000 --reserve-output 8000

References

Load the reference that matches the task — keep this file lean and pull detail on demand:

  • references/context-window-strategies.md — budget allocation, packing strategies, and window-optimization patterns. Read when planning budgets or optimizing a long conversation.
  • references/memory-architecture-guide.md — three-layer memory model, promotion protocol, staleness detection, shared context bus + handoff protocol. Read when designing persistent memory or coordinating agents.
  • references/code-retrieval-patterns.md — file/chunk/dependency-aware retrieval, chunking/embedding guidance, knowledge-graph schema and queries. Read when building RAG for code.
  • references/memory-and-context-editing.md — the memory-tool pattern (file-backed memory, what to store vs. recompute, retention, security) and context editing/compaction (eviction priority, summarize-and-replace, token-savings payoff) and how both weave into the agent loop. Read when persisting state across sessions or keeping a long loop from exhausting the window.
  • references/long-context-strategies.md — long-context vs. RAG vs. hybrid decision-making, budget allocation across a 1M-token window, position/attention effects, and when a bigger window hurts (cost, latency, distraction). Read when choosing a window-vs-retrieval strategy.
  • references/workflows-and-quality.md — the three workflows, anti-patterns, evaluation metrics, troubleshooting, and success criteria. Read before running a workflow and before shipping.

Scope & Limitations

This skill covers:

  • Context window token budget planning, allocation strategies, and packing algorithms for AI coding agents.
  • Multi-layer memory architecture design (working memory, session memory, knowledge base) with promotion and staleness protocols.
  • Code-specific retrieval strategies including file-level, chunk-level, and dependency-aware retrieval for RAG pipelines.
  • Knowledge graph construction from codebases and graph-based context queries for agent workflows.

This skill does NOT cover:

  • Vector store infrastructure setup, embedding model selection, or database deployment — see rag-architect for vector store design and embedding strategies.
  • Agent role definition, personality design, or multi-agent orchestration logic — see agent-designer for agent architecture and agent-workflow-designer for orchestration patterns.
  • Runtime observability, metrics dashboards, or alerting for agent systems — see observability-designer for monitoring and instrumentation.
  • Prompt engineering techniques, chain-of-thought design, or instruction tuning — see prompt-engineer-toolkit for prompt construction patterns.

Integration Points

SkillIntegrationData Flow
rag-architectContext Engine defines retrieval strategies; RAG Architect implements the vector store and embedding pipelineRetrieval queries flow from Context Engine to RAG Architect's indexed store; ranked results flow back as context chunks
agent-designerAgent Designer defines agent roles and capabilities; Context Engine manages per-agent context budgets and memory layersAgent specifications define context requirements; Context Engine returns tailored context windows per agent role
self-improving-agentSelf-Improving Agent identifies recurring patterns and corrections; Context Engine decides when to promote learnings to persistent memoryCandidate learnings flow from Self-Improving Agent; promotion decisions and memory updates flow back through Context Engine's staleness and promotion protocols
observability-designerObservability Designer instruments context utilization metrics (relevance, staleness, cache hits); Context Engine exposes metric endpointsRaw metric events flow from Context Engine; Observability Designer aggregates into dashboards and alerts
agent-workflow-designerAgent Workflow Designer defines multi-agent handoff sequences; Context Engine implements the shared context bus and handoff protocolWorkflow definitions specify which agents share context; Context Engine manages the context bus, serialization, and handoff payloads
codebase-onboardingCodebase Onboarding generates project summaries and architecture maps; Context Engine consumes these as Tier 0 bootstrap contextOnboarding artifacts (project summary, directory map, entry points) feed into Context Engine's initial knowledge graph and context tiers

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Context Engine AI skill do?

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 use Context Engine on TypingMind?

Because you install it once and use it with any model. Context Engine is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Context Engine in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/borghei/Claude-Skills/tree/main/engineering/context-engine. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Context Engine?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Context Engine?

As many as you like. As long as a model supports skills, you can use Context Engine with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Context Engine AI skill free?

It is published on GitHub by borghei. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇