external-model-delegation
# External Model Delegation Pattern
What this skill does
# External Model Delegation Pattern
A `UserPromptSubmit` hook classifies every user prompt into one of six cost/performance tiers. The hook injects `additionalContext` instructing Claude to run a specific delegation script and return the output.
## Tier routing table
| Tier | Delegation command | Cost |
|------|-------------------|------|
| QWEN | `qwen3 "prompt"` | $0 (local Ollama) |
| DEEPSEEK_FLASH | `deepseek --flash "prompt"` | $0.14 / $0.28 per M tokens |
| DEEPSEEK_PRO | `deepseek --pro "prompt"` | $0.44 / $0.87 per M tokens |
| KIMI | `kimi --quiet -p "prompt"` | $0.60 / $2.50 per M tokens |
| CODEX | `codex exec` | varies |
| CLAUDE | handle natively | $3-5 / $15-25 per M tokens |
## Delegation script pattern
Each script is a self-contained executable in `~/bin/` that accepts a prompt and writes the response to stdout:
```
~/bin/
├── qwen3 # Shell: curl to local Ollama API
├── kimi # Shell: execs Kimi CLI binary
├── deepseek # Python: httpx to DeepSeek Anthropic-compat API
└── route-task # Shell + qwen3: classifies prompt into tier
```
### Script contract
1. Accept prompt as first argument: `qwen3 "what is 2+2"`
2. Support `--flash` / `--pro` model flags (deepseek)
3. Support `--quiet` mode flag (kimi)
4. Write response to stdout, errors to stderr
5. Exit 0 on success, non-zero on error
### Writing a new delegation script
```bash
#!/bin/bash
# Minimal delegator template
PROMPT="$1"
API_KEY="${EXTERNAL_API_KEY:-}"
# Call external API, write result to stdout
curl -s https://api.example.com/chat \
-H "Authorization: Bearer $API_KEY" \
-d "$(jq -n --arg p "$PROMPT" '{prompt: $p}')" \
| jq -r '.response'
```
## Routing hook flow
```
User types prompt
↓
UserPromptSubmit hook fires
↓
qwen3 classifies into tier (QWEN|DEEPSEEK_FLASH|DEEPSEEK_PRO|KIMI|CODEX|CLAUDE)
↓
Hook injects additionalContext: "Run: <delegation-command>"
↓
Claude reads context, spawns delegation script, returns output
↓
User sees response from the delegated model
```
## Classification tiers
| Tier | Task types |
|------|-----------|
| QWEN | grep, find, regex, shell, syntax lookups, log reading, short summaries |
| DEEPSEEK_FLASH | Simple code, boilerplate, CRUD, test writing, small fixes, config |
| DEEPSEEK_PRO | Multi-file features, refactors, debugging, medium coding, docs |
| KIMI | Single-file review, medium reasoning, commit messages, diff summaries |
| CODEX | Bulk generation, mechanical changes across many files |
| CLAUDE | Architecture, security, complex debugging, system design, quality-critical |
## Environment
```bash
# Required env vars (set in ~/.zshrc)
export DEEPSEEK_API_KEY="sk-..." # For deepseek delegator
export OPENAI_API_KEY="sk-..." # For codex CLI
# Ollama must be running locally for qwen3 classification + delegation
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.