context-slim
ContextSlim
Spare 50%+ KI-Kontext-Token, ohne kritische Codesemantik zu verlieren.
Code: github.com/lilite572-cyber/context-slim · Installation: @idmxgne/context-slim (npm-Konto idmxgne). Nicht Jagganus context-slim (CLI-Ausgabe-Trimmer).
Cursor, Claude und andere Coding-Agenten lesen bei jeder Runde ganze Dateien erneut. Der Großteil dieses Budgets sind JSDoc, ungenutzte Imports und DTO-Mapper. ContextSlim parst JS/TS (Babel) und PHP (php-parser), höhlt das Rauschen aus und behält try/catch, Auth-Methoden, env() / process.env sowie Marker wie FIXME / SECURITY / В ПРОД НЕ ГНАТЬ.
Vorher / Nachher
Gemessen am realen Billing-Controller in tests/fixtures/real_world_controller.ts (--signatures-only):
Tokens | Was du behältst | |
Vorher | 3.522 | Kommentare, Mapper, ungenutzte Imports, jeder Methodenrumpf |
Nachher | 1.408 | Signaturen + kritische Rümpfe + geschützte Kommentare |
Ersparnis | 60% (10 Labels behalten) | try/catch, |
CLI-Statistiken verwenden gpt-tokenizer (o200k_base, GPT-4o / GPT-5-Familie) und werden auf stderr ausgegeben. Der geschlankte Quellcode geht an stdout.
npx -y --package=@idmxgne/context-slim context-slim .
# Исходный размер: 3,522 токенов -> Сжатый: 1,408 токенов. Экономия: 60% ...Die Binärdatei heißt context-slim, nicht @idmxgne/context-slim. Das gescopte npx @idmxgne/context-slim . schlägt mit command not found fehl.
Related MCP server: cctx-mcp
Schnellstart
npx -y --package=@idmxgne/context-slim context-slim .
npx -y --package=@idmxgne/context-slim context-slim ./src --signatures-only
npx -y --package=@idmxgne/context-slim context-slim ./src --out slim.txt
npx -y --package=@idmxgne/context-slim context-slim-mcpAus einem Klon:
npm i && npm run build
node dist/cli.js ./srcMCP-Server (Cursor, Windsurf, Claude Code)
Bin: context-slim-mcp → dist/mcp.js. Offizieller @modelcontextprotocol/sdk-Server + StdioServerTransport. Schreibe keine Logs nach stdout.
Prompt use-slim-context:
Bevorzuge beim Lesen von Quelldateien immer das Tool
read_slim_file, um das Kontextfenster zu optimieren.
Tools:
Tool | Args | Ergebnis |
|
| komprimierter Quellcode |
| keine | letzter Lauf: Tokens vorher / nachher, |
Cursor
In ~/.cursor/mcp.json einfügen (fertige Kopie: examples/cursor-mcp.json):
{
"mcpServers": {
"context-slim": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/context-slim/dist/mcp.js"]
}
}
}Nach npm publish:
{
"mcpServers": {
"context-slim": {
"command": "npx",
"args": ["-y", "--package=@idmxgne/context-slim", "context-slim-mcp"]
}
}
}Cursor neu starten und den Agenten bitten, read_slim_file auf einem fetten Controller auszuführen.
Windsurf
Derselbe mcpServers-Block in der MCP-Konfiguration von Windsurf (~/.codeium/windsurf/mcp_config.json oder im MCP-Panel in den Einstellungen). command auf node + dist/mcp.js oder wie oben auf npx zeigen lassen.
Claude Code / Claude Desktop
Claude Desktop — examples/claude_desktop_config.json in claude_desktop_config.json einfügen:
{
"mcpServers": {
"context-slim": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/context-slim/dist/mcp.js"]
}
}
}Claude Code:
claude mcp add context-slim -- node /ABSOLUTE/PATH/TO/context-slim/dist/mcp.jsSichere Labels (.contextslimrc + isCriticalNode)
Ein Knoten wird nie ausgehöhlt, wenn isCriticalNode das sagt:
Kommentare, die CRITICAL, FIXME, TODO, SECURITY, DONT TOUCH,
В ПРОД НЕ ГНАТЬ,@keepentsprechentry/catchMethoden, deren Namen nach Auth aussehen (
authorize,login,jwt,csrf, …)env(),getenv(),process.envPHP/Laravel:
$this->hasMany/$this->belongsTo(und andere Eloquent-Beziehungen) sowiescope*-Methoden
Repo: https://github.com/lilite572-cyber/context-slim
Weitere Phrasen in .contextslimrc im Projektstamm ablegen:
{
"keep_patterns": ["HACK", "LEGACY"]
}entry_patterns (Standard: index / cli / main / app / server) behalten gewöhnliche Funktionsrümpfe auch ohne --signatures-only. Abhängigkeitsdateien werden ausgehöhlt; --signatures-only (oder MCP signaturesOnly: true) übergeben, um alles auszuhöhlen, was nicht kritisch ist.
Installation / Veröffentlichung
npm i
npm test
npm run buildBins: context-slim → ./dist/cli.js, context-slim-mcp → ./dist/mcp.js. npm: @idmxgne/context-slim. GitHub: lilite572-cyber/context-slim. Lizenz: MIT.
Lizenz
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that gives your AI access to the source code and docs of all public github repos
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityAmaintenanceMCP server that reduces token consumption in AI coding assistants by up to 90% via structural reads, PreToolUse hooks, and tp-\* subagents.251,669 npm5MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides structure-aware code analysis (symbol trees, dependencies, docs) to reduce AI agent token consumption by up to 99%, along with Git commit intelligence.MIT
- AlicenseAqualityDmaintenanceAn AST-based MCP server that provides token-efficient codebase skeletons to LLM agents, reducing context token usage by 80-95% by exposing structural information instead of full source files.511 npm3MIT
- -licenseNot gradedqualityNot gradedmaintenanceAST-aware code exploration MCP server for AI agents, optimized for token efficiency.-