ClaudeMods
☰
ZH-CN
● — 人在线 · 浏览 — 次
赞助提交作品
GitHub 仓库 · 发布者 korro_ai

我做了一个 Claude Code 模组,削减了约 30% 的 token 成本,还配了一个像素风主题

Seuil 是一个开源的 Claude Code 模组,会在每轮对话后监控会话大小,并在超过可配置阈值(默认 300k tokens)后自动压缩,以降低 token 成本;它带有实时状态栏和 /seuil 命令;还包含一个像素风格的 Campfire 主题。作者报告在 144 次重放的会话中节省约 30%,并提供一个只读的本地模拟器脚本。

已翻译

关于这个 mod

这篇文章介绍了 Seuil:它在每轮之后测量真实会话大小,并在超过 300k tokens(可通过 /seuil 250 调整,通过 /seuil off 禁用)后,在轮次之间进行压缩,保留决策、工作状态和文件路径。状态栏会显示进度(Seuil · 182k / 300k)。一个基准测试脚本会以只读方式重放本地会话,以估算节省量;作者报告总体节省约 30%(在悲观假设损失 50k tokens 的情况下为 27%),且主要集中在长会话中。还捆绑了一个可选的 Windows Terminal 像素艺术“Campfire”主题。安装:/plugin install seuil --marketplace KorroAi/seuil;仓库位于 github.com/KorroAi/seuil。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add KorroAi/seuil
claude plugin install seuil@seuil
原文 / README
<div align="center">

Seuil

Automatic compaction for Claude Code: between two turns, once the conversation passes a threshold.

Every model call re-reads the whole conversation, so a long session pays mostly for re-reading.<br> Seuil keeps the conversation short without you thinking about it. Seuil is French for threshold.

License: MIT Claude Code plugin Tests Paper

Seuil in 15 seconds: every call re-reads the conversation; past 300 k tokens Seuil compacts it between two turns

<sub>Seuil in 15 seconds. The compaction shown (366 k → 47 k) comes from a real session, the 30 % from the paper. <a href="https://github.com/KorroAi/seuil/raw/main/docs/media/seuil-demo.mp4">Watch it in HD (1080p)</a>.</sub>

</div>

Why

On 144 real sessions (30 days, 33,634 model calls), replayed with automatic compaction at 300 k tokens:

  • about 30 % of the total cost saved, 27 % if each summary forgets 50 k tokens that must be read again;
  • about 20 % for a user who already restarts long sessions by hand;
  • nothing for sessions that stay short: all the gain is in long sessions.

Trimming tool outputs instead, the obvious idea, would save 0.1 % without loss and 5 % at most. The method, the tables and the limits are in the paper. bench/simulate.mjs runs the same replay on your own sessions.

Saving by threshold

Install

At the prompt of a Claude Code terminal session:

/plugin install seuil --marketplace KorroAi/seuil

Answer y to add the marketplace, then pick a scope (user scope = every session). From a shell:

claude plugin install seuil --marketplace KorroAi/seuil

In the desktop app: click + next to the prompt box, then Plugins, Add marketplace with KorroAi/seuil, then Add plugin.

Seuil uses the Claude Code mod API (function hooks), which is in early access. Checked on Claude Code 2.1.325.

What it does

  • At the end of each turn it reads the real size of the conversation from Claude Code.

  • Above the threshold (300 k tokens by default) it starts Claude Code's own compaction, with instructions that ask the summary to keep the goal, every decision and correction you gave (quoted), the exact state of the work, the files with their paths, what remains to do, and the pitfalls met.

  • It never compacts in the middle of a turn or inside a subagent.

  • It does not start again right after a compaction that left the conversation close to the threshold: then it waits until the conversation has grown back by half.

  • On a model whose context window is smaller than the setting, the threshold drops to 75 % of the window.

  • You always see where you are, live, even during a long turn. In the terminal, at the end of the hint line under the prompt:

    ? for shortcuts · Seuil · 182 k / 300 k · last compaction 341 k → 64 k
    

    In the desktop app and remote sessions, as the plugin's status line. Each compaction also leaves a line in the transcript.

  • In a headless session (claude -p, an SDK host) it goes through /compact, since direct compaction is not available there yet.

| Command | Effect | |---|---| | /seuil | status, last compaction, total taken out since install | | /seuil 250 | sets the threshold to 250 k (minimum 100 k) | | /seuil now | compacts as soon as the turn ends | | /seuil off, /seuil on | switches automatic compaction off or on |

The model also gets a diagnostic tool that reports the real state read from the engine.

Measure it on your own sessions

node bench/simulate.mjs        # the last 30 days
node bench/simulate.mjs 60     # the last 60 days

It reads ~/.claude/projects without changing anything and sends nothing anywhere. Projects are numbered, never named, so the output can be shared. Node 18 or newer, no dependency.

The Campfire theme (Windows Terminal, optional)

A night landscape in pixel art, drawn by a shader behind the text: starry sky, shooting stars, mountains, forest, and a camp with a fire and a cat that sits, blinks and falls asleep. It stays dark and in the back, fades out under text, and never passes under the line you type in. It is the background of the demo above.

The camp, enlarged

node theme/install.mjs               # adds a "Seuil · Campfire" profile to the new-tab menu
node theme/install.mjs --everywhere  # applies it to every Windows Terminal profile
node theme/install.mjs --remove      # removes everything it added

A copy of Windows Terminal's settings is kept before the first change (settings.json.before-seuil-theme). The theme uses Windows Terminal's experimental pixel shader settings; it was checked on Windows Terminal 1.24. Other terminals (VS Code, macOS, Linux) have no pixel shaders: the theme is Windows Terminal only, the mod works everywhere Claude Code runs. Everything is code: paint.mjs paints the camp, campfire.hlsl draws the rest and animates it.

Limits

  • A compaction loses detail. The instructions limit the damage, they do not remove it.
  • It happens only between turns: a long agentic turn can grow well past the threshold before it ends.
  • It takes time: 45 to 58 s in real sessions.
  • The savings come from a simulation on one heavy user's sessions; see the paper for what it does not cover.

Develop

claude --plugin-dir .          # run Claude Code with this folder as a mod
claude plugin test .           # 15 tests
claude plugin validate .

What changed between versions: CHANGELOG.md.

License

MIT

获取徽章

这是你的项目吗?把这个徽章放进 README 或网站,链接回本页。

Featured on ClaudeMods
尺寸
配色
Markdown
HTML

更多类似作品