Skip to content
Back to skills

History Trim

ASecurity

Analyze conversation history turn-by-turn and identify the exact point to run /clear from to prune stale history while keeping everything relevant to the current task. Use when history has grown long but you want to continue in the same session.

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 11, 2026
ai-agents

Security analysis

A100/100

Scanned June 11, 2026

npx -y skills add msiShariful/claude-token-inspector --skill history-trim --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of History Trim?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for History Trim
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/msishariful-history-trim/badge)](https://www.skillsdirectory.com/skills/msishariful-history-trim)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Analyze conversation history turn-by-turn and identify the exact point to run /clear from to prune stale history while keeping everything relevant to the current task. Use when history has grown long but you want to continue in the same session.
disable-model-invocation: true
---

# 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:

```
⚠️ Before clearing: note this from turn {X}: "{one-sentence summary of the active dependency}"
```

List each active dependency that would be lost, so the user can manually preserve it before running `/clear`.

---

### If everything is safe to clear (no active dependencies at all):

```
✅ Full clear is safe — /clear will lose nothing relevant to your current task.
💡 Run: /clear
```

### If no turns can be cleared:

```
🔴 No safe trim point — every prior turn contains context still relevant to your current task.
💡 Consider /token-inspector:suggest-split to start a fresh session instead.
```

## Trim point rules

- Never recommend clearing a turn that contains: a decision still being acted on, code that was written and is still in use, a constraint or requirement that shapes current work.
- Prefer a trim point at a natural topic boundary (end of a resolved subtask) over an arbitrary line.
- If in doubt about a turn, mark it as active dependency — err on the side of preserving context.

$ARGUMENTS

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.