Skip to content

EA-Studio-SHARK/lean-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lean-code 💰

English | 中文说明

Token-saving skills for Claude Code, Codex, Cursor & Windsurf.

caveman saves tokens by talking like caveman. lean-code saves tokens by being smarter about what gets sent.

Your output tokens are cheap. Your input tokens — the files you load, the history you carry — are where the real bill is.


What it does

4 skills. Each targets a different source of token waste:

Skill What it fixes Typical savings
/diff-only AI rewrites full files for a 3-line fix 60–80% output tokens
/smart-read AI reads 500-line files to find one function 40–90% input tokens
/trim Conversation history balloons over long sessions 55–70% input tokens
/checkpoint Context lost when switching tasks or sessions Compresses 20k tokens → ~500

Benchmark

Real measurements. Claude claude-opus-4-5. 10 prompts per skill.

Skill Output token savings Total token savings
/diff-only 71% output 38% total
/smart-read 12% output 61% total
/trim 8% output 58% total
/checkpoint 45% output 28% total

Last run: 2026-05-22 · Model: claude-opus-4-5

Want to verify? Run python3 benchmarks/run.py with your own API key.


Install

One-liner (auto-detects all agents on your machine):

curl -fsSL https://raw.githubusercontent.com/EA-Studio-SHARK/lean-code/main/install.sh | bash

Per-agent:

Agent Command
Claude Code claude skills install EA-Studio-SHARK/lean-code
Codex npx skills add EA-Studio-SHARK/lean-code -a codex
Cursor npx skills add EA-Studio-SHARK/lean-code -a cursor
Windsurf npx skills add EA-Studio-SHARK/lean-code -a windsurf

Usage

/diff-only      # all code changes shown as diffs from now on
/smart-read     # grep before reading files
/trim           # compress this session's history
/checkpoint     # save portable context snapshot

/diff-only in action

Without lean-code — AI rewrites the whole file:

// Returns 847 tokens of unchanged code + your 3-line fix
class UserService {
  private db: Database;
  constructor(db: Database) { this.db = db; }
  // ... 60 lines you didn't ask to see ...
  async getUser(id: string) {
    return this.db.users.findOne({ id }); // ← the actual fix
  }
}

With /diff-only — AI outputs only what changed:

// filepath: src/services/user.service.ts
- async getUser(id: number) {
+ async getUser(id: string) {
-   return this.db.users.findOne({ id: id });
+   return this.db.users.findOne({ id });
  }

Output: 28 tokens instead of 847. That's 97% less.


/smart-read in action

Without lean-code:

> read src/auth/middleware.ts  ← 340 lines, 2,380 tokens

With /smart-read:

> grep -n "authenticate" src/auth/middleware.ts
  → line 47
> read lines 40-65
  ← 26 lines, 182 tokens

Input: 182 tokens instead of 2,380. That's 92% less.


/trim in action

2-hour session: ~18,000 input tokens of conversation history.
After /trim: ~5,400 tokens. Saves ~70% on every subsequent message.


Cost impact

At Claude claude-opus-4-5 pricing ($3/MTok input, $15/MTok output):

Session type Without lean-code With lean-code Monthly saving
4hr coding session/day ~$8.40/day ~$2.90/day ~$165/month
Background agent (Codex-style) ~$12/day ~$4.10/day ~$236/month

Numbers based on real benchmark runs. Your mileage varies with codebase size.


How it compares to caveman

caveman is brilliant. It saves output tokens by changing how Claude talks.

lean-code saves input tokens by changing what Claude reads.

Use both. They don't overlap.

# install caveman (output savings)
curl -fsSL https://raw.githubusercontent.com/JuliusBrussee/caveman/main/install.sh | bash

# install lean-code (input savings)
curl -fsSL https://raw.githubusercontent.com/EA-Studio-SHARK/lean-code/main/install.sh | bash

Run benchmarks yourself

git clone https://github.com/EA-Studio-SHARK/lean-code
cd lean-code
pip install anthropic
export ANTHROPIC_API_KEY=sk-ant-...
python3 benchmarks/run.py

Results are saved to benchmarks/results/ and README is auto-updated.


🔗 Related Projects

  • awesome-mcp-zh — 🇨🇳 MCP 中文精选指南,国内可用的 MCP 服务器列表
  • china-hot-mcp — 🔥 中国实时热搜 MCP 服务器,让 AI 实时获取中文热点

📖 中文说明

lean-code 是什么?

省 Token 神器 — 给 Claude Code、Cursor、Windsurf、Codex 装上 4 个技能,实测节省 40-80% 的 Token 消耗和费用。

你的输出 Token 其实不贵。真正烧钱的是输入 Token — 你加载的文件、携带的对话历史。

它解决什么问题?

技能 解决的问题 典型节省
/diff-only AI 为了改 3 行代码,重写整个文件 60-80% 输出 Token
/smart-read AI 读完 500 行文件只为找一个函数 40-90% 输入 Token
/trim 长对话的历史越滚越大 55-70% 输入 Token
/checkpoint 切换任务/会话时丢失上下文 2万 Token → ~500

实测数据

基于 Claude claude-opus-4-5,每个技能 10 条 prompt:

技能 输出节省 总节省
/diff-only 71% 38%
/smart-read 12% 61%
/trim 8% 58%
/checkpoint 45% 28%

省多少钱?

按 Claude claude-opus-4-5 定价(输入 $3/百万Token,输出 $15/百万Token):

使用场景 不用 lean-code 用 lean-code 每月省
每天 4 小时编程 ~$8.40/天 ~$2.90/天 ~$165/月
后台 Agent(Codex 模式) ~$12/天 ~$4.10/天 ~$236/月

一键安装

curl -fsSL https://raw.githubusercontent.com/EA-Studio-SHARK/lean-code/main/install.sh | bash

和 Caveman 的区别

Caveman输出 Token(改变 AI 说话方式)。
lean-code 省输入 Token(改变 AI 读取内容)。
两者不冲突,建议同时使用。


License

MIT