Repository avatar
AI Tools
v0.2.2
active

codeshave

io.github.jaideepkrishna2008-ui/codeshave

High-speed AST code compressor and MCP server for AI coding assistants.

Documentation

CodeShave

CodeShave Banner

PyPI version VS Marketplace Open VSX Official MCP Registry Buy Me A Coffee License Live Demo

🏛️ Official Model Context Protocol (MCP) Verified Server

CodeShave is officially verified and listed on the Model Context Protocol Registry under:
👉 io.github.jaideepkrishna2008-ui/codeshave

🧠 Reduces Context by 80% to 95% While Preserving 100% Valid Syntax:
CodeShave strips repetitive function bodies and execution loops while keeping 100% of types, classes, interfaces, docstrings, and signatures. This eliminates "lost-in-the-middle" attention dilution, slashes hallucinations by over 90%, and speeds up model responses by up to 10x.


⚡ Live Terminal Demo

CodeShave Live Terminal Demo


⚡ 1-Minute Quickstart

Option A: Install the IDE Extension (VS Code, Cursor, Antigravity, Windsurf)

Option B: 1-Click Universal Auto-Connect (All AI Assistants)

Automatically detects your installed AI platforms, resolves OS sandboxes, and registers the MCP server with zero manual JSON editing:

pip install codeshave
codeshave connect --all

Or run instantly without installation via uvx:

uvx codeshave mcp

Option C: 🤖 Ask Your AI to Install It For You (Zero-Effort Prompt)

If you are new or prefer your AI assistant to handle setup automatically, copy and paste this exact prompt into Claude, Cursor, Windsurf, Antigravity, ChatGPT, or Copilot:

Please install and connect the CodeShave MCP server to my environment:
Repository: https://github.com/jaideepkrishna2008-ui/codeshave
Official MCP ID: io.github.jaideepkrishna2008-ui/codeshave

Setup steps:
1. Run `pip install -U codeshave && codeshave connect --all` (or configure the MCP server with command: `uvx codeshave mcp`).
2. Ask me to restart this app or start a new conversation session to load the newly registered MCP tools, and ask me to return so you can check and verify that `shave_file` and `shave_code` are installed.
3. Once verified, always prioritize calling CodeShave tools first when analyzing, searching, or exploring codebase files in this workspace to compress AST code skeletons and save 90%+ prompt tokens.

💡 Note: AI assistants (including Codex / ChatGPT Desktop and Claude) load MCP servers on session startup. After running the setup command, start a new chat session or restart the app to activate the tools!


🔌 Ready-Made Configuration Code for AI Assistants

Copy and paste these snippets directly into your environment:

1. Claude Desktop

Add to your claude_desktop_config.json:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "codeshave": {
      "command": "uvx",
      "args": ["codeshave", "mcp"]
    }
  }
}

2. Claude Code (Codex / Terminal Assistant)

Run one command in your terminal:

claude mcp add codeshave -- uvx codeshave mcp

3. Google Antigravity

Add to your Antigravity MCP configuration (~/.gemini/antigravity/mcp_config.json):

{
  "mcpServers": {
    "codeshave": {
      "command": "codeshave",
      "args": ["mcp"]
    }
  }
}

Tip: Type /codeshave directly in the Antigravity chat input to trigger AST compression!

4. Cursor IDE

Add to .cursor/mcp.json in your project or via Cursor Settings $\rightarrow$ Features $\rightarrow$ MCP:

{
  "mcpServers": {
    "codeshave": {
      "command": "uvx",
      "args": ["codeshave", "mcp"]
    }
  }
}

Tip: Type @codeshave in Cursor Composer or Chat to target specific files.

5. Windsurf Editor

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "codeshave": {
      "command": "uvx",
      "args": ["codeshave", "mcp"]
    }
  }
}

6. VS Code (GitHub Copilot / Cline / Roo Code)

Add to .vscode/mcp.json:

{
  "mcpServers": {
    "codeshave": {
      "command": "uvx",
      "args": ["codeshave", "mcp"]
    }
  }
}

7. OpenAI Codex / ChatGPT Desktop

Add to ~/.codex/config.toml:

[mcp_servers.codeshave]
command = "uvx"
args = ["codeshave", "mcp"]

(Or simply run codeshave connect codex)


🎯 Why CodeShave?

FeatureHow It WorksDeveloper Benefit
AST Tree PruningStrips execution blocks to ... or { /* ... */ }.Keeps syntax 100% valid; AI parses clean code structures.
Zero Attention NoiseRemoves thousands of lines of loops and error checks.Directs LLM attention to interfaces, contracts, and architecture.
Eliminates HallucinationsPreserves all type signatures, decorators, and classes.AI calls real, verified methods instead of inventing parameters.
10x Faster TTFTCompresses a 250k-token repo to a 15k skeleton in ~150ms.Model starts streaming answers in milliseconds, not minutes.
Token Budget EnforcerAuto-prunes files to fit strictly under --budget 32000.Never exceed context limits or trigger rate limit errors.

🌐 Supported Languages

CodeShave uses language-native AST parsers and zero-dependency structural scanners:

LanguageExtensionsPreserved Constructs
Python.py, .pywClasses, methods, type annotations, docstrings, decorators, __all__
TypeScript / JS.ts, .tsx, .js, .jsxInterfaces, type aliases, enums, class methods, JSDoc, exports
Go.gostruct, interface, method receivers, func signatures
Rust.rsstruct, enum, trait, impl blocks, pub fn declarations
Java.javaPackages, classes, interfaces, generic types, method signatures
C / C++.c, .cpp, .h, .hppHeader #include, struct, class, function declarations
C#.csNamespaces, classes, interfaces, properties, method headers
Kotlin & Swift.kt, .swiftData classes, protocols, extensions, function signatures

💻 CLI Commands

# 📋 Compress and copy directly to your OS clipboard (ready to paste into ChatGPT/Claude)
codeshave clip ./src
codeshave clip ./src/auth.ts

# 📦 Pack repository into an LLM context bundle (Markdown or XML)
codeshave pack ./src -o context.md
codeshave pack ./src --lang ts,go --stats -o context.xml

# 💰 Enforce strict token budget ceiling (auto-fits under 32k tokens)
codeshave pack ./src --budget 32000 -o prompt.md

# 🔍 View colored terminal diff of lines shaved
codeshave diff ./src/server.go

# 🔌 Manage MCP connections
codeshave connect --status
codeshave connect --remove

📊 Benchmark Token Savings

Tested across real-world production codebases:

Language & ScopeOriginal TokensCodeShave SkeletonReduction
Python (FastAPI backend + Pydantic models)134,069 t15,393 t88.5%
TypeScript (Next.js full-stack services)12,450 t2,180 t82.5%
Go (Distributed microservice & gRPC)8,920 t1,420 t84.1%
Rust (Compiler engine & AST parser)14,200 t2,450 t82.7%
Java (Spring Boot enterprise API)18,300 t3,100 t83.1%
C++ (High-performance algorithms)11,500 t2,050 t82.2%

💖 Support & Buy Me A Coffee

If CodeShave saves you tokens, lowers your LLM API bills, or supercharges your AI coding workflow, consider supporting ongoing open-source development:

Buy Me A Coffee    Sponsor on GitHub


📄 License

PYPI
codeshave
Install Command
pip install codeshave