Context Mode

•
34k
•

Optimizes large language model interactions by significantly reducing context window data and ensuring session continuity.

Context Mode is a crucial virtualization layer for LLM-based development agents, addressing the common problem of rapidly depleting context windows and loss of session state. It functions as an MCP server that intercepts tool calls, sandboxing raw data output to achieve up to a 98% reduction in context window usage. Beyond just saving space, it ensures session continuity by tracking every file edit, git operation, task, and user decision in SQLite. When the agent compacts its conversation, Context Mode indexes these events into FTS5 and retrieves only relevant information via BM25 search, allowing the model to pick up exactly where it left off without re-injecting large amounts of data. This solution dramatically improves the efficiency and reliability of LLM agents across various platforms.

Key Features

013,273 GitHub stars
02Specialized Sandbox Tools: Offers tools like `ctx_execute` (run code with minimal context output), `ctx_index` (chunk markdown into FTS5), and `ctx_fetch_and_index` (fetch and index web content).
03Automated Hook Management: Provides platform-specific hooks to intercept and redirect data-heavy commands, ensuring consistent context optimization.
04Context Saving: Achieves up to 98% reduction in context window data by sandboxing tool outputs.
05Session Continuity: Tracks all session events (file edits, tasks, tool calls) in SQLite and uses FTS5 with BM25 search for intelligent retrieval.
06Broad Platform Support: Integrates seamlessly with Claude Code, Gemini CLI, VS Code Copilot, Cursor, OpenCode, and Codex CLI.

Use Cases

01Reducing token consumption and improving the efficiency of LLM interactions across various development environments.
02Maintaining long-running conversational sessions with LLMs without losing track of previous actions or decisions.
03Developing software with AI agents where large files or extensive logs frequently exceed context window limits.