# Model Router Hook

SessionStart hook that sets the AI model based on task complexity. Rules-based, not AI judgment.

## Configuration

Add to your `.claude/settings.json`:

```json
{
  "hooks": {
    "SessionStart": [
      {
        "command": "sh .claude/hooks/route-model.sh"
      }
    ]
  }
}
```

## Routing Rules (Updated April 2026)

| Task Type | Model ID | Rationale |
|-----------|----------|-----------|
| Template match, simple edits, lint fixes | `claude-haiku-4-5-20251001` | Cheap and fast; rules-based work does not need reasoning |
| Standard builds, code review, refactors | `claude-sonnet-4-6` | Balanced reasoning and throughput for everyday work |
| Architecture, security review, contract drafting | `claude-opus-4-7` | Deepest reasoning; best for high-stakes, high-context decisions |
| Long-context audits (whole-repo, multi-doc, cross-file) | `claude-opus-4-7` (1M context) | Use the extended window for work that would not fit otherwise |

## What changed in April 2026

Opus 4.7 narrowed the cost gap against Sonnet enough that the routing math shifted: more Architect and Verify work justifies the capable tier than it did a quarter ago. If your traces show Sonnet retrying Architect output or Verify missing evidence, promote that lane to Opus 4.7 and re-baseline.

Two other shifts are worth designing around:
- **Vision is reliable** at the Opus tier, so Security Scan and Verify can reason about screenshots, dashboards, and config images, not just text.
- **1M context** means whole-repo audits and weekly curator loops that previously had to chunk can run end-to-end.

## Key Principle

Context window management starts here. Routing the right model to the right task means:
- Fast models do not waste time on simple work
- Capable models are not burned on template fills
- Cost stays proportional to complexity

Re-baseline routing rules whenever a new model ships. The network should absorb capability jumps, not fossilize around old assumptions.
