history-trim

history-trim is a skill for Claude Code from msiShariful/claude-token-inspector. It costs 49 tokens per session (770 once invoked), scanned A, original, MIT.

A conversation-history adviser that examines earlier turns and identifies where old context can be cleared safely.

In plain words
What is it for?
Use it to find a safe point for a /clear command and estimate how much context that cleanup would recover.
Why use it?
It helps reduce a long conversation without removing decisions or information still needed for the current task.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the token-inspector plugin — 8 skills shipped together

Good fit Use it to find a safe point for a /clear command and estimate how much context that cleanup would recover.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/msishariful/claude-token-inspector/history-trim
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add msiShariful/claude-token-inspector --skill history-trim
Clone the repo
git clone --depth 1 https://github.com/msiShariful/claude-token-inspector

Made for: Claude Code.

Or install token-inspector, the plugin that ships this one along with the rest of its 8 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for history-trim

README.md
[![agentmods](https://agentmods.dev/badge/skills/msishariful/claude-token-inspector/history-trim/github.svg)](https://agentmods.dev/skills/msishariful/claude-token-inspector/history-trim)
Your own site
<a href="https://agentmods.dev/skills/msishariful/claude-token-inspector/history-trim"><img src="https://agentmods.dev/badge/skills/msishariful/claude-token-inspector/history-trim/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for history-trim

Your own site · 80×15
<a href="https://agentmods.dev/skills/msishariful/claude-token-inspector/history-trim"><img src="https://agentmods.dev/badge/skills/msishariful/claude-token-inspector/history-trim.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 770 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00049 $0.00770
Opus 5.5 $0.00020 $0.00308
Sonnet 5.5 $0.00010 $0.00154
Haiku 4.5 $0.00005 $0.00077

Measured 4d ago against content hash d3e95f07582d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

history-trim scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/history-trim/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

History Trim Advisor

Analyze the conversation history and find the safest /clear point — the turn where pruning everything before it costs nothing in terms of current task context.

Analysis process

  1. Read the full conversation history — every turn, from first to last.

  2. Identify the current task anchor — the turn where the work the user is currently doing began. This is turn T.

  3. Classify every turn before T:

    • Active dependency: a prior turn contains a decision, piece of code, constraint, or output that is still referenced or needed. Cannot be cleared without loss.
    • Resolved context: a prior turn was relevant at the time but the work it relates to is complete and no longer needed. Safe to clear.
    • Dead weight: unrelated to anything still in progress. Clear immediately.
  4. Find the trim point — the latest turn where everything before it is either "resolved" or "dead weight" with no active dependencies. That's the recommended /clear point.

  5. Estimate the savings — tokens recovered by clearing up to that point.

Output format

Open with a verdict line:

✂️ Safe to clear {N} turns — recover ~{tokens} tokens

Or if no trim is safe:

⚠️ No safe trim point found — all prior turns have active dependencies

Then a turn-by-turn summary table (keep it tight — one row per distinct topic block, not per individual turn):

Turns Summary Status Safe to Clear?
1–5 Initial project setup discussion Resolved ✅ Yes
6–10 Debugged login timeout — fixed in auth.ts Resolved ✅ Yes
11–13 Decided to use JWT over sessions Active dependency 🔴 No — still shapes current work
14–now Current task: refactor auth middleware Current —

Then the recommended action:

💡 Recommended: /clear {N}

Where N is the turn number to clear up to (everything before turn N is pruned).

If there is an active dependency blocking a full clear, add:

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed · +1 lines · +4 tokens per session d3e95f07582d
  2. 1mo ago First seen · 91 lines · 45 tokens per session scan A 41be8346283a

Subscribe to this mod's changes

history-trim is a skill published in the GitHub repository msiShariful/claude-token-inspector (4 stars, last pushed 5d ago), licensed MIT. It adds 49 tokens to every session and 770 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

knowledge-wiki

A tool that turns useful lessons from coding sessions into general articles for a team wiki. A wiki is a collection of linked reference pages, and this one can be kept locally or shared through a Git repository.

wigtn/wigtn-plugins · 154 tokens

team-memory-protocol

A shared-memory process for teams of coding agents working on the same build. It stores project knowledge, shared context, and task progress in separate files or repositories.

wigtn/wigtn-plugins · 42 tokens

fresh-start

Continue in a new chat without losing anything — writes a compact handoff to paste into a fresh conversation. Use whenever the user wants to move to a new chat or conversation, hits usage limits, says replies got slow or Claude forgets earlier details, or the conversation has grown long.

egorfedorov/claude-context-optimizer · 60 tokens

doc-digest

Turn a long document, PDF, transcript, spreadsheet or log into a compact working digest the conversation can continue from. Use when the user shares or pastes something long (several pages or more) and wants to discuss, analyze, compare or use it over more than one message, or asks to summarize a document so they can…

egorfedorov/claude-context-optimizer · 75 tokens

project-context

Turn background the user keeps re-explaining or re-pasting into reusable instructions, so new chats start with it for free. Use when the user repeats the same context, rules, style guide, persona or reference text across messages or chats, says they are tired of explaining the same thing, or asks how to set up a…

egorfedorov/claude-context-optimizer · 81 tokens

token-check

Estimate how many tokens a pasted text, an attached file or the conversation so far takes, what it means for the context window and usage limits, and how to cut it. Use when the user asks how big something is in tokens, why they keep hitting limits, or whether a file is too large to send.

egorfedorov/claude-context-optimizer · 66 tokens