caveman-compress

Compresses natural-language memory files like CLAUDE.md while preserving code, URLs, tables, and file paths.

4|2|Updated May 18, 2022
One-click install
npx skills add https://github.com/pjmagee/starwars-data --skill caveman-compress-pjmagee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: caveman-compress
Source: https://github.com/pjmagee/starwars-data/tree/main/.agents/skills/caveman-compress
Command: npx skills add https://github.com/pjmagee/starwars-data --skill caveman-compress-pjmagee

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires anthropic, tiktoken, and includes scripts (resource) components.

What problem does it solve?

Large project memory files like CLAUDE.md, todos, and preferences are reloaded on every AI session, repeatedly consuming input tokens and increasing cost. Caveman-compress shrinks natural language sections into compact caveman-style text while preserving all technical substance so sessions load fewer tokens without losing important information.

Core Features & Use Cases

  • Compresses markdown and plain-text memory files to reduce per-session token usage and cost.
  • Preserves code blocks, inline code, URLs, file paths, headings, tables, frontmatter, and numeric values exactly.
  • Creates a human-readable backup named <filename>.original.md before overwriting, validates output with deterministic checks, retries up to two targeted fixes via Claude, and restores the original on failure.
  • Supports Anthropic SDK when ANTHROPIC_API_KEY is present and falls back to the local claude CLI for desktop-authenticated users; enforces a 500KB file limit to avoid unsafe processing.
  • Use cases: speed up agent startup, cut recurring token bills for long-running projects, and maintain compact yet accurate project memories.

Quick Start

Run the caveman compression on your project memory file by issuing the agent command /caveman:compress CLAUDE.md

Frequently Asked Questions about caveman-compress

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce input tokens when loading large CLAUDE.md memory files for AI sessions?

To reduce input tokens for memory files, compress markdown natural language into compact caveman-style text while preserving code blocks, URLs, and file paths. This shrinks per-session token usage without losing technical substance.

Does compressing markdown memory files preserve code blocks and file paths?

Compressing markdown memory files preserves code blocks, inline code, URLs, file paths, headings, tables, frontmatter, and numeric values exactly, ensuring all technical substance remains intact while reducing overall token count.

Can I use the Anthropic SDK to compress project memory files, or do I need the claude CLI?

You can compress project memory files using the Anthropic SDK when ANTHROPIC_API_KEY is present, or fall back to the local claude CLI for desktop-authenticated users. Both methods validate output with deterministic checks and targeted Claude fixes.

What is the file size limit for compressing markdown memory files?

The file size limit for compressing markdown memory files is 500KB. This limit is enforced to avoid unsafe processing of excessively large files during the compression and validation workflow.

How do I back up my original markdown files before compressing them for token savings?

Before overwriting your original markdown files, a human-readable backup named <filename>.original.md is created automatically. If validation fails after two targeted fix attempts, the original file is restored.

Why does my project memory file keep consuming too many tokens on every AI session reload?

Project memory files consume tokens on every reload because large natural language sections are loaded repeatedly. Compressing these sections into caveman-style text cuts recurring token bills for long-running projects without losing important information.