# mksglu/context-mode

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mksglu-context-mode).**

17,558 stars · 1,251 forks · TypeScript · NOASSERTION

## Links

- GitHub: https://github.com/mksglu/context-mode
- Homepage: https://context-mode.com
- awesome-repositories: https://awesome-repositories.com/repository/mksglu-context-mode.md

## 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`

## Description

This project provides a system for managing agent context and session memory, featuring an agent context compactor, an AI session memory manager, and a tool output sandbox. It functions as a middleware layer and server extension for the Model Context Protocol to optimize context windows and reduce token usage.

The system optimizes agent performance by sandboxing tool outputs and externalizing large data sets, replacing raw I/O with pointers and concise summaries. It employs a persistent knowledge base that indexes session history and tool outputs for retrieval via full-text search, ensuring session continuity across compaction events.

The capability surface includes full-text indexing for web and local content, parallel I/O orchestration for concurrent network and shell commands, and an isolated environment for polyglot code execution. It also incorporates security primitives such as credential redaction, command permission enforcement, and network fetch hardening to block dangerous URL schemes.

The toolkit includes system health verification and diagnostic tools to track context savings and maintain the internal knowledge base.

## Tags

### Artificial Intelligence & ML

- [Agent Session Memory](https://awesome-repositories.com/f/artificial-intelligence-ml/agent-session-memory.md) — Stores session history to allow searching for prior decisions and constraints to resume work without user input. ([source](https://github.com/mksglu/context-mode/blob/main/configs/openclaw/AGENTS.md))
- [Context Window Optimizations](https://awesome-repositories.com/f/artificial-intelligence-ml/context-window-optimizations.md) — Reduces token consumption by sandboxing tool outputs and managing information flow to agents. ([source](https://github.com/mksglu/context-mode/blob/main/.mcp.json.example))
- [Agent Context Management](https://awesome-repositories.com/f/artificial-intelligence-ml/agent-context-management.md) — Optimizes the agent token window by executing custom commands during tool usage and session starts. ([source](https://github.com/mksglu/context-mode/blob/main/configs/jetbrains-copilot/hooks.json))
- [Agent Memory Managers](https://awesome-repositories.com/f/artificial-intelligence-ml/agent-memory-managers.md) — Provides a persistent knowledge base that indexes session history and tool outputs for retrieval via full-text search.
- [MCP Server Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/artificial-intelligence-tooling/agent-and-tool-integrations/mcp-server-integrations.md) — Provides integration with Model Context Protocol servers to manage tool execution and agent context. ([source](https://github.com/mksglu/context-mode/blob/main/docs/jetbrains-copilot.md))
- [Context Management Tools](https://awesome-repositories.com/f/artificial-intelligence-ml/context-management-tools.md) — Intercepts tool execution to manage the context window and reduce token usage through pre- and post-call actions. ([source](https://github.com/mksglu/context-mode/blob/main/configs/vscode-copilot/hooks.json))
- [Knowledge Base Management](https://awesome-repositories.com/f/artificial-intelligence-ml/knowledge-base-management.md) — Maintains a persistent knowledge base of structured information to support automated retrieval for AI agents. ([source](https://github.com/mksglu/context-mode/blob/main/configs/antigravity/GEMINI.md))
- [Knowledge Retrieval Systems](https://awesome-repositories.com/f/artificial-intelligence-ml/knowledge-retrieval-systems.md) — Retrieves specific information from stored content and session history using queries, filters, and timeline sorting. ([source](https://github.com/mksglu/context-mode/blob/main/configs/openclaw/AGENTS.md))
- [Middleware Extensions](https://awesome-repositories.com/f/artificial-intelligence-ml/mcp-servers/middleware-extensions.md) — Ships a middleware layer that intercepts tool calls to optimize argument parameters and token efficiency.
- [Tool Output Sandboxing](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-calling-integration-frameworks/tool-output-processors/tool-output-sandboxing.md) — Redirects data-heavy tool calls to isolated subprocesses and replaces raw output with concise summaries. ([source](https://github.com/mksglu/context-mode/blob/main/configs/cursor/context-mode.mdc))
- [Context Injection](https://awesome-repositories.com/f/artificial-intelligence-ml/context-injection.md) — Dynamically inserts historical data or summaries into AI model prompts to improve decision-making. ([source](https://github.com/mksglu/context-mode/blob/main/docs/platform-support.md))
- [Session History Retrieval](https://awesome-repositories.com/f/artificial-intelligence-ml/conversational-session-management/multi-session-context-synthesizers/session-history-retrieval.md) — Queries indexed session history and decisions to restore context after a session resume. ([source](https://github.com/mksglu/context-mode/blob/main/CLAUDE.md))
- [Argument Repairers](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/decoding-generation-controls/tool-calling/argument-repairers.md) — Intercepts and corrects malformed tool arguments generated by models to improve execution success. ([source](https://github.com/mksglu/context-mode/blob/main/docs/platform-support.md))
- [Workspace-Scoped Context Managements](https://awesome-repositories.com/f/artificial-intelligence-ml/language-model-orchestration/conversation-management/workspace-scoped-context-managements.md) — Isolates prompts and knowledge bases into distinct operational containers based on project workspace paths. ([source](https://github.com/mksglu/context-mode/blob/main/docs/adapters/openclaw.md))
- [Output Filtering](https://awesome-repositories.com/f/artificial-intelligence-ml/query-intent-interpretation/output-filtering.md) — Analyzes large execution results and returns only the sections matching a natural language query. ([source](https://github.com/mksglu/context-mode/blob/main/llms-full.txt))

### Data & Databases

- [Tool Output Summarization](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching-strategies/query-result-caching/method-result-caches/tool-output-summarization.md) — Condenses raw logs, CSVs, and test outputs into concise summaries to preserve context window space. ([source](https://github.com/mksglu/context-mode/blob/main/BENCHMARK.md))
- [Full Text Search](https://awesome-repositories.com/f/data-databases/full-text-search.md) — Implements full-text indexing for large tool outputs and web content to enable precise retrieval via queries.
- [Full-Text Search Engines](https://awesome-repositories.com/f/data-databases/full-text-search-engines.md) — Implements a full-text search index to store and retrieve specific fragments of data instead of loading raw files. ([source](https://github.com/mksglu/context-mode/blob/main/configs/cursor/context-mode.mdc))
- [Search and Indexing](https://awesome-repositories.com/f/data-databases/search-indexing-technologies/search-indexing/search-and-indexing.md) — Allows querying a local full-text index to retrieve relevant fragments of indexed files and web pages. ([source](https://github.com/mksglu/context-mode/blob/main/configs/antigravity/GEMINI.md))
- [Context-Aware Output Routing](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching-strategies/query-result-caching/method-result-caches/tool-output-summarization/context-aware-output-routing.md) — Directs tool execution results through routing rules to control what information enters the context window. ([source](https://github.com/mksglu/context-mode/blob/main/configs/pi/AGENTS.md))
- [Development State Snapshots](https://awesome-repositories.com/f/data-databases/data-snapshotting/viewport-snapshots/development-state-snapshots.md) — Saves and restores project-state snapshots during context compaction to maintain continuity. ([source](https://github.com/mksglu/context-mode/blob/main/docs/platform-support.md))
- [I/O Rate Limiting](https://awesome-repositories.com/f/data-databases/i-o-rate-limiting.md) — Controls the concurrency of network requests and API calls to optimize throughput and respect rate limits. ([source](https://github.com/mksglu/context-mode/blob/main/CLAUDE.md))
- [Web Content Indexing](https://awesome-repositories.com/f/data-databases/search-indexing-technologies/search-indexing/web-content-indexing.md) — Downloads web pages and stores them in a searchable index to enable querying without loading raw HTML. ([source](https://github.com/mksglu/context-mode/blob/main/CLAUDE.md))
- [Interaction Telemetry Capture](https://awesome-repositories.com/f/data-databases/session-state-management/session-state-summarizers/interaction-telemetry-capture.md) — Captures tool inputs, outputs, and responses to allow sessions to be resumed or analyzed through telemetry. ([source](https://github.com/mksglu/context-mode/tree/main/.cursor-plugin))
- [State Reconstruction](https://awesome-repositories.com/f/data-databases/session-state-management/state-reconstruction.md) — Rebuilds active files and task history from database snapshots when event-based compaction hooks are unavailable. ([source](https://github.com/mksglu/context-mode/blob/main/docs/adapters/openclaw.md))
- [Stateful Session Management](https://awesome-repositories.com/f/data-databases/stateful-session-management.md) — Ensures critical information and state are retained across context compaction events. ([source](https://github.com/mksglu/context-mode/blob/main/package.json))

### Development Tools & Productivity

- [Context-Preserving Redirection](https://awesome-repositories.com/f/development-tools-productivity/output-redirection/context-preserving-redirection.md) — Redirects heavy tool data to isolated processes and returns summaries to prevent context window overflow.
- [Sandboxed Execution Environments](https://awesome-repositories.com/f/development-tools-productivity/sandboxed-execution-environments.md) — Provides isolated computing environments to safely run code and prevent context overflow from tool outputs.
- [Lifecycle Hooks](https://awesome-repositories.com/f/development-tools-productivity/lifecycle-hooks.md) — Triggers custom commands during tool usage and context compaction at key lifecycle events. ([source](https://github.com/mksglu/context-mode/blob/main/docs/jetbrains-copilot.md))
- [Parallel Execution](https://awesome-repositories.com/f/development-tools-productivity/parallel-execution.md) — Runs multiple shell or network commands concurrently and returns consolidated search results. ([source](https://github.com/mksglu/context-mode/blob/main/CLAUDE.md))
- [Tool Execution Hooks](https://awesome-repositories.com/f/development-tools-productivity/terminal-shell-cli/terminal-cli-enhancements/shell-terminal-utilities/automation-integration-tools/shell-integration/tool-execution-hooks.md) — Executes custom scripts before and after tool calls to rewrite arguments and manage information flow.

### Security & Cryptography

- [Code Sandboxing Environments](https://awesome-repositories.com/f/security-cryptography/application-and-system-security/sandbox-and-isolation/code-sandboxing-environments.md) — Provides an isolated environment for executing scripts and shell commands to protect the agent's context window. ([source](https://github.com/mksglu/context-mode/blob/main/configs/claude-code/CLAUDE.md))
- [Agentic Session Persistence](https://awesome-repositories.com/f/security-cryptography/identity-access-management/session-management/stateful-session-persistence/agentic-session-persistence.md) — Tracks agent task progress and state in a database to maintain continuity across context compaction events.
- [Database Memory Persistence](https://awesome-repositories.com/f/security-cryptography/identity-access-management/session-management/stateful-session-persistence/agentic-session-persistence/database-memory-persistence.md) — Persists agent states and decisions in a database to ensure continuity across multiple sessions. ([source](https://github.com/mksglu/context-mode/blob/main/configs/gemini-cli/GEMINI.md))
- [Output Externalization](https://awesome-repositories.com/f/security-cryptography/request-size-limiters/output-size-constraints/output-externalization.md) — Indexes content exceeding a size threshold and replaces it with a pointer to prevent context overflow. ([source](https://github.com/mksglu/context-mode/blob/main/BENCHMARK.md))
- [Data Redaction Tools](https://awesome-repositories.com/f/security-cryptography/data-redaction-tools.md) — Automatically identifies and masks sensitive credentials in tool arguments before persisting them to the database. ([source](https://github.com/mksglu/context-mode#readme))
- [Request Forgery Protections](https://awesome-repositories.com/f/security-cryptography/network-security-hardening/request-forgery-protections.md) — Blocks dangerous URL schemes and metadata endpoints to prevent request forgery and DNS rebinding attacks. ([source](https://github.com/mksglu/context-mode/blob/main/README.md))
- [Command Access Rules](https://awesome-repositories.com/f/security-cryptography/permission-systems/command-access-rules.md) — Enforces granular allow and deny rules for shell commands and file access to prevent unauthorized operations. ([source](https://github.com/mksglu/context-mode/blob/main/README.md))
- [Security Request Filters](https://awesome-repositories.com/f/security-cryptography/request-authentication/request-filter-integrations/signal-request-filtering/security-request-filters.md) — Blocks dangerous URL schemes and redacts sensitive credentials from tool arguments before execution.

### DevOps & Infrastructure

- [Code Execution Sandboxes](https://awesome-repositories.com/f/devops-infrastructure/execution-environments/code-execution-runtimes/code-execution-sandboxes.md) — Runs polyglot source code in a sandboxed environment with configurable timeouts and output limits. ([source](https://github.com/mksglu/context-mode/blob/main/llms-full.txt))

### System Administration & Monitoring

- [Parallel Network I/O](https://awesome-repositories.com/f/system-administration-monitoring/administrative-operations/linux-system-administration/networking/connection-lifecycle-management/parallel-network-i-o.md) — Manages concurrent network requests and shell commands to optimize data gathering throughput.
- [Token Savings Trackers](https://awesome-repositories.com/f/system-administration-monitoring/token-savings-trackers.md) — Provides analytics to measure the reduction in token consumption achieved through context optimization. ([source](https://github.com/mksglu/context-mode/blob/main/llms.txt))
