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

smart-claude

v2.0.0

Published

Token optimization hook for Claude Code — analyzes prompts and suggests improvements to reduce token usage

Downloads

16

Readme

smart-claude

Token optimization hook for Claude Code. Analyzes your prompts in real-time and suggests ways to reduce token usage without losing effectiveness.

What it does

smart-claude installs as a UserPromptSubmit hook in Claude Code. Every time you send a prompt, it:

  1. Counts tokens (approximate, using GPT tokenizer)
  2. Detects inefficiencies: filler phrases, duplicate intents, unnecessary preambles, redundant modifiers, poor structure
  3. Tracks session patterns: context bloat, iterative refinement chains, growing prompt sizes
  4. Outputs actionable suggestions as context that appears alongside Claude's response

When your prompt is clean, the hook stays silent.

Install

npm install -g smart-claude
smart-claude install

This adds a UserPromptSubmit hook to your ~/.claude/settings.json. The hook runs on every prompt with a 5-second timeout.

Uninstall

smart-claude uninstall
npm uninstall -g smart-claude

CLI Commands

smart-claude install          # Add hook to Claude Code settings
smart-claude uninstall        # Remove hook from Claude Code settings
smart-claude status           # Show installation status and session stats
smart-claude reset            # Reset session tracking for current project
smart-claude analyze "prompt" # Analyze a prompt without sending to Claude

What it detects

| Category | Example | Suggestion | |----------|---------|------------| | Filler phrases | "Could you please..." | Direct instructions work equally well | | Duplicate intent | "in detail step by step" | Pick one -- they mean the same thing | | Unnecessary preambles | "Act as a senior engineer" | Claude Code already knows its role | | Redundant modifiers | "very detailed" | Be specific about what you need instead | | Poor structure | Long single-line prompts | Use bullet points for multi-part requests | | Context bloat | Re-pasting previous context | Summarize or reference previous answers | | Refinement chains | Similar consecutive prompts | Combine constraints upfront |

Session tracking

smart-claude tracks per-project session state in ~/.smart-claude/. It monitors:

  • Prompt growth trends -- warns when prompts get progressively larger
  • Context overlap -- detects when you're repeating context between prompts
  • Refinement chains -- flags iterative prompt tweaking (>60% similarity)
  • Cumulative stats -- total tokens, average per prompt, waste score

How it works

The hook receives the prompt via stdin JSON from Claude Code's hook system. Analysis happens locally with no network calls. Output is injected as additional context that Claude can reference when responding.

User prompt → hook.js → analyze → format markdown → stdout → Claude sees tips

Development

git clone <repo-url>
cd smart-claude
npm install
npm test

Testing the hook manually

echo '{"prompt": "Could you please explain how closures work?"}' | node hook.js

License

MIT