📦 Openclaw Skill Parallel Tasks — 技能工具

v1.0.0

Execute multiple tasks in parallel with timeout protection, error isolation, and real-time progress feedback. Use when user says "run these in parallel", "pa...

0· 1·0 当前·0 累计
by @qiukui666·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/14
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
可疑
medium confidence
The skill's code and runtime instructions broadly match the stated purpose (spawning parallel tasks), but there are several mismatches and privacy/operational risks—most notably it invokes an external 'hermes' CLI and forwards the agent environment without declaring required binaries or justifying the environment access.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/4/14

Initial release of the Parallel Tasks Skill — run multiple tasks concurrently with robust timeout and error isolation. - Enables users to execute multiple independent tasks in parallel rather than sequentially. - Provides per-task timeout protection and isolates errors so other tasks continue unaffected. - Includes real-time progress feedback in the terminal, with clear status and duration for each task. - Supports various input formats (named, bullet, numbered, plain text) and configurable concurrency limits. - Offers CLI with flexible options: per-task timeout, max concurrency, error handling, and progress control.

无害

安装命令

点击复制
官方npx clawhub@latest install openclaw-skill-parallel-tasks
🇨🇳 镜像加速npx clawhub@latest install openclaw-skill-parallel-tasks --registry https://cn.longxiaskill.com

技能文档

Execute multiple tasks in parallel with enterprise-grade reliability: timeout protection, error isolation, and real-time progress feedback.

When to Use

Use this skill when:

  • User says "run these in parallel" or "do these simultaneously"
  • Multiple independent tasks need to be executed at once
  • User wants faster results by running tasks concurrently
  • Tasks are slow and user wants to avoid waiting sequentially

Core Concept

Serial vs Parallel:

SERIAL (slow):
Task 1 → Task 2 → Task 3  (5min + 5min + 5min = 15min)

PARALLEL (fast): Task 1 ─┬─> (5min total, not 15min) Task 2 ─┼─> Task 3 ─┘

Usage

Basic Parallel Execution

/parallel
  • Task 1: Search for docs
  • Task 2: Search for code
  • Task 3: Search for examples

Named Tasks with Custom Timeout

/parallel timeout=300
  • [search-docs] Search for relevant documentation
  • [search-code] Find similar implementations
  • [analyze] Analyze the results

CLI Usage (scripts/executor.ts)

# Simple usage
node scripts/executor.ts "Research AI trends" "Research market analysis"

# Named tasks with custom timeout node scripts/executor.ts --timeout 600 \ --task "[research] Research AI trends" \ --task "[implement] Build the feature"

# Read from file (one task per line) node scripts/executor.ts --tasks-file my-tasks.txt --max-concurrent 3

# Named task formats (all equivalent): # - [name] description # - - description (auto-named as task-1, task-2, ...) # - 1. description

Implementation

Core Execution Pattern

The executor uses a semaphore pattern with configurable concurrency:

// 1. Parse tasks from input
const tasks = parseTaskInput(input)

// 2. Execute tasks with concurrency control const results: TaskResult[] = [] const executing: Promise[] = []

for (const task of tasks) { // Wait if at max concurrency if (executing.length >= maxConcurrent) { await Promise.race(executing) }

const promise = runTask(task).then(result => { results.push(result) // Remove from executing list const idx = executing.indexOf(promise) if (idx > -1) executing.splice(idx, 1) })

executing.push(promise) }

await Promise.all(executing)

Task Execution via hermes cli

async function executeTaskViaSpawn(
  task: Task,
  timeoutSeconds: number
): Promise {
  const taskId = parallel-${Date.now()}-${randomId()}

return new Promise((resolve) => { const proc = spawn('hermes', [ 'cli', '--', 'sessions_spawn', '--task', "${task.description}", '--label', "${task.name}", '--timeout', String(timeoutSeconds), '--session-id', taskId ], { stdio: ['ignore', 'pipe', 'pipe'] })

// Timeout handling const timeoutId = setTimeout(() => { proc.kill('SIGTERM') resolve({ name: task.name, status: 'timeout', duration: Date.now() - startTime, error: Exceeded ${timeoutSeconds}s timeout }) }, timeoutSeconds * 1000)

proc.on('close', (code, signal) => { clearTimeout(timeoutId) if (signal === 'SIGTERM') { resolve({ name: task.name, status: 'timeout', ... }) } else if (code === 0) { resolve({ name: task.name, status: 'fulfilled', ... }) } else { resolve({ name: task.name, status: 'rejected', ... }) } }) }) }

Timeout Protection

OptionDefaultDescription
timeout300Default timeout per task (seconds)
Per-task timeout-Override global timeout for specific tasks
Behavior: Task auto-terminates after timeout, other tasks continue.

Error Isolation

Each task runs in complete isolation:

ProblemSerialParallel (This Skill)
One task failsAll others stopOnly failed task affected
One task hangsBlocks entire flowOthers continue normally
One task times outMay cascadeContained, others finish

Concurrency Control

OptionDefaultDescription
maxConcurrent5Maximum tasks running simultaneously
Pattern: Semaphore-style - starts N tasks, when one completes, starts next.

Progress Feedback

Real-time terminal output with colored status:

🚀 Starting 3 tasks in parallel (max 5 concurrent)...

🔄 [task-1] Starting (timeout: 300s)... 🔄 [task-2] Starting (timeout: 300s)... 🔄 [task-3] Starting (timeout: 300s)... ✅ [1/3] [task-1] Complete (23.5s) ✅ [2/3] [task-2] Complete (45.2s) ⏱️ [3/3] [task-3] Timeout after 300s

Task Input Formats

1. Named Tasks (Recommended)

[research] Research AI trends and write report
[implement] Build the feature
[test] Write comprehensive tests

2. Bullet List

- Search for API documentation
  • Find relevant code examples
  • Check for existing implementations

3. Numbered List

1. Research authentication patterns
  • Design database schema
  • Implement API endpoints

4. Plain Text (auto-named)

Research AI trends
Build the feature
Write tests
→ Auto-named: task-1, task-2, task-3

Output Format

Success Case

✅ Parallel Execution Complete
   3 tasks: 2 succeeded, 1 failed (45.2s total)

┌─────────────────────┬────────────┬────────────┐ │ Task │ Status │ Duration │ ├─────────────────────┼────────────┼────────────┤ │ research │ ✅ fulfilled│ 23.5s │ │ implement │ ✅ fulfilled│ 45.2s │ │ test │ ⏱️ timeout │ 300.0s │ └─────────────────────┴────────────┴────────────┘

❌ Failed Tasks: • test: Exceeded 300s timeout

Exit Codes

CodeMeaning
0All tasks succeeded
1Some tasks failed or timed out

Options

CLI Options

OptionDefaultDescription
--timeout, -to300Timeout per task (seconds)
--max-concurrent, -m5Max concurrent tasks
--stop-on-errorfalseStop all if one fails
--no-progressfalseSuppress progress output
--tasks-file, -f-Read tasks from file
--parse-Parse stdin to JSON

Per-Task Options (in task description)

[name] description (timeout=600)

Error Handling

Error Types

StatusCauseBehavior
fulfilledTask succeededReturns result value
timeoutExceeded timeoutTask terminated, others continue
rejectedProcess errorError captured, others continue
cancelledUser cancelledAll running tasks terminate
no_replyNo outputReported as warning

Best Practices

  • Independent tasks first: Tasks should not depend on each other
  • Set reasonable timeouts: Don't set 5min if task should take 30s
  • Use named tasks: Easier to debug when something fails
  • Keep tasks focused: One clear goal per task
  • Mind concurrency: Don't set maxConcurrent higher than system can handle

Examples

Example 1: Research Multiple Topics

node scripts/executor.ts \
  "Research Claude Code best practices" \
  "Find OpenClaw skill examples" \
  "Search for agent design patterns"

Example 2: Named Tasks from File

# tasks.txt:
# [research] Research AI trends
# [implement] Build the feature
# [test] Write tests

node scripts/executor.ts --tasks-file tasks.txt --timeout 600

Example 3: Parallel Implementation

node scripts/executor.ts --timeout 600 \
  --task "[backend] Implement user authentication API" \
  --task "[frontend] Build login form component" \
  --task "[database] Create users table migration"

Example 4: Web Scraping

node scripts/executor.ts \
  --task "[store1] Fetch product data from store1.com" \
  --task "[store2] Fetch product data from store2.com" \
  --task "[store3] Fetch product data from store3.com"

Anti-Patterns

Don't use for dependent tasks:

# WRONG - second task depends on first!
node scripts/executor.ts \
  "Create user account" \
  "Send welcome email"
Use sequential execution instead.

Don't use for very fast tasks:

# WRONG - spawning overhead not worth it
node scripts/executor.ts "Read file A" "Read file B" "Read file C"
The overhead of spawning parallel sessions isn't worth it for sub-second tasks.

Related Skills

  • subagents - Background agent spawning
  • batch-operations - Bulk file operations
  • workflow-orchestrator - Complex multi-step workflows
数据来源:ClawHub ↗ · 中文优化:龙虾技能库