back to home

mksglu / context-mode

Privacy-first. MCP is the protocol for tool access. We're the virtualization layer for context.

4,976 stars
305 forks
5 issues
JavaScriptTypeScriptShell

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing mksglu/context-mode in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/mksglu/context-mode)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Context Mode **The other half of the context problem.** Privacy & Architecture Context Mode is not a CLI output filter or a cloud analytics dashboard. It operates at the MCP protocol layer — raw data stays in a sandboxed subprocess and never enters your context window. Web pages, API responses, file analysis, Playwright snapshots, log files — everything is processed in complete isolation. **Nothing leaves your machine.** No telemetry, no cloud sync, no usage tracking, no account required. Your code, your prompts, your session data — all local. The SQLite databases live in your home directory and die when you're done. This is a deliberate architectural choice, not a missing feature. Context optimization should happen at the source, not in a dashboard behind a per-seat subscription. Privacy-first is our philosophy — and every design decision follows from it. License → 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. Context Mode is an MCP server that solves both halves 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 , previous session data is deleted immediately — a fresh session means a clean slate. https://github.com/user-attachments/assets/07013dbf-07c0-4ef1-974a-33ea1207637b Install Claude Code **Step 1 — Install the plugin:** **Step 2 — Restart Claude Code.** That's it. The plugin installs everything automatically: • MCP server with 6 sandbox tools ( , , , , , ) • PreToolUse hooks that intercept Bash, Read, WebFetch, Grep, and Task calls — nudging them toward sandbox execution • PostToolUse, PreCompact, and SessionStart hooks for session tracking and context injection • A routing instructions file auto-created in your project root • Slash commands for diagnostics and upgrades (Claude Code only) | Command | What it does | |---|---| | | Context savings — per-tool breakdown, tokens consumed, savings ratio. | | | Diagnostics — runtimes, hooks, FTS5, plugin registration, versions. | | | Pull latest, rebuild, migrate cache, fix hooks. | > **Note:** Slash commands are a Claude Code plugin feature. On other platforms, all three utility commands ( , , ) work as MCP tools — just type the command name and the model will invoke it. See Utility Commands. **Alternative — MCP-only install** (no hooks or slash commands): This gives you the 6 sandbox tools but without automatic routing. The model can still use them — it just won't be nudged to prefer them over raw Bash/Read/WebFetch. Good for trying it out before committing to the full plugin. Gemini CLI **Step 1 — Install globally:** **Step 2 — Register the MCP server.** Add to : **Step 3 — Add hooks.** Without hooks, the model can ignore routing instructions and dump raw output into your context window. Hooks intercept every tool call and enforce sandbox routing programmatically — blocking , , and other data-heavy commands before they execute. Add to the same : **Step 4 — Restart Gemini CLI.** On first session start, the sessionstart hook automatically manages routing instructions in your project root: • **File does not exist** — the routing instructions file is written. • **File exists without context-mode rules** — routing instructions are appended after your existing content. • **File already contains context-mode rules** — skipped (idempotent, no duplicate content). This works alongside hooks as a parallel enforcement layer — hooks block dangerous commands programmatically, while teaches the model to prefer sandbox tools from the start. > **Why hooks matter:** Without hooks, context-mode relies on instructions alone (~60% compliance). The model sometimes follows them, but regularly runs raw , reads large files directly, or dumps unprocessed output into context — a single unrouted Playwright snapshot (56 KB) wipes out an entire session's savings. With hooks, every tool call is intercepted before execution — dangerous commands are blocked, and routing guidance is injected in real-time. This is the difference between ~60% and ~98% context savings. Full hook config including PreCompress: VS Code Copilot **Step 1 — Install globally:** **Step 2 — Register the MCP server.** Create in your project root: **Step 3 — Add hooks.** Without hooks, the model can bypass routing and dump raw output into your context. Hooks intercept every tool call and enforce sandbox routing programmatically. Create : **Step 4 — Restart VS Code.** On first session start, the sessionstart hook automatically manages routing instructions in your project: • **File does not exist** — is created and the routing instructions file is written. • **File exists without context-mode rules** — routing instructions are appended after your existing content, preserving project-level coding standards. • **File already contains context-mode rules** — skipped (idempotent, no duplicate content). This works alongside hooks as a parallel enforcement layer — hooks intercept tool calls programmatically, while guides the model's tool selection from session start. > **Why hooks matter:** Without hooks, guides the model but can't block commands. A single unrouted Playwright snapshot (56 KB) or (59 KB) wipes out minutes of context savings. With hooks, these calls are intercepted and redirected to the sandbox before they execute. Full hook…