Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

sandeco-token-reduce-ollama

Skill by sandeco

Compresses prompts with a local Ollama model before they are sent to Claude. Built for users who want to cut token cost and latency and keep the rewrite on their own machine.

  • Score 67
  • 929 stars
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install sandeco-token-reduce-ollama

Built from the published package, never by AI.

git clone --depth 1 https://github.com/sandeco/prompts /tmp/prompts && mkdir -p ~/.claude/skills && cp -r /tmp/prompts/sandeco-token/sandeco-token-reduce-ollama ~/.claude/skills/sandeco-token-reduce-ollama

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install sandeco-token-reduce-ollama in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

Sandeco Token Reduce Ollama is an agent skill that compresses prompts before they are sent to Claude. It rewrites text with a local Ollama model, qwen3:8b by default, instead of classifying tokens with BERT as the LLMLingua-2 skill does. Input can be direct text, a .txt file, or a PDF. For PDFs, the skill extracts markdown with pymupdf4llm, saves the .md next to the PDF, and then compresses it.

The script reports token counts before and after compression, along with the ratio and saving. It can also send the compressed context and a question to Claude with the --ask option, which needs ANTHROPIC_API_KEY. The skill suits users who want local preprocessing, more fluent output than sentence-level cutting, and privacy, since the source says nothing leaves the machine. Use the LLMLingua-2 skill instead when exact word preservation matters.

Written from the project's SKILL.md and checked against it.

What it can do

  • Text compressionRewrites direct text with a local Ollama model to reduce token count.
  • File compressionCompresses the contents of a .txt file using the same Ollama rewrite.
  • PDF to markdownExtracts a PDF to markdown with pymupdf4llm and saves the .md next to the PDF.
  • Compression metricsReturns original and compressed token counts, the ratio and the saving, optionally as JSON.
  • Ask ClaudeWith --ask, sends the compressed context and a question to Claude.
  • Model selectionSwitches the Ollama model with --ollama-model. Default is qwen3:8b.
  • Automatic setupCreates a virtual environment, installs packages and pulls the model on first run.

What you need

  • Ollama installed and running (ollama serve)
  • Python
  • ANTHROPIC_API_KEY set in the environment, for the --ask option

Try asking

  • Compress this long text with Ollama at rate 0.4
  • Compress the PDF report.pdf locally with Ollama before sending it to Claude
  • Summarize notes.txt with the local qwen3 model and ask Claude about it

Good to know

  • Compression is approximate. The model may not reach the requested rate.
  • Generative rewriting can paraphrase, so original words are not preserved.
  • At rate 0.2 the model tends to stop around 30 percent, according to the source.
  • If the Ollama daemon is not running, compress.py stops with an error.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: sandeco-token/sandeco-token-reduce-ollama/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Alternatives to sandeco-token-reduce-ollama

All alternatives →

Compare with agent-reproduce-align, google_contacts or m06-error-handling

sandeco-token-reduce-ollama: common questions

How is this different from LLMLingua-2 compression?

This skill rewrites the text with a generative Ollama model. LLMLingua-2 keeps original tokens by classifying them with BERT-based models.

Does it work with PDF files?

Yes. It converts the PDF to markdown with pymupdf4llm, saves the .md file beside the PDF, and compresses that markdown.

Do I need an Anthropic API key?

Only for the --ask option, which sends the compressed context to Claude. Compression alone runs on the local Ollama model.

How do I install sandeco-token-reduce-ollama?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is sandeco-token-reduce-ollama free?

The code is public, but no licence file was found, so check the repository before commercial use.

Is sandeco-token-reduce-ollama safe to use?

It scores 67 of 100. Grades: maintenance B, licence F, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to sandeco-token-reduce-ollama?

Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.

sandeco-token-reduce-ollama Install

Add to stack

Loading.