MCP HubMCP Hub
Retour aux compétences

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

vamseeachanta
Mis à jour Today
9 vues
3
2
3
Voir sur GitHub
Autregeneral

À propos

Cette compétence offre une exécution parallèle de base en utilisant xargs pour traiter plusieurs éléments simultanément avec un parallélisme contrôlé. Elle démontre les modèles fondamentaux pour gérer les flux d'entrée et inclut des capacités de gestion des erreurs. Les développeurs devraient l'utiliser pour des tâches de traitement parallèle simples où xargs fournit un contrôle suffisant sur la concurrence des travailleurs.

Installation rapide

Claude Code

Recommandé
Principal
npx skills add vamseeachanta/workspace-hub
Commande PluginAlternatif
/plugin add https://github.com/vamseeachanta/workspace-hub
Git CloneAlternatif
git clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/parallel-batch-executor-1-basic-parallel-execution-with-xargs

Copiez et collez cette commande dans Claude Code pour installer cette compétence

Documentation

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"

Dépôt GitHub

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

Compétences associées

algorithmic-art

Méta

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.

Voir la compétence

subagent-driven-development

Développement

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.

Voir la compétence

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.

Voir la compétence

cost-optimization

Autre

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.

Voir la compétence