◈ 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
HOOKAutomatically compresses every prompt you send
How it works
A UserPromptSubmit hook intercepts your message before it reaches Claude, compresses it with TokenShrink, and passes the compressed version — saving tokens on every single turn.
One-command install
curl -fsSL https://tokenshrink.com/install-claude-code.sh | bashRequires Node.js · Works on macOS and Linux · No npm install needed
What you get
- 💰 Token savings counter in your Claude Code status bar
- ⚡ Every prompt automatically compressed before it reaches Claude
- 📋 Per-session log at
~/.claude/.tokenshrink-log.jsonl
▶Manual install steps
Download the hook to ~/.claude/hooks/
curl -fsSL https://tokenshrink.com/hooks/tokenshrink-compress.js \
-o ~/.claude/hooks/tokenshrink-compress.jsRegister it in ~/.claude/settings.json
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "node $HOME/.claude/hooks/tokenshrink-compress.js"
}
]
}
]
}
}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