From tokenkrush
Compresses agent instruction markdown files (CLAUDE.md, AGENTS.md, SOUL.md, GEMINI.md, memory files) using Vercel-style pipe-delimited dense format and telegraphic prose. Reduces token count ~39% (measured across Claude, GPT-5, and Gemini tokenizers) while preserving directive clarity. TRIGGER when user asks to compress, shrink, reduce tokens, optimize, or slim down any agent instruction file. Works globally (~/.claude/CLAUDE.md) or per-project (./CLAUDE.md).
How this skill is triggered — by the user, by Claude, or both
Slash command
/tokenkrush:tokenkrushThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Compresses agent instruction markdown files. Reduces tokens while preserving every directive.
Compresses agent instruction markdown files. Reduces tokens while preserving every directive.
The user asks to compress, shrink, reduce tokens, optimize, or slim down any agent instruction file. Target files include CLAUDE.md, AGENTS.md, SOUL.md, GEMINI.md, Cursor rules, memory files, and any similar markdown used as persistent AI agent context.
Glob both the current working directory and known global paths (tool home dirs) for candidate files. See references/file-detection.md for the exhaustive pattern list and scope rules.
node_modules/, .git/, dist/, build/, gitignored paths, or under 500 bytes.If the user supplied an explicit path (e.g., "compress /path/to/file.md"), skip discovery and operate on that file only.
Show the user a table grouped by scope (GLOBAL / LOCAL) with estimated token savings. Example:
Found 3 files:
GLOBAL (~/.claude/, ~/.openclaw/):
[1] ~/.claude/CLAUDE.md 4.8KB 101 lines
LOCAL (./):
[2] ./CLAUDE.md 2.1KB 84 lines
[3] ./AGENTS.md 1.4KB 52 lines
Compress: [a]ll, [g]lobal, [l]ocal, or numbers (e.g., "1,3")?
If global files were skipped due to permissions, append:
Note: I can also see ~/.claude/CLAUDE.md exists but don't have permission
to read it from this directory. To include global files, either:
- cd ~ and re-run, or
- add ~/.claude to additionalDirectories in settings.json
Token-savings estimate: use chars ÷ 4 as a rough heuristic.
For each file the user selected:
references/compression-rules.md §Classification).references/preservation.md §Protection Trip-wires). Revert any section that trips a wire.Ask the user per file: "Apply compression to <path>? [y/n/all]"
If they say "all", apply to every selected file without further prompts. If they say "n", skip that file (no write). If they say "y", write that file only.
For each approved file:
Edit tool (or Write for complete rewrites) to overwrite the file with the compressed content.Example final output:
Compressed 2 files:
~/.claude/CLAUDE.md 8784 → 4838 chars (-45%, ~986 tokens saved)
./AGENTS.md 1423 → 812 chars (-43%, ~152 tokens saved)
Total: ~1138 tokens saved across 2 files.
references/compression-rules.md — section classification + per-type compression logic + examplesreferences/file-detection.md — filename patterns, scope classification, discovery flowreferences/preservation.md — what NEVER to compress and protection trip-wiresSee examples/before-after-claude-md.md for a complete real-world example: 187 lines → 101 lines (46% reduction), no directive lost.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub gregoramon/tokenkrush --plugin tokenkrush