Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

I got tired of repeating myself on pull requests, so I built a tiny rule-based gatekeeper

Every maintainer knows the loop. A new pull request comes in, and you type the same comments again: please link the issue, please add tests with that source change, please keep the diff small enough to review. Recently

Every maintainer knows the loop. A new pull request comes in, and you type the same comments again: please link the issue, please add tests with that source change, please keep the diff small enough to review.

Recently a fourth line joined the list: was this written by AI?

I don't like that question as a vibe check. AI-detection tools flag real newcomers and miss fluent generated code, and accusing a first-time contributor of being a bot is a good way to never see them again. But I do think contributors should say whether they used AI, the same way they say what they changed. So instead of detecting, I made disclosure one of the house rules - and then automated the reminding.

contrib-gate

contrib-gate is a GitHub Action (also a CLI) that checks each pull request against your repo's contribution rules and posts one polite checklist comment. It is deliberately boring technology: regular expressions and glob matching, one JavaScript file, zero dependencies, no LLM calls, no paid services.

It checks four things:

  1. Linked issue. The PR links an issue with a closing reference (Fixes #123). Optionally, the linked issue must carry a maintainer's label like accepted, so drive-by PRs for unwanted features get caught early.
  2. Tests. If source files changed, at least one test file changed too. Docs-only and config-only PRs pass automatically.
  3. AI-use disclosure. The PR description declares it, e.g. AI assistance: yes or AI assistance: no. A PR template makes this a two-second habit.
  4. Scope. The PR changes at most N files (default 50), and optionally every changed file must match an allowed path.

When something fails, the comment says exactly how to fix it, one line per check. When the contributor pushes again or edits the description, the same comment updates in place instead of stacking new ones.

Why rules instead of an LLM reviewer

AI code review tools are everywhere now, and some are genuinely useful. For this job I wanted determinism:

  • A rule gives the same answer every time, so contributors can predict it.
  • There's nothing to prompt-inject. The check reads PR metadata, not prose it acts on.
  • It costs nothing to run and nothing to trust: you can read the whole thing in one sitting.

The flip side is honesty about scope: contrib-gate checks the contribution, not the code. It will not tell you whether the diff is good. It makes sure the PR is reviewable - linked, tested, disclosed, and small - before a human spends time on it.

Adopting it takes one workflow file

name: contrib-gate
on:
  pull_request:
    types: [opened, synchronize, reopened, edited]

permissions:
  pull-requests: read
  issues: write

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: Havertz2/contrib-gate@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Every rule is configurable from the workflow file, and fail-on-violations: true turns it into a required status check if you want teeth. There's also a CLI mode (node index.js --owner my-org --repo my-repo --pr 123) for testing your rules locally before enforcing them.

What's next

The repo has a handful of good first issue tickets if you want to contribute - docs translations, a --version flag, step outputs, test coverage for the glob matcher. Feedback and issues are welcome.

Full disclosure, matching the tool's own rule: I built contrib-gate with heavy help from an AI assistant. The rules, the tests, and this post's opinions are mine; a lot of the typing was not.

Repo: https://github.com/Havertz2/contrib-gate

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.