This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Auto Assign Action is a GitHub Action that automatically adds reviewers and/or assignees to pull requests when they are opened. The action reads a YAML configuration file (default: .github/auto_assign.yml) and assigns users based on single or grouped reviewer lists, with support for filtering by labels, draft status, and skip keywords.
npm run build # Compile TypeScript to lib/ directory
npm test # Run all Jest tests
npm run format # Format all TypeScript files with Prettier
npm run format-check # Check formatting without modifying files
npm run package # Bundle with ncc into dist/index.js for distributionnpm test -- __tests__/utils.test.ts # Run specific test file
npm test -- -t "test name pattern" # Run tests matching pattern- main.ts - Entry point that calls
run() - run.ts - Orchestrates the action:
- Fetches inputs (
repo-token,configuration-path) - Creates GitHub Octokit client
- Loads config from repository using
utils.fetchConfigurationFile() - Delegates to
handler.handlePullRequest()
- Fetches inputs (
handler.ts - Main business logic
handlePullRequest(): Validates PR against filters (skip keywords, draft status, labels), then adds reviewers and assigneesConfiginterface: Defines all configuration options from YAML file- Filters execute in order: skip keywords → draft check → label filters → assignment
utils.ts - Selection logic
chooseReviewers()/chooseAssignees(): Select users from single list or groupschooseUsers(): Filters out PR creator, returns all users ifnumberOfReviewers: 0, otherwise randomly sampleschooseUsersFromGroups(): Iterates groups and selects users from eachfetchConfigurationFile(): Retrieves and parses YAML config from repository via GitHub API
pull_request.ts - GitHub API wrapper
PullRequestclass encapsulates context and clientaddReviewers(): Callspulls.requestReviewersAPIaddAssignees(): Callsissues.addAssigneesAPI (PRs are issues)hasAnyLabel(): Checks if PR has any of the specified labels
The action expects a YAML configuration file (default .github/auto_assign.yml) with these key options:
addReviewers/addAssignees: Enable reviewer/assignee assignmentreviewers/assignees: Single list modeuseReviewGroups/useAssigneeGroups: Enable grouped modereviewGroups/assigneeGroups: Multiple lists keyed by group namenumberOfReviewers/numberOfAssignees: How many to assign (0 = all)skipKeywords: Skip assignment if PR title contains thesefilterLabels.include/filterLabels.exclude: Label-based filteringrunOnDraft: Whether to run on draft PRs (default: false)- Special:
addAssignees: "author"assigns PR creator as assignee
- PR Creator Exclusion: The PR author is always filtered out from reviewers/assignees (unless
addAssignees: "author") - Random Sampling: When
numberOfReviewers> 0, useslodash.sampleSize()for random selection - Group Mode: When using groups, the specified number is selected from EACH group, not total
- Error Handling: Reviewer/assignee addition failures are logged as warnings, not failures
- Configuration Validation: Throws errors if group flags are enabled but group lists are missing
The action uses @vercel/ncc to bundle everything into dist/index.js. After making changes:
- Run
npm run buildto compile TypeScript - Run
npm run packageto create the bundled distribution - Commit both
lib/anddist/directories
The action runs on Node 20 (specified in action.yml).
Tests use Jest with ts-jest transformer. Test files mirror source structure:
__tests__/utils.test.ts- Tests selection logic and utility functions__tests__/handler.test.ts- Tests main handler logic and filtering__tests__/run.test.ts- Tests action entry point
Mock @actions/github for testing without real API calls.