Stop Dumping 50,000 Tokens Into Your AI Agent.
ctx scans your codebase, extracts an AST Knowledge Graph, and calculates Shannon Entropy $H(P)$ to yield a surgical ~40-token Senior Engineer Context Plan—or pauses at the Clarification Gate when your prompt is ambiguous. Runs on 1–2 CPU cores with zero GPU overhead.
Token Reduction
Strict CPU Bound
Zero GPU Downloads
Shannon Entropy $H(P)$ Distillation in Action
Test how the engine detects ambiguous prompts and prevents hallucinatory multi-file writes.
Shannon Entropy $H(P)$ Distillation Simulator
Watch $H(P)$ evaluate uncertainty and route to either the Clarification Gate or the Senior Context Blueprint.
ctx distillMode: Feature ImplementationMatched src/mcp/tools.js, src/scanner.js, and src/graph.js with 94.2% confidence.
Propagated dependencies across 18 AST edges; identified downstream callers.
Ranked by ΔH / token density. Extracted exported AST signatures only.
H(P) dropped to 0.21 bits. Zero ambiguity. Exact 41-token blueprint produced.
Surgical Context Blueprint (41 tokens | CPU 1 core):
Zero hallucinations. AI receives only exact signatures and AST dependencies.
### Senior Engineer Context Plan (41 tokens)
- Task: update mcp tools and scanner graph
- Engineering Mode: Feature Implementation
- Primary Files to Reference:
• src/mcp/tools.js [js/mcp]
exports: [registerTools, handleCall]
• src/graph.js [js/core]
exports: [buildDependencyGraph]
- Blast Radius (Dependents):
• src/index.js (imports tools)
- Architecture Guardrail:
Keep tool schema backwards compatible.3-Step Workflow: From Repo to Live MCP
Run the CLI in your repository root, distill your prompts, and connect any AI agent.
Scan & Graph AST
Run ctx -d in any repo. The AST scanner parses file dependencies and generates artifacts in context/.
$ ctx -dDistill With EGRD
Run ctx distill "prompt". The entropy governor runs on 1 CPU core, evaluating $H(P)$ to guard against hallucinated multi-file overwrites.
$ ctx distill <prompt>Connect Any MCP Agent
Add our MCP config to Cursor, Antigravity, Claude Code, or VS Code. Your models get live codebase awareness with built-in public tunneling.
$ ctx serveModel Context Protocol (MCP) Configuration
Select your client to copy the exact configuration:
{
"mcpServers": {
"context-code": {
"command": "ctx",
"args": ["serve"]
}
}
}Common Workflows with ctx
Commands to eliminate context rot, prevent hallucinated imports, and keep CPU usage capped at 1–2 cores.
1. Zero-Config Workspace Boot (ctx -d)
Run once when you open any repo. Scans files, maps dependencies, starts the MCP server on port 3456, and auto-syncs on save.
⚡ context-gen-cli — Default All-In-One Mode (-d) ✓ Context files generated in context/ (agent.md, agent.json, agent.yaml) ✓ MCP Server live on http://localhost:3456/mcp 👀 Watch Mode: Running in background (auto-syncing changes)
2. Catching Vague Prompts Before AI Guesses
When you type a short, ambiguous prompt, Shannon Entropy stays ≥ 1.5 bits—forcing the AI to ask concrete questions using your actual files.
╔═══════════════════════════════════════════════════════════════╗
║ ⚠️ CLARIFICATION NEEDED — Ambiguous Prompt Detected ║
╚═══════════════════════════════════════════════════════════════╝
▸ 1. Implementation Pattern: Should I extend an existing module?
(e.g., "Follow src/mcp/auth.js" or "Create a standalone module")
▸ 2. Side Effects & Persistence: Persist to disk/DB or stay stateless?3. Senior Engineer Blueprint for Targeted Edits
Give a clear intent and EGRD distills only the exact exports, imports, and downstream Blast Radius callers in ~40 tokens.
╔═══════════════════════════════════════════════════════════════╗ ║ 🧠 SENIOR ENGINEER CONTEXT PLAN (41 tokens | CPU: 1 core) ║ ╚═══════════════════════════════════════════════════════════════╝ 🎯 Task: update mcp tools and scanner graph in src 📂 Primary Files to Reference: ✔ src/graph.js [js/lib] — exports: [buildDependencyGraph] ✔ src/scanner.js [js/lib] — exports: [scanProject] 💥 Blast Radius: src/mcp/server.js, src/mcp/tools.js 🛡️ Architecture Guardrail: Mirror existing patterns; keep modular.
4. Multi-Language & Monorepo Filtering
Works natively across TypeScript, Python, Rust, Go, Dart/Flutter, and C#—automatically detecting apps/ and packages/ workspaces.
🎯 Task: add billing webhook handler (services/api) 📂 Primary Files to Reference: ✔ services/api/routes/webhooks.py [python/api] — exports: [stripe_webhook] ✔ services/api/models/subscription.py [python/model] — exports: [Subscription] 💥 Blast Radius: services/api/main.py
System Design & Technical Pillars
Every layer of ctx delivers maximum semantic context with minimal token overhead and zero cloud dependencies.
Entropy-Guided Reference Distillation (EGRD)
Unlike naive RAG systems that retrieve hundreds of raw code lines, EGRD calculates Shannon Entropy H(P) = -∑ p log₂(p). It measures the ambiguity of your request against your codebase signatures and extracts only surgical AST symbol references.
Hardware-Aware Resource Governor
Runs strictly on 1–2 CPU cores using lightweight quantized ONNX embeddings or probabilistic fallback. Zero CUDA, zero Torch, zero 2GB model downloads.
Dependency & Blast Radius Analysis
Deep static analysis traces import/export relationships, entrypoints, and downstream callers across TypeScript, JavaScript, Python, Go, and Rust projects.
Entrypoints detected:src/index.js, src/distill.js
Graph traversal depth:3 levels (configurable)
Blast radius warning:Active
Multi-Tunnel Remote MCP Server
Share your local project context with cloud-based AI agents via free native SSH tunnels (localhost.run, serveo.net) or token-based providers (ngrok, cloudflared).
Intelligent Security & Redaction
Automatically respects .gitignore, .dockerignore, and .npmignore while redacting API keys, SSH credentials, certificates, and environment secret patterns.
.env & secrets:[REDACTED]
Target storage:Local context/ directory
Third-party telemetry:Zero (Air-gapped)
Raw File Dumps vs. EGRD Distillation
Flooding 1M-token context windows with unrelated boilerplate dilutes attention weights, degrades reasoning accuracy, and increases inference latency.
Raw Context Dump
~50,000 to 120,000 TokensConcatenates dozens of whole source files into the prompt, including unrelated imports, formatting comments, and unused helper routines.
EGRD Surgical Blueprint
~41 to 120 TokensCalculates Shannon Entropy across AST edges, identifies blast radius callers, and feeds the AI only exact type signatures and architecture guardrails.
Frequently Asked Questions
Details on entropy calculation, hardware bounds, and protocol integration.