Skip to content
coordinate-subagents logo

Subagent Troubleshooting & Advanced Patterns

coordinate-subagents

Advanced subagent troubleshooting. Use when subagent calls fail, return bad output, or need voting for critical decisions.

SKILL.md

Full skill instructions

Subagent Troubleshooting & Advanced Patterns

Core coordination patterns are in CLAUDE.md <subagent_coordination>. This skill covers edge cases.


When to Load This Skill

  • Subagent returned malformed output twice
  • Need voting pattern for critical/​irreversible decision
  • Debugging why coordination isn't working
  • Learning TOON format syntax details

Voting for Critical Decisions

For irreversible actions (deletions, deployments, security assessments), run same query 2-3 times in parallel:

<!-- 3 parallel agents, same question -->
<invoke name="Task">
  <parameter name="subagent_type">Explore</​parameter>
  <parameter name="model">haiku</​parameter>
  <parameter name="prompt">@type: AssessAction about: "safe to delete auth_old.ts" ...</​parameter>
</​invoke>
<invoke name="Task">
  <parameter name="subagent_type">Explore</​parameter>
  <parameter name="model">haiku</​parameter>
  <parameter name="prompt">@type: AssessAction about: "safe to delete auth_old.ts" ...</​parameter>
</​invoke>
<invoke name="Task">
  <parameter name="subagent_type">Explore</​parameter>
  <parameter name="model">haiku</​parameter>
  <parameter name="prompt">@type: AssessAction about: "safe to delete auth_old.ts" ...</​parameter>
</​invoke>

Interpret results:

  • 3 agree → proceed confidently
  • 2 agree → proceed with caution, note dissent
  • All differ → query is ambiguous, refine and retry

Red-Flag Recovery

SymptomAction
Output exceeds budget by >30%Discard entirely, retry same prompt
Wrong format (expected TOON, got prose)Discard, retry with stricter instruction
2 consecutive failuresRefine query OR escalate model (haiku→sonnet)
Contradictory answers across retriesQuery is ambiguous, decompose further

Never: Try to parse/​repair confused output. Discard and retry.


TOON Format Reference

Token-Oriented Object Notation. Use for uniform arrays (file lists, steps, configs).

Basic Syntax

# Array with header declaring fields
items[N]{field1,field2,field3}:
  value1,value2,value3
  value1,value2,value3

Escaping

  • Commas in values: wrap in quotes "value, with comma"
  • Quotes in values: escape \"nested quote\"
  • Newlines: use \n

Examples

File list:

files[3]{path,purpose,lines}:
  src/​auth/​login.ts,Main login handler,145
  src/​auth/​session.ts,Session management,89
  src/​auth/​token.ts,JWT utilities,67

Process steps:

steps[4]{position,action,file}:
  1,Parse request body,src/​middleware/​parser.ts
  2,Validate auth token,src/​middleware/​auth.ts
  3,Check permissions,src/​middleware/​rbac.ts
  4,Execute handler,src/​routes/​api.ts

Key-value config:

config[3]{key,value}:
  maxTokens,1500
  format,toon
  itemLimit,10

Anti-Patterns Checklist

If coordination isn't working, check for these:

Anti-PatternFix
Single agent doing multiple tasksSplit: one task per agent
No token budget specifiedAdd @constraints: maxTokens: N
Using opus for simple searchDowngrade to haiku
Full conversation history in promptStrip to goal + constraints only
Sequential independent callsParallelize in one message
Parsing broken outputDiscard and retry instead
Asking to "explain" or "describe"Request structured format
Direct MCP/​web tool calls in main contextDelegate: payloads unpredictable, request TOON summary
Verifying N external sources inlineDelegate: N scrapes = N×2000 tokens wasted

Decomposition Examples

Bad: Compound task

Find authentication code and analyze security vulnerabilities and suggest fixes

Good: Three focused agents

Agent 1: Find authentication code (haiku, 1500 tokens)
Agent 2: Analyze security of [files from agent 1] (sonnet, 2000 tokens)
Agent 3: Suggest fixes for [issues from agent 2] (sonnet, 2000 tokens)

Note: Agent 2 depends on Agent 1, so run sequentially. But if you had 3 independent searches, run all in parallel.


Quick Diagnostics

Subagent returned garbage
├─ Was format specified? → Add explicit TOON/​JSON instruction
├─ Was budget set? → Add @constraints maxTokens
├─ Was task atomic? → Check for "and", split if needed
├─ Right model? → Simple task shouldn't use opus
└─ Second failure? → Escalate model or refine query

External Data Operations

MCP tools and web scrapes are context pollution hazards:

ToolTypical PayloadRisk
firecrawl_scrape500-5000 tokensHigh - full page content
firecrawl_search200-1000 tokensMedium - result snippets
WebFetch500-3000 tokensHigh - full page content

Rule: Any task involving N external fetches should be delegated with:

  • Token budget: min(N × 200, 2500) tokens for summary output
  • Format: TOON for uniform results, JSON for complex analysis
  • Scrape options: onlyMainContent: true, formats: ["markdown"]

Example - URL verification:

Task(Explore, sonnet):
  "Verify these 10 legislation URLs. For each, scrape with onlyMainContent:true,
   confirm HTTP 200, identify managing authority from page content.

   @return ItemList in TOON:
   results[10]{jurisdiction,url,status,authority}:
     Commonwealth,https://legislation.gov.au,valid,Office of Parliamentary Counsel
     ...

   @constraints: maxTokens: 2000"

Reference

  • Core patterns: CLAUDE.md <subagent_coordination>
  • TOON format details: references/​toon-format.md
  • Source: "Solving a Million-Step LLM Task with Zero Errors" (arxiv:2511.09030)

More Security skills

supabase logo
Security

supabase

Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...

2.7K 308.9K
View

Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.

98 216.2K
View

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

462 163.8K
View

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

462 127.7K
View

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

462 125.1K
View

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

222 118.2K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View
cloudflare logo
Security

cloudflare

Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.

3K 110.7K
View

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

253 103K
View
gws-gmail logo
Security

gws-gmail

Send, read, and manage Gmail messages, drafts, labels, and account settings.

31.2K 78.9K
View

Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.

94 72.3K
View
gws-shared logo
Security

gws-shared

Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.

31.2K 63.4K
View

Security AI tools

StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
GeoSpy logo
Security

GeoSpy

GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams

Free
View

Detect AI-generated voices to protect against audio fraud.

Paid
View

Ensure Your Content's Originality with AI Plagiarism Checker

Freemium
View
Img Upscaler logo
Security

Img Upscaler

Upscale images by 400% without quality loss

Freemium
View
AICheatCheck logo
Security

AICheatCheck

Accurately Detect AI-Generated Content with TheChecker.AI

Free
View
D
Security

Detect GPT

Chrome extension that detects and flags AI-generated content

Free
View