token-saver
/token-saver
语义无损文本压缩与上下文治理。要压缩或精简文本与对话、降低 token 消耗而不改变含义、给超长 prompt 或 skill 瘦身、诊断上下文开销时使用。压缩稿可直接替换原文,不丢事实、数字、专名、条件与否定。
- Author
- ikdeaplop ↗
- Repository
- public-generalized-products ↗
- Licence
- MIT
- Last repository change
- 13.11.2026
Assessment and security
- Files in this package
- 7
- Scripts
- 3
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 3 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/context_cost.py, scripts/prompt_profiler.py, scripts/slc_check.py
What it does and when to use it
语义无损文本压缩与上下文治理。要压缩或精简文本与对话、降低 token 消耗而不改变含义、给超长 prompt 或 skill 瘦身、诊断上下文开销时使用。压缩稿可直接替换原文,不丢事实、数字、专名、条件与否定。
Original author description
语义无损文本压缩与上下文治理。要压缩或精简文本与对话、降低 token 消耗而不改变含义、给超长 prompt 或 skill 瘦身、诊断上下文开销时使用。压缩稿可直接替换原文,不丢事实、数字、专名、条件与否定。
How it works
- ⚠️ 本机覆盖规则(优先级最高)
- A · 语义无损压缩(SLC)
- B · 上下文治理
- 资源索引
SKILL.md preview
--- name: token-saver description: "语义无损文本压缩与上下文治理。要压缩或精简文本与对话、降低 token 消耗而不改变含义、给超长 prompt 或 skill 瘦身、诊断上下文开销时使用。压缩稿可直接替换原文,不丢事实、数字、专名、条件与否定。" agent_created: true version: 1.1.0 display_name: Token 节约器 · 语义无损压缩 display_name_en: Token Saver - Semantics-Lossless Compression description_zh: 在不改变任何含义的前提下压缩文本与对话:精简冗余表述、去除无意义格式与重复内容,严格保留事实、数字、专有名词、条件与否定。含三档压缩档位、不可压清单、交付前自检脚本,以及上下文开销诊断。 description_en: Compress text and dialogue without changing meaning - trim redundancy and noise formatting while strictly preserving facts, numbers, proper nouns, conditions and negation. Output is a drop-in replacement for the original. Includes three compression levels, a never-touch list, a verification script and context-cost diagnosis. --- # Token 节约器 ## ⚠️ 本机覆盖规则(优先级最高) 1. **默认不启用 L3 电报体**:用户要求中文完整、结构化表达,L3(省"的/了/是"虚词)默认不用;除非用户明确说"极限压缩 / L3 / 极限省 token"。 2. **默认档位 = L2 标准**,仅在本技能被明确触发(用户说压缩/精简/省 token/上下文太大)时才生效;日常回复不得被本技能改写风格。 3. **纯输出约束仅对压缩结果生效**:`pure` 模式的"禁止前言后语"只约束压缩稿本身,不影响助手在该任务里给用户的正常中文说明。 4. **语言**:压缩稿与说明一律中文。 --- 两条路径,先判断走哪条: | 你要解决的事 | 路径 | 产出 | |---|---|---| | 把**一段文本或对话**变小,含义一个字都不能变 | **A · 语义无损压缩** | 可直接替换原文的压缩稿 | | 把**一次任务的上下文开销**降下来(读什么、写什么、skill 怎么改) | **B · 上下文治理** | 读取策略 / 改造清单 / 开销报告 | --- ## A · 语义无损压缩(SLC) 一句话定义:像 minifier 对代码做的事,只不过对象是自然语言 —— 去冗余、去噪声,**不做总结、不做改写、不做解释**。 **核心等式:压缩 ≠ 摘要。摘要丢细节,压缩只丢"表述"。** 合格标准是:只读压缩稿,能还原出原文的全部事实主张与可执行动作。 ### 输入格式 三种入口,按优先级: 1. **文件路径**(首选,最省 token)—— 大文件不要整读进上下文,先跑 `scripts/context_cost.py` 估成本;超过 8k token 一律脚本处理,不 Read。 2. **粘贴文本** —— 任意自然语言文本。 3. **对话记录** —— 多轮问答,需保留"谁说的"归属与轮次边界。 可选参数(用户口头指定即可): | 参数 | 取值 | 默认 | |---|---|---| | 档位 | L1 轻压 / L2 标准 / L3 极限 | L2 | | 输出模式 | `pure` 仅压缩稿;`diff` 原文对照表 | pure | | 落盘 | 目标文件名,默认 原名 + `.min.md` | 短文本不落盘 | | 保留项 | 用户点名必须原样保留的字段 | 无 | ### 输出格式(硬约束) - `pure` 模式**只输出压缩后的正文**,可整段替换原文使用。 - **禁止**任何前言后语:不写"以下是压缩结果"、不加标题、不加解释、不加收尾寒暄、不套代码围栏(除非原文自带)。 - 短文本(低于 300 字)直接贴在回复里;长文本落盘,回复只给「文件路径 + 压缩比」两行。 - `diff` 模式输出三列表格:`原文片段 | 压缩后 | 手法`。 ### 三档压缩档位 | 档位 | 压什么 | 典型压缩比 | 何时用 | |---|---|---|---| | **L1 轻压** | 空行、多余空格、重复标点、装饰性 emoji、格式噪声、空转句("如题""以上""如下所述") | 15–25% | 原文已规范,只需去噪 | | **L2 标准**(默认) | L1 + 删冗余修饰与同义反复、去寒暄与自我指涉("我想说的是""其实""我觉得")、合并重复表述、列表去重、长句合流 | 30–50% | 投喂模型的 prompt、会议记录、需求文档、邮件 | | **L3 极限** | L2 + 电报体(省可省虚词"的/了/是")、并列信息表格化、括号补充并入主句 | 50–70% | 上下文吃紧、长历史对话、skill 与 reference 文件 | **档位只决定"表述能压多狠",不决定"信息留多少"。三档的信息量必须完全相同。** ### 不可压清单(无论多高档位都不许动) 1. **数字**:金额、日期、时间、比例、数量、版本号、单位 —— `3%` 不许变成"约 3%" 2. **专名**:人名、公司名、产品名、型号、地名、品牌、代号 3. **否定与范围词**:不、没有、禁止、仅、只、一律、全部、至少、至多、以上、以下 4. **条件与逻辑连接**:如果、除非、否则、且、或、则、当且仅当、前提是 5. **模态强度**:必须 强于 应当 强于 建议 强于 可以 —— 强度不许升也不许降 6. **引用与标识符**:原文引语、法条、代码、命令、URL、邮箱、文件名、API 字段名、变量名 7. **立场与情绪强度**:强烈反对 ≠ 不太同意 8. **时序与时态**:先/后、已经/将要、曾经 9. **用户点名的保留项** ### 五个禁止 - 禁止总结 —— 把 5 条并列压成"若干要求"就是毁信息 - 禁止脑补 —— 不加原文没有的因果、推论、评价 - 禁止改写强度 —— "可选"不许变"必须" - 禁止补全或解释 —— 不替原文补主语、不解释术语 - 禁止为凑压缩比硬压 —— **不确定是否冗余,就保留** ### 交付前自检门(必须跑) ```bash python3 scripts/slc_check.py 原文件 压缩稿 # 自动比对数字/专名/否定词,算压缩比 ``` 脚本查不到的,自己回答这 4 问: 1. 数字、专名、否定、条件是否逐条对照过? 2. 有没有冒出原文没有的因果或评价? 3. **反向检验**:只看压缩稿,能否还原原文全部事实主张与可执行动作? 4. **歧义检验**:有没有哪个词变得可两解,而原文本来明确? 任何一问答"否" —— 回退重压该段,或原样保留该段。 ### 不适用场景(遇到就拒绝压缩并说明原因) - 法务、医疗、财务合规文本(需逐字) - 代码与配置文件(用对应语言的 minifier,不用本技能) - 本身不足 100 字且无冗余的文本(收益为负) - 需要保留文风的创意文案、品牌 slogan(压完就不是它了) ### 示例库 `references/compression-rules.md` —— **必读**,含 12 组原文/压缩稿对照与手法标注,开始压缩前读一次。 --- ## B · 上下文治理 目标是"用最小上下文拿到同样好的结果"。核心不是少说话,而是**别把不需要的读进来、别把已知道的再写一遍**。 六条铁律(详版见 `references/context-economics.md`): 1. **读之前先问代价** —— `scripts/context_cost.py FILE` 估成本:低于 2k 直接读;2k–8k 先 Grep 定位再局部 Read;超过 8k 禁止整读,改脚本 parse。 2. **输出不回显已知** —— 超过 200 行落文件;不复述工具输出原文;最终回复控制在 50–70 行。 3. **能并行就并行** —— 互相独立的工具调用放同一个 block 一次发出。 4. **大上下文用子代理隔离** —— 派 Explore 子代理,并要求"报告 200 字内,只给结论和路径,不贴原文"。 5. **搜索一次问清** —— query 写全实体名与时间范围;多关键词并行搜,不排成一串。 6. **复用而非重算** —— 重复 3 次以上的操作固化成 `scripts/` 脚本。 诊断与审计: ```bash python3 scripts/context_cost.py --top 30 ~/.workbuddy/skills/NAME # 审计 skill 体积 python3 scripts/prompt_profiler.py prompts-dir/ # 量化固定开销占比 ``` 改造 skill 按**渐进式披露**三级加载:metadata(约 100 词常驻)→ SKILL.md body(触发时,目标 5k 词内)→ references(按需)。每条 reference 必须在 SKILL.md 里有索引,且文件顶部写一行"何时读取本文件"。 --- ## 资源索引 | 文件 | 何时读 | |---|---| | `references/compression-rules.md` | **必读**。开始 A 路径压缩前读一次:判定细则、档位边界、12 组示例 | | `references/context-economics.md` | 走 B 路径,或需要审计 / 改造 skill 体积时 | | `scripts/slc_check.py` | 每次压缩后跑(自检门) | | `scripts/context_cost.py` | 读文件前估 token 成本、审计目录体积 | | `scripts/prompt_profiler.py` | 诊断 prompt 样本与埋点日志里的固定开销 |
Files in this package (7)
- SKILL.md 9 KB
- _skillhub_meta.json 1 KB
- references/compression-rules.md 11 KB
- references/context-economics.md 5 KB
- scripts/context_cost.py 3 KB
- scripts/prompt_profiler.py 11 KB
- scripts/slc_check.py 13 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · ikdeaplop/public-generalized-products | 100 | MIT |
| haiderejaz6692/codex-powerpack | 100 | MIT |
| swap-cameroon/kuro-antigravity-config | 100 | MIT |
| cyberspezie/Token-Saver | 100 | MIT |
| ladansojudi/token-saver | 100 | Apache-2.0 |
| punyawatt51/token-saver | 90 | MIT |
| kreht1/anchor | 90 | MIT |
| lokikill123/codex-token-skills | 90 | MIT |
Database snapshot: 13.11.2026 · package version d3d3a91fe758 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 3 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100token-saver-config
Use when context window output compression engine for CLI commands (60-99% token reduction). - 100token-saver-config
Configure and diagnose token-saver compression settings. Use when the user asks about adjusting compression levels, checking processor status, debugging hook issues, or reviewing savings statistics. - 100handoff
Writes .token-saver/handoff.md so work can continue in a fresh, cheap session. Use when the user says "handoff", "continue in a new session", "context is full", or answers yes to a token-saver prompt. - 85grok-bot-token-saver
Use when a bot team wastes context or quota on long histories: chief/worker routing, short role cards, archivist handoffs and reviving a long chat into a fresh one (Chakhdz/grok-bot-token-saver). - 92prompter
Turn a vague or too-short request into a precise prompt before doing any work. Use when token-saver flags a prompt as underspecified, or when the user's request leaves the goal, scope or done criteria unclear. - 90cost-saver
Shows where context and tokens are going and trims them with concrete tips, including when to /clear, /compact or start a fresh session. Use when the user says I'm hitting my limit, usage is too high, save tokens, session feels slow, context is full, or reduce cost.