Compress CLAUDE.md with caveman-compress and Save Input Tokens
機械翻訳 / Machine-translated
Original article: Compress CLAUDE.md with caveman-compress and Save Input Tokens (cccskills)
Skill page: caveman-compress
Key takeaways from this article
With caveman-compress installed, Claude Code users can compress the text in CLAUDE.md and task lists into shorter expressions.
This reduces the input tokens loaded on every run.
Code and headings are left untouched, and the human-readable original is saved in a separate location.
This article walks through what gets removed and what stays, how to install it, example prompts, and important notes on data transmission.
When you ask it to compress a file by providing the path, the file is rewritten in shorter expressions.
The original text is saved in a separate location.
For a project's CLAUDE.md, for example, the message you send looks like this:
/caveman-compress /Users/me/my-app/CLAUDE.md
The agent runs the bundled Python script, determines the file type, and then asks the configured model to compress it.
The compressed result is validated, and if there are problems, only the affected parts are fixed using the same model.
Fixing is attempted a maximum of two times.
If it still doesn't pass validation, an error is reported and the original file is left untouched.
On success, CLAUDE.md is overwritten with the compressed version.
The human-readable original is saved with .original.md appended to its name in the following data folder:
| Environment | Backup location |
|---|---|
| Non-Windows | $XDG_DATA_HOME/caveman-compress/backups/<parent folder name>/ |
| Windows | %LOCALAPPDATA%\caveman-compress\backups<parent folder name>\ |
Here is an example of how the text changes after compression.
The skill's documentation is written in English and the examples are also in English.
(Before compression)
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.
(After compression)
Run tests before push to main. Catch bugs early, prevent broken prod deploys.
Preamble like "you should" and "always make sure to" is removed, leaving only the action and the reason.
This skill removes words that carry no meaning from instruction files that are loaded on every run.
Because what gets removed and what stays are clearly defined, technical information is not lost in the process of shortening.
| Treatment | Target |
|---|---|
| Remove | Articles, filler words like "just" and "really", pleasantries like "sure" and "of course", hedges like "you could consider", connectives like "however" |
| Rephrase to be shorter | Roundabout expressions like "in order to" → "to", lengthy words like "utilize" → "use" |
| Leave as-is | Code blocks, inline code, URLs, file paths, commands, technical terms such as library names, proper nouns, dates, versions, numbers, environment variables |
| Preserve structure | Heading wording, nested bullet points, numbered lists, table layout, leading YAML |
Rephrasing also applies to sentence structure.
For example, "You should always run tests before committing" becomes a fragment like "Run tests before commit."
Bullet points that merely restate the same thing are consolidated into one.
If multiple examples follow the same pattern, only one is kept.
The contents of code blocks are treated as read-only.
Comments, whitespace, line order, and command length are all copied exactly, so build steps and command examples written in CLAUDE.md remain unchanged.
In tables, only the text in cells is shortened.
Supported file types are .md, .txt, .typ, .typst, .tex, and plain-text files with no extension.
Code and configuration files such as .py, .json, .yaml, and .env are not modified.
For files that mix prose and code, only the prose portions are compressed.
Sections where the type is ambiguous are left untouched.
The installation command is as follows.
When you run it, you can choose the target agent such as Claude Code or Codex.
npx skills add https://github.com/JuliusBrussee/caveman --skill caveman-compress
If you prefer to let the agent handle it, send the following message as-is.
It instructs the agent to review the contents before placing the files.
Please install the following Agent Skill.
https://github.com/JuliusBrussee/caveman/tree/main/skills/caveman-compress
First check the contents of SKILL.md and the accompanying files to confirm there are no suspicious operations (sending data externally, reading credentials, etc.), then place it in ~/.claude/skills/caveman-compress/ for Claude Code or ~/.agents/skills/caveman-compress/ for Codex.
For manual installation, the locations are as follows:
| Agent | Use across all projects | Use in a specific project only |
|---|---|---|
| Claude Code | ~/.claude/skills/ | .claude/skills/ in the project |
| Codex | ~/.agents/skills/ | .agents/skills/ in the project |
The skill consists of SKILL.md and a Python script in the scripts folder.
Place the entire folder and make sure scripts sits next to SKILL.md.
When making a request, always specify the path of the file to compress.
In addition to CLAUDE.md, it can also be used on task lists and notes summarizing your preferences.
/caveman-compress /Users/me/my-app/CLAUDE.md
CLAUDE.md is replaced with the compressed version, and the original is saved in the backup folder.
Headings and command examples remain intact; only the body text is shortened.
Please compress the task list in /Users/me/notes/todo.md
Task bullet points retain their nesting and numbering while each item is shortened to a brief phrase.
Items that repeat the same content are consolidated into one.
Please compress the following text.
(paste text here)
In this case, the agent will not compress the text on the spot.
It will either ask for the path of the file to compress or suggest saving the pasted text to a file first.
This is a rule to prevent the agent's own comments from accidentally being mixed into the saved content.
The most important thing to be aware of is that the entire contents of the file are sent to the model provider.
Only specify files whose contents are acceptable to send.
The destination is one of the following depending on the script's configuration: claude CLI, Anthropic API, codex CLI, opencode, or an OpenAI-compatible endpoint.
Running it requires Python 3 and an environment where at least one of these is available.
The Anthropic API is one of the available destinations; it is not required.
Protections for sensitive information are also built in.
Files with names like .env, credentials, secrets, and .netrc are rejected before they are even read.
If the body text contains private keys or tokens for cloud, Git hosting, or model API services, processing stops before transmission.
The compressed version overwrites the original file.
Although a validation mechanism is in place, the first time you use it compare the backup original with the result to confirm the meaning of the instructions has not changed.
Note that backup .original.md files are excluded from compression.
The examples listed under removal rules are English articles and stock phrases.
If you use it on files written in Japanese, try it on a short file first and check the result.
The license is Apache-2.0.
Before installing, it is a good idea to read SKILL.md, the scripts inside scripts, and the bundled SECURITY.md to verify what the processing does.
The same repository contains other skills for reducing token and context consumption.
Combining them with compression lets you review both input and output.
caveman-learn addresses the review of heavy instruction files and repeatedly passed context.
Based on an analysis of token usage, it edits with approval at each change and re-measures to confirm the reduction.
It is a skill to use before deciding which files to compress.
caveman shapes the agent's replies into concise text that leads with the conclusion.
Where caveman-compress shortens the input side, this skill shortens the reply side.
cavecrew delegates tasks such as locating code, making small fixes, and reviewing diffs to sub-agents.
Because results are received in a short structured format, context consumption by the main agent is kept down.
No.
The original is saved as a file with .original.md appended to its name, in a data folder separate from the source.
It is not placed next to the source in order to prevent the original from being picked up again by the skill's auto-loading.
The Anthropic API is one of the available destinations.
You can configure and use any of the following: claude CLI, codex CLI, opencode, or an OpenAI-compatible endpoint.
Regardless of which you choose, the full contents of the file are sent to that provider.
If the compressed result does not pass validation, only the problematic parts are fixed using the same model.
Retries are attempted a maximum of two times.
If it still does not pass, an error is reported and the original file is left unchanged.
No.
Supported targets are plain-text files such as .md and .txt; files such as .py, .json, and .yaml are not modified.
caveman-compress removes unnecessary words from the text in CLAUDE.md and task lists, shortening the input loaded on every run.
Code, commands, and headings remain intact, and the human-readable original is saved in a separate folder.
Be sure to confirm before use that the full contents of your files are acceptable to send to a model provider.
For more details, see the cccskills page.
This article is a repost of the cccskills article "Compress CLAUDE.md with caveman-compress and Save Input Tokens".
Skill details and installation instructions can be found on the cccskills caveman-compress page.