Skip to main content

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 codeshave && codeshave connect --all` (or configure the MCP server with command: `uvx codeshave mcp`).
2. Verify that `shave_file` and `shave_code` tools are available.
3. When analyzing, searching, or exploring codebase files in this workspace, always prioritize calling CodeShave tools first 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?

Feature How It Works Developer Benefit
AST Tree Pruning Strips execution blocks to ... or { /* ... */ }. Keeps syntax 100% valid; AI parses clean code structures.
Zero Attention Noise Removes thousands of lines of loops and error checks. Directs LLM attention to interfaces, contracts, and architecture.
Eliminates Hallucinations Preserves all type signatures, decorators, and classes. AI calls real, verified methods instead of inventing parameters.
10x Faster TTFT Compresses a 250k-token repo to a 15k skeleton in ~150ms. Model starts streaming answers in milliseconds, not minutes.
Token Budget Enforcer Auto-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:

Language Extensions Preserved Constructs
Python .py, .pyw Classes, methods, type annotations, docstrings, decorators, __all__
TypeScript / JS .ts, .tsx, .js, .jsx Interfaces, type aliases, enums, class methods, JSDoc, exports
Go .go struct, interface, method receivers, func signatures
Rust .rs struct, enum, trait, impl blocks, pub fn declarations
Java .java Packages, classes, interfaces, generic types, method signatures
C / C++ .c, .cpp, .h, .hpp Header #include, struct, class, function declarations
C# .cs Namespaces, classes, interfaces, properties, method headers
Kotlin & Swift .kt, .swift Data 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 & Scope Original Tokens CodeShave Skeleton Reduction
Python (FastAPI backend + Pydantic models) 134,069 t 15,393 t 88.5%
TypeScript (Next.js full-stack services) 12,450 t 2,180 t 82.5%
Go (Distributed microservice & gRPC) 8,920 t 1,420 t 84.1%
Rust (Compiler engine & AST parser) 14,200 t 2,450 t 82.7%
Java (Spring Boot enterprise API) 18,300 t 3,100 t 83.1%
C++ (High-performance algorithms) 11,500 t 2,050 t 82.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

Metadata

Release files for codeshave 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeshave 0.2.2
File Size Uploaded Provenance Actions
codeshave-0.2.2.tar.gz 29.9 kB Without provenance Details for codeshave-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codeshave 0.2.2
File Interpreter ABI Platform Actions
codeshave-0.2.2-py3-none-any.whl Python 3 none any Details for codeshave-0.2.2-py3-none-any.whl

Total release size: 55.8 kB

Release files / codeshave-0.2.2.tar.gz

Download URL codeshave-0.2.2.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8f770172bb98eb418a88f2526f9f5c657a94053324713d26ff46cb4ae54ea153
BLAKE2b-256 checksum
How to use checksums
b0ea0214fedfe33f48611d4b0b032872fd1864a6551a81d51feae062166c4f83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / codeshave-0.2.2-py3-none-any.whl

Download URL codeshave-0.2.2-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bad030ea349ad124e5958737cf7b3f7fb551e3061922900b499bf666e737c675
BLAKE2b-256 checksum
How to use checksums
23693c17582e28faf0263e39fef088900f14adad4c230000ff27578a67541078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for codeshave 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page