Claude
Skills
Sign in
Back

multi-repository-orchestrator

Included with Lifetime
$97 forever

Coordinate development workflows across multiple Git repositories with synchronized branching, batch commits, cross-repo operations, and monorepo-like workflows for microservices and multi-package projects.

Generalmulti-repogitorchestrationmicroservicesmonorepocoordination

What this skill does


# Multi-Repository Orchestrator

Manage development workflows seamlessly across multiple Git repositories.

## Overview

Many modern projects span multiple repositories:
- Microservices architectures
- Frontend + Backend + Shared libraries
- Multi-package monorepos split across repos
- Infrastructure + Application code
- Documentation + Code repositories

This skill provides tools and patterns to orchestrate changes, commits, and workflows across multiple repositories as if they were one.

## When to Use

Use this skill when:
- Working with microservices split across repos
- Maintaining frontend/backend in separate repositories
- Managing shared libraries used by multiple repos
- Coordinating infrastructure and application code
- Synchronizing changes across dependent projects
- Running tests across multiple repositories
- Deploying multi-repo applications
- Maintaining consistency across project family

## Repository Discovery

### Auto-Discovery Pattern

```bash
#!/bin/bash
# discover-repos.sh - Find all related repositories

BASE_DIR="${1:-.}"
WORKSPACE_FILE=".workspace"

# Find all git repositories
find "$BASE_DIR" -name ".git" -type d | while read git_dir; do
    REPO_DIR=$(dirname "$git_dir")
    REPO_NAME=$(basename "$REPO_DIR")

    # Get remote URL
    cd "$REPO_DIR"
    REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "none")

    echo "$REPO_NAME|$REPO_DIR|$REMOTE_URL"
done | tee "$WORKSPACE_FILE"

echo ""
echo "Discovered $(wc -l < $WORKSPACE_FILE) repositories"
echo "Workspace file: $WORKSPACE_FILE"
```

### Manual Workspace Configuration

```yaml
# workspace.yaml - Define multi-repo workspace

workspace:
  name: my-microservices
  base_dir: ~/projects

repositories:
  - name: api-gateway
    path: ./api-gateway
    url: https://github.com/org/api-gateway
    category: backend

  - name: user-service
    path: ./user-service
    url: https://github.com/org/user-service
    category: backend

  - name: frontend
    path: ./frontend
    url: https://github.com/org/frontend
    category: frontend

  - name: shared-lib
    path: ./shared-lib
    url: https://github.com/org/shared-lib
    category: library

  - name: infrastructure
    path: ./infrastructure
    url: https://github.com/org/infrastructure
    category: infra
```

## Synchronized Branching

### Create Branches Across Repos

```bash
#!/bin/bash
# sync-branch-create.sh - Create same branch in multiple repos

BRANCH_NAME="$1"
REPOS_FILE="${2:-.workspace}"

if [ -z "$BRANCH_NAME" ]; then
    echo "Usage: $0 <branch-name> [repos-file]"
    exit 1
fi

echo "=== Creating branch: $BRANCH_NAME ==="
echo ""

while IFS='|' read -r name path url; do
    echo "Repository: $name"
    cd "$path" || continue

    # Get current branch
    CURRENT=$(git branch --show-current)

    # Create and checkout new branch
    if git checkout -b "$BRANCH_NAME" 2>/dev/null; then
        echo "  ✓ Created and checked out $BRANCH_NAME"
    else
        # Branch might already exist
        if git checkout "$BRANCH_NAME" 2>/dev/null; then
            echo "  ✓ Checked out existing $BRANCH_NAME"
        else
            echo "  ✗ Failed to create/checkout $BRANCH_NAME"
        fi
    fi

    cd - > /dev/null
    echo ""
done < "$REPOS_FILE"

echo "✓ Branch creation complete"
```

### Claude-Compatible Multi-Repo Branching

```bash
#!/bin/bash
# claude-multi-branch.sh - Create Claude-formatted branches across repos

FEATURE="$1"
SESSION_ID="${2:-$(date +%s)}"
REPOS_FILE="${3:-.workspace}"

if [ -z "$FEATURE" ]; then
    echo "Usage: $0 <feature-name> [session-id] [repos-file]"
    exit 1
fi

while IFS='|' read -r name path url; do
    echo "=== $name ==="
    cd "$path" || continue

    # Claude branch format
    BRANCH="claude/${FEATURE}-${name}-${SESSION_ID}"

    git checkout main 2>/dev/null || git checkout master 2>/dev/null
    git pull

    if git checkout -b "$BRANCH"; then
        echo "✓ Created: $BRANCH"
    fi

    cd - > /dev/null
done < "$REPOS_FILE"
```

## Batch Operations

### Batch Status Check

```bash
#!/bin/bash
# multi-status.sh - Check status across all repos

REPOS_FILE="${1:-.workspace}"

echo "=== Repository Status ==="
echo ""

while IFS='|' read -r name path url; do
    cd "$path" || continue

    BRANCH=$(git branch --show-current)
    STATUS=$(git status --porcelain)
    UNPUSHED=$(git log origin/$BRANCH..$BRANCH --oneline 2>/dev/null | wc -l)

    echo "📁 $name"
    echo "   Branch: $BRANCH"

    if [ -z "$STATUS" ]; then
        echo "   Status: ✓ Clean"
    else
        CHANGES=$(echo "$STATUS" | wc -l)
        echo "   Status: ⚠️  $CHANGES file(s) changed"
    fi

    if [ "$UNPUSHED" -gt 0 ]; then
        echo "   Commits: ⚠️  $UNPUSHED unpushed"
    else
        echo "   Commits: ✓ Synced"
    fi

    echo ""
    cd - > /dev/null
done < "$REPOS_FILE"
```

### Batch Commit

```bash
#!/bin/bash
# multi-commit.sh - Commit changes across all repos

COMMIT_MSG="$1"
REPOS_FILE="${2:-.workspace}"

if [ -z "$COMMIT_MSG" ]; then
    echo "Usage: $0 <commit-message> [repos-file]"
    exit 1
fi

echo "=== Committing to all repositories ==="
echo "Message: $COMMIT_MSG"
echo ""

while IFS='|' read -r name path url; do
    cd "$path" || continue

    # Check if there are changes
    if [ -n "$(git status --porcelain)" ]; then
        echo "📁 $name"

        # Show what will be committed
        git status --short

        # Commit
        git add .
        if git commit -m "$COMMIT_MSG"; then
            echo "  ✓ Committed"
        else
            echo "  ✗ Commit failed"
        fi
        echo ""
    else
        echo "📁 $name - No changes"
    fi

    cd - > /dev/null
done < "$REPOS_FILE"

echo "✓ Batch commit complete"
```

### Batch Push with Retry

```bash
#!/bin/bash
# multi-push.sh - Push all repos with retry logic

REPOS_FILE="${1:-.workspace}"
MAX_RETRIES=4

push_with_retry() {
    local repo_name="$1"
    local branch="$2"

    for attempt in $(seq 1 $MAX_RETRIES); do
        if git push -u origin "$branch" 2>&1; then
            echo "  ✓ Pushed successfully"
            return 0
        else
            if [ $attempt -lt $MAX_RETRIES ]; then
                DELAY=$((2 ** attempt))
                echo "  ⚠️  Push failed (attempt $attempt/$MAX_RETRIES), retrying in ${DELAY}s..."
                sleep $DELAY
            fi
        fi
    done

    echo "  ✗ Push failed after $MAX_RETRIES attempts"
    return 1
}

echo "=== Pushing all repositories ==="
echo ""

FAILED_REPOS=()

while IFS='|' read -r name path url; do
    cd "$path" || continue

    BRANCH=$(git branch --show-current)
    UNPUSHED=$(git log origin/$BRANCH..$BRANCH --oneline 2>/dev/null | wc -l)

    if [ "$UNPUSHED" -gt 0 ]; then
        echo "📁 $name ($UNPUSHED commits)"
        if ! push_with_retry "$name" "$BRANCH"; then
            FAILED_REPOS+=("$name")
        fi
        echo ""
    else
        echo "📁 $name - Nothing to push"
    fi

    cd - > /dev/null
done < "$REPOS_FILE"

if [ ${#FAILED_REPOS[@]} -gt 0 ]; then
    echo "⚠️  Failed repositories:"
    printf '  - %s\n' "${FAILED_REPOS[@]}"
    exit 1
else
    echo "✓ All repositories pushed successfully"
fi
```

## Cross-Repository Operations

### Find File Across Repos

```bash
#!/bin/bash
# find-file.sh - Search for file across all repositories

PATTERN="$1"
REPOS_FILE="${2:-.workspace}"

if [ -z "$PATTERN" ]; then
    echo "Usage: $0 <filename-pattern> [repos-file]"
    exit 1
fi

echo "=== Searching for: $PATTERN ==="
echo ""

while IFS='|' read -r name path url; do
    cd "$path" || continue

    MATCHES=$(find . -name "$PATTERN" ! -path "*/node_modules/*" ! -path "*/.git/*")

    if [ -n "$MATCHES" ]; then
        echo "📁 $name"
        echo "$MATCHES" | sed 's/^/   /'
        echo ""
    fi

    cd - > /dev/null
done < "$REPOS_FILE"
```

### Grep Across Repos

```bash
#!/bin/bash
# multi-grep.sh - Search for pattern in all repos

PATTERN="$1"
REPOS_FILE="${2:-.workspace}"

if [ -z "$PATTERN" ]; then
    echo "Usage: $0 <searc

Related in General