Skip to content
Back to skills

Token Optimizer

ASecurity

Read large logs, JSON/API responses, data exports and long documents through LatentGate's token optimizer instead of reading them raw. Use when a file you only need to understand (not edit) is likely over ~2,000 tokens — log files, stack-trace dumps, pretty-printed JSON, CSV/NDJSON exports, long docs or RAG chunks — or when the user asks to save tokens/context.

  • 25 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 8, 2026
ai-agentsapi

Works with

  • api
  • mcp

Security analysis

A100/100

Scanned October 8, 2026

npx -y skills add KathanModh259/latent-gate --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/kathanmodh259-token-optimizer/badge)](https://www.skillsdirectory.com/skills/kathanmodh259-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: Read large logs, JSON/API responses, data exports and long documents through LatentGate's token optimizer instead of reading them raw. Use when a file you only need to understand (not edit) is likely over ~2,000 tokens — log files, stack-trace dumps, pretty-printed JSON, CSV/NDJSON exports, long docs or RAG chunks — or when the user asks to save tokens/context.
---

# Token optimizer

The `latent-gate` MCP server returns a compact version of text with the
facts intact. It runs locally in ~1ms per file, needs no Ollama or API key,
and gives the same output for the same input.

## Use it for files you need to *understand*

Call `read_file_optimized` instead of reading the file directly when it is
large and you only need its content:

- **Logs**: runs of repeated lines are folded to the first line, the last line,
  and the range of each varying field (`id=5001…5398`). Often 90%+ smaller.
- **Pretty-printed JSON**: minified losslessly (values and spellings untouched). ~30% smaller.
- **Long docs / RAG chunks**: pass `question` and `level: "aggressive"` or a
  `max_tokens` budget to keep only the sentences relevant to what you need.

Code blocks, URLs and quoted strings are always returned byte-for-byte.

## Don't use it for files you will edit

The optimized text is not byte-identical to the file (JSON is minified, runs
are folded). Read files you intend to modify with the normal file-reading tool,
so your edits match the real content.

## Levels

| level | what it does | facts kept |
|-------|--------------|------------|
| `lossless` | whitespace, JSON minify, exact-duplicate folding | all |
| `balanced` (default) | + log-run folding, filler removal | all except folded log values (ranges kept) |
| `aggressive` | + keeps the most relevant sentences (~50%) | most; the actual request is never dropped |

`optimize_text` does the same for text you already have, and `count_tokens`
measures size. Report the savings (`original_tokens` → `optimized_tokens`)
when it helps the user see what was saved.

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…