claude-flow
Version:
Enterprise-grade AI agent orchestration with ruv-swarm integration (Alpha Release)
251 lines (208 loc) • 5.57 kB
Markdown
Create and manage AI swarms directly from GitHub Pull Requests, enabling seamless integration with your development workflow.
```bash
gh pr view 123 --json body | npx ruv-swarm swarm create-from-pr
gh pr view 123 --json labels | npx ruv-swarm swarm auto-spawn
```
Execute swarm commands via PR comments:
```markdown
<!-- In PR comment -->
/swarm init mesh 6
/swarm spawn coder "Implement authentication"
/swarm spawn tester "Write unit tests"
/swarm status
```
```yaml
name: Swarm PR Handler
on:
pull_request:
types: [opened, labeled]
issue_comment:
types: [created]
jobs:
swarm-handler:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Handle Swarm Command
run: |
if [[ "${{ github.event.comment.body }}" == /swarm* ]]; then
npx ruv-swarm github handle-comment \
--pr ${{ github.event.pull_request.number }} \
--comment "${{ github.event.comment.body }}"
fi
```
Map PR labels to agent types:
```json
{
"label-mapping": {
"bug": ["debugger", "tester"],
"feature": ["architect", "coder", "tester"],
"refactor": ["analyst", "coder"],
"docs": ["researcher", "writer"],
"performance": ["analyst", "optimizer"]
}
}
```
```bash
npx ruv-swarm github pr-topology --pr 123
```
```bash
npx ruv-swarm github pr-init 123 \
--auto-agents \
--load-diff \
--analyze-impact
```
```bash
npx ruv-swarm github pr-update 123 \
--comment "🐝 Swarm Progress: 75% complete" \
--details
```
```bash
npx ruv-swarm github pr-review 123 \
--agents "security,performance,style" \
--post-comments
```
```bash
npx ruv-swarm github multi-pr \
--prs "123,124,125" \
--strategy "parallel" \
--share-memory
```
```bash
npx ruv-swarm github pr-deps 123 \
--spawn-agents \
--resolve-conflicts
```
```bash
npx ruv-swarm github pr-fix 123 \
--issues "lint,test-failures" \
--commit-fixes
```
```markdown
<!-- .github/pull_request_template.md -->
- Topology: [mesh/hierarchical/ring/star]
- Max Agents: [number]
- Auto-spawn: [yes/no]
- Priority: [high/medium/low]
- [ ] Task 1 description
- [ ] Task 2 description
```
```yaml
required_status_checks:
contexts:
- "swarm/tasks-complete"
- "swarm/tests-pass"
- "swarm/review-approved"
```
```bash
npx ruv-swarm github pr-automerge 123 \
--when "all-tasks-complete" \
--require-reviews 2
```
```javascript
// webhook-handler.js
const { createServer } = require('http');
const { execSync } = require('child_process');
createServer((req, res) => {
if (req.url === '/github-webhook') {
const event = JSON.parse(body);
if (event.action === 'opened' && event.pull_request) {
execSync(`npx ruv-swarm github pr-init ${event.pull_request.number}`);
}
res.writeHead(200);
res.end('OK');
}
}).listen(3000);
```
```bash
npx ruv-swarm github pr-init 456 \
--topology hierarchical \
--agents "architect,coder,tester,security" \
--auto-assign-tasks
```
```bash
npx ruv-swarm github pr-init 789 \
--topology mesh \
--agents "debugger,analyst,tester" \
--priority high
```
```bash
npx ruv-swarm github pr-init 321 \
--topology ring \
--agents "researcher,writer,reviewer" \
--validate-links
```
```bash
npx ruv-swarm github pr-report 123 \
--metrics "completion-time,agent-efficiency,token-usage" \
--format markdown
```
```bash
npx ruv-swarm github export-metrics \
--pr 123 \
--to-insights
```
1. **Token Permissions**: Ensure GitHub tokens have appropriate scopes
2. **Command Validation**: Validate all PR comments before execution
3. **Rate Limiting**: Implement rate limits for PR operations
4. **Audit Trail**: Log all swarm operations for compliance
When using with Claude Code:
1. Claude Code reads PR diff and context
2. Swarm coordinates approach based on PR type
3. Agents work in parallel on different aspects
4. Progress updates posted to PR automatically
5. Final review performed before marking ready
See also: [swarm-issue.md](./swarm-issue.md), [workflow-automation.md](./workflow-automation.md)