orchestrating-agents/SKILL.md
Orchestrates parallel API instances, delegated sub-tasks, and multi-agent workflows with streaming and tool-enabled delegation patterns. Use for parallel analysis, multi-perspective reviews, or complex task decomposition.
npx skillsauth add oaustegard/claude-skills orchestrating-agentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill hand-rolls subagent orchestration via raw Anthropic API calls. A managed runtime now does the same job. Which one to use depends on your surface:
/deep-research, trigger a run with the workflow keyword, set
/effort ultracode, or spawn Task subagents — do that instead. The runtime gives
16-concurrent / 1000-agent ceilings, an approval gate, adversarial cross-review,
and in-session resume that this skill would otherwise reimplement badly. Dynamic
workflows shipped in research preview (Claude Code v2.1.154+, 2026).Discriminator: do you have a native subagent/Task tool or a workflow command? Yes → native. No → this skill. Never reimplement the runtime where it already exists.
This skill enables programmatic API invocations for advanced workflows including parallel processing, task delegation, and multi-agent analysis using the Anthropic API.
Primary use cases:
Trigger patterns:
import sys
sys.path.append('/home/user/claude-skills/orchestrating-agents/scripts')
from claude_client import invoke_claude
response = invoke_claude(
prompt="Analyze this code for security vulnerabilities: ...",
model="claude-sonnet-4-6"
)
print(response)
from claude_client import invoke_parallel
prompts = [
{
"prompt": "Analyze from security perspective: ...",
"system": "You are a security expert"
},
{
"prompt": "Analyze from performance perspective: ...",
"system": "You are a performance optimization expert"
},
{
"prompt": "Analyze from maintainability perspective: ...",
"system": "You are a software architecture expert"
}
]
results = invoke_parallel(prompts, model="claude-sonnet-4-6")
for i, result in enumerate(results):
print(f"\n=== Perspective {i+1} ===")
print(result)
For parallel operations with shared base context, use caching to reduce costs by up to 90%:
from claude_client import invoke_parallel
# Large context shared across all sub-agents (e.g., codebase, documentation)
base_context = """
<codebase>
...large codebase or documentation (1000+ tokens)...
</codebase>
"""
prompts = [
{"prompt": "Find security vulnerabilities in the authentication module"},
{"prompt": "Identify performance bottlenecks in the API layer"},
{"prompt": "Suggest refactoring opportunities in the database layer"}
]
# First sub-agent creates cache, subsequent ones reuse it
results = invoke_parallel(
prompts,
shared_system=base_context,
cache_shared_system=True # 90% cost reduction for cached content
)
For sub-agents that need multiple rounds of conversation:
from claude_client import ConversationThread
# Create a conversation thread (auto-caches history)
agent = ConversationThread(
system="You are a code refactoring expert with access to the codebase",
cache_system=True
)
# Turn 1: Initial analysis
response1 = agent.send("Analyze the UserAuth class for issues")
print(response1)
# Turn 2: Follow-up (reuses cached system + turn 1)
response2 = agent.send("How would you refactor the login method?")
print(response2)
# Turn 3: Implementation (reuses all previous context)
response3 = agent.send("Show me the refactored code")
print(response3)
For real-time feedback from sub-agents:
from claude_client import invoke_claude_streaming
def show_progress(chunk):
print(chunk, end='', flush=True)
response = invoke_claude_streaming(
"Write a comprehensive security analysis...",
callback=show_progress
)
Monitor multiple sub-agents simultaneously:
from claude_client import invoke_parallel_streaming
def agent1_callback(chunk):
print(f"[Security] {chunk}", end='', flush=True)
def agent2_callback(chunk):
print(f"[Performance] {chunk}", end='', flush=True)
results = invoke_parallel_streaming(
[
{"prompt": "Security review: ..."},
{"prompt": "Performance review: ..."}
],
callbacks=[agent1_callback, agent2_callback]
)
Cancel long-running parallel operations:
from claude_client import invoke_parallel_interruptible, InterruptToken
import threading
import time
token = InterruptToken()
# Run in background
def run_analysis():
results = invoke_parallel_interruptible(
prompts=[...],
interrupt_token=token
)
return results
thread = threading.Thread(target=run_analysis)
thread.start()
# Interrupt after 5 seconds
time.sleep(5)
token.interrupt()
| Function | Module | Purpose |
|---|---|---|
| invoke_claude() | core | Single synchronous invocation, full parameter control |
| invoke_parallel() | core | Concurrent invocations, results in input order |
| invoke_claude_streaming() | core | Single invocation, token-by-token callback |
| invoke_parallel_streaming() | core | Concurrent invocations with per-agent stream callbacks |
| invoke_parallel_interruptible() | core | Concurrent invocations cancellable mid-flight |
| ConversationThread | core | Stateful multi-turn thread with cached history |
| StallDetector | core | Flags agents idle beyond a timeout |
| TaskTracker | task_state | Tracks task status across an orchestration run |
| invoke_with_retry() | orchestration | Single invocation with backoff on transient errors |
| invoke_parallel_managed() | orchestration | Concurrency-limited parallel run with retry, stall hooks, reconciliation |
Full signatures, parameters, and worked examples for each: references/function-reference.md.
See references/workflows.md for detailed examples including:
For autonomous sub-agents that should execute without asking questions:
from claude_client import invoke_claude, EXECUTE_MODE
response = invoke_claude(
prompt="Review auth.py for SQL injection vulnerabilities",
system=f"You are a security expert.\n\n{EXECUTE_MODE}"
)
EXECUTE_MODE encodes these principles (adapted from OpenAI Codex):
For workflows where multiple agents need to communicate:
from agent_pool import AgentPool
pool = AgentPool(
shared_system="You are reviewing the auth module of a web app.",
max_depth=3, # prevent recursive spawn explosion
max_agents=10,
)
# Spawn named agents with roles
pool.spawn("security", system=f"Focus on vulnerabilities.\n\n{pool.EXECUTE_MODE}")
pool.spawn("perf", system=f"Focus on performance.\n\n{pool.EXECUTE_MODE}")
# Run turns (pending inter-agent messages auto-injected)
sec_result = pool.run("security", "Review the login flow")
# Agent-to-agent messaging
pool.send("security", to="perf",
content="Auth does N+1 queries in the session check loop",
trigger_turn=True) # auto-runs perf with this context
# Broadcast to all agents
pool.broadcast("security", "Auth uses bcrypt cost=12, 200ms per hash")
# Query pool state
pool.agents() # ["security", "perf"]
pool.agent_info("perf") # {name, depth, children, pending_messages, turns}
For complex workflows where agent creation might fail:
from agent_pool import AgentPool
pool = AgentPool(shared_system="Code review team")
# Reservation pattern: name is reserved, rolled back on exception
with pool.reserve("analyst", parent="lead") as res:
res.configure(system="You analyze code complexity.", model="claude-opus-4-6")
# If configure or any other work raises, the name is released
# Agent "analyst" is now live
# Depth limits prevent unbounded recursion
pool.spawn("sub-analyst", parent="analyst") # depth=2, OK
pool.spawn("sub-sub", parent="sub-analyst") # depth=3, raises ValueError
| Pattern | Use When |
|---------|----------|
| invoke_parallel() | Independent tasks, no inter-agent communication needed |
| AgentPool | Agents need to share findings, build on each other's work, or have parent/child relationships |
| invoke_parallel_managed() | Independent tasks with retry, stall detection, concurrency limits |
Prerequisites:
Install anthropic library:
uv pip install anthropic
Configure API key via project knowledge file:
Option 1 (recommended): Individual file
ANTHROPIC_API_KEY.txtsk-ant-api03-...)Option 2: Combined file
API_CREDENTIALS.json{
"anthropic_api_key": "sk-ant-api03-..."
}
Get your API key: https://console.anthropic.com/settings/keys
Installation check:
python3 -c "import anthropic; print(f'✓ anthropic {anthropic.__version__}')"
The module provides comprehensive error handling:
from claude_client import invoke_claude, ClaudeInvocationError
try:
response = invoke_claude("Your prompt here")
except ClaudeInvocationError as e:
print(f"API Error: {e}")
print(f"Status: {e.status_code}")
print(f"Details: {e.details}")
except ValueError as e:
print(f"Configuration Error: {e}")
Common errors:
For detailed caching workflows and best practices, see references/workflows.md.
Token efficiency:
Rate limits:
Cost management:
Use parallel invocations for independent tasks only
Set appropriate system prompts
Handle errors gracefully
Test with small batches first
Consider alternatives
This skill uses ~800 tokens when loaded but enables powerful multi-agent patterns that can dramatically improve complex analysis quality and speed.
development
Write effective instructions for Claude: project instructions, standalone prompts, and skill content. Use when users need help writing prompts, setting up project instructions, choosing between instruction formats, or improving how they communicate with Claude. Covers writing principles, model-aware calibration, and format selection. For building and testing complete skills, use skill-creator instead.
data-ai
Discover and load skills on demand from /mnt/skills/user/. Use when you need a capability but don't know which skill provides it, when the boot-emitted skill list is names-only and you need a full description, or when you want to list the catalog. Verbs are list (names only), search (rank by name/description match against a query), and show (emit the full SKILL.md for a named skill).
documentation
Reads the visual content of slides, pages, and images the way a human would, not just their embedded text. Use when a PPTX or PDF has image slides, screenshots, charts, scanned figures, or flattened-to-image layouts that the built-in pptx/pdf skills read as empty; when asked to transcribe, describe, OCR, or extract what is shown in an image, slide deck, or document page; or when embedded-text extraction returned little or nothing from a visually rich file. Triggers on 'read this deck', 'what's on these slides', 'transcribe', 'OCR', 'extract text from image', 'describe this chart/diagram', .pptx/.pdf/.png/.jpg with visual content.
development
Portrait Mode for SVGs — foveated vectorization with 4-zone selective detail. Combines vision annotations, MediaPipe segmentation/landmarks, and optional saliency. Like phone portrait mode, but vectorized. Use when vectorizing a portrait or photo where subject detail should outrank background detail.