# donimas/ai-routing architecture

> Architecture diagram of the GitHub repository donimas/ai-routing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/donimas/ai-routing
- Repository: https://github.com/donimas/ai-routing

## Overview

This repository is a guide and starter kit for routing coding tasks to Claude models and effort levels, plus a small standalone Anthropic API router. The documented workflows are: Claude Code uses the installed settings and routing guidance to delegate work to fixed-model agents, with an optional hook enforcing explicit model selection; separately, a user runs the example router, which classifies a task, selects a route, and requests an answer. The map follows README-described relationships; source excerpts were unavailable, so implementation details beyond those documented are omitted.

Main entry points: [`templates/CLAUDE.md`](https://github.com/donimas/ai-routing/blob/main/templates/CLAUDE.md) (Routing guidance), [`examples/router.py`](https://github.com/donimas/ai-routing/blob/main/examples/router.py) (Task router), [`templates/.claude/agents/code-searcher.md`](https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/code-searcher.md) (Code searcher), [`templates/.claude/hooks/require-subagent-model.py`](https://github.com/donimas/ai-routing/blob/main/templates/.claude/hooks/require-subagent-model.py) (Model guard hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_claude_setup["Claude Code setup"]
  node_routing_guide["Routing guidance<br/>[CLAUDE.md]"]
  node_settings["Session settings<br/>[settings.json]"]
  node_hook_settings["Hook settings"]
  node_searcher["Code searcher<br/>[code-searcher.md]"]
  node_implementer["Implementer<br/>[implementer.md]"]
  node_test_runner["Test runner<br/>[test-runner.md]"]
  node_reviewer["Reviewer<br/>[reviewer.md]"]
  node_model_guard["Model guard hook"]
end

subgraph group_api_router["Standalone API router"]
  node_router["Task router<br/>[router.py]"]
  node_task_classification["Task classification<br/>[router.py]"]
  node_route_selection["Route selection<br/>[router.py]"]
  node_answer_request["Answer request<br/>[router.py]"]
end

node_user(("User"))
node_claude_code["Claude Code"]
node_anthropic_api["Anthropic API"]

node_settings -->|"configures"| node_claude_code
node_routing_guide -->|"routes lookup"| node_searcher
node_routing_guide -->|"routes edits"| node_implementer
node_routing_guide -->|"routes tests"| node_test_runner
node_routing_guide -->|"routes escalation"| node_reviewer
node_claude_code -->|"delegates to"| node_searcher
node_claude_code -->|"delegates to"| node_implementer
node_claude_code -->|"delegates to"| node_test_runner
node_claude_code -->|"delegates to"| node_reviewer
node_hook_settings -->|"enables hook"| node_claude_code
node_claude_code -->|"runs before launch"| node_model_guard
node_model_guard -->|"checks model"| node_searcher
node_user -->|"runs task"| node_router
node_router -->|"classifies task"| node_task_classification
node_task_classification -->|"requests label"| node_anthropic_api
node_router -->|"selects route"| node_route_selection
node_router -->|"requests answer"| node_answer_request
node_answer_request -->|"requests response"| node_anthropic_api

click node_routing_guide "https://github.com/donimas/ai-routing/blob/main/templates/CLAUDE.md"
click node_settings "https://github.com/donimas/ai-routing/blob/main/templates/settings.json"
click node_hook_settings "https://github.com/donimas/ai-routing/blob/main/templates/settings.with-hook.json"
click node_searcher "https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/code-searcher.md"
click node_implementer "https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/implementer.md"
click node_test_runner "https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/test-runner.md"
click node_reviewer "https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/reviewer.md"
click node_model_guard "https://github.com/donimas/ai-routing/blob/main/templates/.claude/hooks/require-subagent-model.py"
click node_router "https://github.com/donimas/ai-routing/blob/main/examples/router.py"
click node_task_classification "https://github.com/donimas/ai-routing/blob/main/examples/router.py"
click node_route_selection "https://github.com/donimas/ai-routing/blob/main/examples/router.py"
click node_answer_request "https://github.com/donimas/ai-routing/blob/main/examples/router.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routing_guide,node_settings,node_hook_settings,node_searcher,node_implementer,node_test_runner,node_reviewer,node_model_guard,node_user toneBlue
class node_router,node_task_classification,node_route_selection,node_answer_request toneAmber
class node_claude_code toneIndigo
class node_anthropic_api toneMint
```

## Components

### Claude Code setup

- [Routing guidance](https://github.com/donimas/ai-routing/blob/main/templates/CLAUDE.md): `templates/CLAUDE.md`
- [Session settings](https://github.com/donimas/ai-routing/blob/main/templates/settings.json): `templates/settings.json`
- [Hook settings](https://github.com/donimas/ai-routing/blob/main/templates/settings.with-hook.json): `templates/settings.with-hook.json`
- [Code searcher](https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/code-searcher.md): `templates/.claude/agents/code-searcher.md`
- [Implementer](https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/implementer.md): `templates/.claude/agents/implementer.md`
- [Test runner](https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/test-runner.md): `templates/.claude/agents/test-runner.md`
- [Reviewer](https://github.com/donimas/ai-routing/blob/main/templates/.claude/agents/reviewer.md): `templates/.claude/agents/reviewer.md`
- [Model guard hook](https://github.com/donimas/ai-routing/blob/main/templates/.claude/hooks/require-subagent-model.py): `templates/.claude/hooks/require-subagent-model.py`

### Standalone API router

- [Task router](https://github.com/donimas/ai-routing/blob/main/examples/router.py): `examples/router.py`
- [Task classification](https://github.com/donimas/ai-routing/blob/main/examples/router.py): `examples/router.py`
- [Route selection](https://github.com/donimas/ai-routing/blob/main/examples/router.py): `examples/router.py`
- [Answer request](https://github.com/donimas/ai-routing/blob/main/examples/router.py): `examples/router.py`

### Other components

- **User**
- **Claude Code**
- **Anthropic API**

## Connections

- Session settings → Claude Code: configures (evidence: `README.md`)
- Routing guidance → Code searcher: routes lookup (evidence: `README.md`)
- Routing guidance → Implementer: routes edits (evidence: `README.md`)
- Routing guidance → Test runner: routes tests (evidence: `README.md`)
- Routing guidance → Reviewer: routes escalation (evidence: `README.md`)
- Claude Code → Code searcher: delegates to (evidence: `README.md`)
- Claude Code → Implementer: delegates to (evidence: `README.md`)
- Claude Code → Test runner: delegates to (evidence: `README.md`)
- Claude Code → Reviewer: delegates to (evidence: `README.md`)
- Hook settings → Claude Code: enables hook (evidence: `README.md`)
- Claude Code → Model guard hook: runs before launch (evidence: `README.md`)
- Model guard hook → Code searcher: checks model (evidence: `README.md`)
- User → Task router: runs task (evidence: `README.md`)
- Task router → Task classification: classifies task (evidence: `README.md`)
- Task classification → Anthropic API: requests label (evidence: `README.md`)
- Task router → Route selection: selects route (evidence: `README.md`)
- Task router → Answer request: requests answer (evidence: `README.md`)
- Answer request → Anthropic API: requests response (evidence: `README.md`)
