semantic-compression
它能做什么
这项技能向智能体展示如何在保留每项要求的前提下,让说明变得更短。适合编写提示词、工具描述或智能体说明,并希望减少浪费文字的人。
适用场景
- ✓当你想缩短系统提示词、工具描述或智能体说明的时候。
- ✓当冗长的说明占用了过多 AI 的工作记忆的时候。
- ✓当你希望以紧凑形式编写文档,同时 AI 仍能精确遵循的时候。
技能链接
https://github.com/can1357/oh-my-pi/blob/main/.omp/skills/semantic-compression/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这段系统提示词非常长。你能在不丢失任何规则的前提下把它缩短吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先检查文本是否已经足够紧凑,值得缩短。如果是,它就保留原文。否则,它会把文本拆分为单独的论断,并以更紧凑的形式重写每一条,然后衡量节省了多少。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Semantic Compression
Compression is re-encoding, not word deletion. Filtering function words out of an English sentence leaves a damaged English sentence (System design: efficient process incoming data, multiple sources). 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.
Target texts are load-bearing: tool descriptions, system prompts, skills. A model executes them cold, with no author present to disambiguate. Compression that forces a guess is a bug, not a saving.
Procedure
- Density gate — check before touching anything. Two signals, in order: (a) are articles and copulas already near-absent? (b) compress one representative section and measure the token delta. Already in this register (house-style prompt, tool doc, spec) or delta under ~10%? STOP. Report that it is already dense and keep the original. Bullet length alone is a weak signal — API literals and enumerations inflate it. Measured on a real house-style tool prompt: 853 → 778 tokens (8.8%), while that pass silently dropped a
NEVER assume …rule, a throw condition, and afull-resdetail. On already-dense text the remaining words are the payload, and the expected saving is smaller than the expected loss. - Split the source into atomic claims: one definition, obligation, default, or fact each.
- Inventory the payload first, before deleting anything. List every load-bearing token: identifiers, error/exception names, throw conditions, defaults with their units, bounds, and every MUST/NEVER/PREFER line. Anything you then drop is a loss you declare deliberately rather than discover later.
- Cut what the model already knows. "JSON is a text format", "tests catch regressions" → delete. Keep only what is specific to this tool, repo, or domain.
- Cut restatements. Merge every duplicate of one rule into a single canonical line, placed where it is needed. Two statements of one rule with different scope are not duplicates.
- Frame each claim — definition · obligation · default · condition→consequence · enumeration · verdict. The frame picks the construction.
- Hoist repeated qualifiers into one scope line: three mentions of "relative to the repo root" →
All paths repo-relative.once, up top. - Re-encode, then run Verification.
Frames
| frame | English | compressed |
|---|---|---|
| definition | "The name field is the stable launch identifier." |
name: stable launch id. |
| obligation | "You must call open before you can run code." | MUST open before run. |
| default | "If no value is given, the timeout defaults to 30 seconds." | Default 30s. |
| condition→consequence | "Because navigation re-renders the page, refs become stale, so you should snapshot again." | Navigation invalidates refs → re-snapshot. |
| property chain | "z' is an integer because z divides x²+y², and it is positive because x²+y²>0." | z' integer since z divides x²+y²; positive since x²+y²>0. |
| enumeration | "The action may be open, close, or run." | action: open, close, run. |
| exclusion | "any triple that is neither (1,1,1) nor (1,1,2)" | triple ≠ (1,1,1),(1,1,2) |
| verdict | "Claim A is true, and claim B is false as stated." | A true; B false as stated. |
| precondition | "This requires that the branch has already been checked out." | Requires prior checkout. |
Constructions behind them:
- Verbless assertion —
X true/X false/X required/X unsupported. Copula deleted; the predicate carries. - Label frame —
X: valuefor "the X is / means / consists of". One colon per line, never nested. - Subject elision across a run — name the subject once, chain bare predicates:
Integer since …; positive since …; unique. - Asyndeton — parallel items, no conjunction:
articles, copulas, expletives. - Scope declaration — one line retypes everything after it:
All paths repo-relative.·Times in ms.·All congruences mod 4. - Lazy specification — state only enough to decide:
3·13·34-1 big(over the bound; exact value irrelevant). Name the bound somewhere the reader can see it. - Metonymy — an object stands for the proposition about it:
y=z implies (1,1,1). Only where exactly one reading exists.
Operators
Punctuation carries the connective:
:— announce, name, define ("is", "means", "the following")→— yields, produces, becomes ("which results in")⇒— therefore, concludes—— gloss, or "therefore"/
常见问题
为了节省空间,它会删除重要的规则吗?
设计上不会。每条规则都会被保留,智能体会在完成前检查没有遗漏任何内容。
如果文本本身已经很短怎么办?
智能体会停下来并保留原文,因为重写本已经很紧凑的文字,通常损失的比节省的更多。
它会改变说明的含义吗?
目标是保持相同的含义,靠更紧凑的排版,而不是简单地删除文字。
详情
作者的原始描述
Re-encode verbose prose into a dense telegraphic register — punctuation as connectives, label frames, verbless assertions — without losing normativity or precision. Use when compressing system prompts, tool/function descriptions, skill bodies, or agent instructions; reducing token count or context bloat; making documentation token-efficient for LLM input; or rewriting text in compressed notation.
repo: can1357/oh-my-pi
热度
- GitHub 星标
- 38k
- 排名
- #7492
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …