{"data":{"slug":"mksglu-context-mode","name":"context-mode","tagline":"Context window optimization for AI coding agents","github_url":"https://github.com/mksglu/context-mode","owner":"mksglu","repo":"context-mode","owner_avatar_url":"https://avatars.githubusercontent.com/u/6067714?v=4","primary_language":"TypeScript","stars":20138,"forks":1458,"topics":["antigravity","claude","claude-code","claude-code-hooks","claude-code-plugins","claude-code-skill","codex","codex-cli","context-mode","copilot","cursor-plugin","kiro","mcp","mcp-server","mcp-tools","openclaw","opencode","pi-agent","skills","zed-extension"],"archived":false,"github_pushed_at":"2026-08-25T12:06:51+00:00","maintenance_label":"Very active","stars_delta_30d":810,"url":"https://www.graphcanon.com/tools/mksglu-context-mode","markdown_url":"https://www.graphcanon.com/tools/mksglu-context-mode.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/mksglu-context-mode","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=mksglu-context-mode","description":"Context window optimization for AI coding agents. Sandboxes tool output (98% reduction), persists session memory, and   enforces routing across 17 platforms via MCP + hooks.","homepage_url":"https://context-mode.com","license":"Other","open_issues":180,"watchers":85,"ai_summary":"A tool that optimizes context windows for AI coding agents by sandboxing outputs and persisting session memory with support across multiple platforms using MCP plus hooks.","readme_excerpt":"## Install\n\nPlatforms are grouped by install complexity. Hook-capable platforms get automatic routing enforcement. Non-hook platforms need a one-time routing file copy.\n\n<details open>\n<summary><strong>Claude Code</strong> — plugin marketplace, fully automatic</summary>\n\n**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`.\n\n**Install:**\n\n```bash\n/plugin marketplace add mksglu/context-mode\n/plugin install context-mode@context-mode\n```\n\nRestart Claude Code (or run `/reload-plugins`).\n\n**Verify:**\n\n```\n/context-mode:ctx-doctor\n```\n\nAll checks should show `[x]`. The doctor validates runtimes, hooks, FTS5, and plugin registration.\n\n**Routing:** Automatic. The SessionStart hook injects routing instructions at runtime — no file is written to your project. The plugin registers all hooks (PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, SessionStart, Stop) and 11 MCP tools — six sandbox tools (`ctx_batch_execute`, `ctx_execute`, `ctx_execute_file`, `ctx_index`, `ctx_search`, `ctx_fetch_and_index`) plus five meta-tools (`ctx_stats`, `ctx_doctor`, `ctx_upgrade`, `ctx_purge`, `ctx_insight`).\n\n| Slash Command | What it does |\n|---|---|\n| `/context-mode:ctx-stats` | Context savings — per-tool breakdown, tokens consumed, savings ratio. |\n| `/context-mode:ctx-doctor` | Diagnostics — runtimes, hooks, FTS5, plugin registration, versions. |\n| `/context-mode:ctx-index` | Index a local file or directory into the persistent FTS5 knowledge base. |\n| `/context-mode:ctx-search` | Search previously indexed content. |\n| `/context-mode:ctx-upgrade` | Pull latest, rebuild, migrate cache, fix hooks. |\n| `/context-mode:ctx-purge` | Permanently delete all indexed content from the knowledge base. |\n| `/context-mode:ctx-insight` | Opens the hosted Insight dashboard ([context-mode.com/insight](https://context-mode.com/insight)) in your browser — org analytics for AI-assisted engineering teams. |\n\n> **Note:** Slash commands are a Claude Code plugin feature. On other platforms, type `ctx stats`, `ctx doctor`, `ctx index`, `ctx search`, `ctx upgrade`, or `ctx insight` in the chat — the model calls the MCP tool automatically. See [Utility Commands](#utility-commands).\n\n**Status line (optional):** Claude Code's plugin manifest cannot declare a status line, so this is a one-time manual edit to `~/.claude/settings.json`:\n\n```json\n{\n  \"statusLine\": {\n    \"type\": \"command\",\n    \"command\": \"context-mode statusline\"\n  }\n}\n```\n\nAfter saving, restart Claude Code. The bar shows `$ saved this session · $ saved across sessions · % efficient` so you can see savings accumulate in real time. The wiring is path-free — `context-mode statusline` resolves through the bundled CLI regardless of where the plugin cache lives.\n\n<details>\n<summary>Alternative — MCP-only install (no hooks or slash commands)</summary>\n\n```bash\nclaude mcp add context-mode -- npx -y context-mode\n```\n\nThis gives you all 11 MCP tools 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.\n\n</details>\n\n</details>\n\n<details>\n<summary><strong>Gemini CLI</strong> — one config file, hooks included</summary>\n\n**Prerequisites:** Node.js >= 22.5 (or Bun), Gemini CLI installed.\n\n**Install:**\n\n1. Install context-mode globally:\n\n   ```bash\n   npm install -g context-mode\n   ```\n\n2. Add the following to `~/.gemini/settings.json`. This single file registers the MCP server and all four hooks:\n\n   ```json\n   {\n     \"mcpServers\": {\n       \"context-mode\": {\n         \"command\": \"context-mode\"\n       }\n     },\n     \"hooks\": {\n       \"BeforeTool\": [\n         {\n           \"matcher\": \"run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill|mcp__plugin_context-mode|mcp__context-mode|mcp__(?!.*context-mode)\",\n           \"hooks\": [{","github_created_at":"2026-02-23T05:56:28+00:00","created_at":"2026-07-11T11:48:29.459276+00:00","updated_at":"2026-08-26T00:01:55.377187+00:00","categories":[{"slug":"ai-agents","name":"AI Agents","url":"https://www.graphcanon.com/categories/ai-agents","markdown_url":"https://www.graphcanon.com/categories/ai-agents.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/ai-agents"}],"tags":[{"slug":"antigravity","name":"antigravity"},{"slug":"claude-code","name":"claude-code"},{"slug":"copilot","name":"copilot"},{"slug":"mcp","name":"mcp"},{"slug":"skills","name":"skills"}],"trust":{"provenance":{"is_fork":false,"github_id":1164477708,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-08-26T00:01:54.368Z","maintenance":{"label":"Very active","score":96,"methodology":"github_public_v1","releases_90d":18,"days_since_push":0,"last_release_at":"2026-06-29T18:18:53Z","stars_delta_30d":810,"open_issues_delta_30d":72},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-12T04:02:07.123Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"mcp":{"source":"package.json:@modelcontextprotocol/*","observed_at":"2026-08-26T00:01:54.811Z","server_manifest":true},"scan":{"source":"repo_scan","observed_at":"2026-08-26T00:01:54.811Z"},"has_cli":{"value":true,"source":"package.json:bin|scripts","observed_at":"2026-08-26T00:01:54.811Z"},"languages":{"value":["typescript","javascript"],"source":"github.language+package.json","observed_at":"2026-08-26T00:01:54.811Z"},"license_spdx":{"value":"Other","source":"github.license","observed_at":"2026-08-26T00:01:54.811Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":null,"constraints":null,"when_to_use":["You require seamless support for multiple coding environments including antigravity, claude-code, codex, copilot, and more.","Your use case involves frequent switching between coding tasks needing a persistent context window without losing memory state."],"when_not_to_use":["Your project works only on platforms not covered by the 17 supported environments listed in the repository topics section.","You need real-time updates and direct manipulation of code snippets that bypass the sandboxed output feature, as it enforces an up to 98% reduction without manual override options."],"source":"enrich:decision_facts","observed_at":"2026-07-17T07:17:23.478Z"},"constraint_facets":null,"decision_summary":[{"label":"Adopt for","value":"Optimizes AI coding agent context windows via sandboxing and persisting session memory across 17 platforms using MCP plus hooks."},{"label":"License detail","value":"Other license type applies. Consult license file for exact terms."}]}}