关于 github-multi-repo
github-multi-repo 是用于协调多个 GitHub 仓库工作的 Claude Flow 技能,涵盖包与依赖同步、仓库结构管理,以及跨项目测试和部署。
主要功能
- 01协调跨仓库群组工作
- 02对齐包版本与依赖
- 03分析仓库结构并创建模板
- 04协调集成测试与部署
- 05监控仓库健康状况和依赖
适用场景
- 01同步微服务契约与集成测试
- 02向共享库的各个使用方更新版本
- 03在多个仓库应用组织级策略
MCP 相关
该技能使用 Claude Flow 群组协调,并介绍了用于仓库操作的 GitHub MCP 工具,包括推送文件和更新仓库内容。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill github-multi-repo安装后在 Claude Code 中输入/github-multi-repo确认已加载。
详细介绍
GitHub 多仓库协调技能
概述
高级多仓库协调系统,结合了群体智能、软件包同步和仓库架构优化。此技能可实现组织范围的自动化、跨项目协作和可扩展的仓库管理。
核心功能
🔄 多仓库群体协调
针对分布式开发工作流的跨仓库 AI 群体编排。
📦 软件包同步
在多个软件包间智能解析依赖项并统一版本。
🏗️ 仓库架构
针对可扩展项目进行结构优化和模板管理。
🔗 集成管理
协调跨软件包集成测试和部署。
快速入门
初始化多仓库协调
# Basic swarm initialization
npx claude-flow skill run github-multi-repo init \
--repos "org/frontend,org/backend,org/shared" \
--topology hierarchical
# Advanced initialization with synchronization
npx claude-flow skill run github-multi-repo init \
--repos "org/frontend,org/backend,org/shared" \
--topology mesh \
--shared-memory \
--sync-strategy eventual
同步软件包
# Synchronize package versions and dependencies
npx claude-flow skill run github-multi-repo sync \
--packages "claude-code-flow,ruv-swarm" \
--align-versions \
--update-docs
优化架构
# Analyze and optimize repository structure
npx claude-flow skill run github-multi-repo optimize \
--analyze-structure \
--suggest-improvements \
--create-templates
功能
1. 跨仓库群体编排
仓库发现
// Auto-discover related repositories with gh CLI
const REPOS = Bash(`gh repo list my-organization --limit 100 \
--json name,description,languages,topics \
--jq '.[] | select(.languages | keys | contains(["TypeScript"]))'`)
// Analyze repository dependencies
const DEPS = Bash(`gh repo list my-organization --json name | \
jq -r '.[].name' | while read -r repo; do
gh api repos/my-organization/$repo/contents/package.json \
--jq '.content' 2>/dev/null | base64 -d | jq '{name, dependencies}'
done | jq -s '.'`)
// Initialize swarm with discovered repositories
mcp__claude-flow__swarm_init({
topology: "hierarchical",
maxAgents: 8,
metadata: { repos: REPOS, dependencies: DEPS }
})
同步操作
// Execute synchronized changes across repositories
[Parallel Multi-Repo Operations]:
// Spawn coordination agents
Task("Repository Coordinator", "Coordinate changes across all repositories", "coordinator")
Task("Dependency Analyzer", "Analyze cross-repo dependencies", "analyst")
Task("Integration Tester", "Validate cross-repo changes", "tester")
// Get matching repositories
Bash(`gh repo list org --limit 100 --json name \
--jq '.[] | select(.name | test("-service$")) | .name' > /tmp/repos.txt`)
// Execute task across repositories
Bash(`cat /tmp/repos.txt | while read -r repo; do
gh repo clone org/$repo /tmp/$repo -- --depth=1
cd /tmp/$repo
# Apply changes
npm update
npm test
# Create PR if successful
if [ $? -eq 0 ]; then
git checkout -b update-dependencies-$(date +%Y%m%d)
git add -A
git commit -m "chore: Update dependencies"
git push origin HEAD
gh pr create --title "Update dependencies" --body "Automated update" --label "dependencies"
fi
done`)
// Track all operations
TodoWrite { todos: [
{ id: "discover", content: "Discover all service repositories", status: "completed" },
{ id: "update", content: "Update dependencies", status: "completed" },
{ id: "test", content: "Run integration tests", status: "in_progress" },
{ id: "pr", content: "Create pull requests", status: "pending" }
]}
2. 软件包同步
版本统一
// Synchronize package dependencies and versions
[Complete Package Sync]:
// Initialize sync swarm
mcp__claude-flow__swarm_init({ topology: "mesh", maxAgents: 5 })
// Spawn sync agents
Task("Sync Coordinator", "Coordinate version alignment", "coordinator")
Task("Dependency Analyzer", "Analyze dependencies", "analyst")
Task("Integration Tester", "Validate synchronization", "tester")
// Read package states
Read("/workspaces/ruv-FANN/claude-code-flow/claude-code-flow/package.json")
Read("/workspaces/ruv-FANN/ruv-swarm/npm/package.json")
// Align versions using gh CLI
Bash(`gh api repos/:owner/:repo/git/refs \
-f ref='refs/heads/sync/package-alignment' \
-f sha=$(gh api repos/:owner/:repo/git/refs/heads/main --jq '.object.sha')`)
// Update package.json files
Bash(`gh api repos/:owner/:repo/contents/package.json \
--method PUT \
-f message="feat: Align Node.js version requirements" \
-f branch="sync/package-alignment" \
-f content="$(cat aligned-package.json | base64)"`)
// Store sync state
mcp__claude-flow__memory_usage({
action: "store",
key: "sync/packages/status",
value: {
timestamp: Date.now(),
packages_synced: ["claude-code-flow", "ruv-swarm"],
status: "synchronized"
}
})
文档同步
// Synchronize CLAUDE.md files across packages
[Documentation Sync]:
// Get source documentation
Bash(`gh api repos/:owner/:repo/contents/ruv-swarm/docs/CLAUDE.md \
--jq '.content' | base64 -d > /tmp/claude-source.md`)
// Update target documentation
Bash(`gh api repos/:owner/:repo/contents/claude-code-flow/CLAUDE.md \
--method PUT \
-f message="docs: Synchronize CLAUDE.md" \
-f branch="sync/documentation" \
-f content="$(cat /tmp/claude-source.md | base64)"`)
// Track sync status
mcp__claude-flow__memory_usage({
action: "store",
key: "sync/documentation/status",
value: { status: "synchronized", files: ["CLAUDE.md"] }
})
跨软件包集成
// Coordinate feature implementation across packages
[Cross-Package Feature]:
// Push changes to all packages
mcp__github__push_files({
branch: "feature/github-integration",
files: [
{
path: "claude-code-flow/.claude/commands/github/github-modes.md",
content: "[GitHub modes documentation]"
},
{
path: "ruv-swarm/src/github-coordinator/hooks.js",
content: "[GitHub coordination hooks]"
}
],
message: "feat: Add GitHub workflow integration"
})
// Create coordinated PR
Bash(`gh pr create \
--title "Feature: GitHub Workflow Integration" \
--body "## 🚀 GitHub Integration
### Features
- ✅ Multi-repo coordination
- ✅ Package synchronization
- ✅ Architecture optimization
### Testing
- [x] Package dependency verification
- [x] Integration tests
- [x] Cross-package compatibility"`)
3. 仓库架构
结构分析
// Analyze and optimize repository structure
[Architecture Analysis]:
// Initialize architecture swarm
mcp__claude-flow__swarm_init({ topology: "hierarchical", maxAgents: 6 })
// Spawn architecture agents
Task("Senior Architect", "Analyze repository structure", "architect")
Task("Structure Analyst", "Identify optimization opportunities", "analyst")
Task("Performance Optimizer", "Optimize structure for scalability", "optimizer")
Task("Best Practices Researcher", "Research architecture patterns", "researcher")
// Analyze current structures
LS("/workspaces/ruv-FANN/claude-code-flow/claude-code-flow")
LS("/workspaces/ruv-FANN/ruv-swarm/npm")
// Search for best practices
Bash(`gh search repos "language:javascript template architecture" \
--limit 10 \
--json fullName,description,stargazersCount \
--sort stars \
--order desc`)
// Store analysis results
mcp__claude-flow__memory_usage({
action: "store",
key: "architecture/analysis/results",
value: {
repositories_analyzed: ["claude-code-flow", "ruv-swarm"],
optimization_areas: ["structure", "workflows", "templates"],
recommendations: ["standardize_structure", "improve_workflows"]
}
})
创建模板
// Create standardized repository template
[Template Creation]:
// Create template repository
mcp__github__create_repository({
name: "claude-project-template",
description: "Standardized template for Claude Code projects",
private: false,
autoInit: true
})
// Push template structure
mcp__github__push_files({
repo: "claude-project-template",
files: [
{
path: ".claude/commands/github/github-modes.md",
content: "[GitHub modes template]"
},
{
path: ".claude/config.json",
content: JSON.stringify({
version: "1.0",
mcp_servers: {
"ruv-swarm": {
command: "npx",
args: ["ruv-swarm", "mcp", "start"]
}
}
})
},
{
path: "CLAUDE.md",
content: "[Standardized CLAUDE.md]"
},
{
path: "package.json",
content: JSON.stringify({
name: "claude-project-template",
engines: { node: ">=20.0.0" },
dependencies: { "ruv-swarm": "^1.0.11" }
})
}
],
message: "feat: Create standardized template"
})
跨仓库标准化
// Synchronize structure across repositories
[Structure Standardization]:
const repositories = ["claude-code-flow", "ruv-swarm", "claude-extensions"]
// Update common files across all repositories
repositories.forEach(repo => {
mcp__github__create_or_update_file({
repo: "ruv-FANN",
path: `${repo}/.github/workflows/integration.yml`,
content: `name: Integration Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with: { node-version: '20' }
- run: npm install && npm test`,
message: "ci: Standardize integration workflow",
branch: "structure/standardization"
})
})
4. 编排工作流
依赖管理
// Update dependencies across all repositories
[Organization-Wide Dependency Update]:
// Create tracking issue
TRACKING_ISSUE=$(Bash(`gh issue create \
--title "Dependency Update: [email protected]" \
--body "Tracking TypeScript update across all repositories" \
--label "dependencies,tracking" \
--json number -q .number`))
// Find all TypeScript repositories
TS_REPOS=$(Bash(`gh repo list org --limit 100 --json name | \
jq -r '.[].name' | while read -r repo; do
if gh api repos/org/$repo/contents/package.json 2>/dev/null | \
jq -r '.content' | base64 -d | grep -q '"typescript"'; then
echo "$repo"
fi
done`))
// Update each repository
Bash(`echo "$TS_REPOS" | while read -r repo; do
gh repo clone org/$repo /tmp/$repo -- --depth=1
cd /tmp/$repo
npm install --save-dev [email protected]
if npm test; then
git checkout -b update-typescript-5
git add package.json package-lock.json
git commit -m "chore: Update TypeScript to 5.0.0
Part of #$TRACKING_ISSUE"
git push origin HEAD
gh pr create \
--title "Update TypeScript to 5.0.0" \
--body "Updates TypeScript\n\nTracking: #$TRACKING_ISSUE" \
--label "dependencies"
else
gh issue comment $TRACKING_ISSUE \
--body "❌ Failed to update $repo - tests failing"
fi
done`)
重构操作
// Coordinate large-scale refactoring
[Cross-Repo Refactoring]:
// Initialize refactoring swarm
mcp__claude-flow__swarm_init({ topology: "mesh", maxAgents: 8 })
// Spawn specialized agents
Task("Refactoring Coordinator", "Coordinate refactoring across repos", "coordinator")
Task("Impact Analyzer", "Analyze refactoring impact", "analyst")
Task("Code Transformer", "Apply refactoring changes", "coder")
Task("Migration Guide Creator", "Create migration documentation", "documenter")
Task("Integration Tester", "Validate refactored code", "tester")
// Execute refactoring
mcp__claude-flow__task_orchestrate({
task: "Rename OldAPI to NewAPI across all repositories",
strategy: "sequential",
priority: "high"
})
安全更新
// Coordinate security patches
[Security Patch Deployment]:
// Scan all repositories
Bash(`gh repo list org --limit 100 --json name | jq -r '.[].name' | \
while read -r repo; do
gh repo clone org/$repo /tmp/$repo -- --depth=1
cd /tmp/$repo
npm audit --json > /tmp/audit-$repo.json
done`)
// Apply patches
Bash(`for repo in /tmp/audit-*.json; do
if [ $(jq '.vulnerabilities | length' $repo) -gt 0 ]; then
cd /tmp/$(basename $repo .json | sed 's/audit-//')
npm audit fix
if npm test; then
git checkout -b security/patch-$(date +%Y%m%d)
git add -A
git commit -m "security: Apply security patches"
git push origin HEAD
gh pr create --title "Security patches" --label "security"
fi
fi
done`)
配置
多仓库配置文件
# .swarm/multi-repo.yml
version: 1
organization: my-org
repositories:
- name: frontend
url: github.com/my-org/frontend
role: ui
agents: [coder, designer, tester]
- name: backend
url: github.com/my-org/backend
role: api
agents: [architect, coder, tester]
- name: shared
url: github.com/my-org/shared
role: library
agents: [analyst, coder]
coordination:
topology: hierarchical
communication: webhook
memory: redis://shared-memory
dependencies:
- from: frontend
to: [backend, shared]
- from: backend
to: [shared]
仓库角色
{
"roles": {
"ui": {
"responsibilities": ["user-interface", "ux", "accessibility"],
"default-agents": ["designer", "coder", "tester"]
},
"api": {
"responsibilities": ["endpoints", "business-logic", "data"],
"default-agents": ["architect", "coder", "security"]
},
"library": {
"responsibilities": ["shared-code", "utilities", "types"],
"default-agents": ["analyst", "coder", "documenter"]
}
}
}
通信策略
1. 基于 Webhook 的协调
const { MultiRepoSwarm } = require('ruv-swarm');
const swarm = new MultiRepoSwarm({
webhook: {
url: 'https://swarm-coordinator.example.com',
secret: process.env.WEBHOOK_SECRET
}
});
swarm.on('repo:update', async (event) => {
await swarm.propagate(event, {
to: event.dependencies,
strategy: 'eventual-consistency'
});
});
2. 事件流
# Kafka configuration for real-time coordination
kafka:
brokers: ['kafka1:9092', 'kafka2:9092']
topics:
swarm-events:
partitions: 10
replication: 3
swarm-memory:
partitions: 5
replication: 3
同步模式
1. 最终一致性
{
"sync": {
"strategy": "eventual",
"max-lag": "5m",
"retry": {
"attempts": 3,
"backoff": "exponential"
}
}
}
2. 强一致性
{
"sync": {
"strategy": "strong",
"consensus": "raft",
"quorum": 0.51,
"timeout": "30s"
}
}
3. 混合方式
{
"sync": {
"default": "eventual",
"overrides": {
"security-updates": "strong",
"dependency-updates": "strong",
"documentation": "eventual"
}
}
}
使用场景
1. 微服务协调
npx claude-flow skill run github-multi-repo microservices \
--services "auth,users,orders,payments" \
--ensure-compatibility \
--sync-contracts \
--integration-tests
2. 库更新
npx claude-flow skill run github-multi-repo lib-update \
--library "org/shared-lib" \
--version "2.0.0" \
--find-consumers \
--update-imports \
--run-tests
3. 组织范围的变更
npx claude-flow skill run github-multi-repo org-policy \
--policy "add-security-headers" \
--repos "org/*" \
--validate-compliance \
--create-reports
架构模式
单体仓库结构
ruv-FANN/
├── packages/
│ ├── claude-code-flow/
│ │ ├── src/
│ │ ├── .claude/
│ │ └── package.json
│ ├── ruv-swarm/
│ │ ├── src/
│ │ ├── wasm/
│ │ └── package.json
│ └── shared/
│ ├── types/
│ ├── utils/
│ └── config/
├── tools/
│ ├── build/
│ ├── test/
│ └── deploy/
├── docs/
│ ├── architecture/
│ ├── integration/
│ └── examples/
└── .github/
├── workflows/
├── templates/
└── actions/
命令结构
.claude/
├── commands/
│ ├── github/
│ │ ├── github-modes.md
│ │ ├── pr-manager.md
│ │ ├── issue-tracker.md
│ │ └── sync-coordinator.md
│ ├── sparc/
│ │ ├── sparc-modes.md
│ │ ├── coder.md
│ │ └── tester.md
│ └── swarm/
│ ├── coordination.md
│ └── orchestration.md
├── templates/
│ ├── issue.md
│ ├── pr.md
│ └── project.md
└── config.json
监控与可视化
多仓库仪表板
npx claude-flow skill run github-multi-repo dashboard \
--port 3000 \
--metrics "agent-activity,task-progress,memory-usage" \
--real-time
依赖关系图
npx claude-flow skill run github-multi-repo dep-graph \
--format mermaid \
--include-agents \
--show-data-flow
健康监控
npx claude-flow skill run github-multi-repo health-check \
--repos "org/*" \
--check "connectivity,memory,agents" \
--alert-on-issues
最佳实践
1. 仓库组织
- 明确的仓库角色和边界
- 统一的命名规范
- 记录依赖关系
- 共享配置标准
2. 通信
- 使用适当的同步策略
- 实施熔断器
- 监控延迟和故障
- 明确传播错误
3. 安全
- 确保跨仓库身份验证安全
- 加密通信渠道
- 记录所有操作的审计追踪
- 遵循最小权限原则
4. 版本管理
- 统一语义化版本
- 验证依赖兼容性
- 自动协调版本升级
5. 测试集成
- 验证跨软件包测试
- 自动化集成测试
- 检测性能回归
性能优化
缓存策略
npx claude-flow skill run github-multi-repo cache-strategy \
--analyze-patterns \
--suggest-cache-layers \
--implement-invalidation
并行执行
npx claude-flow skill run github-multi-repo parallel-optimize \
--analyze-dependencies \
--identify-parallelizable \
--execute-optimal
资源池化
npx claude-flow skill run github-multi-repo resource-pool \
--share-agents \
--distribute-load \
--monitor-usage
故障排查
连接问题
npx claude-flow skill run github-multi-repo diagnose-connectivity \
--test-all-repos \
--check-permissions \
--verify-webhooks
内存同步
npx claude-flow skill run github-multi-repo debug-memory \
--check-consistency \
--identify-conflicts \
--repair-state
性能瓶颈
npx claude-flow skill run github-multi-repo perf-analysis \
--profile-operations \
--identify-bottlenecks \
--suggest-optimizations
高级功能
1. 分布式任务队列
npx claude-flow skill run github-multi-repo queue \
--backend redis \
--workers 10 \
--priority-routing \
--dead-letter-queue
2. 跨仓库测试
npx claude-flow skill run github-multi-repo test \
--setup-test-env \
--link-services \
--run-e2e \
--tear-down
3. 单体仓库迁移
npx claude-flow skill run github-multi-repo to-monorepo \
--analyze-repos \
--suggest-structure \
--preserve-history \
--create-migration-prs
示例
全栈应用更新
npx claude-flow skill run github-multi-repo fullstack-update \
--frontend "org/web-app" \
--backend "org/api-server" \
--database "org/db-migrations" \
--coordinate-deployment
跨团队协作
npx claude-flow skill run github-multi-repo cross-team \
--teams "frontend,backend,devops" \
--task "implement-feature-x" \
--assign-by-expertise \
--track-progress
指标与报告
同步质量指标
- 软件包版本统一率
- 文档一致性评分
- 集成测试成功率
- 同步完成时间
架构健康指标
- 仓库结构一致性评分
- 文档覆盖率
- 跨仓库集成成功率
- 模板采用和使用统计
自动化报告
- 每周同步状态报告
- 依赖漂移检测
- 文档差异警报
- 集成健康监控
集成点
Related Skills
github-workflow- GitHub workflow automationgithub-pr- Pull request managementsparc-architect- Architecture designsparc-optimizer- Performance optimization
Related Commands
/github sync-coordinator- Cross-repo synchronization/github release-manager- Coordinated releases/github repo-architect- Repository optimization/sparc architect- Detailed architecture design
Support and Resources
- Documentation: https://github.com/ruvnet/claude-flow
- Issues: https://github.com/ruvnet/claude-flow/issues
- Examples:
.claude/examples/github-multi-repo/
Version: 1.0.0 Last Updated: 2025-10-19 Maintainer: Claude Flow Team
评论
支持 Markdown