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

@morphllm/morphrouter

v0.1.12

Published

Morph-powered Claude Code subscription router that switches Haiku, Sonnet, and Opus per user turn.

Readme

@morphllm/morphrouter

Morph-powered model routing for Claude Code.

You stay signed into Claude Code with your normal Claude account. This wrapper runs the real Claude Code TUI, classifies each prompt with Morph (difficulty / ambiguity / domain), and switches the live session between haiku, sonnet, and opus by injecting /model. It can also inject /effort low|medium|high|xhigh|max. The default matrix routes difficulty to model (easy -> haiku, medium -> sonnet, hard -> opus) and ambiguity to effort (low -> low, medium -> medium, high -> high).

No Anthropic API key, OpenRouter key, or per-user provider key is required for this mode.

Install

npm install -g @morphllm/morphrouter
# or run without installing:
npx @morphllm/morphrouter chat

Requires Node.js >= 20 and an installed, logged-in Claude Code.

Quick start

export MORPH_API_KEY=...           # your Morph key
morphrouter init                   # write a starter config
morphrouter chat "fix the parser bug"

Running morphrouter with no subcommand is the same as morphrouter chat. chat (alias enterprise-chat) launches the native Claude Code TUI. When you submit a normal prompt it: clears the draft line, calls Morph, sends /model <selected-model> if the model changed, auto-confirms Claude Code's switch prompt, sends /effort <selected-effort> if needed, waits for it to settle, then resends your prompt.

The Morph status bar is part of normal chat startup. When Claude Code does not already have a custom statusLine, morphrouter wires the bar automatically.

Slash commands (/status, /model opus, /exit, …) pass through unchanged.

Works with all Claude Code flags

Any flag you pass is forwarded straight to the underlying claude process, so subagents, MCP, sessions, and permission modes all work as normal:

# boolean flags can be passed directly:
morphrouter chat --dangerously-skip-permissions

# expose the local routed session through Claude Code Remote Control:
morphrouter chat -- --remote-control

# use `--` before value-flags so they aren't read as prompt text:
morphrouter chat "refactor auth" -- --add-dir ../shared --resume
morphrouter chat -- --mcp-config ./mcp.json --permission-mode plan

Notes:

  • The router owns --model, so a --model you pass is ignored.
  • Subagents and remote control work because this drives the real TUI — the wrapper only touches the top-level input line and /model switching.
  • In the SDK fallback (chat-sdk), --dangerously-skip-permissions and --add-dir are translated to SDK options; other flags are TUI-only.

Config

The subscription route is just the Claude Code model alias. Thinking effort is configured beside it:

{
  "routing": {
    "defaultRoute": "sonnet",
    "defaultEffort": "medium",
    "matrix": [
      { "difficulty": "easy", "ambiguity": "low",  "domain": "*", "route": "haiku", "effort": "low" },
      { "difficulty": "easy", "ambiguity": "high", "domain": "*", "route": "haiku", "effort": "high" },
      { "difficulty": "hard", "ambiguity": "low", "domain": "*", "route": "opus", "effort": "low" },
      { "difficulty": "hard", "ambiguity": "high", "domain": "*", "route": "opus", "effort": "high" }
    ]
  }
}

Stop switching on long context (KV cache)

Switching models mid-conversation busts the upstream KV/prefix cache. Set a token ceiling past which the router pins the current model instead of re-routing:

{ "routing": { "contextLock": { "enabled": true, "maxTokens": 60000 } } }

In the gateway this counts the full request (system + tools + messages); in native chat it counts the rendered output the router can observe, so it is approximate and errs toward locking a little early.

Tuning for native /model switching lives under claudeCodeSubscription (switchIdleMs, switchConfirmTimeoutMs, autoConfirmModelSwitch, autoConfirmEffortSwitch, …). See config.example.json in the repo for the full set.

Debug trace:

MORPH_NATIVE_TRACE=/tmp/morph-native-trace.jsonl morphrouter chat

Commands

morphrouter                 # same as morphrouter chat
morphrouter chat            # route each turn in native Claude Code via /model
morphrouter enterprise-chat # alias for chat
morphrouter chat-sdk        # Claude Agent SDK wrapper (non-TTY fallback)
morphrouter plan-chat "..." # route once at startup, then hand off to claude
morphrouter statusline      # print latest Morph decision for statusLine
morphrouter doctor          # diagnose the setup
morphrouter config          # open the config file in your editor (alias: edit-config)

Develop

npm ci
npm test

This package is published by the landing repo's morphcli-publish-mcp.yml workflow.

License

MIT