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

@better-compact/cli

v0.2.5

Published

On-disk context compaction for Claude Code sessions

Readme

@better-compact/cli

On-disk compaction for Claude Code sessions.

Install

Requires Node.js 22.15 or newer.

npm install -g @better-compact/cli

Usage

Compact a closed session:

better-compact claude <session-id>

Compact and reopen it:

better-compact claude <session-id> --resume

Run Claude Code through the wrapper:

better-compact claude --run

The wrapper supports the companion plugin's /better-compact:compact command. Exit the session after running the command; the wrapper compacts and reopens it.

Options

| Option | Action | | ------------------------ | ------------------------------------------------------- | | --resume | Reopen the session after compaction | | --run [claude args...] | Launch Claude Code and handle queued compaction on exit | | --keep-tokens <n> | Keep a larger or smaller raw tail; default is 25k | | --from-backup | Restore original entries before compacting | | --aggressive | Write a compact boundary and summary |

Examples:

better-compact claude <session-id> --keep-tokens 40000 --resume
better-compact claude <session-id> --from-backup
better-compact claude <session-id> --aggressive --resume

Companion plugin

Install the Claude Code slash command:

claude plugin marketplace add AshishKumar4/better-compact
claude plugin install better-compact@better-compact

Then launch Claude Code through the wrapper:

better-compact claude --run

Run /better-compact:compact in the session, then exit with Ctrl-D.

Legacy cleanup

Older Better Compact releases used a local proxy. Remove that configuration with:

better-compact install claude-code

On a fresh installation, this command makes no changes.

Safety

The CLI operates on closed sessions only. Before replacing a transcript, it:

  1. checks that the session is not active;
  2. writes a backup under ~/.better-compact/claude-backups/;
  3. compacts a structured copy;
  4. validates the rewritten transcript;
  5. writes a temporary file and renames it into place.

Behavior

Normal mode keeps every conversation entry. It replaces old tool output and large tool input with short stubs, removes old reasoning, keeps the recent tail, and resets stale input accounting.

--aggressive appends Claude Code-compatible compact boundary and summary entries. Old turns leave the active context after resume.

Development

From the repository root:

pnpm install
pnpm --filter @better-compact/cli typecheck
pnpm --filter @better-compact/cli test
pnpm --filter @better-compact/cli build

Architecture

Claude Code enforces its context limit before sending the model request. It rebuilds that state from session JSONL when a session resumes. Better Compact edits the closed transcript because an outgoing request transform cannot change that client-side state.

The CLI uses the shared Anthropic codec to pair tool calls with results and preserve unknown content. It uses the shared pruning helpers for estimates, tool targets, and boundary selection.

Session lookup, live-process checks, backup recovery, JSONL parsing, usage reset, atomic replacement, and resume arguments remain Claude Code-specific.

License

AGPL-3.0-or-later