Skip to content
Back to skills

Token Optimizer

ASecurity

Token usage optimization — prune stale tool outputs, analyze usage, reduce context bloat. Triggers when user says: - "context too long", "token limit", "reduce tokens" - "context bloat", "running out of context" - "optimize", "prune old messages"

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentsgobash

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add m4stanuj/MAST --skill token-optimizer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Token Optimizer?

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

Security grade badge for Token Optimizer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/m4stanuj-token-optimizer/badge)](https://www.skillsdirectory.com/skills/m4stanuj-token-optimizer)

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
---
name: token-optimizer
description: |
  Token usage optimization — prune stale tool outputs, analyze usage, reduce context bloat.
  
  Triggers when user says:
  - "context too long", "token limit", "reduce tokens"
  - "context bloat", "running out of context"
  - "optimize", "prune old messages"
---

# Token Optimizer — Context Management Skills

**Maximize agent efficiency by managing context window intelligently.**
Critical for long OpenWork v6 automation sessions.

---

## Plugin 1: Token Pruner

Automatically removes stale tool outputs from conversation context.

```jsonc
{
  "plugin": ["opencode-token-pruner"]
}
```

**What it prunes:**
- Duplicate file reads
- Old bash command outputs (keeps last N)
- Redundant search results
- Tool errors that were resolved

---

## Plugin 2: Token Usage Analyzer

Real-time token analysis per session.

```jsonc
{
  "plugin": ["opencode-token-analyzer"]
}
```

**Commands:**
```bash
/tokens          # Current usage breakdown
/tokens history  # Usage across sessions
/tokens expensive # Most expensive tool calls
```

---

## Manual Optimization Strategies

### 1. Skill-based Context Loading

Instead of loading everything upfront:
```
# BAD: All skills loaded at once
# GOOD: Load skills on demand
use_skill("browser")        # Only when browsing
use_skill("screenpipe")     # Only when searching history
```

### 2. Session Handoff

When approaching context limit, create handoff:
```bash
/handoff  # Creates continuation prompt for new session
```

### 3. AGENTS.md Hierarchy (via omo /init-deep)

Generate lean per-directory context:
```bash
/init-deep  # Creates AGENTS.md in each subdirectory
```

Result: Agent loads only relevant context per task.

---

## OpenWork v6 Token Budget (Estimated)

| Provider | Context | Cost/1M tokens | Best For |
|----------|---------|----------------|---------|
| Groq (free) | 32K | $0 | Quick tasks |
| Cerebras (free) | 8K | $0 | Speed |
| DeepSeek | 128K | ~$0.14 | Long sessions |
| Gemini 2.5 Pro | 1M | ~$1.25 | Very long sessions |
| Claude Opus | 200K | $15 | Complex reasoning |

**Tip:** Route long automation sessions to DeepSeek or Gemini to minimize cost.

---

## .opencode/rules/token-hygiene.md

Create this file:
```markdown
# Token Hygiene Rules

- After completing a subtask, summarize findings in 3 bullet points max
- Don't re-read files you've already processed; reference them by name
- Use /handoff when context > 80% full
- Prefer grep/search over reading entire files
- After bash commands, acknowledge key output only — don't echo full output
```

---

## Rating

| Feature | Score |
|---------|-------|
| Free | ✅ 10/10 |
| Automatic | ✅ 9/10 |
| Context Savings | ~30-50% |

**Overall: 9/10** — Essential for long automation sessions!

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

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