Prompt Compress
Compress LLM instructions with calibrated risk. Research shows ~60% of instruction
tokens are removable without degrading output quality — and compression often
improves performance by concentrating model attention.
Core Principles
- Instructions are the most sensitive prompt component. Apply maximum
compression to examples and context, moderate compression to structure,
minimal compression to core behavioral rules.
- Semantic equivalence ≠ behavioral equivalence. Two phrasings that mean the
same thing to a human can produce different model behavior. Every change
beyond mechanical cleanup carries nonzero risk.
- Compress in tiers. Apply safest changes first, present riskier changes as
suggestions. The user decides how far to go.
Workflow
1. Analyze
Before compressing anything, analyze the input:
- Count tokens (estimate: words × 1.3 for English)
- Identify sections by function: safety, formatting, tone, behavior, examples,
context, metadata
- Detect duplicates: rules that express the same constraint in different words
- Flag filler: politeness markers, hedging, verbose connectives
- Note structural issues: scattered related rules, inconsistent formatting
- Identify examples and assess whether they're redundant with stated rules
Present a brief analysis summary with estimated savings per tier.
2. Compress in Tiers
Apply changes tier by tier. For each tier, show a diff and token savings.
Tier 1 — Mechanical (auto-apply, safe)
These changes preserve exact meaning. Apply all of them:
- Fix typos and inconsistent punctuation
- Normalize whitespace (double spaces, trailing spaces, excessive blank lines)
- Apply word-level substitutions from
references/substitutions.md
- Remove pure filler: "please note that," "it is important to," "keep in mind"
- Remove politeness in system prompts: "please," "kindly," "if you don't mind"
- Strip unnecessary articles in imperative instructions ("Write the response" → "Write response")
- Remove self-referential meta-commentary ("The following rules govern your behavior:" → just list the rules)
Tier 2 — Structural (recommend, low-medium risk)
These reorganize without changing meaning, but removal of "redundant" rules
may remove useful reinforcement:
- Deduplicate: Merge rules expressing the same constraint. Keep the most
specific version. Example: "Be professional" + "Maintain professional tone" +
"Always respond professionally" → "Maintain professional tone."
- Group by function: Collect scattered rules under section headers.
Consolidating related rules eliminates repetitive framing ("When responding...",
"In your responses...", "Your responses should...").
- Flatten conditionals: Convert nested if-else to flat patterns.
"If user asks X, check Y, and if Y then Z" → "X + Y → Z; X + ¬Y → W"
- Remove hedging on directives: "You should try to ensure responses are
accurate" → "Be accurate." Only where the hedge adds no real nuance.
- Trim verbose examples: If 5+ examples illustrate the same pattern, keep
2-3 that cover distinct cases. Flag which ones you'd cut and why.
Tier 3 — Semantic (suggest only, medium-high risk)
These change wording while attempting to preserve intent. Present as suggestions
with explicit risk notes. Never auto-apply:
- Telegraphic style: Drop articles, pronouns, connectives from behavioral
rules. "When the user asks you a question, you should provide a clear and
concise answer" → "Answer questions clearly and concisely."
- Principalize examples: Replace remaining examples with a principle
statement. "Example: 'Hello!' → 'Hi there!' / 'Hey' → 'Hello!'" →
"Mirror greeting energy, match formality level."
- Merge overlapping rules: Combine rules that address related behaviors.
Only where the merged version clearly covers both originals.
- Remove examples entirely: If the rule is clear without them. Flag as
HIGH RISK — few-shot examples reduce prompt sensitivity by ~30%.
- Reorder sections: Move most critical rules to beginning and end of prompt
(attention U-curve). Flag as MEDIUM RISK — reordering alone can cause
significant behavioral shifts.
Tier 4 — Aggressive (flag only, high risk)
Only mention these as possibilities. Never draft them without explicit user request:
- Removing safety/guardrail instructions
- Changing role/persona framing
- Switching prompting strategies (zero-shot ↔ chain-of-thought)
- SPR-style compression (reducing to associative priming cues)
- Removing entire sections deemed low-value
3. Present Results
Output a compression report with this structure:
## Compression Report
**Original**: ~{n} tokens ({word_count} words)
### Tier 1 — Mechanical [{savings}% reduction]
{compressed text with changes}
### Tier 2 — Structural [{cumulative savings}% reduction]
{compressed text with Tier 1+2 applied}
Changes made:
- {change 1}: {rationale}
- {change 2}: {rationale}
### Tier 3 — Suggestions [{potential additional savings}%]
- [ ] {suggestion 1} — saves ~{n} tokens — RISK: {level} — {why risky}
- [ ] {suggestion 2} — saves ~{n} tokens — RISK: {level} — {why risky}
### Tier 4 — Aggressive options [{potential savings}%]
- {option}: {what it would save} — {what might break}
**Summary**: Tier 1+2 achieves ~{n}% reduction ({old} → {new} tokens).
Tier 3 suggestions could reach ~{n}% total if accepted.
4. Deliver
- If the user wants a specific tier applied, produce the final compressed text
with all changes through that tier
- If they want to cherry-pick Tier 3 suggestions, apply only selected ones
- Always provide the final compressed version as a clean, copy-pasteable block
Important Caveats to Communicate
- Compression effectiveness depends on the target model. What works for Claude
may not work identically for GPT or Gemini.
- Larger/newer models tolerate more compression. If targeting smaller models,
be more conservative.
- The only real validation is testing compressed prompts against actual tasks.
This skill optimizes for likely preservation, not guaranteed preservation.
- Examples are disproportionately valuable. Cutting examples saves the most tokens
but carries the most risk.
Reference Files
- Read
references/substitutions.md for the mechanical substitution dictionary
used in Tier 1. Load this before applying Tier 1 changes.
- Read
references/examples.md for before/after compression examples across
different instruction types. Consult when unsure about a compression decision.
1---2name: ai-config-compress3description: Compress LLM instruction sets, system prompts, rules, and guidelines to reduce token count while preserving behavioral intent. Use this skill whenever the user wants to shorten, truncate, optimize, or compress prompts, system instructions, CLAUDE.md files, custom instructions, rules, guidelines, or any instruction set meant for an LLM. Also trigger when users mention "too many tokens," "prompt is too long," "reduce prompt size," or ask to make instructions more concise.4---56# Prompt Compress78Compress LLM instructions with calibrated risk. Research shows ~60% of instruction9tokens are removable without degrading output quality — and compression often10_improves_ performance by concentrating model attention.1112## Core Principles13141. **Instructions are the most sensitive prompt component.** Apply maximum15 compression to examples and context, moderate compression to structure,16 minimal compression to core behavioral rules.172. **Semantic equivalence ≠ behavioral equivalence.** Two phrasings that mean the18 same thing to a human can produce different model behavior. Every change19 beyond mechanical cleanup carries nonzero risk.203. **Compress in tiers.** Apply safest changes first, present riskier changes as21 suggestions. The user decides how far to go.2223## Workflow2425### 1. Analyze2627Before compressing anything, analyze the input:2829- Count tokens (estimate: words × 1.3 for English)30- Identify sections by function: safety, formatting, tone, behavior, examples,31 context, metadata32- Detect duplicates: rules that express the same constraint in different words33- Flag filler: politeness markers, hedging, verbose connectives34- Note structural issues: scattered related rules, inconsistent formatting35- Identify examples and assess whether they're redundant with stated rules3637Present a brief analysis summary with estimated savings per tier.3839### 2. Compress in Tiers4041Apply changes tier by tier. For each tier, show a diff and token savings.4243#### Tier 1 — Mechanical (auto-apply, safe)4445These changes preserve exact meaning. Apply all of them:4647- Fix typos and inconsistent punctuation48- Normalize whitespace (double spaces, trailing spaces, excessive blank lines)49- Apply word-level substitutions from `references/substitutions.md`50- Remove pure filler: "please note that," "it is important to," "keep in mind"51- Remove politeness in system prompts: "please," "kindly," "if you don't mind"52- Strip unnecessary articles in imperative instructions ("Write the response" → "Write response")53- Remove self-referential meta-commentary ("The following rules govern your behavior:" → just list the rules)5455#### Tier 2 — Structural (recommend, low-medium risk)5657These reorganize without changing meaning, but removal of "redundant" rules58may remove useful reinforcement:5960- **Deduplicate**: Merge rules expressing the same constraint. Keep the most61 specific version. Example: "Be professional" + "Maintain professional tone" +62 "Always respond professionally" → "Maintain professional tone."63- **Group by function**: Collect scattered rules under section headers.64 Consolidating related rules eliminates repetitive framing ("When responding...",65 "In your responses...", "Your responses should...").66- **Flatten conditionals**: Convert nested if-else to flat patterns.67 "If user asks X, check Y, and if Y then Z" → "X + Y → Z; X + ¬Y → W"68- **Remove hedging on directives**: "You should try to ensure responses are69 accurate" → "Be accurate." Only where the hedge adds no real nuance.70- **Trim verbose examples**: If 5+ examples illustrate the same pattern, keep71 2-3 that cover distinct cases. Flag which ones you'd cut and why.7273#### Tier 3 — Semantic (suggest only, medium-high risk)7475These change wording while attempting to preserve intent. Present as suggestions76with explicit risk notes. Never auto-apply:7778- **Telegraphic style**: Drop articles, pronouns, connectives from behavioral79 rules. "When the user asks you a question, you should provide a clear and80 concise answer" → "Answer questions clearly and concisely."81- **Principalize examples**: Replace remaining examples with a principle82 statement. "Example: 'Hello!' → 'Hi there!' / 'Hey' → 'Hello!'" →83 "Mirror greeting energy, match formality level."84- **Merge overlapping rules**: Combine rules that address related behaviors.85 Only where the merged version clearly covers both originals.86- **Remove examples entirely**: If the rule is clear without them. Flag as87 HIGH RISK — few-shot examples reduce prompt sensitivity by ~30%.88- **Reorder sections**: Move most critical rules to beginning and end of prompt89 (attention U-curve). Flag as MEDIUM RISK — reordering alone can cause90 significant behavioral shifts.9192#### Tier 4 — Aggressive (flag only, high risk)9394Only mention these as possibilities. Never draft them without explicit user request:9596- Removing safety/guardrail instructions97- Changing role/persona framing98- Switching prompting strategies (zero-shot ↔ chain-of-thought)99- SPR-style compression (reducing to associative priming cues)100- Removing entire sections deemed low-value101102### 3. Present Results103104Output a compression report with this structure:105106```107## Compression Report108109**Original**: ~{n} tokens ({word_count} words)110111### Tier 1 — Mechanical [{savings}% reduction]112{compressed text with changes}113114### Tier 2 — Structural [{cumulative savings}% reduction]115{compressed text with Tier 1+2 applied}116Changes made:117- {change 1}: {rationale}118- {change 2}: {rationale}119120### Tier 3 — Suggestions [{potential additional savings}%]121- [ ] {suggestion 1} — saves ~{n} tokens — RISK: {level} — {why risky}122- [ ] {suggestion 2} — saves ~{n} tokens — RISK: {level} — {why risky}123124### Tier 4 — Aggressive options [{potential savings}%]125- {option}: {what it would save} — {what might break}126127**Summary**: Tier 1+2 achieves ~{n}% reduction ({old} → {new} tokens).128Tier 3 suggestions could reach ~{n}% total if accepted.129```130131### 4. Deliver132133- If the user wants a specific tier applied, produce the final compressed text134 with all changes through that tier135- If they want to cherry-pick Tier 3 suggestions, apply only selected ones136- Always provide the final compressed version as a clean, copy-pasteable block137138## Important Caveats to Communicate139140- Compression effectiveness depends on the target model. What works for Claude141 may not work identically for GPT or Gemini.142- Larger/newer models tolerate more compression. If targeting smaller models,143 be more conservative.144- The only real validation is testing compressed prompts against actual tasks.145 This skill optimizes for likely preservation, not guaranteed preservation.146- Examples are disproportionately valuable. Cutting examples saves the most tokens147 but carries the most risk.148149## Reference Files150151- Read `references/substitutions.md` for the mechanical substitution dictionary152 used in Tier 1. Load this before applying Tier 1 changes.153- Read `references/examples.md` for before/after compression examples across154 different instruction types. Consult when unsure about a compression decision.