kodemux router ladder guardrails GitHub ↗
repo-native middleware · for AI coding agents

Route each task to the cheapest model that can do it.

kodemux estimates how hard a prompt really is — from signals, not a keyword lookup — and picks a rung on a Haiku → Sonnet → Opus → Fable ladder. It flags security & production risk, and when it isn't sure, it escalates instead of guessing. Then it wraps the change in git-level guardrails.

View on GitHub
01

Try the router

This runs the actual estimator + policy, ported line-for-line from the source. No server, no API calls.

files touched3
diff size (lines)40

In the CLI these numbers are read automatically from git diff, and the critical-path flag fires on the real changed files — here you drive them by hand. All signals are additive.

This page demonstrates the free, instant deterministic core only. The CLI also has an optional AI-assist step (--no-ai to disable) that consults a cheap Haiku judge — reusing your existing Anthropic credentials, no setup — whenever this confidence score drops low; a static page can't safely make that call, so it isn't shown here. See docs/INTERNALS.md §5.8.

intent
confidence
why this route
    02

    The capability ladder

    Four rungs by cost & capability. The router picks the lowest rung that clears the complexity threshold — then floors upward for risk.

    TierModelReaches at complexityEffortBest for

    Floors: any security/production risk → complex (Opus) minimum · architecture intent → complex · features/fixes/refactors never route below standard (Sonnet). Haiku takes no /effort directive.

    03

    Guardrails, before and after

    Pre-hooks catch problems before the agent runs; post-hooks clean up after. Both are live below.

    kodemux scan pre-hook

    Scans changed files for secret-shaped strings and refuses to hand them to an agent. Findings are always masked.

    kodemux guard pre-hook

    Refuses direct edits on a protected branch, so an agent is forced onto a feature branch first.

    protected: main, master, production

    04

    Get started

    Node ≥ 20. Free and open source, MIT.

    STEP 1

    Install

    One curl line, or clone and build from source.

    STEP 2

    Init

    kodemux init detects your stack and scaffolds .kodemux/.

    STEP 3

    Route & guard

    Wire route, scan, guard, and post into your agent or git hooks.

    # install from source (published to npm in a later release)
    curl -fsSL https://raw.githubusercontent.com/vibhusharma101/kodemux/main/install.sh | sh
    
    # in any repo
    kodemux init
    kodemux route "design a distributed rate limiter"   # → opus-4-8 / xhigh / /plan
    kodemux route "fix a typo in the README"          # → haiku-4-5 / single
    kodemux guard # refuse edits on main
    kodemux scan  # secrets check
    the one idea

    Model choice should track how hard the task actually is — estimated from many signals, floored for risk, and escalated when unsure. That's a decision you can read, test, and override — not a habit.