npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

thedistillery

v0.1.1

Published

The Distillery — token optimization proxy for Claude Code

Readme

The Distillery

A token optimization proxy for Claude Code. Intercepts Anthropic API requests via ANTHROPIC_BASE_URL, removes redundant context, and reduces your Claude Code bill.

Install

npm install -g thedistillery

Quick Start

# Log in (one-time)
thedistillery auth login

# Start the proxy — automatically configures Claude Code routing
thedistillery start

# Use Claude Code normally — The Distillery runs in the background
# Check your savings
thedistillery stats

Using a tool other than Claude Code (Cline, Goose, Aider, Zed, Codex CLI)? Run export ANTHROPIC_BASE_URL=http://127.0.0.1:3080 or use your tool's config mechanism. See Supported clients for per-tool instructions.

How It Works

The Distillery sits between Claude Code and the Anthropic API. It intercepts every request and removes redundant context before forwarding:

  1. Deduplication — removes identical tool outputs seen earlier in the session
  2. Compression — trims oversized tool results to head+tail with a ~N tokens omitted marker
  3. History trim — prunes old turns when context is too large

All processing is local. No code or prompts reach The Distillery's servers — only token counts and cost deltas sync for billing.

Supported clients

The Distillery works with any AI coding tool that can be pointed at a custom Anthropic base URL, plus OpenAI-API-compatible tools through either the OpenAI adapter at /v1/chat/completions or the OpenAI passthrough at /openai/v1.

| Client | Configuration mechanism | OpenAI adapter required | |---|---|---| | Claude Code | auto-configured by thedistillery start (injected into ~/.claude/settings.json) | No | | Cline | cline.anthropicBaseUrl in VSCode settings.json | No | | Goose | ANTHROPIC_HOST=http://localhost:3080 | No | | Zed | language_models.anthropic.api_url in settings.json | No | | Aider | --openai-api-base http://localhost:3080/v1 + --model openai/claude-sonnet-4-5 | Yes | | Codex CLI | API-key auth + OPENAI_BASE_URL=http://localhost:3080/openai/v1 | Yes |

Full step-by-step guides for each client live on the marketing site at thedistillery.dev/clients. Clients marked "OpenAI adapter required" route requests through The Distillery's OpenAI-compatible endpoints. Codex CLI must be logged in with codex login --with-api-key; ChatGPT login uses a websocket backend and bypasses OPENAI_BASE_URL.

Using AWS Bedrock (Bedrock-Mantle OpenAI-compatible)? See Bedrock setup for the manual OPENAI_BASE_URL and .distilleryrc.json configuration.

Configuration

Preset

Set a project-level optimization preset by creating .distilleryrc.json in your project directory (or any parent):

{ "preset": "balanced" }

Presets: conservative (dedup only), balanced (dedup + compression at 8,000 chars), aggressive (dedup + compression at 2,000 chars).

Disable compression per project

{ "preset": "balanced", "compression": false }

Environment variables

| Variable | Description | |----------|-------------| | DISTILLERY_PORT | Port the proxy listens on (default: 3080) | | DISTILLERY_BYPASS | Set to 1 to disable optimization (pass-through mode) |

CLI Commands

thedistillery start            # Start the proxy (default port 3080)
thedistillery start --port 4000  # Use a different port
thedistillery stats            # Show cumulative token and cost savings
thedistillery config show      # Show active config resolution chain
thedistillery export           # Export session log as JSON or CSV
thedistillery billing invoices # Show invoice history

Data

Session data is stored in ~/.distillery/data.db (SQLite, WAL mode).

Links

Uninstall

For a longer explanation of why each step is needed, see thedistillery.dev/docs/uninstalling.

Important: If you added export ANTHROPIC_BASE_URL=http://127.0.0.1:3080 to a shell profile (.zshrc, .bashrc, $PROFILE, or similar), you must remove that line before finishing. After uninstall the proxy port is dead — Claude Code will fail on every request until the variable is gone. The env-var cleanup step below covers this in detail.

1. Save your savings history (optional)

thedistillery export --format json --output ~/distillery-history.json

2. Stop the proxy

thedistillery stop

3. Log out (clears your API token from disk)

thedistillery auth logout

4. Remove Claude Code hook entries

Open ~/.claude/settings.json and delete any entry under hooks.Stop[] or hooks.PreToolUse[] whose hooks[].command path contains any of these substrings: thedistillery, tokenslayer, cliptoken. If an array becomes empty after deletion, leave it as [] or remove the key entirely — both are valid.

5. Uninstall the package

# npm
npm uninstall -g thedistillery

# pnpm
pnpm remove -g thedistillery

# Yarn classic
yarn global remove thedistillery

6. Delete the data directory

macOS / Linux:

rm -rf ~/.distillery

Windows PowerShell:

Remove-Item -Recurse -Force $HOME\.distillery

7. Scrub your shell profile

Open the profile files you use and remove any lines that set the following variables: ANTHROPIC_BASE_URL, DISTILLERY_PORT, DISTILLERY_BYPASS, and (for legacy users) TOKENSLAYER_PORT, TOKENSLAYER_BYPASS, CLIPTOKEN_PORT, CLIPTOKEN_BYPASS.

Profile files to check:

  • bash/zsh: ~/.bashrc, ~/.bash_profile, ~/.zshrc, ~/.profile
  • fish: ~/.config/fish/config.fish
  • Windows PowerShell: $PROFILE (usually Documents\PowerShell\Microsoft.PowerShell_profile.ps1)

After editing, restart your shell so the changes take effect.

8. Remove per-project config files (optional)

macOS / Linux:

find ~ -name '.distilleryrc.json' -o -name '.tokenslayerrc.json' 2>/dev/null

Windows PowerShell:

Get-ChildItem -Path $HOME -Recurse -Force -Include .distilleryrc.json,.tokenslayerrc.json -ErrorAction SilentlyContinue

Delete any files the search returns.

Verify the uninstall is complete

macOS / Linux:

which thedistillery   # should print nothing
ls ~/.distillery      # should report: No such file or directory
echo $ANTHROPIC_BASE_URL  # should be empty

Windows PowerShell:

where thedistillery                          # should print nothing
Test-Path $HOME\.distillery                  # should return False
$env:ANTHROPIC_BASE_URL                      # should be empty

Self-Hosting

The Distillery is designed for local, loopback-only use. The proxy binds to 127.0.0.1 (localhost) by default and must remain on loopback.

Warning: Do not bind to 0.0.0.0. Binding to all interfaces exposes the proxy to your local network. Because the proxy forwards requests using your Anthropic API key, any host on the network could then make authenticated API calls at your expense.

Supported deployment:

  • ANTHROPIC_BASE_URL=http://127.0.0.1:3080 — single developer machine
  • Port override via DISTILLERY_PORT — stays on loopback regardless of port

For the full threat model covering the BYOK architecture, see the SECURITY.md.

License

This project is licensed under the Elastic License 2.0.