MCP HubMCP Hub
Zurück zu Fähigkeiten

parallel-batch-executor-1-basic-parallel-execution-with-xargs

vamseeachanta
Aktualisiert Today
7 Ansichten
3
2
3
Auf GitHub ansehen
Anderegeneral

Über

Diese Fähigkeit bietet grundlegende parallele Ausführung unter Verwendung von xargs, um mehrere Elemente gleichzeitig mit kontrolliertem Parallelismus zu verarbeiten. Sie demonstriert grundlegende Muster für die Handhabung von Eingabeströmen und beinhaltet Fehlerbehandlungsfunktionen. Entwickler sollten dies für einfache Parallelverarbeitungsaufgaben verwenden, bei denen xargs ausreichende Kontrolle über die Nebenläufigkeit der Worker bietet.

Schnellinstallation

Claude Code

Empfohlen
Primär
npx skills add vamseeachanta/workspace-hub
Plugin-BefehlAlternativ
/plugin add https://github.com/vamseeachanta/workspace-hub
Git CloneAlternativ
git clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/parallel-batch-executor-1-basic-parallel-execution-with-xargs

Kopieren Sie diesen Befehl und fügen Sie ihn in Claude Code ein, um diese Fähigkeit zu installieren

Dokumentation

1. Basic Parallel Execution with xargs (+2)

1. Basic Parallel Execution with xargs

The fundamental pattern for parallel execution:

#!/bin/bash
# ABOUTME: Basic parallel execution using xargs
# ABOUTME: Process multiple items concurrently with controlled parallelism

PARALLEL="${PARALLEL:-5}"  # Default to 5 parallel workers

# Process items from stdin in parallel
cat items.txt | xargs -I {} -P "$PARALLEL" bash -c 'echo "Processing: {}"'

# Process with error handling
cat items.txt | xargs -I {} -P "$PARALLEL" bash -c '
    item="{}"
    if process_item "$item"; then
        echo "✓ $item"
    else
        echo "✗ $item" >&2
    fi
'

2. JSON Array Processing

Process JSON arrays in parallel (from batch_runner.sh):

#!/bin/bash
# ABOUTME: Process JSON array items in parallel
# ABOUTME: Uses jq for parsing and xargs for parallel execution

set -e

PARALLEL="${1:-5}"
ORCHESTRATOR="./scripts/routing/orchestrate.sh"

# Check dependencies
if ! command -v jq &> /dev/null; then
    echo "Error: jq is not installed."
    exit 1
fi

echo "Starting batch execution with $PARALLEL parallel workers..."

# Read JSON array from stdin, extract items, process in parallel
jq -r '.[]' | xargs -I {} -P "$PARALLEL" bash -c "$ORCHESTRATOR \"{}\" > /dev/null"

echo "Batch execution complete."

3. Repository Batch Operations

Execute commands across multiple repositories:

#!/bin/bash
# ABOUTME: Execute operations across multiple repositories in parallel
# ABOUTME: Pattern from workspace-hub repository_sync

PARALLEL="${PARALLEL:-5}"
REPOS_DIR="/mnt/github"

# Get list of repositories
get_repos() {
    find "$REPOS_DIR" -maxdepth 1 -type d -name "[!.]*" | sort
}

# Execute command in each repository in parallel
batch_repo_command() {
    local command="$1"
    local repos
    repos=$(get_repos)

    echo "$repos" | xargs -I {} -P "$PARALLEL" bash -c "
        repo=\"{}\"
        repo_name=\$(basename \"\$repo\")

        if cd \"\$repo\" 2>/dev/null; then
            result=\$($command 2>&1)
            exit_code=\$?

            if [[ \$exit_code -eq 0 ]]; then
                echo \"✓ \$repo_name: \$result\"
            else
                echo \"✗ \$repo_name: \$result\" >&2
            fi
        else
            echo \"⊘ \$repo_name: Directory not accessible\" >&2
        fi
    "
}

# Usage examples
batch_repo_command "git status --porcelain | head -1"
batch_repo_command "git pull --rebase"
batch_repo_command "git push"

GitHub Repository

vamseeachanta/workspace-hub
Pfad: .claude/skills/_core/bash/parallel-batch-executor/1-basic-parallel-execution-with-xargs

Verwandte Skills

algorithmic-art

Meta

This Claude Skill creates original algorithmic art using p5.js with seeded randomness and interactive parameters. It generates .md files for algorithmic philosophies, plus .html and .js files for interactive generative art implementations. Use it when developers need to create flow fields, particle systems, or other computational art while avoiding copyright issues.

Skill ansehen

subagent-driven-development

Entwicklung

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

Skill ansehen

executing-plans

Design

Use the executing-plans skill when you have a complete implementation plan to execute in controlled batches with review checkpoints. It loads and critically reviews the plan, then executes tasks in small batches (default 3 tasks) while reporting progress between each batch for architect review. This ensures systematic implementation with built-in quality control checkpoints.

Skill ansehen

cost-optimization

Andere

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

Skill ansehen