技能 caveman-compress

caveman-compress

低风险 ⚙️ 外部命令🔑 环境变量

压缩记忆文件以降低token成本

像CLAUDE.md这样的大型记忆文件会在每次AI会话启动时浪费token。这个技能可以将它们压缩约46%,同时保留所有技术内容。

支持: Claude Codex Code(CC)
🥉 75 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“caveman-compress”。 一个706个token的CLAUDE.md文件,包含TypeScript偏好、测试指南和以完整散文编写的项目约定。

预期结果:

一个285个token的压缩版本,保留了所有技术指令的直接穴居人风格文本。标题、代码示例和URL保持不变。原始文件保存为CLAUDE.original.md。

正在使用“caveman-compress”。 一个1145个token的项目笔记文件,包含架构描述、部署步骤和团队约定。

预期结果:

一个535个token的压缩文件。所有章节标题精确保留。代码块和URL完整。冗余解释被压缩为关键事实。备份保存为project-notes.original.md。

安全审计

低风险
v1 • 4/15/2026

Static analysis flagged 107 potential issues across 10 files with a risk score of 100/100. After semantic evaluation, all flagged patterns are false positives. The external_commands findings (74 locations) are primarily markdown backticks in documentation files misidentified as shell execution. The one real subprocess call in scripts/compress.py uses hardcoded arguments with stdin input and no shell interpolation. Network findings (2 locations) are static URLs in README.md documentation, not runtime requests. Filesystem findings (2 locations) are standard path resolution for a file-processing tool. Environment access findings (9 locations) are legitimate ANTHROPIC_API_KEY and CAVEMAN_MODEL configuration for API usage. The critical heuristic finding about code execution plus network plus credential access is a false positive describing the normal operation of an Anthropic API client. No prompt injection attempts, data exfiltration patterns, or malicious intent detected. The tool has appropriate safeguards including file size limits (500KB), automatic backups, and retry logic with rollback on failure.

10
已扫描文件
964
分析行数
5
发现项
1
审计总数
低风险问题 (3)
Subprocess CLI Call
The tool calls the claude CLI via subprocess.run as a fallback when ANTHROPIC_API_KEY is not set. Arguments are hardcoded and user content is passed via stdin, not shell arguments. This is a standard pattern for Claude CLI integration. The risk is minimal but warrants documentation.
Environment Variable Access for API Key
The tool reads ANTHROPIC_API_KEY from environment variables to authenticate with the Anthropic API. This is standard and expected behavior for API tooling. The key is used only for direct API calls to Anthropic, not transmitted elsewhere.
File Write to User-Specified Path
The tool writes compressed content back to the same file path the user specifies. A backup is created before overwriting. The path is resolved to an absolute path and validated for existence and size (max 500KB). No files outside the user-specified path are modified.

风险因素

⚙️ 外部命令 (1)
🔑 环境变量 (1)
审计者: claude

质量评分

59
架构
100
可维护性
87
内容
50
社区
84
安全
83
规范符合性

你能构建什么

降低日常会话成本

将CLAUDE.md项目记忆文件压缩一次。较小的文件会在每次会话启动时加载,每次使用AI工作时都能节省token。

优化团队文档

压缩共享的偏好文件、风格指南和项目约定。团队成员获得相同的指令,但每次会话的输入token更少。

精简长期项目笔记

将积累的待办事项、会议记录和决策日志压缩为关键事实。保留所有信息但去除冗长的开销。

试试这些提示

压缩单个文件
将CLAUDE.md文件压缩为穴居人格式。
压缩多个偏好文件
压缩以下记忆文件:CLAUDE.md、todos.md和preferences.txt。
编辑后重新压缩
我用新的编码标准更新了CLAUDE.original.md。请再次压缩它以替换CLAUDE.md。
使用自定义模型压缩
将CAVEMAN_MODEL设置为claude-haiku并压缩CLAUDE.md。

最佳实践

  • 编辑.origi nal.md备份文件,然后再压缩。这样可以让你的人类可读格式的真相来源保持不变。
  • 在记忆文件进行重大更新后运行压缩。新编辑的内容通常会添加冗长的解释,这些内容压缩效果很好。
  • 在依赖压缩输出之前先检查。由于验证会检查技术内容,但风格变化可能会影响细节。

避免

  • 不要压缩代码文件、配置文件或任何以代码内容为主的文件。该工具会自动跳过这些文件。
  • 不要删除.origi nal.md备份。这是你的人类可读真相来源和恢复点。
  • 不要对未更改的文件重复运行压缩。每次运行都会消耗API token。仅在有意义的编辑后进行压缩。

常见问题

我的原始文件会怎样处理?
你的原始文件会被压缩版本覆盖。在此之前,会备份一个.origi nal.md扩展名的文件。你随时可以读取或编辑备份。
除了CLAUDE.md,我还能压缩其他文件吗?
是的。任何markdown(.md)、纯文本(.txt)或reStructuredText(.rst)文件都可以使用。不带扩展名但包含自然语言的文件也被支持。代码和配置文件会自动跳过。
压缩会丢失任何技术信息吗?
不会。代码块、URL、文件路径、命令和技术术语会被精确保留。验证步骤在压缩后检查标题、代码块、URL和结构。如果验证失败,该工具会用有针对性的修复重试。
如果压缩失败或产生错误输出怎么办?
该工具会用有针对性的修复重试最多2次。如果所有重试都失败,你的原始文件会被恢复并保持不变。备份仅在成功压缩时保留。
压缩能节省多少token?
平均而言,大约节省46%的输入token。单个文件的节省范围在36%到60%之间,取决于原始文本的冗长程度。
使用这个技能需要Anthropic API密钥吗?
是的,需要在环境中设置ANTHROPIC_API_KEY,或者安装带有桌面身份验证配置的claude CLI。该技能会使用可用的任一方式。

开发者详情

文件结构