From htmlgraph
Spawner selection, cost optimization, and HeadlessSpawner patterns for coordinating multiple AI models (Codex, Gemini, Copilot, Claude).
npx claudepluginhub shakestzd/htmlgraphThis skill uses the workspace's default tool permissions.
Use this skill for spawner selection, cost optimization, and HeadlessSpawner patterns. MUST coordinate multiple AI models efficiently.
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
Use this skill for spawner selection, cost optimization, and HeadlessSpawner patterns. MUST coordinate multiple AI models efficiently.
Trigger keywords: spawner, multi-ai, headless, codex, gemini, copilot, model selection, cost optimization, parallel agents
Claude Code is EXPENSIVE and has usage limits. You MUST use FREE/CHEAP AIs first.
COST HIERARCHY (lowest to highest):
1. Gemini 2.0-Flash: FREE (2M tokens/min) ← USE FIRST
2. Codex (GPT-4): $ (cheap, code-specialized)
3. Copilot: $ (cheap, GitHub integration)
4. Claude Haiku: $$ (fallback ONLY)
5. Claude Sonnet: $$$ (coordination only)
6. Claude Opus: $$$$ (strategic decisions only)
BEFORE delegating ANY task, you MUST ask these questions IN ORDER:
┌─────────────────────────────────────────────────────────┐
│ 1. Can Gemini do this? (exploration, research, batch) │
│ → YES = MUST use spawn_gemini (FREE) │
│ → NO = Continue to step 2 │
├─────────────────────────────────────────────────────────┤
│ 2. Is this code work? (implementation, fixes, tests) │
│ → YES = MUST use spawn_codex (cheap, specialized) │
│ → NO = Continue to step 3 │
├─────────────────────────────────────────────────────────┤
│ 3. Is this git/GitHub? (commits, PRs, issues) │
│ → YES = MUST use spawn_copilot (GitHub integration) │
│ → NO = Continue to step 4 │
├─────────────────────────────────────────────────────────┤
│ 4. Does this require deep reasoning? │
│ → YES = Use Claude Opus (expensive, but needed) │
│ → NO = Continue to step 5 │
├─────────────────────────────────────────────────────────┤
│ 5. Is this multi-agent coordination? │
│ → YES = Use Claude Sonnet (mid-tier) │
│ → NO = Use Gemini (FREE) or Haiku (fallback) │
└─────────────────────────────────────────────────────────┘
❌ WRONG (NEVER use Haiku for everything):
- Implementation → Haiku # WRONG: MUST use Codex
- Git commits → Haiku # WRONG: MUST use Copilot
- Code generation → Haiku # WRONG: MUST use Codex
- Research → Haiku # WRONG: MUST use Gemini (FREE!)
- File analysis → Haiku # WRONG: MUST use Gemini (FREE!)
✅ CORRECT (ALWAYS use cost-first routing):
- Implementation → spawn_codex # MUST use: Cheap, code-specialized
- Git commits → spawn_copilot # MUST use: Cheap, GitHub integration
- Research → spawn_gemini # MUST use: FREE, high context
- File analysis → spawn_gemini # MUST use: FREE, multimodal
- Strategic planning → Opus # Use when needed: Expensive, but needed
- Haiku → FALLBACK ONLY # ONLY when others fail
| Task Type | MUST Use | Fallback | Why |
|---|---|---|---|
| Exploration, research, codebase analysis | spawn_gemini | Haiku | FREE, 2M tokens/min, high context |
| Code generation, implementation | spawn_codex | Sonnet | Code-specialized, sandbox isolation |
| Bug fixes, refactoring | spawn_codex | Haiku | Edit tracking, workspace-write |
| Git operations, commits, PRs | spawn_copilot | Haiku | GitHub integration, tool permissions |
| File operations, batch processing | spawn_gemini | Haiku | FREE, fast, multimodal |
| Image/screenshot analysis | spawn_gemini | - | Vision API, multimodal |
| Testing, validation | spawn_codex | Haiku | Can execute tests in sandbox |
| Strategic planning, architecture | Opus | Sonnet | Deep reasoning required |
| Multi-agent coordination | Sonnet | - | Complex coordination |
| Last resort fallback | Haiku | - | When Gemini/Codex/Copilot fail |
MONTHLY USAGE IMPACT:
Claude Code (Sonnet/Opus): $$$$
- Limited usage quota
- Exhausts quickly with heavy use
- RESERVE for strategic work only
Gemini 2.0-Flash: FREE
- 2M tokens per minute (rate limited)
- 1M token context window
- Multimodal (images, PDFs, audio)
- Use FIRST for exploration
Codex (GPT-4): $
- Cheap for code work
- Sandbox isolation
- Worth premium for specialization
Copilot: $
- Cheap for GitHub work
- Tool permission controls
- Native GitHub integration
BEFORE (using Haiku everywhere):
- 10 implementations × Haiku = $$$$
- 5 git commits × Haiku = $$$
- 20 file searches × Haiku = $$$$$
AFTER (cost-first routing):
- 10 implementations × Codex = $$
- 5 git commits × Copilot = $
- 20 file searches × Gemini = FREE
SAVINGS: 80-90% reduction in Claude Code usage
Priority order (first match wins, cost-first):
| Priority | Use Case | Spawner | Cost |
|---|---|---|---|
| 1 | Exploration, research, batch ops | spawn_gemini | FREE |
| 2 | Code generation, bug fixes | spawn_codex | $ |
| 3 | Git/GitHub workflows, PRs | spawn_copilot | $ |
| 4 | Image/multimodal analysis | spawn_gemini | FREE |
| 5 | Complex reasoning, architecture | spawn_claude | $$$$ |
| 6 | Fallback when others fail | Task(haiku) | $$ |
spawn_gemini (FREE)spawn_codex (cheap)spawn_copilot (cheap)spawn_gemini (FREE)spawn_claude (expensive)spawn_gemini FIRST, then Haiku fallbackUse spawn_*() (PRIMARY):
Use Task(haiku) (FALLBACK ONLY):
# ALWAYS start with Gemini for exploration
result = spawn_gemini("Search codebase for all auth patterns")
if not result.success:
# Fallback to Haiku ONLY if Gemini fails
Task(prompt="Search codebase for auth patterns", subagent_type="haiku")
# Use Codex for code work (not Haiku!)
result = spawn_codex(
prompt="Implement OAuth authentication",
sandbox="workspace-write"
)
if not result.success:
Task(prompt="Implement OAuth", subagent_type="sonnet") # Fallback
# Use Copilot for git (not Haiku!)
result = spawn_copilot(
prompt="Commit changes and create PR",
allow_tools=["shell(git)", "github(*)"]
)
# Research with FREE Gemini
research = spawn_gemini("Analyze current auth implementation")
# Code with cheap Codex
code = spawn_codex("Implement OAuth based on research")
# Git with cheap Copilot
pr = spawn_copilot("Create PR for OAuth implementation")
# Reserve Claude for strategic decisions ONLY
# architecture = spawn_claude("Design long-term auth strategy")
spawn_gemini (FREE)spawn_codex (cheap, specialized)spawn_copilot (cheap, integrated)spawn_claude (expensive)Violating these rules wastes Claude Code quota unnecessarily.
After Gemini/Codex generates code, ALWAYS verify quality:
# MUST run quality verification script
./scripts/test-quality.sh src/path/to/file.py
# Returns: exit code 0 (pass) or 1 (fail)
# Runs: ruff check, ruff format, mypy, pytest
If verification fails, MUST iterate with the same spawner (NEVER Claude).
For detailed API documentation: → See REFERENCE.md For real-world examples: → See EXAMPLES.md