| name | github-swarm-pr-1-pr-based-swarm-creation |
| description | Sub-skill of github-swarm-pr: 1. PR-Based Swarm Creation (+7). |
| version | 1.0.0 |
| category | development |
| type | reference |
| scripts_exempt | true |
1. PR-Based Swarm Creation (+7)
1. PR-Based Swarm Creation
PR_DATA=$(gh pr view 123 --json title,body,labels,files,additions,deletions,reviews)
PR_DIFF=$(gh pr diff 123)
ADDITIONS=$(echo "$PR_DATA" | jq '.additions')
DELETIONS=$(echo "$PR_DATA" | jq '.deletions')
TOTAL_CHANGES=$((ADDITIONS + DELETIONS))
if [ $TOTAL_CHANGES -gt 500 ]; then
TOPOLOGY="hierarchical"
MAX_AGENTS=8
elif [ $TOTAL_CHANGES -gt 100 ]; then
TOPOLOGY="mesh"
MAX_AGENTS=5
else
TOPOLOGY="ring"
MAX_AGENTS=3
fi
echo "PR #123: $TOTAL_CHANGES changes, using $TOPOLOGY topology with $MAX_AGENTS agents"
2. Multi-Agent PR Review
FILES=$(gh pr view 123 --json files --jq '.files[].path')
JS_FILES=$(echo "$FILES" | grep -E '\.(js|ts|tsx)$' || true)
PY_FILES=$(echo "$FILES" | grep -E '\.py$' || true)
TEST_FILES=$(echo "$FILES" | grep -E '(test|spec)\.' || true)
CONFIG_FILES=$(echo "$FILES" | grep -E '\.(json|yaml|yml)$' || true)
REVIEW_BODY="## Multi-Agent PR Review
## Code Review
$([ -n "$JS_FILES" ] && echo "**JavaScript/TypeScript**: Files reviewed")
$([ -n "$PY_FILES" ] && echo "**Python**: Files reviewed")
## Test Coverage
$([ -n "$TEST_FILES" ] && echo "Test files detected and validated" || echo "No test files found")
## Configuration Changes
$([ -n "$CONFIG_FILES" ] && echo "Configuration changes reviewed" || echo "No config changes")
## Summary
- Total files: $(echo "$FILES" | wc -l)
- Recommendation: Approve with minor suggestions
---
Generated by Swarm PR Agent"
gh review 123 --comment --body
3. PR Comment Commands
Use these commands in PR comments to control swarms:
<!-- Initialize swarm -->
/swarm init mesh 6
<!-- Spawn specific agents -->
/swarm spawn coder "Implement the authentication logic"
/swarm spawn tester "Write comprehensive tests"
/swarm spawn security "Review for vulnerabilities"
<!-- Check swarm status -->
/swarm status
<!-- Get analysis -->
/swarm analyze
<!-- Complete swarm work -->
/swarm complete
4. Automated PR Validation
validate_pr() {
local PR_NUM=$1
PR=$(gh pr view $PR_NUM --json state,mergeable,reviews,statusCheckRollup)
MERGEABLE=$(echo "$PR" | jq -r '.mergeable')
CI_STATUS=$(echo "$PR" | jq -r '.statusCheckRollup[0].conclusion // "pending"')
APPROVALS=$(echo "$PR" | jq '[.reviews[] | select(.state == "APPROVED")] | length')
cat << EOF