Claude Skills Guide

Manual PR reviewer assignment is time-consuming and often inconsistent. Teams waste valuable developer hours playing the assignment game, and new team members have no visibility into who should review what. This tutorial shows you how to build an automated reviewer assignment system using Claude Code that scales with your team and enforces consistent review policies.

Understanding the Auto-Assign Reviewer Problem

Before diving into code, let’s identify what makes reviewer assignment challenging. Every development team faces these common pain points:

An automated system solves these by applying consistent rules, considering real-time availability, and distributing load evenly across your team.

Setting Up Your Claude Code Skill

The foundation of your auto-assign workflow is a custom Claude Code skill. Create a new skill file in your project’s .claude/ directory:

mkdir -p .claude
touch .claude/auto-assign-reviewer.md

This skill will handle the logic for selecting and assigning reviewers based on multiple factors.

Building the Reviewer Selection Logic

Your auto-assign skill needs a structured approach. Here’s a practical implementation:

// auto-assign-reviewer.js - Core assignment logic
const AVAILABLE_REVIEWERS = [
  { name: 'alice', expertise: ['backend', 'api'], load: 2 },
  { name: 'bob', expertise: ['frontend', 'ui'], load: 1 },
  { name: 'charlie', expertise: ['security', 'devops'], load: 3 },
  { name: 'diana', expertise: ['database', 'backend'], load: 2 }
];

function selectReviewer(changes, reviewers, currentLoad) {
  // Priority: lowest load first
  const available = reviewers.filter(r => r.load < currentLoad.maxLoad);
  
  // Match expertise to changed files
  const scored = available.map(reviewer => {
    let score = 0;
    changes.files.forEach(file => {
      if (reviewer.expertise.some(e => file.includes(e))) {
        score += 2;
      }
    });
    // Prefer less loaded reviewer
    score += (currentLoad.maxLoad - reviewer.load);
    return { reviewer, score };
  });
  
  return scored.sort((a, b) => b.score - a.score)[0].reviewer;
}

This basic algorithm considers two key factors: current workload and file expertise matching.

Integrating with GitHub’s API

To actually assign reviewers automatically, you need to interact with GitHub’s API. Here’s how to wire this into your Claude Code skill:

async function assignReviewer(owner, repo, prNumber, reviewer) {
  const response = await fetch(
    `https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}/requested_reviewers`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.GITHUB_TOKEN}`,
        'Accept': 'application/vnd.github.v3+json'
      },
      body: JSON.stringify({ reviewers: [reviewer.name] })
    }
  );
  
  return response.ok;
}

This function makes the actual API call to request a reviewer on your pull request.

Creating the Claude Code Skill Definition

Now wrap this logic in a proper Claude Code skill file:

---
name: Auto Assign Reviewer
description: Automatically assign appropriate reviewers to pull requests based on expertise and availability
---

# Auto Assign Reviewer Skill

This skill helps you automatically assign reviewers to pull requests.

## Usage

/auto-assign-reviewer –pr 123 –files “src/api/, src/utils/


## Configuration

Set these environment variables:
- GITHUB_TOKEN: GitHub personal access token with repo scope
- MAX_REVIEW_LOAD: Maximum concurrent reviews per person (default: 3)

## How It Works

1. Analyzes changed files in the PR
2. Matches file patterns to reviewer expertise
3. Checks current review load for each candidate
4. Selects the best match considering both factors
5. Assigns via GitHub API

Automating with GitHub Actions

For true automation, trigger your reviewer assignment automatically when PRs are created or updated:

# .github/workflows/auto-assign-reviewer.yml
name: Auto Assign Reviewer

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  assign-reviewer:
    runs-on: ubuntu-latest
    steps:
      - name: Get changed files
        id: files
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Get PR diff
        run: |
          CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD)
          echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
      
      - name: Run Claude Code skill
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          CHANGED_FILES: ${{ steps.files.outputs.files }}
        run: |
          claude --skill auto-assign-reviewer \
            --pr $PR_NUMBER \
            --files "$CHANGED_FILES"

This workflow runs on every PR event and automatically invokes Claude Code to assign reviewers.

Advanced: Round-Robin with Expertise Fallback

A more sophisticated approach combines multiple strategies:

function advancedSelect(changes, reviewers, config) {
  const { strategy, exclude, maxLoad } = config;
  
  let candidates = reviewers
    .filter(r => !exclude.includes(r.name))
    .filter(r => r.load < maxLoad);
  
  if (strategy === 'expertise-first') {
    return matchByExpertise(changes, candidates);
  } else if (strategy === 'round-robin') {
    return selectRoundRobin(candidates, reviewers);
  } else {
    // Hybrid: try expertise, fallback to round-robin
    const expertMatch = matchByExpertise(changes, candidates);
    return expertMatch || selectRoundRobin(candidates, reviewers);
  }
}

This lets you configure different strategies for different situations.

Best Practices for Implementation

When deploying your auto-assign system, keep these recommendations in mind:

  1. Start with a dry-run mode: Test your logic before actually assigning reviewers
  2. Add exclusion windows: Allow reviewers to mark themselves unavailable
  3. Monitor and adjust: Track assignment patterns and tweak weights as needed
  4. Provide feedback loops: Let developers report misassigned reviews
  5. Handle code owner requirements: Respect CODEOWNERS file for critical paths

Wrapping Up

Automating reviewer assignment with Claude Code transforms a tedious manual task into a consistent, efficient process. Start simple with basic load balancing, then add sophistication as your team learns the patterns.

The key is maintaining the right balance: enough automation to save time, enough flexibility to handle edge cases. Your Claude Code skill can evolve with your team’s needs, making reviewer assignment one less thing to worry about in your daily workflow.

Built by theluckystrike — More at zovo.one