Skip to main content
skill CX Codex

context-engine · borghei — Claude Code skill: agent context management

context-engine — a skill for Claude Code, Codex, Cursor, GitHub Copilot, and Gemini CLI that decides what goes into the context window, what gets written to persistent memory, and what is retrieved on demand.

LicenseRef-MIT-Commons-Clause 112 installs ★ 1,183 updated 2026-11-08

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add borghei/Claude-Skills --skill context-engine -a claude-code
Open on GitHub

What context-engine does

The skill works across Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode, attaching in each as a SKILL.md file. It ships four Python scripts: context_analyzer.py estimates token counts for files or a prompt, context_budget_planner.py allocates a window across components and returns an eviction order on overflow, context_pruner.py strips comments, docstrings, and duplicates from code, and memory_indexer.py builds a TF-IDF index over a directory of notes or docs.

Four placement zones govern every piece of content. Anchors — instructions and the task spec — stay in the window. Decisions and conventions go to a memory file and reload at session start. A large codebase gets indexed and retrieved per step. Recomputable facts such as test output are never stored. Compaction fires at 70–80% of the window: stale tool outputs leave first, then old history is summarised and replaced, but only after conclusions are written to memory.

All scripts accept --json for machine-readable output. context_budget_planner.py exits with 1 on overflow and 2 on bad arguments. Token counting uses roughly 4 characters per token as an approximation; for exact figures, call the provider's token-counting endpoint directly.

What it helps with

  • allocate a token budget across system prompt, history, tools, and RAG
  • build a RAG pipeline over a codebase using a TF-IDF index
  • trigger context compaction before the window ceiling is reached
  • persist decisions and open questions across agent sessions
  • strip comments and duplicates from source files before loading them into context

Example prompts for the agent

  • Analyse token usage in references/ against a budget of 128000 and show what to evict first
  • Run context_pruner.py on src/ with --aggressive and report how many tokens are freed

How to install context-engine

1Skills CLI (Vercel)

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

2Manually: put the files in place

~/.claude/skills/context-engine/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/context-engine/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about context-engine

How do I install context-engine in Claude Code?

Run npx skills add borghei/Claude-Skills --skill context-engine -a claude-code. The skill is then available at ~/.claude/skills/context-engine/SKILL.md.

What does the context-engine skill do?

It guides the agent on what to keep in the active window, what to write to long-term memory, and what to retrieve through an index. The four included scripts handle token analysis, budget planning, code pruning, and memory indexing.

How accurate is the token count from context_analyzer.py?

The script estimates roughly 4 characters per token. For exact numbers, use the token-counting endpoint provided by your model's API.

Similar skills

All skills for Agent setup: memory, context, orchestration →

context-engine by other authors comes first.

context-engine Alireza Rezvani context-engine keeps a company profile in the agent's memory: stage, top challenge, 12-month target. Flags stale notes and strips identifying data before outside calls. CX Codex +1 585installs context-engineering-advisor deanpeters context-engineering-advisor is a Claude Code skill that finds why agent workflows degrade under heavy prompts and helps structure memory retrieval. CX Codex +1 2,800installs Context Engine melonelish Context Engine prepares dense, noise-free context from logs, RAG chunks, and code for LLMs. It trims boilerplate repetitions and sorts key evidence within a token budget. CX Codex +1 ★ 324repo stars agent-platform-rag-engine-management official google The agent-platform-rag-engine-management skill manages Agent Platform RAG Engine corpora and retrieves grounded context with the Google GenAI SDK. It also supports content generation tied to a corpus. CX Codex +1 8,626installs agent-orchestration-context-manager Seth Hobson agent-orchestration-context-manager — a context engineering subagent designed to manage memory architectures and vector retrieval. Useful for long-running workflows and token budget planning. CX Codex ★ 42,780repo stars context-compressor oimiragieo context-compressor compresses large text files, chat histories, and RAG payloads before sending to the model while preserving evidence for correct answers. Reduces token spend when context balloons. CX Codex +1 274installs hindsight-docs vectorize-io hindsight-docs is a Claude Code skill that loads full Hindsight documentation into the agent's context, covering architecture, retain/recall/reflect operations, configuration, and SDK. CX Codex +1 9,700installs

From the same set120

The whole set →
stripe-integration-expert stripe-integration-expert is a Claude Code skill for building Stripe billing integrations for SaaS, covering subscriptions, webhooks, and local testing with Stripe CLI. CX Codex +1 116installs summarize-meeting summarize-meeting — a skill for Claude Code and Codex that turns meeting transcripts into action items and logged decisions. Flags missing assignees or dates instead of inventing them. CX Codex +1 114installs executive-mentor executive-mentor challenges strategic plans, exposes blind spots, and prepares founders for tough board inquiries. CX Codex +1 113installs copy-editing copy-editing — a skill for Claude Code, Codex, Cursor and other agents that runs text through seven sequential editorial passes: clarity, voice, benefit framing, proof, specificity, emotional pull, and CTA friction removal. CX Codex +1 113installs competitive-teardown The competitive-teardown skill structures competitor research, product scoring, and side-by-side comparisons. Use it to inform a roadmap discussion or prepare sales material. CX Codex +1 112installs api-test-suite-builder api-test-suite-builder is a Claude Code skill that creates API test scaffolds from OpenAPI and checks endpoint coverage. Use it to add tests, audit assertions, or spot contract drift. CX Codex +1 111installs brainstorm-okrs brainstorm-okrs — a skill for AI-powered code editors that drafts and validates quarterly OKRs using the Radical Focus method: one objective, three measurable key results, and counter-metrics. CX Codex +1 111installs browser-automation browser-automation is a Claude Code and Codex skill that scaffolds rate-limited Python requests scrapers and form scripts, then audits automation code for server overload and blocking risks. CX Codex +1 111installs

Project sponsors

Companies that keep this analytics open