MIT License

项目介绍

g-akshay/ClaudeShrink 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 MIT License 许可证,目前获得 5 个 Star、1 次 Fork。

仓库全名
g-akshay/ClaudeShrink
开源许可证
MIT License
Star 数
5
Fork 数
1

README 摘要

ClaudeShrink A Claude Code skill that shrinks massive prompts and files using LLMLingua to save tokens. This skill enables Claude Code to handle massive files (logs, documentation, long traces) by compressing them using LLMLingua. It uses the gpt2 model locally on your CPU to reduce text size while maintaining semantic integrity, significantly saving context window tokens. Estimated Token Savings ClaudeShrink uses a…

完整内容见 GitHub 原始 README 或本页 。

常见问题

ClaudeShrink 用什么语言开发?

主要使用 Python 编写,采用 MIT License 许可证,目前有 5 个 Star。

ClaudeShrink 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 ClaudeShrink 的源码?

可以直接克隆仓库:git clone https://github.com/g-akshay/ClaudeShrink.git,默认分支为 main;安装与运行步骤见仓库 README。

ClaudeShrink 最近还在维护吗?

仓库最近一次更新为 4月25日,当前没有未关闭的 Issue;Star 数为 5,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A Claude Code skill that shrinks massive prompts and files using LLMLingua to save tokens.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Python
Shell

贡献者

README

ClaudeShrink

A Claude Code skill that shrinks massive prompts and files using LLMLingua to save tokens.

This skill enables Claude Code to handle massive files (logs, documentation, long traces) by compressing them using LLMLingua. It uses the gpt2 model locally on your CPU to reduce text size while maintaining semantic integrity, significantly saving context window tokens.

Estimated Token Savings

ClaudeShrink uses a dynamic adaptive sizing algorithm to decide how heavily to compress inputs. By default, it targets a ~70% reduction but respects hard floors and ceilings.

Input Type Text Size Original Tokens Compressed Tokens Reduction Notes
Small Prompts < 2,000 chars ~500 ~500 0% Meets 512-token safety floor; stays uncompressed
Large Texts ~15,000 chars ~3,750 ~1,125 ~70% Targets 30% of original tokens
Massive Files > 50,000 chars > 12,500 4,096 > 70-90% Hits the 4096-token hard safety cap

Installation

Run this one-liner in your terminal:

curl -fsSL https://raw.githubusercontent.com/g-akshay/ClaudeShrink/main/install.sh | bash

This will:

  1. Clone the repo into ~/.claude/skills/ClaudeShrink
  2. Create an isolated Python venv (no system pollution)
  3. Install llmlingua, torch, transformers, and accelerate

Requirements: Python 3.9+ and git must be on your PATH.

  • macOS: install Python via brew install python or python.org
  • Linux (Ubuntu/Debian): sudo apt install python3 git — python3-venv is auto-handled by the installer

Note: The gpt2 model (~500 MB) is downloaded on first use, not at install time.

Updating

To update to the latest version, simply run the exact same command again. It is designed to be safe, additive, and will pull the latest code without destroying your environment:

curl -fsSL https://raw.githubusercontent.com/g-akshay/ClaudeShrink/main/install.sh | bash

System & Hardware Requirements

Because ClaudeShrink uses GPT-2 instead of massive local LLMs, it is incredibly lightweight and runs smoothly in the background while you code.

Component Requirement Explanation
Memory (RAM) 2GB+ (4GB recommended) The local GPT-2 model is tiny. Standard developer machines will not notice it running.
Storage (Disk) ~4GB torch and dependencies take ~3.5GB; the model weights are ~500MB.
Compute Basic CPU No GPU required. Runs lightning-fast on Intel, AMD, and Apple Silicon CPUs.
Software Python 3.9+, Git Standard environment prerequisites.

How to Trigger

Claude will automatically use this skill when it detects a request to process a large file. You can also explicitly trigger it by asking:

“Use the ClaudeShrink skill to read ./very_large_log.log and summarize the errors.”

Configuration

Defaults in scripts/compressor.py:

Setting Default Notes
Model gpt2 Lightweight, CPU-friendly
Device cpu Change to cuda if you have a GPU
Target Tokens Auto (30% of input, 512–4096) Adaptive — no manual tuning needed

Edit ~/.claude/skills/ClaudeShrink/scripts/compressor.py to override.


The “Why”: Solving the AI Budget Burn

As Agentic AI and long context windows become the norm, token consumption has skyrocketed. Sending massive trace logs or full code repositories to LLMs on every query often leads to unseen budget explosions.

Recently, companies like Uber have made headlines for burning through their entire annual AI budgets in mere months. Giving engineers tools to push massive payloads to AI is powerful, but doing so without a compression layer is financially dangerous.

ClaudeShrink prevents this by:

  1. Stripping redundant or low-information tokens exactly where humans easily miss them.
  2. Handling the compression entirely on your local CPU for free before the payload touches the paid cloud API.
  3. Giving AI assistants a standardized, enforced cap on how many tokens they consume per request.

Platform Support

Platform Supported Notes
macOS ✅ Intel + Apple Silicon
Linux ✅ Ubuntu, Debian (auto-installs python3-venv), Fedora, Arch
Windows ⚠️ Via WSL (Ubuntu recommended) only

评论

暂无评论