Agent skill

github-swarm-pr-1-pr-based-swarm-creation

Sub-skill of github-swarm-pr: 1. PR-Based Swarm Creation (+7).

Stars 4
Forks 4

Install this agent skill to your Project

npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/_archive/development/github/github-swarm-pr/1-pr-based-swarm-creation

SKILL.md

1. PR-Based Swarm Creation (+7)

1. PR-Based Swarm Creation

bash
# Get comprehensive PR data
PR_DATA=$(gh pr view 123 --json title,body,labels,files,additions,deletions,reviews)
PR_DIFF=$(gh pr diff 123)

# Analyze PR complexity for swarm topology
ADDITIONS=$(echo "$PR_DATA" | jq '.additions')
DELETIONS=$(echo "$PR_DATA" | jq '.deletions')
TOTAL_CHANGES=$((ADDITIONS + DELETIONS))

# Determine topology based on size
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

bash
# Get changed files by type
FILES=$(gh pr view 123 --json files --jq '.files[].path')

# Categorize files for agent assignment
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)

# Generate comprehensive review
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 pr review 123 --comment --body "$REVIEW_BODY"

3. PR Comment Commands

Use these commands in PR comments to control swarms:

markdown
<!-- 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

bash
# Run comprehensive PR validation
validate_pr() {
  local PR_NUM=$1

  # Get PR details
  PR=$(gh pr view $PR_NUM --json state,mergeable,reviews,statusCheckRollup)

  # Check merge status
  MERGEABLE=$(echo "$PR" | jq -r '.mergeable')

  # Check CI status
  CI_STATUS=$(echo "$PR" | jq -r '.statusCheckRollup[0].conclusion // "pending"')

  # Check review status
  APPROVALS=$(echo "$PR" | jq '[.reviews[] | select(.state == "APPROVED")] | length')

  # Validation report
  cat << EOF

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results