Home
cd ../playbooks
Developer ToolsAdvanced

Semantic Prompt Compression

Re-encode verbose system prompts, tool descriptions, and skill bodies into a dense telegraphic register — punctuation as connectives, label frames, verbless assertions — via re-encoding, not word deletion, with a density gate and a declared-loss verification pass.

5 minutes
By can1357 (oh-my-pi)Source
#prompt-engineering#token-optimization#system-prompts#technical-writing#claude-md#agent-instructions

Deleting function words out of a sentence doesn't compress it, it just damages it — the actual technique is re-framing each claim in a register whose grammar is punctuation, and the difference between the two shows up the first time a compressed rule gets silently misread by the model executing it cold.

Who it's for: prompt engineers reducing system-prompt token count, developers writing tool and function descriptions for AI agents, skill authors trying to fit more into a context budget, anyone whose compressed prompts have quietly lost a rule or a throw condition without anyone noticing

Example

"Compress this tool description" → A density gate check first (is this already dense enough that compression would lose more than it saves?), a payload inventory listing every MUST/NEVER line and exact identifier before anything gets cut, each claim re-framed into a definition/obligation/default/condition-consequence construction, and a verification pass that names every declared loss and measures the real token delta rather than assuming symbols automatically save space

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add semantic-prompt-compression
# Semantic Prompt Compression

Re-encode verbose prose into a dense, telegraphic register — punctuation as connectives, label frames, verbless assertions — without losing normativity or precision. Use for compressing system prompts, tool/function descriptions, skill bodies, and agent instructions: text a model executes cold, with no author present to disambiguate.

**Compression is re-encoding, not word deletion.** Filtering function words out of an English sentence leaves a damaged English sentence. Instead, re-frame each claim in a register whose grammar is punctuation and layout — then the function words have no work left and drop out on their own. Compression that forces the reader (or the model) to guess is a bug, not a saving.

## Procedure

### 0. Density Gate — Check Before Touching Anything

Two signals, in order: are articles and copulas already near-absent, and what's the actual token delta on a representative section once compressed? If the text is already in this register (a house-style prompt, a tool doc, a spec), or the measured delta is under roughly 10%, **stop and keep the original.** Bullet length alone is a weak signal — API literals and enumerations inflate it without meaning the prose is loose. On already-dense text, the remaining words *are* the payload, and the expected saving is smaller than the expected loss.

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

A precise discipline for compressing load-bearing, machine-executed text — system prompts, tool and function descriptions, skill bodies, agent instructions — where a model executes the text cold with no author present to disambiguate a mistake. The core reframe: compression is re-encoding, not word deletion. Stripping function words out of an English sentence leaves a damaged English sentence; the actual technique re-frames each claim into a construction (a verbless assertion, a label frame, a condition→consequence arrow) whose grammar is punctuation and layout, so the function words have no work left to do and drop out on their own.

It opens with a density gate that stops the whole exercise before it starts if the text is already dense enough that compression would lose more than it saves, requires a full payload inventory (every MUST/NEVER line, identifier, and default) before anything gets deleted, and closes with a verification pass that names every declared loss explicitly and measures the real token delta against the target model's actual tokenizer — since word counts and symbol substitutions don't reliably predict token savings, and a naive pass has been measured silently dropping a real behavioral rule while claiming a saving.


Quick Start

Step 1: Create a Project Folder

mkdir semantic-compression && cd semantic-compression

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ./

Step 3: Compress a Prompt

claude

Paste in the system prompt, tool description, or skill body you want compressed and ask Claude to apply the density gate first, then compress it using this methodology.


Tips & Best Practices

  • Run the density gate honestly — the biggest failure mode isn't under-compressing, it's compressing an already-dense house-style prompt and silently losing a throw condition or a NEVER rule in the process.
  • When in doubt about a connective symbol, write the word instead. The whole point of this register is a model executing it cold with no author to disambiguate — an ambiguous glyph is worse than a slightly longer sentence.
  • Never compress a tool or skill's trigger description the way you compress its body — the description is retrieval surface matched against varied user phrasing, and keeping natural, redundant alternatives there is load-bearing, not wasteful.

Limitations

  • Built for load-bearing, machine-executed text — applying this register to human-facing narrative prose, teaching documentation, or marketing copy actively works against those genres' actual goals.
  • Token-cost claims about specific symbols are tokenizer-dependent — always measure the real delta with the target model's actual tokenizer rather than assuming a glyph substitution saves tokens.
  • A text-level compression discipline, distinct from information-architecture decisions like what belongs in-file versus behind a pointer — pair it with a document-structure playbook for that separate concern.

$Related Playbooks

Developer Tools

Simplified Technical English for Docs

Write or rewrite technical documentation with the ASD-STE100 Simplified Technical English discipline — the aerospace maintenance-manual standard adapted for READMEs, runbooks, error messages, incident reports, and agent instructions.

10 minutes
Intermediate
Developer Tools

Project Graveyard: Autopsy Your Abandoned Side Projects

Scan local repos for dead side projects, autopsy each one from its git history, surface your personal death patterns, and pick the one corpse most worth resurrecting — then help ship it.

10 minutes
Intermediate
Developer Tools

Secure Coding Practices

A threat-model-first secure coding reference — trust-boundary mapping, a STRIDE quick-pass, a three-tier always/ask-first/never boundary system, and copy-paste prevention patterns for injection, XSS, broken access control, and SSRF.

10 minutes
Intermediate
Developer Tools

PR Review Toolkit

Six specialist reviewers — comments, tests, error handling, type design, general quality, and simplification — each triggered by name or automatically based on what changed in the diff.

5 minutes
Intermediate
Developer Tools

Security Guidance Review

Three-layer continuous security review for AI-generated code — instant regex warnings on edit, an LLM diff review at end of turn, and an agentic commit-time reviewer that traces data flow across files.

10 minutes
Advanced
Developer Tools

Vercel Analytics & Speed Insights Setup

Wire up Vercel Analytics, Speed Insights, and SPA routing rewrites into a React/Vite project in one pass — including the routing fix most people miss.

5 minutes
Beginner
Developer Tools

Shannon: Autonomous Pentesting for Your Own Apps

An operating guide for driving Keygraph's Shannon CLI: scope a white-box pentest against an app you own, run it, and turn the proven findings into fix tasks

15 minutes
Advanced
Developer Tools

Unslop UI Skill for Claude: Kill the AI Design Tells

A frontend guardrail built from a 3.2M-post Reddit analysis of what people actually call AI slop, with a build mode that forces design decisions up front and an audit mode that scans existing code for the tells

10 minutes
Intermediate
Developer Tools

Redesign Existing Projects: UI Audit and Upgrade

A design audit checklist that finds generic AI-look patterns in an existing codebase and fixes them without breaking functionality or migrating frameworks

10 minutes
Intermediate
Developer Tools

Soft UI Design Skill: Premium, Awwwards-Tier Interfaces

A design system that makes Claude build $150k-agency-feeling UI — double-bezel cards, spring-physics motion, magnetic buttons, and a banned list that blocks every cheap AI-design tell

5 minutes
Intermediate
Developer Tools

Stitch Design Taste: Semantic DESIGN.md Generator for Google Stitch

Generates a DESIGN.md that encodes premium, anti-generic design rules in Google Stitch's natural-language format — color, type, layout, motion intent, and a full banned-pattern list

5 minutes
Intermediate
Developer Tools

Prompt Optimizer (EARS)

Transform vague prompts into precise, well-structured specifications using EARS (Easy Approach to Requirements Syntax) — ideal for AI-generated code, products, and docs.

10 minutes
Intermediate

Browse all Developer Tools playbooks →