Skip to content

Hayatelin/caveman-zh-CN / skills/caveman-compress

caveman-compress

Unverified

把自然语言的记忆文件(CLAUDE.md、待办、偏好设置)压缩成 caveman 格式,省下 input token。 完整保留所有技术内容、代码、URL 与结构。 压缩版会覆写原文件,人类可读的备份存成 FILE.original.md。 Trigger: /caveman-compress FILEPATH or "compress memory file"

FileKindSize
README.mdmarkdown5.4 KB
SECURITY.mdmarkdown1.5 KB
SKILL.mdskill md4.4 KB
scripts/__init__.pyscript224 B
scripts/__main__.pyscript30 B
scripts/benchmark.pyscript2.4 KB
scripts/cli.pyscript2.0 KB
scripts/compress.pyscript12.8 KB
scripts/detect.pyscript4.6 KB
scripts/validate.pyscript5.6 KB
<p align="center">
  <img src="https://em-content.zobj.net/source/apple/391/rock_1faa8.png" width="80" />
</p>

<h1 align="center">caveman-compress</h1>

<p align="center">
  <strong>记忆文件变小。每个 session 都省 token。</strong>
</p>

---

一个 Claude Code skill,把你的项目记忆文件(`CLAUDE.md`、待办、偏好设置)压成 caveman 格式——之后每个 session 自动少加载一堆 token。

Claude 每次开 session 都读 `CLAUDE.md`。文件大,成本就大。Caveman 让文件变小。成本永远降下去。

## 它做什么

```
/caveman-compress CLAUDE.md
```

```
CLAUDE.md          ← 压缩版(Claude 读这个——每个 session 少吃 token)
CLAUDE.original.md ← 人类可读的备份(你编辑这个)
```

原文件绝不遗失。你可以读、可以改 `.original.md`。改完再跑一次 skill 重新压缩。

## 实测数据

真实项目文件的真实结果:

| 文件 | 原始 | 压缩后 | 省下 |
|------|----------:|----------:|------:|
| `claude-md-preferences.md` | 706 | 285 | **59.6%** |
| `project-notes.md` | 1145 | 535 | **53.3%** |
| `claude-md-project.md` | 1122 | 636 | **43.3%** |
| `todo-list.md` | 627 | 388 | **38.1%** |
| `mixed-with-code.md` | 888 | 560 | **36.9%** |
| **平均** | **898** | **481** | **46%** |

所有验证全数通过 ✅ — 标题、代码区块、URL、文件路径完全保留。

## 压缩前/压缩后

<table>
<tr>
<td width="50%">

### 📄 原始(706 tokens)

> "I strongly prefer TypeScript with strict mode enabled for all new code. Please don't use `any` type unless there's genuinely no way around it, and if you do, leave a comment explaining the reasoning. I find that taking the time to properly type things catches a lot of bugs before they ever make it to runtime."

</td>
<td width="50%">

### <img src="../../docs/assets/dancing-rock.svg" width="20" height="20" alt="rock"/> Caveman(285 tokens)

> "Prefer TypeScript strict mode always. No `any` unless unavoidable — comment why if used. Proper types catch bugs early."

</td>
</tr>
</table>

**同样的指示。少 60% token。每。一。个。Session。**

## 安全性

`caveman-compress` 被 Snyk 标为 High Risk,原因是静态分析侦测到 subprocess 与文件 I/O 的模式。这是误判——完整说明请见 [SECURITY.md](./SECURITY.md),里面讲清楚这个 skill 做什么、不做什么。

## 安装

Compress 内置在 `caveman` plugin 里。装一次 `caveman`,之后就能用 `/caveman-compress`。

如果你需要本地文件,compress skill 位于:

```bash
caveman-compress/
```

**需求:**Python 3.10+

## 用法

```
/caveman-compress <filepath>
```

范例:
```
/caveman-compress CLAUDE.md
/caveman-compress docs/preferences.md
/caveman-compress todos.md
```

### 哪些文件可以压

| 类型 | 压缩? |
|------|-----------|
| `.md`、`.txt`、`.rst`、`.typ`、`.typst`、`.tex` | ✅ 可以 |
| 无扩展名的自然语言文件 | ✅ 可以 |
| `.py`、`.js`、`.ts`、`.json`、`.yaml` | ❌ 跳过(代码/设置) |
| `*.original.md` | ❌ 跳过(备份文件) |

## 它怎么运作

```
/caveman-compress CLAUDE.md
        ↓
判断文件类型            (不耗 token)
        ↓
Claude 进行压缩         (耗 token——一次调用)
        ↓
验证输出                (不耗 token)
  检查:标题、代码区块、URL、文件路径、项目符号
        ↓
若有错误:Claude 只修被挑出来的问题          (耗 token——定点修正)
  不重新压缩——只修补坏掉的部分
        ↓
最多重试 2 次
        ↓
写入压缩版 → CLAUDE.md
写入原始版 → CLAUDE.original.md
```

只有两件事会耗 token:初次压缩,以及验证失败时的定点修正。其他全是本机 Python。

## 什么会被保留

Caveman 压的是自然语言。它绝不碰:

- 代码区块(` ``` ` 围住的或缩进的)
- 行内代码(`` `反引号内容` ``)
- URL 与链接
- 文件路径(`/src/components/...`)
- 指令(`npm install`、`git commit`)
- 技术术语、函数库名称、API 名称
- 标题(文本完全保留)
- 表格(结构保留,保存格文本压缩)
- 日期、版本号、数值

## 这为什么重要

`CLAUDE.md` 在**每次 session 开始**时加载。一个 1000 token 的项目记忆文件,每次开项目都要付一次。100 个 session 就是 100,000 token 的额外开销——而且只是为了你早就写好的脉络。

Caveman 平均砍掉约 46%。同样的指示。同样的准确度。少一堆浪费。

```
┌────────────────────────────────────────────┐
│  单文件 TOKEN 省下量      █████       46%  │
│  受惠的 SESSION 比例      ██████████ 100%  │
│  信息保留程度             ██████████ 100%  │
│  设置时间                 █            1x  │
└────────────────────────────────────────────┘
```

## Caveman 家族的一员

这个 skill 属于 [caveman](https://github.com/JuliusBrussee/caveman) 工具组——让 Claude 用更少 token,又不损失准确度。

- **caveman** — 让 Claude *讲话*像 caveman(输出 token 砍约 65%)
- **caveman-compress** — 让 Claude *读*得更少(context token 砍约 46%)
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall