model-routing

model-routing is a skill for Claude Code, Codex from alinaqi/maggy. It costs 17 tokens per session (1,708 once invoked), scanned A, original, MIT.

A system that classifies each user request into one of nine complexity levels before an AI model handles it. It uses fallback classifiers and can reuse a cached decision when classification fails.

In plain words
What is it for?
Use it to classify prompts, choose models by task complexity, provide classifier fallbacks, and evaluate whether routing results can be verified.
Why use it?
It helps route simple work to cheaper or local models while reserving more capable models for harder requests, with backup paths when a classifier or tool fails.

Skill for Claude CodeCodex

Written for Claude Code and Codex: user-invocable in frontmatter, but also runs codex exec. Also seen: reads .claude/ paths; positional $N argument; mentions Codex.

Good fit Use it to classify prompts, choose models by task complexity, provide classifier fallbacks, and evaluate whether routing results can be verified.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alinaqi/maggy/model-routing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add alinaqi/maggy --skill model-routing
Clone the repo
git clone --depth 1 https://github.com/alinaqi/maggy

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for model-routing

README.md
[![agentmods](https://agentmods.dev/badge/skills/alinaqi/maggy/model-routing/github.svg)](https://agentmods.dev/skills/alinaqi/maggy/model-routing)
Your own site
<a href="https://agentmods.dev/skills/alinaqi/maggy/model-routing"><img src="https://agentmods.dev/badge/skills/alinaqi/maggy/model-routing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for model-routing

Your own site · 80×15
<a href="https://agentmods.dev/skills/alinaqi/maggy/model-routing"><img src="https://agentmods.dev/badge/skills/alinaqi/maggy/model-routing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 17 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,708 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Excessive Agency · line 72
    Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.
    Fix: Remove the model/provider override or disclose it prominently and require explicit operator approval before invoking an external coding CLI or billed model.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00017 $0.01708
Opus 5 $0.00009 $0.00854
Sonnet 5 $0.00003 $0.00342
Haiku 4.5 $0.00002 $0.00171

Measured 4d ago against content hash 82f75f78cf31, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

model-routing scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

├── qwen3 # Shell: curl to local Ollama API
skills/model-routing/SKILL.md · 168 lines

How it starts

The opening of the file, as written. The whole thing — 168 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Model Routing System

How Routing Decisions Are Made

Every user prompt goes through a 9-tier classification pipeline before any AI model processes it. The system answers three questions:

  1. Which model should handle this? — 9-tier cost/complexity classification
  2. Is the classifier itself working? — Cascading fallback (qwen3 → kimi → deepseek → cache)
  3. Can we verify the result? — Tool-level fallback + auto-evaluation

The Pipeline

User types prompt
    ↓
UserPromptSubmit hook fires (~/.claude/hooks/route-task-hook)
    ↓
Classifier: qwen3 (local, free) classifies into tier
    ↓  (fails?)
Classifier: kimi (local, free) retries
    ↓  (fails?)
Classifier: deepseek-flash (~$0.0001) retries
    ↓  (fails?)
Classifier: cached tier from last success
    ↓
Hook injects routing decision into Claude's context
    ↓
Claude delegates to the right model or handles directly

9-Tier Routing Table

Tier Model Input (per M) Output (per M) Handles
0 Qwen3 (local) $0 $0 grep, find, shell, syntax, log reading
1 Gemini 2.5 Flash-Lite $0.10 $0.40 Bulk extraction, classification, CIG pipelines
2 DeepSeek V4 Flash $0.14 $0.28 Simple code, CRUD, test writing, small fixes
3 DeepSeek V4 Pro $0.44 $0.87 Multi-file features, refactors, debugging (~80% of work)
4 Gemini 2.5 Flash $0.15 $0.60 Multimodal (images, video, audio), brand analysis
5 Kimi K2.6 $0.60 $2.50 Code review, commit messages, diff summaries
6 Gemini 3.1 Pro + Search $1.25 $10.00 Deep research, Google grounding, 2M context
7 Codex varies varies Bulk generation, code review
8 Claude Sonnet/Opus $3-5 $15-25 Architecture, security, quality-critical

Delegation Commands

When the hook says "delegate to X", run the matching command and return its output:

# Tier 0 — Qwen3
~/bin/qwen3 "prompt"

# Tier 1 — Gemini Flash-Lite
~/bin/gemini --flash-lite "prompt"

# Tier 2 — DeepSeek Flash
~/bin/deepseek --flash "prompt"

# Tier 3 — DeepSeek Pro
~/bin/deepseek --pro "prompt"

# Tier 4 — Gemini Flash
~/bin/gemini --flash "prompt"

# Tier 5 — Kimi
~/bin/kimi --quiet -p "prompt"

# Tier 6 — Gemini Pro Search
~/bin/gemini --pro-search "prompt"

# Tier 7 — Codex
codex exec "prompt"

# Tier 8 — Claude
# Handle directly (no delegation)

Read the full file on GitHub · 168 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed · +8 lines · +17 tokens per session 82f75f78cf31
  2. 9d ago First seen · 160 lines · 0 tokens per session scan A 1634fa9281f1

Subscribe to this mod's changes

model-routing is a skill published in the GitHub repository alinaqi/maggy (707 stars, last pushed 4d ago), licensed MIT. It adds 17 tokens to every session and 1,708 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

writing-python

Idiomatic Python 3.12+ development. Use when writing Python code, CLI tools, scripts, or services. Emphasizes stdlib, type hints, fast pytest feedback, uv/ruff/pyright toolchain, and minimal dependencies. NOT for Go, Rust, TypeScript, or shell-only tasks.

alexei-led/cc-thingz · 67 tokens

python-authoring

Write, edit, refactor, or review Python in easy-cheese with concise stdlib-first code, Python 3.12, Shiv .pyz packaging, and repository test and validation conventions. Use for Python changes under src/, scripts/, .github/scripts/, or tests/, especially when the user asks for Pythonic, succinct, de-slopped…

paulnsorensen/easy-cheese · 88 tokens

frappe-backend

Frappe backend guidance for Python and backend-adjacent JavaScript surfaces such as client interaction patterns, hooks, APIs, patches, scheduler logic, reports, and server-side review. Use when implementing or reviewing Frappe backend behavior.

Dkm0315/frappe-agent · 53 tokens

python-best-practices

Python/FastAPI coding standards including async patterns, Pydantic v2, SQLAlchemy 2.0, and project structure. Use when writing Python code, reviewing FastAPI projects, or learning FastAPI conventions.

KunanonJ/ai-skills-hub · 50 tokens

python-packaging

Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI.

KunanonJ/ai-skills-hub · 33 tokens

python-type-annotator

Add missing type annotations to Python code. Generates mypy-compatible type hints for function signatures, variables, and class attributes. Triggers on "add types", "type annotate", "add type hints", "type this file".

luqiang-code/claude-code-skills · 51 tokens