◈ 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
RETIREDThe 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:
- Open
~/.claude/settings.jsonand delete theUserPromptSubmitentry whose command containstokenshrink-compress. Also delete anyPreToolUseorSessionStartentry whose command containstokenshrink-. - Run:
rm -f ~/.claude/hooks/tokenshrink-*.js ~/.claude/.tokenshrink-saved ~/.claude/.tokenshrink-log.jsonl - If you set up the session vocabulary, also run:
rm -f ~/.claude/session-vocab.json - If you added a status line that reads
~/.claude/.tokenshrink-saved, remove it from~/.claude/settings.json.
OpenClaw
OpenClaw
SDKCompress 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.
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
SDKTwo functions. Works with every LLM.
// Single prompt
import { compress } from 'tokenshrink';
const { compressed, stats } = compress(myPrompt);
// → stats.tokensSaved
// → stats.ratio// Full conversation history
import { compressHistory } from 'tokenshrink';
const { messages, stats } = compressHistory(history);
// → stats.totalTokensSaved
// → stats.messagesCompressednpm install tokenshrink