Customizing GitHub's built‐in Copilot's PR Feature - TerrenceMcGuinness-NOAA/global-workflow GitHub Wiki

GitHub Copilot's PR review feature can be customized in several ways to better fit your team's workflow and requirements.

Repository-Level Settings

  1. Enable/Disable Copilot Reviews

    • Go to your repository's Settings → Code security and analysis
    • Toggle "GitHub Copilot autofix" and review features on/off
  2. Review Triggers

    • Configure when Copilot should automatically review PRs
    • Set up rules based on file types, PR size, or specific paths

Copilot Review Configuration

  1. Review Focus Areas

    • Security: Focus on security vulnerabilities and best practices
    • Performance: Highlight potential performance issues
    • Code Quality: Check for maintainability and readability
    • Best Practices: Enforce language-specific conventions
  2. Custom Review Prompts

    • Create custom instructions for what Copilot should focus on
    • Add repository-specific context or coding standards
    • Include domain-specific requirements

Configuration Methods

1. .github/copilot-instructions.md

Create this file in your repository to provide custom instructions:

# Copilot Review Instructions

## Focus Areas
- Pay special attention to error handling in Python scripts
- Ensure all shell scripts follow shellcheck guidelines
- Verify proper logging practices
- Check for hardcoded paths or credentials

## Ignore Patterns
- Don't review generated files in `/build` directory
- Skip reviewing test fixtures in `/fixtures`

## Specific Guidelines
- For weather/climate code, ensure units are clearly documented
- Validate that all file paths use proper environment variables

2. GitHub Actions Workflow

You can create a workflow to customize Copilot's behavior:

name: Custom Copilot Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  copilot-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Custom Copilot Review
        uses: github/copilot-review-action@v1
        with:
          focus: "security,performance"
          exclude-paths: "*.md,docs/**"
          custom-instructions: |
            Focus on scientific computing best practices.
            Ensure proper error handling for file I/O operations.

3. Pull Request Templates

Modify pull_request_template.md to guide Copilot:

## Copilot Review Guidelines
- [ ] Check for proper error handling
- [ ] Verify environment variable usage
- [ ] Ensure logging is appropriate
- [ ] Review shell script best practices

<!-- @copilot: focus on shell scripting best practices and error handling -->

Advanced Customizations

  1. Team-Specific Rules

    • Set up different review criteria for different teams
    • Configure based on file ownership (CODEOWNERS)
  2. Integration with Other Tools

    • Combine with existing linters and static analysis tools
    • Coordinate with CI/CD pipeline checks
  3. Review Scheduling

    • Configure when reviews should be triggered
    • Set up different rules for draft vs. ready PRs

Best Practices for Your Workflow

Given that you're working with shell scripts and scientific computing workflows:

  1. Create specific instructions for shell script validation (building on your shellcheck work)
  2. Focus on environment handling since your scripts use many environment variables
  3. Emphasize error handling for the complex workflow orchestration
  4. Include domain knowledge about weather/climate computing practices