context-mode
mksglu/context-mode · Updated
Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and enforces routing across 17 platforms via MCP + hooks.
mksglu/context-mode is a TypeScript repository in the Coding Assistants category with 32,791 stars and 2,266 forks on GitHub, last updated today.
How to install context-mode in your AI client
Setup for Claude Code, Claude Desktop, Cursor, Codex, Windsurf, Cline and VS Code — copy-paste ready.
How to install context-mode in Claude CodeAnthropic's agentic CLI
Clone & open
bashgit clone https://github.com/mksglu/context-mode.git cd context-mode claudeLet Claude read it
Ask “/init” to generate a CLAUDE.md, then have Claude explain, run, or extend the codebase. It reads files on demand.
How to install context-mode in Claude DesktopDesktop app (MCP config)
Clone the repository
bashgit clone https://github.com/mksglu/context-mode.gitOpen in your AI editor
Open the folder in your assistant and ask it to index the codebase, then reference files in chat.
How to install context-mode in CursorAI-first code editor
Clone & open in Cursor
bashgit clone https://github.com/mksglu/context-mode.gitIndex & chat
Open the folder — Cursor indexes it automatically. Use @Codebase in chat to ask about it or scaffold from it.
How to install context-mode in Codex CLIOpenAI coding agent
Clone
bashgit clone https://github.com/mksglu/context-mode.gitPoint Codex at it
Run codex in the repo root; add setup notes to AGENTS.md so the agent knows how to build & test.
How to install context-mode in WindsurfCodeium's agentic IDE
Clone & open
bashgit clone https://github.com/mksglu/context-mode.gitUse Cascade
Windsurf indexes the workspace; ask Cascade to explain or reuse modules from the repo.
How to install context-mode in ClineVS Code autonomous agent
Clone the repository
bashgit clone https://github.com/mksglu/context-mode.gitOpen in your AI editor
Open the folder in your assistant and ask it to index the codebase, then reference files in chat.
How to install context-mode in VS CodeCopilot / MCP support
Clone the repository
bashgit clone https://github.com/mksglu/context-mode.gitOpen in your AI editor
Open the folder in your assistant and ask it to index the codebase, then reference files in chat.
Documentation
Full READMEContext Mode
The other half of the context problem.
<sub>Used across teams at</sub>
The Problem
Every MCP tool call dumps raw data into your context window. A Playwright snapshot costs 56 KB. Twenty GitHub issues cost 59 KB. One access log — 45 KB. After 30 minutes, 40% of your context is gone. And when the agent compacts the conversation to free space, it forgets which files it was editing, what tasks are in progress, and what you last asked for. On top of that, the agent wastes output tokens on filler, pleasantries, and verbose explanations — burning context from both sides.
How Context Mode Solves It
Context Mode is an MCP server that solves all four sides of this problem:
- Context Saving — Sandbox tools keep raw data out of the context window. 315 KB becomes 5.4 KB. 98% reduction.
- Session Continuity — Every file edit, git operation, task, error, and user decision is tracked in SQLite. When the conversation compacts, context-mode doesn't dump this data back into context — it indexes events into FTS5 and retrieves only what's relevant via BM25 search. The model picks up exactly where you left off. If you don't
--continue, previous session data is deleted immediately — a fresh session means a clean slate. - Think in Code — The LLM should program the analysis, not compute it. Instead of reading 50 files into context to count functions, the agent writes a script that does the counting and
console.log()s only the result. One script replaces ten tool calls and saves 100x context. This is a mandatory paradigm across all 17 supported clients, plus the OpenClaw gateway integration: stop treating the LLM as a data processor, treat it as a code generator.
// Before: 47 × Read() = 700 KB. After: 1 × ctx_execute() = 3.6 KB.
ctx_execute("javascript", `
const files = fs.readdirSync('src').filter(f => f.endsWith('.ts'));
files.forEach(f => console.log(f + ': ' + fs.readFileSync('src/'+f,'utf8').split('\\n').length + ' lines'));
`);- No prose-style enforcement — context-mode keeps raw data out of context but never dictates how the model writes its final answer. Brevity, completeness, formatting — your model's call (or yours via your own
CLAUDE.md/AGENTS.md). Aggressive brevity prompts have been shown to degrade coding/reasoning benchmarks (Moonshot AI on `kimi-k2.5`) — the routing block stays focused on *where data goes*, not on *how the model talks*.
Install
Platforms are grouped by install complexity. Hook-capable platforms get automatic routing enforcement. Non-hook platforms need a one-time routing file copy.
<details open> <summary><strong>Claude Code</strong> — plugin marketplace, fully automatic</summary>
Prerequisites: Claude Code v1.0.33+ (claude --version). If /plugin is not recognized, update first: brew upgrade claude-code or npm update -g @anthropic-ai/claude-code.
Excerpt — the full document is on GitHub.
More Coding Assistants repositories
- Coding Assistants144k
system-prompts-and-models-of-ai-tools
FULL Augment Code, Claude Code, Cluely, CodeBuddy, Comet, Cursor, Devin AI, Junie, Kiro, Leap.new, Lovable, Manus, NotionAI, Orchids.app, Perplexity, Poke, Qoder, Replit, Same.dev, Trae, Traycer AI, VSCode Agent, Warp.dev, Windsurf, Xcode, Z.ai Code, Dia & v0. (And other Open Sourced) System Prompts, Internal Tools &…
GPL-3.0x1xhlol/system-prompts-and-models-of-ai-tools
- Coding Assistants144k
spec-kit
💫 Toolkit to help you get started with SDD or any other process!
PythonMITgithub/spec-kit
- Coding Assistants142k
ui-ux-pro-max-skill
An AI skill that provides design intelligence for building professional UI/UX across multiple platforms.
PythonMITnextlevelbuilder/ui-ux-pro-max-skill
- Coding Assistants42k
chatbox
Powerful AI Client
TypeScriptGPL-3.0chatboxai/chatbox
- Coding Assistants38k
CopilotKit
The Frontend Stack for Agents & Generative UI. React, Angular, Mobile, Slack, and more. Makers of the AG-UI Protocol
TypeScriptMITCopilotKit/CopilotKit
- Coding Assistants32k
9router
Unlimited FREE AI coding. Connect Claude Code, Codex, Cursor, Cline, Copilot, Antigravity to FREE Claude/GPT/Gemini via 40+ providers. Auto-fallback, RTK -40% tokens, never hit limits.
JavaScriptMITdecolua/9router
Catalog data refreshed . Something wrong? Report it.