External Model Delegation Pattern

Routes user prompts to tiers via UserPromptSubmit hook and delegation scripts.

705|56|Updated Dec 26, 2025
One-click install
npx skills add https://github.com/alinaqi/maggy --skill external-model-delegation-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: External Model Delegation Pattern
Source: https://github.com/alinaqi/maggy/tree/main/skills/external-model-delegation
Command: npx skills add https://github.com/alinaqi/maggy --skill external-model-delegation-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of getting inconsistent quality or cost blowups when deciding which LLM to run for each user request.

Core Features & Use Cases

  • Cost/Performance Tier Routing: Classifies every prompt into six tiers (QWEN, DEEPSEEK_FLASH, DEEPSEEK_PRO, KIMI, CODEX, CLAUDE) and selects a delegation command accordingly.
  • Deterministic Delegation Script Contract: Requires delegator scripts to accept the prompt as the first argument, support specific flags (like deepseek flash/pro and kimi quiet), write the result to stdout, and use exit codes to signal success or failure.
  • Hook-Injected Additional Context: Uses a UserPromptSubmit hook to inject delegation instructions into additionalContext so Claude executes the routed script and returns its output to the user.

Quick Start

Ask Claude to handle your prompt and ensure your delegation scripts are installed in ~/bin/ with the expected flags and stdout contract, then run via the UserPromptSubmit hook so it routes each prompt to the correct tier.

Frequently Asked Questions about External Model Delegation Pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I route LLM prompts to different models automatically?

Multi-model orchestration routes prompts to different models automatically by using a UserPromptSubmit hook to classify each prompt into quality and cost tiers, then injecting a delegation command into additionalContext for Claude to execute. This ensures optimal model selection without manual switching.

What's the best way to optimize LLM costs for code reviews and refactoring?

Optimizing LLM costs for code reviews and refactoring is best handled by tiered delegation, which classifies prompts across six model tiers like QWEN, DEEPSEEK_FLASH, and CLAUDE. This cost optimization approach matches task complexity to the cheapest capable model, preventing cost blowups on simple tasks.

How do I set up Claude Code hooks for multi-model orchestration?

Set up Claude Code hooks for multi-model orchestration by configuring a UserPromptSubmit hook to intercept prompts, classify them into model tiers, and inject delegation instructions into additionalContext. You must also install delegation scripts in ~/bin/ that accept prompt arguments, support required model flags, and write responses to stdout.

Can I use prompt routing with DeepSeek and Kimi models for CLI scripting?

You can use prompt routing with DeepSeek and Kimi models for CLI scripting by configuring delegation scripts that support specific flags like deepseek flash, deepseek pro, and kimi quiet. The scripts must accept the prompt as the first argument, output results to stdout, and return correct exit codes.

Does multi-model delegation require specific exit codes and stdout output?

Multi-model delegation requires delegator scripts to write results to stdout and use exit codes to signal success or failure. This deterministic delegation script contract ensures the hook-injected context can reliably capture the external model's response and return it to the user.

Why does prompt routing fail to execute the delegated model script?

Prompt routing fails to execute the delegated model script when delegation scripts are not installed in the expected ~/bin/ directory, lack the required model flags, or do not write responses to stdout with correct exit codes. The UserPromptSubmit hook relies on this strict contract to route prompts successfully.