Agent skill

Context Engine

by borghei in borghei/Claude-Skills

Context management engine for AI coding agents. An agent skill from borghei/Claude-Skills.

MITAuto-check passedAgent Workflows

Install Context Engine

skills CLI
$ npx skills add borghei/Claude-Skills --skill context-engine -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install borghei/Claude-Skills context-engine --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/borghei/Claude-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engineering/context-engine .claude/skills/context-engine && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
context-engine
GitHub stars
874
Token cost
~2.2k tokens
SKILL.md length
918 words
Files
11 (incl. scripts, references)
Skills in repo
364
Repo updated
First seen
Licence
MIT

At a glance

Context management engine for AI coding agents. An agent skill from borghei/Claude-Skills.

  • Building agent memory systems
  • SKILL.md covers Core Capabilities, When to Use, Clarify First and Tools, plus 3 more sections
  • Runs Python scripts from its folder; calls python
  • Optimizing context windows

What it does

Context Engine is an agent skill from borghei/Claude-Skills. 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.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 12 other files, including scripts and reference files (for example `references/code-retrieval-patterns.md`, `references/context-window-strategies.md` and `references/long-context-strategies.md`).

It sits in Agent Workflows, covering Context engineering, LLM cost and token optimization and Retrieval-augmented generation. The repository describes itself as: 385 AI skills, 77 expert agents, and 900 stdlib Python tools for every team: engineering, PM, marketing, C-level, compliance, business ops, research, and a LinkedIn toolkit… The licence is MIT.

When your agent uses it

  • Building agent memory systems
  • Optimizing context windows
  • Allocating token budgets
  • Designing RAG pipelines for code

Example prompts

  • “/context-engine”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit c9a1487. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 4 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Context Engine loads about 2.2k tokens when it runs, and up to ~10k if it reads all its reference files. Until then it costs about 60 tokens; SKILL.md has 918 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~10k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from borghei/Claude-Skills at commit c9a1487, republished under its MIT licence (© borghei). 918 words, ~2,186 tokens.

Download SKILL.mdSave it as .claude/skills/context-engine/SKILL.md (or your agent's skills folder). This skill also uses 10 other files; get the full folder from GitHub.
name
context-engine
description
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.
license
MIT + Commons Clause
metadata.version
1.2.0
metadata.author
borghei
metadata.category
engineering
metadata.domain
ai-agents
metadata.tier
POWERFUL
metadata.updated
2026-06-29
metadata.frameworks
context-window-optimization, memory-architecture, knowledge-graphs

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.
Show full SKILL.md (339 more words)Show less

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

© borghei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 10 other files (scripts, references) in engineering/context-engine of borghei/Claude-Skills.

  • SKILL.md
  • references/code-retrieval-patterns.md
  • references/context-window-strategies.md
  • references/long-context-strategies.md
  • references/memory-and-context-editing.md
  • references/memory-architecture-guide.md
  • references/workflows-and-quality.md
  • scripts/context_analyzer.py
  • scripts/context_budget_planner.py
  • scripts/context_pruner.py
  • scripts/memory_indexer.py

Open the folder on GitHubat commit c9a1487

Compare with similar skills

Context Engine next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Context Engine compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Context Engine this skillborghei/Claude-Skills874—~2.2kAutomated safety check: PassMIT
Context DoctorjzOcb/context-doctor119—~642Automated safety check: PassMIT
Caveman Learn Token FixesJuliusBrussee/caveman110k—~2.8kAutomated safety check: PassApache-2.0
Deep Agentslangchain-ai/docs424—~1.1kAutomated safety check: PassMIT
Discover Agenticrand/cc-polymath1811 repos~1.4kAutomated safety check: PassMIT
OmniRoute Context CLIdiegosouzapw/OmniRoute74k—~1.2kAutomated safety check: PassMIT

Similar skills

  • Context Doctor

    jzOcb/context-doctor

    Visualize and diagnose OpenClaw context window usage. An agent skill from jzOcb/context-doctor.

    119 GitHub stars~642 tokensUpdated 6 mo ago
    Agent WorkflowsAuto-check passed
  • Caveman Learn Token Fixes

    JuliusBrussee/caveman

    Acts on a Caveman learn report: reviews ranked token sinks, applies cost-lowering edits one at a time with your consent, and reports what each fix returned.

    110k GitHub stars~2.8k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Deep Agents

    langchain-ai/docs

    Official

    Build batteries-included agents with planning, context management, subagent delegation, and sandboxed execution.

    424 GitHub stars~1.1k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Discover Agentic

    rand/cc-polymath

    Automatically discover agentic workflow skills when building AI agents, implementing tool use patterns, managing context windows, decomposing complex tasks, or designing multi-step autonomous…

    181 GitHub starsUsed in 1 repo~1.4k tokens
    Agent WorkflowsAuto-check passed
  • OmniRoute Context CLI

    diegosouzapw/OmniRoute

    Manage context engineering configurations, RTK filter sets, and conversation sessions from the CLI. Apply context-relay settings and inspect active context…

    74k GitHub stars~1.2k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Subagent Brief Discipline

    LichAmnesia/lich-skills

    Checks every subagent prompt before spawning, swapping pasted files and context for paths and short summaries and trimming the brief, to avoid multiplied token cost.

    234 GitHub stars~1.6k tokensUpdated 4 mo ago
    Agent WorkflowsAuto-check passed

More from borghei/Claude-Skills

All 364 skills in this repo
  • Agents In The Team

    borghei/Claude-Skills

    Run delivery when AI coding and ops agents take tickets. An agent skill from borghei/Claude-Skills.

    874 GitHub stars~4.2k tokensUpdated yesterday
    Auto-check passed
  • AI Content Disclosure

    borghei/Claude-Skills

    Check AI-generated marketing content and reviews for required disclosures under the EU AI Act, FTC rules and platform AI-label policies.

    874 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • AI Prototyping

    borghei/Claude-Skills

    Idea to AI-generated prototype to customer validation to engineering handoff.

    874 GitHub stars~3.6k tokensUpdated yesterday
    Auto-check passed
  • Analytics Engineer

    borghei/Claude-Skills

    Analytics engineering across data modeling, dbt, transformation, and semantic layers.

    874 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • Ansoff Matrix

    borghei/Claude-Skills

    Ansoff Matrix — 4-quadrant framework for growth options: market penetration, market/product development, and diversification.

    874 GitHub stars~2.2k tokensUpdated yesterday
    Auto-check passed
  • Brainstorm Okrs

    borghei/Claude-Skills

    OKR brainstorming and validation using the Radical Focus framework — outcome objectives, measurable key results, counter-metrics.

    874 GitHub stars~1.4k tokensUpdated yesterday
    Auto-check passed

Questions about Context Engine

What does Context Engine do?

Context management engine for AI coding agents. An agent skill from borghei/Claude-Skills. Context Engine is an agent skill from borghei/Claude-Skills. Context management engine for AI coding agents.

When should I use Context Engine?

Context Engine fits situations like: building agent memory systems; optimizing context windows; allocating token budgets; designing RAG pipelines for code.

How do I install Context Engine in Claude Code?

Run `npx skills add borghei/Claude-Skills --skill context-engine -a claude-code`. Or copy the skill folder (engineering/context-engine in borghei/Claude-Skills) into .claude/skills/context-engine in your project. Claude Code loads it when a task matches its description.

How do I install Context Engine in Codex?

Run `npx skills add borghei/Claude-Skills --skill context-engine -a codex`. Or copy the skill folder (engineering/context-engine in borghei/Claude-Skills) into .agents/skills/context-engine in your project. Codex loads it when a task matches its description.

Can I use Context Engine in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add borghei/Claude-Skills --skill context-engine -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-engine, .gemini/skills/context-engine, .github/skills/context-engine and .opencode/skills/context-engine in your project.

What does Context Engine need to run?

Going by SKILL.md and its folder, Context Engine needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Context Engine access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Context Engine safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Context Engine use?

Context Engine is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Context Engine use?

About 2.2k tokens (SKILL.md is roughly 8.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.2k tokens, read only when the agent opens those files.

What are the alternatives to Context Engine?

Skills that share tags, products or a category with Context Engine: Context Doctor (jzOcb/context-doctor, 119 stars), Caveman Learn Token Fixes (JuliusBrussee/caveman, 110k stars), Deep Agents (langchain-ai/docs, 424 stars) and Discover Agentic (rand/cc-polymath, 181 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Context Engine?

borghei (a GitHub user) maintains it in borghei/Claude-Skills, which has 874 GitHub stars. The repository holds 364 skills in this directory. The repository was last updated on October 7, 2026.

Source: borghei/Claude-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.