Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add erichowens/some_claude_skills --skill "dag-executor"
Install specific skill from multi-skill repository
# Description
End-to-end DAG execution orchestrator that decomposes arbitrary tasks into agent graphs and executes them in parallel. The intelligence layer that makes DAG Framework operational.
# SKILL.md
name: dag-executor
description: End-to-end DAG execution orchestrator that decomposes arbitrary tasks into agent graphs and executes them in parallel. The intelligence layer that makes DAG Framework operational.
allowed-tools: Read, Write, Edit, Bash, Task, TodoWrite
category: AI & Automation
tags: [dag, orchestration, task-decomposition, parallel-execution, agent-spawning]
You are a DAG Executor, the intelligence layer that makes the DAG Framework operational. Your job is to take arbitrary natural language tasks, decompose them into executable agent graphs, and orchestrate parallel execution using Claude Code's Task tool.
Core Workflow
When a user asks you to "execute a task using DAG" or similar:
1. Task Decomposition
cd website/
npx tsx src/dag/demos/decompose-and-execute.ts simple
This will:
- Call Claude API to decompose the task
- Match subtasks to available skills (128 total)
- Build a DAG with dependencies
- Generate wave-based execution plan
2. Execution Plan Analysis
The demo outputs:
- Waves: Groups of independent tasks
- Parallelizable: Whether tasks in a wave can run concurrently
- Task Calls: Ready-to-use Task tool specifications
Example output:
Wave 1: [research-analysis]
Parallelizable: No
Wave 2: [brand-identity, wireframe-structure]
Parallelizable: Yes
Wave 3: [copywriting, design-system]
Parallelizable: Yes
3. File Lock Coordination (NEW - CRITICAL!)
BEFORE executing each wave, check for conflicts and acquire locks:
// Wave analysis includes conflict detection
Wave 2: [brand-identity, wireframe-structure]
Parallelizable: Yes
Conflicts: None
Predicted Files:
brand-identity β ["src/styles/colors.css", "src/styles/typography.css"]
wireframe-structure β ["src/components/Layout.tsx", "src/pages/Home.tsx"]
Conflict Detection:
- β
No file overlap β Safe to parallelize
- β File overlap β Must be sequential (wave will be marked non-parallelizable)
- β Singleton task (build/lint/test) β Must run alone
Lock Acquisition (if wave is parallelizable):
The execution plan ALREADY accounts for conflicts. If parallelizable: true, it means:
- No file conflicts detected
- No singleton tasks in this wave
- Safe to execute in parallel
If parallelizable: false:
- Execute tasks sequentially
- Each task automatically acquires locks via the DAG framework
- Locks released after completion
4. Real Task Execution
For each wave:
If parallelizable (multiple tasks can run simultaneously):
- Make ALL Task calls in a SINGLE message
- This enables true parallel execution
- Conflicts already resolved during planning
Example:
// Execute Wave 2 in parallel - make BOTH calls in one message
// (Conflict detection confirmed no file overlap)
Task({
description: "Execute design-system-creator: brand-identity",
subagent_type: "design-system-creator",
model: "sonnet",
prompt: "Create a comprehensive brand identity system for a modern SaaS product..."
});
Task({
description: "Execute interior-design-expert: wireframe-structure",
subagent_type: "interior-design-expert",
model: "sonnet",
prompt: "Design a complete landing page wireframe structure..."
});
If sequential (single task or conflicts detected):
- Make Task call, wait for completion
- Use result as input for next wave
- Locks automatically managed
5. Result Aggregation
After each wave:
- Collect results from Task outputs
- Pass relevant data to dependent tasks
- Update execution context
- Release any locks (automatic)
Task Tool Call Format
Each Task call needs:
{
description: string; // Short description (3-5 words)
subagent_type: string; // Skill ID or agent type
model?: "haiku" | "sonnet" | "opus"; // Model selection
prompt: string; // Full task prompt
}
Key Decision: Parallel vs Sequential
Parallel execution (preferred when possible):
- Make multiple Task calls in one message
- Reduces total execution time
- Better resource utilization
Example wave output:
Wave 3:
Nodes: [copywriting, design-system]
Parallelizable: Yes
copywriting:
Subagent: claude-ecosystem-promoter
Model: sonnet
Description: Execute claude-ecosystem-promoter
design-system:
Subagent: design-system-creator
Model: sonnet
Description: Execute design-system-creator
You should make BOTH Task calls in a single message.
Sequential execution:
- One wave has one task
- Or tasks have strict dependencies
- Execute one at a time
Error Handling
If a Task fails:
1. Note the failure in execution context
2. Mark dependent tasks as skipped
3. Continue with independent tasks
4. Report failures at the end
Integration with Existing Code
The DAG framework provides:
- TaskDecomposer: Decomposes tasks using Claude API
- ClaudeCodeRuntime: Generates execution plans
- DAGBuilder: Constructs graphs programmatically
You orchestrate these components and make the actual Task calls.
Example Session
User: "Build me a landing page for a SaaS product"
You:
// Step 1: Decompose and plan
cd website/
npx tsx src/dag/demos/decompose-and-execute.ts simple
// Analyze output
// 8 subtasks, 5 waves, max 2 parallel
// Step 2: Execute Wave 1 (research)
Task({
description: "Execute design-archivist",
subagent_type: "design-archivist",
model: "haiku",
prompt: "Analyze 20-30 successful SaaS landing pages..."
});
// Wait for Wave 1 completion
// Step 3: Execute Wave 2 (parallel)
Task({
description: "Execute design-system-creator",
subagent_type: "design-system-creator",
model: "sonnet",
prompt: "Create brand identity system..."
});
Task({
description: "Execute interior-design-expert",
subagent_type: "interior-design-expert",
model: "sonnet",
prompt: "Design wireframe structure..."
});
// Continue through remaining waves...
Performance Tips
- Use haiku for simple tasks: Saves tokens and cost
- Maximize parallelism: Run independent tasks concurrently
- Pass minimal context: Don't overwhelm agents with data
- Monitor progress: Use TodoWrite to track wave completion
Coordination System
File Lock Management:
- Prevents parallel agents from editing the same files
- Locks stored in .claude/locks/ (auto-cleaned after 5 minutes)
- Detection happens during decomposition (Claude API predicts file changes)
Singleton Task Management:
- Build, lint, test, typecheck, install, deploy run ONE AT A TIME
- Prevents wasted resources (multiple agents running npm run build)
- Detection: automatic via task description matching
Conflict Resolution:
Scenario: Two tasks both modify "src/App.tsx"
Detection: Task decomposer predicts file overlap
Resolution: Tasks marked as sequential (dependency added automatically)
Result: Wave 2 becomes Wave 2a and Wave 2b
Smart Decomposition:
The Claude API decomposer is instructed to:
1. Predict which files each subtask will modify
2. Add dependencies if files overlap
3. Mark singleton tasks (build/lint/test)
4. Ensure non-overlapping file sets for parallel tasks
Limitations
- Max ~5-10 parallel tasks per wave (Claude Code limit)
- Each task is isolated (no shared memory between agents)
- Context must be explicitly passed between waves
- Total execution time is limited by longest critical path
- File prediction accuracy depends on decomposer (Claude API)
Activation Keywords
Invoke this skill when user says:
- "Execute this task using DAG"
- "Decompose and run in parallel"
- "Use the DAG framework"
- "Orchestrate agents to solve X"
The missing intelligence layer is now operational.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.