◈ Drop-in compression for every workflow

Integrations

TokenShrink plugs into your existing workflow. No new tools to learn. No changes to how you work.

Claude Code Hook

Claude Code

RETIRED

The TokenShrink Claude Code hook is retired. Claude Code's UserPromptSubmit hooks can add context to a prompt, but they can't replace it. So the hook never reduced what Claude received, and the savings counter it showed was not real.

The hook installed by the one-line installer also sent each prompt you typed to tokenshrink.com for compression. TokenShrink's database stored only counts (word and token totals), never the prompt text. The installer and the hook download now do nothing.

If you installed the hook, please remove it:

  1. Open ~/.claude/settings.json and delete the UserPromptSubmit entry whose command contains tokenshrink-compress. Also delete any PreToolUse or SessionStart entry whose command contains tokenshrink-.
  2. Run: rm -f ~/.claude/hooks/tokenshrink-*.js ~/.claude/.tokenshrink-saved ~/.claude/.tokenshrink-log.jsonl
  3. If you set up the session vocabulary, also run: rm -f ~/.claude/session-vocab.json
  4. If you added a status line that reads ~/.claude/.tokenshrink-saved, remove it from ~/.claude/settings.json.

OpenClaw

OpenClaw

SDK

Compress conversation history before routing to your agents

What is OpenClaw

OpenClaw is a Discord-to-AI gateway that routes messages to local agents. TokenShrink's compressHistory() reduces the token cost of every conversation before it hits your Ollama models.

openclaw-handler.js
import { compressHistory } from 'tokenshrink';

// Before sending conversation to your agent
const { messages, stats } = compressHistory(conversationHistory);
console.log(`Saved ${stats.totalTokensSaved} tokens this turn`);

// Pass compressed messages to Ollama or any OpenAI-compatible API
const response = await fetch('http://localhost:11434/api/chat', {
  method: 'POST',
  body: JSON.stringify({
    model: 'your-model',
    messages: messages,
  }),
});

Note

Works with any Ollama model. Compression happens locally — no data leaves your machine.

SDK

Any Claude App

SDK

Two functions. Works with every LLM.

single-prompt.js
// Single prompt
import { compress } from 'tokenshrink';

const { compressed, stats } = compress(myPrompt);
// → stats.tokensSaved
// → stats.ratio
conversation.js
// Full conversation history
import { compressHistory } from 'tokenshrink';

const { messages, stats } = compressHistory(history);
// → stats.totalTokensSaved
// → stats.messagesCompressed
npm install tokenshrink