/claude-slim:claude-slimfrom claude-slim
Scans Claude Code skills, plugins, memory files, and CLAUDE.md for token bloat, then proposes non-destructive cleanup with user approval.
Ships in claude-slim. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Analyze the user's Claude Code environment for token waste and perform non-destructive cleanup.
/claude-slim or /claude-slim run → full pipeline (scan → propose → execute → report)/claude-slim scan → report only, no changes/claude-slim scan --json → raw JSON output/claude-slim doctor → check scanner prerequisites and session-log signal quality/claude-slim check-update → report whether a newer version is published/claude-slim restore → restore previously disabled itemsEvery command block below opens with a claude_slim() resolver. It is repeated in full each
time on purpose: each Bash invocation is a fresh shell, so a function defined in one
block does not survive into the next. It resolves in three tiers — the plugin's own
dist/cli.js when CLAUDE_PLUGIN_ROOT is set, then a claude-slim on PATH, then
npx. That last tier is what makes the skill work when it was installed by
npx skills add rather than claude plugin install, where no plugin root exists.
The npx tier pins a minimum version, not just a major. claude-slim@^2 looks
safer but is worse: npx reuses any cached _npx install that satisfies the range and
never re-checks the registry, so a machine that once fetched an older 2.x keeps running
it — a security fix would never arrive. --prefer-online does not override this. Pinning
to the exact release changes the cache key every time, which forces a fresh fetch while
still refusing an unreviewed next major. npm run check:versions keeps this pin equal to
package.json, so bump them together.
Do not shorten the name. A two-letter cs collides with claude-squad's binary, and a
shell function is invisible to timeout, env, and xargs — a wrapped call would
silently run that other program instead. Call claude_slim directly, never through a
wrapper.
An outdated claude-slim does not merely lack features — it reports wrong numbers. Versions before 2.8.0 summed memory across every project on disk and inflated the startup estimate roughly 8×; versions before 2.15.0 summed every topic file in the current project, when only MEMORY.md loads at startup — a 20× inflation on a memory-heavy project. Presenting those figures as fact is worse than not running at all, so check first:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim check-update --json
The check is cached for 24h and fails open — if it errors, times out, or returns "latest": null, proceed silently. Never block the user because a version lookup failed.
The response carries installMethod. When it is "npx" the gate is structurally
inert — the CLI was just fetched at the tag it is being compared against, so outdated
can never be true. Note that the version was resolved at run time and move on; do not
present the gate as a safeguard it is not.
If "outdated": true, stop and tell the user before scanning:
설치된 claude-slim이 {installed}이고 최신은 {latest}입니다. 2.8.0 이전 버전은 시작 토큰을 약 8배 부풀려 보고합니다 — 지금 스캔하면 그 숫자가 나옵니다.
{upgradeCommand}
업데이트 후 진행할까요, 아니면 현재 버전으로 계속할까요?
Then honour their answer. If they choose to continue, run the scan but label the numbers as coming from an outdated version in your report.
Plugin installs need a restart (only when installMethod is "plugin"). claude plugin update writes the new version to disk, but the running session keeps the loaded copy. Tell the user this explicitly — otherwise they update, re-run, and see the same stale numbers with no idea why.
If "outdated": false, say nothing and continue to Phase 1.
Run the CLI to collect environment data:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim scan --json
If that command fails for any reason — node missing, or the npx tier unable to
reach the npm registry because the machine is offline or behind a proxy — fall back to
the legacy bash scanner. It needs neither node nor a network:
for d in "${CLAUDE_PLUGIN_ROOT:+$CLAUDE_PLUGIN_ROOT/skills/claude-slim}" "$HOME/.claude/skills/claude-slim" "./.claude/skills/claude-slim"; do
[ -n "$d" ] || continue
if [ -f "$d/scripts/scan.sh" ]; then bash "$d/scripts/scan.sh" json; exit $?; fi
done
echo "claude-slim: no scan.sh found in any known skill directory" >&2
exit 1
If this fails too, tell the user the scan could not run and stop. Never continue to Phase 2 without data: an empty scan is indistinguishable from a clean environment, and reporting zeros as fact is the one outcome worse than reporting nothing.
After getting the scan JSON, YOU must interpret and present results to the user. Do NOT just dump raw CLI output. Present a full diagnostic report in the user's language.
Templates below are shown in English for readability. Always translate headers, labels, and prompts into the user's detected language when rendering.
The JSON reports token counts in two different units, and mixing them produces savings figures larger than the entire thing being saved:
listingTokens (and totalTokensBefore, recoverableStartupTokens) —
what a session pays at startup for the catalog line.tokens on a skill or an issue — the whole SKILL.md body, paid only when
that skill is actually invoked.Issue.tokens is the second kind. Never sum it and call the result savings.
On a real machine that sum was 215,535 against a 13,434-token startup total —
16× the whole budget. Use recoverableStartupTokens, which the CLI already
computes with duplicates collapsed and the right unit.
Quote body tokens only when explaining what one skill costs per invocation, and label them that way.
Show a summary table:
| Item | Count | Tokens |
|---|---|---|
| Local skills | N (XKB) | X tok |
| Plugins | N (M skills) | ~X tok |
| CLAUDE.md | XKB | X tok (+ X tok @path imports) |
| Rules | N files | X tok at launch (X tok path-scoped) |
| Memory index | MEMORY.md XKB | X tok at startup (currentProjectMemoryTokens) |
| Session startup overhead | ~X tok (totalTokensBefore) |
Check currentProjectKnown before presenting memory numbers. When it is
false, Claude Code holds no state for that slug. The 0 is correct, but it
may be answering the wrong question — the slug can point at a plugin cache or a
git worktree rather than the project the user meant. Say that no project state
backs this path and offer --project-dir <path>, instead of presenting the 0 as
a clean result. Do not assert the memory was lost: a directory Claude has never
opened really does have none.
When the JSON has measuredStartup and listingVisibility, they come from the
newest session log — what Claude Code actually sent, not a disk estimate. Present
them after the snapshot table, citing the session date and Claude Code version
(listingVisibility.sessionDate, .claudeCodeVersion), and say so if
fromOtherProject is true.
listingVisibility.collapsed). The skill listing
is capped at budgetChars (1% of the context window). Past it Claude Code drops
descriptions from the least-used skills; the model then sees only the name and
rarely picks them. Give the count out of skillCount, group by plugin/source,
and mark flaggedUnused ones. Offer the three fixes: clean unused skills
(restoredIfFlaggedCleaned descriptions come back), set hand-invoked skills to
"name-only" in skillOverrides, or raise skillListingBudgetFraction.skillListingUncappedTokens exceeds listingVisibility.budgetTokens, the
listing already costs only its budget. Do not promise token savings from
removing skills; recoverableStartupTokens already accounts for this.measuredStartup.deferredTools.duplicateServers: two MCP servers exposing
the same tool names — usually one connector added twice. Recommend removing one
copy. collisions outside those pairs mean Claude may call the wrong server.firstTurnInputTokens is the whole first request, Claude Code's own prompt and
tools included. Do not present it as claude-slim's overhead figure.List each plugin with skill count and a judgment:
| Plugin | Skills | Notes |
|---|---|---|
| omc | 36 | Core plugin. Keep. |
| temp_local_... | 1 | Failed install remnant. Cleanup target. |
Annotate each with status: actively used, possibly unused, or cleanup target. Flag temp_local_* entries as failed install remnants.
Group issues by tier and explain EACH one with context and recommendation:
Tier 1 — Immediate cleanup (zero risk): These are safe to remove with zero risk: broken symlinks, empty templates, .skill/ duplicates, temp_local_* cache. Pre-selected. Explain why each is safe.
Tier 2 — Recommended cleanup: These are recommended but need user judgment. For each issue, explain:
Example: "frontend-design exists both locally and in a plugin. Removing the local copy is safe because the plugin version remains. Saves ~823 tok."
Tier 3 — Optional (user judgment): These are large skills that cost tokens but might be in active use. For each:
End with a numbered action list, ordered by impact:
For total savings, quote recoverableStartupTokens and state it against
totalTokensBefore ("~2,700 of ~13,400 startup tokens"). Do not add up the
per-issue numbers — see 2-0. A skill flagged three times is one cleanup, and
its body size is not a startup cost.
If subcommand is scan, stop here. Ask a localized equivalent of "Proceed with cleanup?" only for the full pipeline.
Run the interactive clean command:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim clean
Or with dry-run:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim clean --dry-run
After cleanup, re-run scan to get updated numbers, then show the savings report:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim report
Present the report box AND the before/after breakdown table to the user.
When /claude-slim restore is invoked:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim restore
When /claude-slim doctor is invoked:
claude_slim(){ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "$CLAUDE_PLUGIN_ROOT/dist/cli.js" ]; then node "$CLAUDE_PLUGIN_ROOT/dist/cli.js" "$@"; elif command -v claude-slim >/dev/null 2>&1; then claude-slim "$@"; else npx -y 'claude-slim@^2.17.0' "$@"; fi; }
claude_slim doctor
Explain warnings in the user's language. Pay special attention to session-log warnings because they explain why unused-skill detection may be suppressed.
Detect the user's language from their most recent message. Present all reports, analysis, and explanations in that language — including table headers, tier labels, prompts, and every user-facing string. The CLI output is machine-readable (always English) and must not be echoed verbatim; translate its content into the user's language when you interpret it. The example tables above are written in English only for authoring clarity — do not treat them as a required output format.
~/.claude/skills.disabled/; dead symlink files and failed-install temp_local_* caches are permanent cleanups and should be described that way.--dry-run to preview changes.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub iops-leo/claude-slim --plugin claude-slimOther plugins' skills for the same job