Skip to content
Proyek

Tentang

GitHub Action yang mendeteksi dan menutup secara otomatis pull request berkualitas rendah dan PR berisi AI slop.

AI dan pembelajaran mesin

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
+20
dalam 15 hari
+33
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Anti Slop

A GitHub Action that detects and automatically closes low-quality and AI slop PRs. It ships with 33 check rules covering PR branches, size, title, description, template, commit messages, file changes, user signals and contributor history.

Everything is configurable through 56 options, the checks, exemptions and failure actions, with sensible defaults you do not have to touch.

[!IMPORTANT] Anti Slop is currently v0 and subject to breaking changes prior to v1.0.0. Pin to a specific version or commit SHA if you need stability.

[!CAUTION] From December 2, 2026 GitHub blocks pull_request_target in public repositories, so Anti Slop stops checking PRs until you explicitly allow the event. Allow it with an Actions policy, see step 2 of the Quick Start.

Why Anti Slop?

Open-source maintainers are drowning in low-quality and AI-generated slop PRs. These PRs undermine real contributions and waste reviewers time. Anti Slop stops these PRs before they reach your review queue.

  • Fast: The entire action runs in under 15 seconds which means slop PRs are caught and closed before you even notice them.
  • Keep open source open: The beauty of open source is that anyone can contribute. Anti Slop blocks low-quality and AI-generated PRs without forcing you to restrict contributions to Members only - new contributors are not penalized just for being new.
  • Language agnostic: All checks are fully language agnostic and work with any programming language out of the box.
  • Battle-tested rules: All 33 checks are derived from patterns identified across 130+ manually reviewed AI slop PRs submitted to different large open-source projects.
  • Thoughtful defaults: Defaults are created and adjusted based on hands-on experience maintaining Coolify (50K+ stars, 120+ slop PRs per month).
  • Anti-slop, not anti-AI: Genuinely good AI-assisted contributions are not penalized.
  • Configurable sensitivity: The max-failures threshold controls how many checks must fail before any actions are taken. The higher the number, the less likely a legitimate contributor is flagged.
  • Zero-configuration exemptions: Owners, Members and Collaborators of a public repository are automatically exempt by default with zero configuration needed.
  • No inline scripts: No ugly, unmaintainable and unreadable inline GitHub Action scripts. Just clean, well-named configuration options that are easy to understand and maintain.
  • Immutable releases: Pin to a specific version (e.g. v0.4.0) and it is guaranteed immutable by GitHub - no convoluted SHA pinning needed but the same security benefits as if you pinned to a specific SHA.

Quick Start

  1. Add the workflow .github/workflows/pr-quality.yaml:

    name: PR Quality
    
    on:
      # The action reads the PR through the API and never checks out or runs its code
      pull_request_target:
        types: [opened, reopened]
    
    permissions: {}
    
    cache-mode: none
    
    concurrency:
      group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
      cancel-in-progress: true
    
    jobs:
      anti-slop:
        name: Anti Slop
        permissions:
          contents: read # read the PR template and the commits of the PR
          issues: read # read the reactions on the PR
          pull-requests: write # label, comment on, close and lock the PR
        runs-on: ubuntu-26.04
        timeout-minutes: 5
        steps:
          - uses: peakoss/[email protected]
    
  2. Allow pull_request_target for the workflow under Settings → Actions → Policies of the repository or the organization:

    1. Create a policy named Anti Slop with the enforcement status Active
    2. Target only this action's workflow with the target pattern .github/workflows/pr-quality.yaml (make sure to match the name and extension of your file, .yml or .yaml)
    3. Enable Restrict events and check pull_request_target in the list

See why pull_request_target is safe for this workflow.

Full Example

The workflow of the Quick Start with every input set to its default:

Full Example Workflow
name: PR Quality

on:
  # The action reads the PR through the API and never checks out or runs its code
  pull_request_target:
    types: [opened, reopened]

permissions: {}

cache-mode: none

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  anti-slop:
    name: Anti Slop
    permissions:
      contents: read # read the PR template and the commits of the PR
      issues: read # read the reactions on the PR
      pull-requests: write # label, comment on, close and lock the PR
    runs-on: ubuntu-26.04
    timeout-minutes: 5
    steps:
      - uses: peakoss/[email protected]
        with:
          # Repo Auth Token
          github-token: ${{ github.token }}

          # General Settings
          max-failures: 4

          # PR Branch Checks
          allowed-target-branches: ""
          blocked-target-branches: ""
          allowed-source-branches: ""
          blocked-source-branches: |
            main
            master

          # PR Size Checks
          max-changed-files: 50
          max-changed-lines: 10000

          # PR Quality Checks
          max-negative-reactions: 0
          require-maintainer-can-modify: true

          # PR Title Checks
          require-conventional-title: false

          # PR Description Checks
          require-description: true
          max-description-length: 2500
          max-emoji-count: 2
          max-code-references: 5
          require-linked-issue: false
          blocked-terms: ""
          blocked-issue-numbers: ""

          # PR Template Checks
          require-pr-template: false
          strict-pr-template-sections: ""
          optional-pr-template-sections: ""
          max-additional-pr-template-sections: 0

          # Commit Message Checks
          max-commit-message-length: 500
          require-conventional-commits: false
          require-commit-author-match: true
          blocked-commit-authors: ""

          # File Checks
          allowed-file-extensions: ""
          allowed-paths: ""
          blocked-paths: |
            README.md
            SECURITY.md
            LICENSE
            CODE_OF_CONDUCT.md
          require-final-newline: true
          max-added-comments: 10

          # User Checks
          detect-spam-usernames: true
          min-account-age: 30
          max-daily-forks: 6
          min-profile-completeness: 4

          # Merge Checks
          min-repo-merged-prs: 0
          min-repo-merge-ratio: 0
          min-global-merge-ratio: 30
          global-merge-ratio-exclude-own: false

          # Exemptions
          exempt-draft-prs: false
          exempt-bots: |
            actions-user
            autofix-ci[bot]
            dependabot[bot]
            renovate[bot]
            github-actions[bot]
          exempt-users: ""
          exempt-author-association: "OWNER,MEMBER,COLLABORATOR"
          exempt-label: "exempt"
          exempt-pr-label: ""
          exempt-all-milestones: false
          exempt-all-pr-milestones: false
          exempt-milestones: ""
          exempt-pr-milestones: ""

          # PR Success Actions
          success-add-pr-labels: ""

          # PR Failure Actions
          failure-remove-pr-labels: ""
          failure-remove-all-pr-labels: false
          failure-add-pr-labels: ""
          failure-pr-message: ""
          close-pr: true
          lock-pr: false

All Options

Each input links to its details in docs/rules.md. The only required input is github-token, which defaults to the GITHUB_TOKEN of the run.

Inputs

Input Description Default
github-token GitHub token used to authenticate API requests. ${{ github.token }}
max-failures Number of check failures needed before failure actions are triggered. 4
allowed-target-branches Newline-separated target branch patterns to allow. Empty allows all branches. ""
blocked-target-branches Newline-separated target branch patterns to block. ""
allowed-source-branches Newline-separated source branch patterns to allow. Empty allows all branches. ""
blocked-source-branches Newline-separated source branch patterns to block. main, master
max-changed-files Maximum number of changed files allowed in the PR. 0 disables this check. 50
max-changed-lines Maximum number of changed lines (additions + deletions) allowed in the PR. 0 disables this check. 10000
max-negative-reactions Maximum number of negative reactions (thumbs down + confused) allowed on the PR. 0 disables this check. 0
require-maintainer-can-modify Require the PR to allow maintainers to push to the source branch. true
require-conventional-title Require PR titles to follow Conventional Commits format (e.g. 'feat:', 'fix:', 'feat(scope):'). false
require-description Require a non-empty PR description. true
max-description-length Maximum character length for the PR description. 0 disables this check. 2500
max-emoji-count Maximum number of emojis allowed in the PR title and description. 0 disables this check. 2
max-code-references Maximum number of code references (file paths, function/method calls) allowed in the PR description. 0 disables this check. 5
require-linked-issue Require the PR to reference at least one issue in the PR description. false
blocked-terms Newline-separated list of terms blocked from appearing in the PR description. ""
blocked-issue-numbers Comma-separated list of issue numbers blocked from being referenced in the PR description. ""
require-pr-template Require the PR description to follow the repository PR template structure. false
strict-pr-template-sections Comma-separated PR template section headings (without '#') classified as strict. All checkboxes must be present and checked. Only applies when require-pr-template is enabled. ""
optional-pr-template-sections Comma-separated PR template section headings (without '#') classified as optional. Can be removed from the description without failing the check. Only applies when require-pr-template is enabled. ""
max-additional-pr-template-sections Maximum number of additional sections not in the template that are allowed in the PR description. 0 disables this check. 0
max-commit-message-length Maximum character length for individual commit messages. 0 disables this check. 500
require-conventional-commits Require all commit messages to follow Conventional Commits format (e.g. 'feat:', 'fix:', 'feat(scope):'). false
require-commit-author-match Require every commit in the PR to be authored by the same GitHub user who opened the PR. true
blocked-commit-authors Comma-separated list of blocked commit author usernames. ""
allowed-file-extensions Comma-separated list of allowed file extensions (e.g. '.ts,.js') for changed files. Empty allows all. ""
allowed-paths Newline-separated file or folder paths to allow for changed files. Entries ending with '/' match folders. Empty allows all. ""
blocked-paths Newline-separated file or folder paths to block for changed files. Entries ending with '/' match folders. README.md, SECURITY.md, LICENSE, CODE_OF_CONDUCT.md
require-final-newline Require all changed files to end with a newline character. true
max-added-comments Maximum number of added comments in all changed files. 0 disables this check. 10
detect-spam-usernames Detect usernames that match common spam patterns. true
min-account-age Minimum GitHub account age in days. 0 disables this check. 30
max-daily-forks Maximum number of repositories forked by the user in any 24-hour window. 0 disables this check. 6
min-profile-completeness Minimum number of profile signals (name, email, bio, etc.) the user must have to pass. 0 disables this check. 4
min-repo-merged-prs Minimum number of merged PRs in this repository from the author. 0 disables this check. 0
min-repo-merge-ratio Minimum merge/close PR ratio percentage in this repository. 0 disables this check. 0
min-global-merge-ratio Minimum merge/close PR ratio percentage across all repositories. 0 disables this check. 30
global-merge-ratio-exclude-own Exclude PRs to the author's own repositories from the global merge ratio calculation. false
exempt-draft-prs Exempt draft PRs from all checks. false
exempt-bots Newline-separated list of bot usernames exempt from all checks. actions-user, autofix-ci[bot], dependabot[bot], renovate[bot], github-actions[bot]
exempt-users Comma-separated list of GitHub usernames exempt from all checks. ""
exempt-author-association Comma-separated list of GitHub author associations exempt from all checks in a public repository. OWNER,MEMBER,COLLABORATOR
exempt-label Label name that exempts PRs and Issues from all checks when it is present. exempt
exempt-pr-label Label name that exempts PRs from all checks when it is present. ""
exempt-all-milestones Exempt all PRs and Issues that are assigned to any milestone. false
exempt-all-pr-milestones Exempt all PRs that are assigned to any milestone. false
exempt-milestones Comma-separated list of milestone titles. PRs and Issues assigned to any listed milestone are exempt. ""
exempt-pr-milestones Comma-separated list of milestone titles. PRs assigned to any listed milestone are exempt. ""
success-add-pr-labels Comma-separated list of labels to add to the PR on success. ""
failure-remove-pr-labels Comma-separated list of labels to remove from the PR on failure. ""
failure-remove-all-pr-labels Remove all labels from the PR on failure. false
failure-add-pr-labels Comma-separated list of labels to add to the PR on failure. ""
failure-pr-message Comment posted on the PR when the maximum number of failures is reached. Empty posts no comment. ""
close-pr Close the PR when the maximum number of failures is reached. true
lock-pr Lock the PR conversation after closing. false

Outputs

Output Description
total-checks Total number of checks that were run.
failed-checks Number of checks that failed.
passed-checks Number of checks that passed.
result Overall result: passed, failed or skipped.

Why pull_request_target is safe

pull_request_target runs the workflow with the token of the base repository, which is safe for this workflow:

  • GitHub runs the workflow and its inputs from the default branch, and a PR cannot change them
  • The action never checks out, builds or runs the code of a PR, it reads the PR through the API
  • The PR reaches the action only as text, which it compares with your rules and never passes to a shell or an expression, so a PR cannot inject code
  • The token gets only the job permissions, it can read the repository and edit PRs, such as label, comment on, close and lock them, but it cannot push code or merge, as that would need contents: write, which you should not grant to this workflow

Using pull_request instead

The workflow can also run on pull_request, but this is not recommended:

  • GitHub holds the run of a first-time contributor, or of every outside contributor if the repository requires it, until a maintainer approves it
  • A PR from a fork gets a read-only token, so Anti Slop only reports the checks in the job summary and cannot label, comment on or close the PR
    • Set close-pr: false, otherwise the run warns that it could not close the PR
  • GitHub runs the workflow of the PR itself, so a PR can change its pr-quality.yaml to skip the checks

Debugging

Set the secret ACTIONS_STEP_DEBUG to true in the repository to see the debug logs of the action.

Star History

Jelajahi proyek terkait

Memuat…