首页 / Skills / 开发提效 / Caveman 记忆文件压缩
开发提效

Caveman 记忆文件压缩

Julius BrusseeApache-2.0Skill 语言: 英文
协议已核对含脚本依赖外部服务
演示真实运行记录 · claude-opus-5-5 · 2026年10月
docs/preferences.md (before, 1,391 bytes)
Project Preferences
Code Style

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

When you are writing React components, it would be good to use function components with hooks rather than class components. You should also try to keep each component in its own file under `src/components/`, because it really makes it a lot easier to find things later on.

Testing

You should always make sure to run the test suite before pushing any changes to the main branch. This is important because it helps catch bugs early and prevents broken builds from being deployed to production. Run the tests with:

```bash pnpm test --run ```

If a test is flaky, please don't just skip it. Instead, open an issue on https://github.com/acme/web-app/issues and add the `flaky` label so that we can actually track it down.

Commits and Pull Requests
  • Please use Conventional Commits for all of your commit messages.
  • It would be great if you could keep pull requests small, ideally under about 400 lines of changes.
  • Make sure to always update `CHANGELOG.md` whenever you change any user-facing behavior.
docs/preferences.md (after /caveman-compress, 881 bytes)
Project Preferences
Code Style

Strongly prefer TypeScript, strict mode on, all new code. No `any` type unless truly no way around — if used, leave comment explaining why. Proper typing catches many bugs before runtime.

React components: function components with hooks, not class components. One component per file under `src/components/` — easier to find later.

Testing

Always run test suite before pushing to main branch. Catches bugs early, prevents broken builds deploying to production. Run tests with:

```bash pnpm test --run ```

Flaky test? Don't skip. Open issue on https://github.com/acme/web-app/issues and add `flaky` label so it can be tracked down.

Commits and Pull Requests
  • Use Conventional Commits for all commit messages.
  • Keep PRs small, ideally under ~400 lines changed.
  • Always update `CHANGELOG.md` when changing user-facing behavior.

Real run recorded with claude-code / claude-opus-5-5. Prompt: "Compress docs/preferences.md so it costs fewer tokens when the agent loads it, but keep a backup of the original." The skill ran its bundled script (python3 -m scripts), which calls the claude CLI to do the compression. The first validation found a stray comma after a URL, and the script fixed it automatically before passing. The left and right columns are the file's exact contents before and after, unmodified, only split into headings, paragraphs and lists for display. The original was backed up to preferences.original.md in the tool's data directory.

它做什么

把 CLAUDE.md、项目笔记、待办清单、偏好设置这类自然语言文件改写成精简的表达,让代理每次加载时消耗更少的 token。标题、代码块、行内代码、URL 和文件路径必须保持不变。

工作方式

  1. 输入 /caveman-compress <文件>,或要求压缩某个记忆文件时触发。
  2. 运行自带的 Python 脚本:先检查文件类型、大小(最大 500 KB)和文件名,再把文本发给 Claude 压缩。代码块会先被遮蔽,模型无法改动。
  3. 在本地校验结果;校验不通过就让 Claude 只修出错的地方,最多 2 次,仍失败则原文件不动。
  4. 原地写入压缩后的文件,并把原文以 <文件名>.original.md 存到单独的数据目录,避免代理重复加载。

适合场景

每次会话都会加载的大型项目记忆文件。

需要了解

只压缩纯文字文件(.md、.mdc、.txt、.rst、.typ、.tex 和无扩展名文件),代码和配置文件会跳过。需要 Python 3.10 或更新版本。我们试用时,一个 1,391 字节的偏好文件压缩到 881 字节,标题、代码块、行内代码和 URL 全部保持原样。

说明与风险

含 Python 脚本,由代理运行。脚本会把你指定的文件内容发送给 Anthropic:设置了 ANTHROPIC_API_KEY 时走 Anthropic Python SDK,否则调用你已登录的 `claude` 命令行,用量计入你的 Anthropic 账户。脚本会覆盖目标文件,并在 ~/.local/share/caveman-compress(Windows 为 %LOCALAPPDATA%)下写入备份和锁文件;文件名看起来像凭据或密钥的文件会被拒绝。我们逐个读过脚本,没有发现其他联网或文件读写行为。不想发给 Anthropic 的内容,不要用它压缩。

SKILL.md 原文包内共 12 个文件