Build a Jev Model Router for Claude Code¶
| Category | Claude Code |
| Status | ๐ก Partially completed |
| Repo | nextwork-build-a-jev-model-router-for-claude-code |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Build a Jev Model Router for Claude Code guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ Claude Code
Status: ๐ก Partially completed
Overview¶
Sending every request to the biggest model is slow and wasteful, but routing blindly is risky. My router decides the path and confidence up front, refuses to act on vague or consequential requests, and keeps review strictly read-only.
Summary¶
I built my own task router in Python. Each request is classed as routine or reasoning, with a confidence score and risk tags. Vague requests and consequential ones (delete, migrate, production, payments) are blocked before any model runs. Routine work goes to a small local model (qwen2.5:0.5b) and reasoning work to a larger one (qwen2.5:3b). A separate read-only review worker checks a file and proves by SHA-256 hash that it didn't change it. In my run of six tasks, two went routine, two went reasoning, 'fix it' was blocked as too vague and a production delete was blocked as consequential. The reviewer found the negative-total bug in my sample cart and left the file unchanged. Partial: this isn't Jev, local Ollama models stand in for Haiku and Sonnet, and Claude Code isn't the worker.
The checks behind this are in docs/verification.txt.
Skills & tools¶
Python, Ollama, Routing heuristics, Risk gating, pytest
What I built¶
router.py:route()(path, confidence, risk tags, gate),run_worker()(calls the local model for the chosen path),review()(read-only review with before/after SHA-256) andhandle().sample_project/cart.py: a small cart total with a deliberate negative-discount bug for the reviewer to find.demo.py: runs six tasks and the review;docs/run.mdanddocs/run.jsonhold the results (paths, gates, worker, timings and answers).tests/test_router.py: unit tests for routing and gating.
How to run¶
ollama pull qwen2.5:0.5b && ollama pull qwen2.5:3b
python demo.py # writes docs/run.md
python -m pytest -q tests/test_router.py
Verification¶
I ran the verification command on 2026-12-03. The full output is in docs/verification.txt.
/workspace/nextwork-portfolio/.venv/bin/python -m pytest -q -p no:cacheprovider tests/test_router.py 2>&1 | tail -1 | grep -q '2 passed' && grep -q 'file unchanged after review: True' docs/run.md && echo ROUTER OK
Notes¶
The routing is keyword and length heuristics, so it's easy to fool. In the run the production-delete request was classed 'routine' before the risk gate stopped it, which is exactly why the gate runs regardless of path.
What isn't done, and why¶
No Jev product or Claude Code: the workers are local qwen2.5 models standing in for Haiku and Sonnet, and the routing rules are my own.
Original project: https://nextwork.ai/projects/e315e12d-76d8-4a62-b4a7-19bdcf42878c ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ /workspace/nextwork-portfolio/.venv/bin/python -m pytest -q -p no:cacheprovider tests/test_router.py 2>&1 | tail -1 | grep -q '2 passed' && grep -q 'file unchanged after review: True' docs/run.md && echo ROUTER OK
ROUTER OK
[exit code 0]