Agent Skillsalinaqi/maggy › external-model-delegation

external-model-delegation

GitHub

通过UserPromptSubmit Hook将提示词按成本/性能分为六类,自动委托至外部模型CLI执行。支持本地Ollama及DeepSeek、Kimi等API,实现智能路由与成本控制。

skills/external-model-delegation/SKILL.md alinaqi/maggy

Trigger Scenarios

需要调用外部AI模型处理任务 根据任务复杂度选择最经济的模型 配置或新增模型代理脚本

Install

npx skills add alinaqi/maggy --skill external-model-delegation -g -y
More Options

Use without installing

npx skills use alinaqi/maggy@external-model-delegation

指定 Agent (Claude Code)

npx skills add alinaqi/maggy --skill external-model-delegation -a claude-code -g -y

安装 repo 全部 skill

npx skills add alinaqi/maggy --all -g -y

预览 repo 内 skill

npx skills add alinaqi/maggy --list

SKILL.md

Frontmatter
{
    "name": "external-model-delegation",
    "effort": "medium",
    "description": "UserPromptSubmit hook pattern that classifies prompts into six cost tiers and delegates to external model CLIs",
    "when-to-use": "When configuring or debugging prompt-based delegation to qwen3, deepseek, kimi, or codex",
    "user-invocable": false
}

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

#!/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

# 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

Version History

  • 2a98228 Current 2026-09-09 08:48

Same Skill Collection

skills/aeo-optimization/SKILL.md
skills/agent-teams/SKILL.md
skills/agentic-development/SKILL.md
skills/ai-models/SKILL.md
skills/android-java/SKILL.md
skills/android-kotlin/SKILL.md
skills/autonomous-testing/SKILL.md
skills/aws-aurora/SKILL.md
skills/aws-dynamodb/SKILL.md
skills/azure-cosmosdb/SKILL.md
skills/base/SKILL.md
skills/build-in-public/SKILL.md
skills/cloudflare-d1/SKILL.md
skills/code-deduplication/SKILL.md
skills/code-graph/SKILL.md
skills/codex-review/SKILL.md
skills/commit-hygiene/SKILL.md
skills/context-shunt/SKILL.md
skills/council-review/SKILL.md
skills/cpg-analysis/SKILL.md
skills/cross-agent-delegation/SKILL.md
skills/database-schema/SKILL.md
skills/existing-repo/SKILL.md
skills/firebase/SKILL.md
skills/flutter/SKILL.md
skills/gemini-review/SKILL.md
skills/icpg/SKILL.md
skills/iterative-development/SKILL.md
skills/klaviyo/SKILL.md
skills/llm-patterns/SKILL.md
skills/maggy/SKILL.md
skills/medusa/SKILL.md
skills/mnemos/SKILL.md
skills/model-routing/SKILL.md
skills/ms-teams-apps/SKILL.md
skills/nodejs-backend/SKILL.md
skills/playwright-testing/SKILL.md
skills/polyphony/SKILL.md
skills/project-tooling/SKILL.md
skills/pwa-development/SKILL.md
skills/python/SKILL.md
skills/react-native/SKILL.md
skills/react-web/SKILL.md
skills/reddit-api/SKILL.md
skills/session-management/SKILL.md
skills/shopify-apps/SKILL.md
skills/site-architecture/SKILL.md
skills/supabase/SKILL.md
skills/team-coordination/SKILL.md

Metadata

Files
0
Version
2a98228
Hash
eeda8d81
Indexed
2026-09-09 08:48

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-09 20:34
浙ICP备14020137号-1 $お客様$