adaptive-subagents

Use this skill when the user asks to create, build, implement, add, update, write, document, refactor, debug, fix, optimize, or migrate something. Routes subtasks to the cheapest sufficient model (Haiku/Sonnet), saving 3-15x on token costs.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "adaptive-subagents" with this command: npx skills add maleko91/claude-code-adaptive-subagents/maleko91-claude-code-adaptive-subagents-adaptive-subagents

Adaptive Subagent Routing

FIRST: Decompose Before Acting

Do NOT start working on the task directly. Before reading files or making edits, decompose the task into subtasks and delegate each one to the cheapest sufficient model via the Agent tool. The only exception is if the entire task is under ~100 tokens of output (a one-liner fix).

Quick Decision (apply to EVERY delegation)

Default: Haiku. Escalate only with reason.

  1. Is this a mechanical lookup? (find files, grep for a string, list structure, check if something exists) → Haiku
  2. Does it require comprehension or writing? (implement, refactor, test, debug, fix, analyze code, explain logic, summarize complex systems) → Sonnet
  3. Is it architectural, security-sensitive, or ambiguous? → Opus

Haiku boundary: Haiku can find things and format things. It cannot understand or reason about code. If the task requires reading code and making a judgment, that's Sonnet.

If unsure between two tiers, pick the cheaper one. Escalate after failure, not before.

Before each delegation, output **Routing to {Model}:** {brief reason} on its own line. When handling work inline, output **Staying on {Model}:** {brief reason} instead.

When to Delegate vs Handle Inline

Always delegate to a cheaper tier — the 3x–15x cost savings always outweigh subagent overhead.

Skip delegation only when:

  • The output is under ~100 tokens (one-liner answers, quick fixes already in context)
  • The overhead of spawning a subagent exceeds the work itself
  • The subtask needs the same model tier you're already on and context is already available

Routing Rules

Haiku (1x)Sonnet (3x)Opus (15x)
File search, grep, globImplementation, bug fixArchitecture, migration
Format/lint existing textRefactor (< 10 files)Security review
Check if file/string existsTest writingAmbiguous/conflicting scope
List files, directory structureDebugging with stack tracesMulti-system design
Literal string replacementsCode generation (< 500 lines)Performance analysis
Summarize/analyze code logic
Rename across multiple files
Code review, explain code

Escalate +1 tier: ambiguous requirements, public-facing output, security-sensitive, production-critical, or 2 consecutive failures. Downgrade: after planning completes, or remaining work is formatting/summarization.

Cost Ratios

ModelRelative CostPricing
Haiku (1x)Baseline~$1/M input, $5/M output
Sonnet (3x)3x Haiku~$3/M input, $15/M output
Opus (15x)15x Haiku~$15/M input, $75/M output

A 10-delegation task routed to Haiku instead of Opus saves ~93% on those calls.

Per-Subtask Routing

When a request involves multiple steps:

  1. Decompose first. Break the request into a todo list of subtasks.
  2. Route each subtask independently. Most items are cheaper than the overall task.
  3. Downgrade after planning. If Opus produces a plan, implementation goes to Sonnet. Lookups and cleanup go to Haiku.

Example — "design and implement a caching layer":

  • Plan the architecture → Opus
  • Search for existing cache usage → Haiku
  • Implement the cache module → Sonnet
  • Write tests → Sonnet
  • Update internal dev notes → Haiku
  • Write public API docs → Sonnet (escalated: public-facing)

Delegation

Choose agent type by task and model by complexity independently.

Agent TypeUse WhenTools Available
ExploreSearch, grep, read-only explorationRead, Glob, Grep (no Edit/Write)
general-purposeImplementation, edits, multi-step workAll tools
PlanArchitecture design, implementation planningRead, Glob, Grep (no Edit/Write)

Combine freely — Explore + haiku for file lookups, general-purpose + sonnet for implementation, Explore + sonnet for complex investigation, Plan + sonnet for straightforward design.

Agent(subagent_type: "Explore", model: "haiku", description: "...", prompt: "...")
Agent(subagent_type: "general-purpose", model: "sonnet", description: "...", prompt: "...")
Agent(subagent_type: "Explore", model: "sonnet", description: "...", prompt: "...")
Agent(subagent_type: "Plan", model: "sonnet", description: "...", prompt: "...")

Keep prompts scoped: relevant files, constraints, expected output format. The description parameter is required — use a short 3-5 word summary.

Expected Output Formats

TierExpected Output
HaikuFile paths, grep results, existence checks, formatted text
SonnetCode diffs, implementation files, test files, error analysis
OpusNumbered plan steps, architecture decisions with rationale, risk assessment

Parallel Fan-Out

When a request contains independent subtasks, launch multiple subagents in a single message.

Before splitting, build a dependency graph. Does any subtask need another's output, or do they modify the same file? If yes, run them sequentially.

PatternParallel?Why
Separate files, separate concernsYesNo shared state
Research + unrelated implementationYesRead-only doesn't conflict with writes
Implementation + its testsNoTests depend on the implementation
Feature + docs describing that featureNoDocs need to reflect what was built
Two features touching different modulesYesIndependent code paths
Refactor + anything in same filesNoRefactor changes the baseline

After all phases return, review outputs for conflicts before applying.

User Overrides

If the user says any of the following, respect it for the current request:

  • "no routing" / "don't delegate" — handle everything inline on the current model.
  • "use Opus" / "use Sonnet" / "use Haiku" — force that tier for all delegations.

Log the override with **Override:** {what the user requested} and resume normal routing on the next request.

Routing Log

After each routing decision, append a line to routing.log in the project root using the Bash tool:

echo "{model} | {agent_type or inline} | {estimated savings vs Opus, e.g. ~93%} | {brief task description}" >> routing.log

Log every **Routing to** and **Staying on** decision.

Guardrails

  • Max 2 retries per subagent, then escalate or ask the user.
  • Max 5 sequential delegations per user request. No limit on parallel.
  • Always review subagent outputs before applying — check for conflicts, hallucinated paths, and incomplete work.
  • Do NOT modify project files: Never write routing rules to CLAUDE.md. Never add hooks to settings.json. This skill is loaded automatically by the plugin.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Claw Insights Install

Install and run Claw Insights, a read-only observability dashboard that monitors your OpenClaw agent with zero intrusion — no code changes, no cloud dependen...

Registry SourceRecently Updated
Coding

QR Campaign Studio

Generate marketing QR codes with batch output, UTM tracking links, logo embedding, and poster composition. Use when users ask 生成二维码/批量二维码/渠道追踪码/带logo二维码. Sup...

Registry SourceRecently Updated
Coding

Seerr server manager

CLI for the Seerr media request management API. Search movies and TV shows, create and manage media requests, manage users, track issues, and administer a se...

Registry SourceRecently Updated
Coding

AI Corporate Training Video Factory — Build a Complete Employee Training Program in 2 Hours

Automates creation of complete corporate training programs with up-to-date curricula, professional videos, assessments, and automated employee delivery in 2...

Registry SourceRecently Updated
adaptive-subagents | V50.AI