In devDeveloper Tooling · LLM Infrastructure

CLI · TypeScript · SQLite · MCP · Claude Code hook · MIT

claude-smart

Decide what the model sees before it sees anything.

claude-smart intercepts a prompt before a single token goes upstream. Weighted keyword taxonomies classify it into a workload — bug fix, feature, refactor, search, review — with a confidence score. That workload maps to a model tier, escalating for large prompts, wide file sets, or low-confidence classifications. Then a two-stage curator builds the context: a fast deterministic heuristic filter, then an optional Haiku refinement pass bounded by a timeout with graceful fallback. It runs three ways — as a CLI, as a Claude Code PreToolUse hook, or as an MCP server.

  • TypeScript (strict)
  • Node.js 18+
  • Zod
  • SQLite (WAL)
  • Model Context Protocol
  • node:test
  • MIT

Origin

How it started

The expensive part of agentic coding is not the model, it's everything you hand the model. Most of a context window is routinely filled with files that have nothing to do with the question, and the same premium tier gets used to rename a variable as to debug a race condition. Both of those are decisions, and both were being made by default rather than deliberately.

Features

What it does

  • Intent detection with a confidence score

    Weighted keyword taxonomies, one JSON file per workload, classify the prompt and report how sure they are. The confidence is not decoration — low confidence is itself a routing signal that escalates the tier rather than guessing cheap.

  • Tier routing, not model pinning

    Workloads map to cheap, balanced, or premium tiers rather than to hardcoded model IDs, with escalation rules for prompt size and file count. Model names change constantly; the mapping is configuration so the routing logic outlives any particular model.

  • Two-stage context curation

    Stage one is a deterministic heuristic filter that costs nothing and always runs. Stage two is an optional Haiku refinement pass with a timeout and a graceful fallback to stage one. Spending a model call to decide a model call only pays when it is strictly bounded and can always be skipped.

  • Three entry points, one pipeline

    CLI, Claude Code PreToolUse hook, and MCP server are thin adapters over the same pipeline. The hook path runs heuristic-only so it stays fast enough to sit in front of every tool call.

  • Local telemetry

    Every invocation writes a event to a local SQLite store, so `stats` can answer what it actually classified, where it routed, and what that cost — in aggregate, on your own machine, with nothing reported anywhere.

  • Config that fails loudly

    A `.claude-smart.json` validated by a strict Zod schema — unknown keys and bad values are errors, not silent defaults. API keys come from the environment only, never from config and never from a committed file.

Under the hood

Engineering

  • Scaffold, stated plainly

    The structure, types, and control flow are complete and buildable: config loading, intent detection, routing, curation, telemetry, and three entry points all exist and typecheck under strict tsc. The provider API calls and the MCP server binding are stubbed with marked TODOs. Calling this a shipped tool would be a lie, and it is the kind of lie that gets found in about ninety seconds by anyone who clones it.

  • A pipeline, not a pile of scripts

    One orchestrator composes five focused modules, and the CLI, hook, and MCP entrypoints are thin adapters over it rather than three parallel implementations that drift. The domain vocabulary lives in a dependency-free types module so nothing in the core reaches for a provider SDK — which is exactly what makes swapping or adding a provider a small change instead of a rewrite.