claude-slim 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -9
- package/dist/tokenizer.js +12 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
# claude-slim
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/claude-slim)
|
|
6
|
+
[](https://www.npmjs.com/package/claude-slim)
|
|
6
7
|
[](https://github.com/iops-leo/claude-slim/actions/workflows/ci.yml)
|
|
8
|
+
[](https://nodejs.org)
|
|
7
9
|
[](./LICENSE)
|
|
8
10
|
|
|
9
11
|
**Your Claude Code session burns thousands of tokens before you even say "hello."**
|
|
@@ -28,17 +30,20 @@ No proxy, no compression, no changes to how Claude Code talks to the API — it
|
|
|
28
30
|
<img src="docs/demo.gif" alt="claude-slim cleanup: 11,442 tokens of overhead reduced to ~5,800 in 45 seconds" width="900" />
|
|
29
31
|
</p>
|
|
30
32
|
|
|
31
|
-
Where the bloat hides:
|
|
33
|
+
Where the bloat hides — measured on one real install:
|
|
32
34
|
|
|
33
|
-
| Source |
|
|
34
|
-
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
| Deferred tools list | ~1,500 tokens |
|
|
39
|
-
|
|
|
35
|
+
| Source | What it costs | |
|
|
36
|
+
|--------|:---:|---|
|
|
37
|
+
| Skill listings | ~10,100 tokens | 256 skills × their `name: description` line |
|
|
38
|
+
| Agent catalog | ~2,250 tokens | `~/.claude/agents/`, 12 agents |
|
|
39
|
+
| CLAUDE.md | ~2,000 tokens | plugin instructions |
|
|
40
|
+
| Deferred tools list | ~1,500 tokens | MCP tool schemas |
|
|
41
|
+
| Slash commands | ~80 tokens | `~/.claude/commands/` |
|
|
42
|
+
| Memory files | **0 – 63,500 tokens** | current project only — varies wildly per project |
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
Skill listings are the part people underestimate: each installed skill contributes one `- name: description` line to the system prompt, and those run anywhere from **30 to 509 tokens each**. Sixty terse skills and sixty verbose ones are not the same bill.
|
|
45
|
+
|
|
46
|
+
That's slower responses. Hitting your usage cap faster. Paying for context you're not using — on every turn, of every session.
|
|
42
47
|
|
|
43
48
|
---
|
|
44
49
|
|
|
@@ -176,6 +181,7 @@ npx claude-slim report # Show savings from last clean
|
|
|
176
181
|
|
|
177
182
|
- **`~/.claude/CLAUDE.md`** — your system instructions, read-only.
|
|
178
183
|
- **`~/.claude/settings.json`** — MCP server config, hooks, and any other settings. Read-only.
|
|
184
|
+
- **`~/.claude/agents/` and `~/.claude/commands/`** — measured and reported since v2.8, never moved or deleted. There is no restore path for them yet, and a destructive action without its undo isn't worth shipping.
|
|
179
185
|
- **Plugin internals** (`~/.claude/plugins/config.json`, individual `plugin.json` files) — left alone; use `claude plugin` to manage plugins.
|
|
180
186
|
- **Git / project sources** — claude-slim only looks inside `~/.claude/`, never at your code.
|
|
181
187
|
- **Anything outside `~/.claude/`** — a path-containment guard refuses destructive ops anywhere else, even if a tampered manifest asked it to.
|
|
@@ -214,6 +220,12 @@ From a real cleanup session:
|
|
|
214
220
|
| Memory files | 15KB | 2KB | **-87%** |
|
|
215
221
|
| **Est. token savings** | | **~4,300/session** | |
|
|
216
222
|
|
|
223
|
+
### A note on the numbers
|
|
224
|
+
|
|
225
|
+
claude-slim reports what a session in **this** directory pays. Memory is per-project — Claude Code loads `~/.claude/projects/<slug>/memory/` for the project you're in, not every project on disk — so running `scan` from two different repos will legitimately give you two different totals.
|
|
226
|
+
|
|
227
|
+
Token counts come from [js-tiktoken](https://github.com/nicolo-ribaudo/js-tiktoken) against the actual file contents. The only estimates left are marked with `~`: MCP tool schemas (~8 tokens/tool) and skills whose frontmatter can't be parsed (~30 tokens). Everything else is measured.
|
|
228
|
+
|
|
217
229
|
---
|
|
218
230
|
|
|
219
231
|
## v2.8.0 — What's new
|
package/dist/tokenizer.js
CHANGED
|
@@ -11,13 +11,18 @@ function getCachePath() {
|
|
|
11
11
|
let cache = { version: 1, entries: {} };
|
|
12
12
|
let cacheDirty = false;
|
|
13
13
|
export async function initTokenizer() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
// Building the cl100k_base encoder parses a large rank table — hundreds of
|
|
15
|
+
// milliseconds, and far more under CPU contention. It is immutable once
|
|
16
|
+
// built, so reuse it across calls. Only the cache is per-init state.
|
|
17
|
+
if (encoder === null && !useFallback) {
|
|
18
|
+
try {
|
|
19
|
+
// cl100k_base is closest to Claude's tokenizer (gpt-4o uses o200k_base which undercounts by ~15%)
|
|
20
|
+
const { getEncoding } = await import('js-tiktoken');
|
|
21
|
+
encoder = getEncoding('cl100k_base');
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
useFallback = true;
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
// Reset in-memory state so repeated initTokenizer() calls (e.g. across
|
|
23
28
|
// test cases) don't bleed cache entries from a prior invocation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-slim",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "Audit and shrink your Claude Code startup context. Measures what every skill, plugin, agent, command, and memory file costs in the system prompt, then reversibly disables the dead weight. Non-destructive scan, tiered proposals, one-command restore — no proxy, no compression.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|