mksglu/context-mode

Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and enforces routing across 17 platforms via MCP + hooks.

What it solves

Context Mode addresses the "context window problem" where LLM agents flood their limited memory with raw data from tool calls (like large file reads or web snapshots), causing them to forget previous instructions or lose track of current tasks. It also prevents the agent from wasting tokens on verbose, prose-style filler when performing technical analysis.

How it works

Context Mode is an MCP (Model Context Protocol) server that implements four primary strategies to preserve context:

  1. Context Saving: It uses sandbox tools to keep raw data out of the main context window, significantly reducing token consumption.
  2. Session Continuity: It tracks file edits, git operations, and user decisions in a SQLite database. Instead of dumping all history back into the context, it uses FTS5 and BM25 search to retrieve only the most relevant events.
  3. Think in Code: It encourages the LLM to write and execute scripts (e.g., via ctx_execute) to process data locally rather than reading entire files into the context window for simple analysis.
  4. No Prose-Style Enforcement: It manages where data goes without forcing the model to change its natural speaking style, avoiding the degradation of reasoning benchmarks associated with aggressive brevity prompts.

Who it’s for

Developers using AI agents and LLM-powered IDEs (such as Claude Code, Gemini CLI, VS Code Copilot, JetBrains Copilot, GitHub Copilot CLI, and Cursor) who want to extend their session length and maintain agent coherence over long technical tasks.

Highlights

  • Massive Token Reduction: Claims up to a 98% reduction in context usage for certain tool calls.
  • Wide Platform Support: Integrated with 17+ clients including major AI coding assistants.
  • Persistent Knowledge Base: Uses SQLite and FTS5 for efficient retrieval of session history.
  • Diagnostic Tools: Includes a ctx-doctor for validating runtimes and hooks, and ctx-stats for tracking real-time context savings.

Related

  • Project
  • Project
  • Project
  • Project
  • Project