Skip to content

Ebuodinde/PR_SENTRY

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ PR-Sentry

License: MIT Tests Python 3.11+ GitHub Release

Zero-Nitpick AI code review for open source maintainers.

PR-Sentry protects your repository from AI-generated slop and security vulnerabilities β€” without spamming your PR timeline with linter-style noise.

Key Features:

  • πŸ€– AI Slop Detection β€” Filters AI-generated noise before expensive LLM calls
  • πŸ”„ Multi-Provider Support β€” Claude, GPT-4, DeepSeek β€” use any LLM you prefer
  • πŸ’° Smart Multi-LLM Routing β€” 60% cost reduction with intelligent model cascading
  • πŸ”’ Advanced Security Scanning β€” 50+ vulnerability patterns, entropy analysis, cloud credentials
  • 🚫 Zero-Nitpick β€” Only reports crashes, security issues, race conditionsβ€”no style complaints
  • ⚑ Lightweight β€” No external database, no servers, works out-of-the-box

The Problem

AI coding tools have created an asymmetry: code is generated in seconds, but reviewing it still takes human time and attention. Open source maintainers are drowning in:

  • AI Slop β€” syntactically correct but contextually meaningless PRs
  • False positives β€” review bots that flag whitespace and variable names instead of real bugs
  • Review fatigue β€” spending more time dismissing bot noise than catching actual issues

curl's author shut down their bug bounty program because 20% of reports were AI-generated garbage. Godot, Blender, and VLC maintainers report thousands of AI PRs flooding their queues.

PR-Sentry is the defense layer that was missing.


How It Works

PR opened
  β†’ AI Slop Detection (statistical analysis, no API call)
      β†’ High slop score? Flag immediately, skip LLM.
      β†’ Clean? Continue.
  β†’ Smart Model Selection (complexity + security analysis)
      β†’ Simple PR? Use fast model
      β†’ Security patterns detected? Use premium model
      β†’ Complex PR? Use premium model
  β†’ Diff parsed + security pattern scan (regex + entropy analysis)
  β†’ LLM review (security issues, crashes, race conditions only)
  β†’ PR summary generated (file stats, additions/deletions)
  β†’ Single comment posted to PR

Estimated Cost: ~$0.01-0.05 per average PR (varies by size and complexity)

Zero-Nitpick philosophy: PR-Sentry never comments on style, formatting, or anything a linter can catch. Only runtime crashes, security vulnerabilities, race conditions, and memory leaks.

Smart Routing:

  • Default: Works with just Anthropic key (smart model cascading)
  • Optional: Add DeepSeek key for additional cost savings on simple PRs
  • Security-critical code always uses premium models

Security scanning:

  • 50+ credential patterns (AWS, Azure, GCP, GitHub, OpenAI, Anthropic, databases)
  • Shannon entropy-based secret detection (catches high-entropy strings)
  • SQL injection, command injection, XSS detection
  • Memory safety analysis (C/C++/Rust)

Quick Start

Option 1: Anthropic (Claude) β€” Recommended

name: PR-Sentry Review

on:
  pull_request:
    types: [opened, synchronize]

permissions:
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - name: Run PR-Sentry
        uses: Ebuodinde/PR_SENTRY@v3
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Option 2: OpenAI (GPT-4)

      - name: Run PR-Sentry
        uses: Ebuodinde/PR_SENTRY@v3
        with:
          openai_api_key: ${{ secrets.OPENAI_API_KEY }}

Option 3: DeepSeek (Budget-Friendly)

      - name: Run PR-Sentry
        uses: Ebuodinde/PR_SENTRY@v3
        with:
          deepseek_api_key: ${{ secrets.DEEPSEEK_API_KEY }}

Option 4: Explicit Provider Selection

      - name: Run PR-Sentry
        uses: Ebuodinde/PR_SENTRY@v3
        with:
          provider: "openai"
          api_key: ${{ secrets.OPENAI_API_KEY }}
          model: "gpt-4o"  # optional model override

Get API keys:

Cost-Optimized Setup (Multi-Provider)

Use multiple providers for intelligent cost routing:

      - name: Run PR-Sentry
        uses: Ebuodinde/PR_SENTRY@v3
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          deepseek_api_key: ${{ secrets.DEEPSEEK_API_KEY }}

Routing Logic:

  • AI slop β†’ Skip LLM entirely (free)
  • Simple PR + DeepSeek key β†’ Use DeepSeek (cheapest)
  • Security patterns β†’ Use premium Claude model
  • Complex PR β†’ Use premium Claude model

πŸ€– Using with AI Assistants

PR-Sentry works seamlessly with AI coding assistants. Just share this repository and ask them to set it up!

Claude Code / Cursor / Windsurf / GitHub Copilot

Simply tell your AI assistant:

"Add PR-Sentry to my repository for automated code review. Use this repo: https://github.com/Ebuodinde/PR_SENTRY"

Or be more specific:

"Set up PR-Sentry workflow in my repo. I have an OpenAI API key stored as OPENAI_API_KEY in my GitHub secrets."

The AI assistant will:

  1. Create .github/workflows/pr-sentry.yml
  2. Configure the correct provider based on your available API keys
  3. Set up proper permissions

Copy-Paste Prompt

Add PR-Sentry (https://github.com/Ebuodinde/PR_SENTRY) to this repository:

1. Create .github/workflows/pr-sentry.yml
2. Use [ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY] from secrets
3. Trigger on pull_request opened and synchronize events
4. Grant pull-requests: write permission

MCP Server (Model Context Protocol)

PR-Sentry is available as an MCP server for direct integration with Claude Code, Cursor, and other MCP-compatible tools.

Setup in Claude Code:

Add to your ~/.config/claude/claude_desktop_config.json:

{
  "mcpServers": {
    "pr-sentry": {
      "command": "python",
      "args": ["/path/to/pr-sentry/mcp_server.py"]
    }
  }
}

Available Tools:

  • review_diff β€” Review code diff for security issues and bugs
  • check_slop β€” Detect AI-generated content (slop score)
  • scan_security β€” Scan for 50+ security vulnerability patterns

Usage in Claude Code:

> Use pr-sentry to review this diff: [paste diff]
> Check if this PR description is AI-generated slop
> Scan this code for security vulnerabilities

What PR-Sentry Reports

βœ… Always reports:

  • Security issues:
    • Hardcoded secrets, API keys, passwords (35+ patterns)
    • High-entropy strings (potential secrets)
    • SQL injection, command injection, XSS
    • Unsafe cryptography, path traversal
  • Runtime crashes:
    • Null pointer / undefined behavior
    • Race conditions, deadlocks
    • Memory leaks, use-after-free
  • Logic errors:
    • Edge case handling
    • Error handling gaps
    • Unvalidated user input

βœ… Also includes:

  • PR summary (file count, lines changed, file type breakdown)
  • AI-generated content detection (slop score)

❌ Never reports:

  • Code style or formatting
  • Variable naming conventions
  • Import organization
  • Anything ESLint / Prettier / Black / Pylint would catch
  • Subjective architecture opinions

How PR-Sentry Detects AI-Generated Pull Requests

Most tools that claim to detect AI-generated code rely on external APIs like GPTZero or Originality.ai, or on simple regex heuristics β€” both of which are unreliable and easy to bypass.

PR-Sentry takes a different approach: statistical NLP analysis that runs locally, before any LLM call is made. The slop detector computes a composite score from four signals: buzzword density (frequency of filler terms like "robust", "seamless", "leverage"), passive voice ratio, sentence length uniformity, and repetition score. These four dimensions capture the characteristic flatness of AI-generated text β€” high surface density, low semantic signal. A PR scoring above 60/100 is flagged as AI-generated content and skipped entirely, saving the LLM call.

For secret detection, PR-Sentry uses Shannon entropy analysis on every string in the diff. Human-written code rarely produces strings with entropy above 4.5 bits per character. API keys, tokens, and accidentally committed passwords almost always do. This entropy-based approach catches secrets that regex patterns miss β€” including novel key formats that no pattern library has seen yet.

When a PR passes both filters and reaches the LLM review stage, a strict zero-nitpick system prompt enforces one rule: report only runtime crashes, security vulnerabilities, race conditions, and memory leaks.

This is what separates PR-Sentry from tools like CodeRabbit or GitHub Copilot review, which function as verbose linters rather than security reviewers. If you're looking for a CodeRabbit alternative or a GitHub Copilot review alternative that focuses exclusively on what breaks in production β€” PR-Sentry is built for that.


Why Not CodeRabbit or Copilot?

Feature CodeRabbit GitHub Copilot PR-Sentry
AI Slop detection ❌ ❌ βœ…
Zero-Nitpick ❌ ❌ βœ…
Cost optimization ❌ ❌ βœ… (60% savings)
No external database ❌ βœ… βœ…
Free for open source Partial ❌ βœ…
Plug-and-play βœ… βœ… βœ…

CodeRabbit floods PR timelines with verbose comments on whitespace and naming. Copilot lacks security depth. Neither detects AI-generated contributions or optimizes costs.


πŸ’° Cost Optimization

PR-Sentry is designed to minimize API costs while maximizing review quality.

Estimated Costs

PR Size Estimated Cost
Small (< 100 lines) ~$0.005 - $0.01
Medium (100-500 lines) ~$0.01 - $0.03
Large (500+ lines) ~$0.03 - $0.05
AI slop detected $0 (skipped)

Monthly estimate (100 PRs/month): $1-5 depending on PR complexity

Cost Saving Strategies

  1. AI Slop Detection: ~30% of PRs are flagged and skipped, saving 100% on those
  2. Smart Model Routing: Simple PRs use cheaper models automatically
  3. DeepSeek Integration: Optional - add DeepSeek key for additional savings on non-security PRs
  4. Large PR Filtering: PRs with 50+ files are auto-filtered to essential files only

Configuration

Basic Configuration (GitHub Action)

Input Description Default
provider LLM provider (anthropic, openai, deepseek) Auto-detect
api_key API key for selected provider β€”
anthropic_api_key Anthropic API key β€”
openai_api_key OpenAI API key β€”
deepseek_api_key DeepSeek API key β€”
model Model override Provider default
locale Report language (en/tr) en

Supported Models

Provider Models
Anthropic claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001
OpenAI gpt-4o, gpt-4o-mini
DeepSeek deepseek-chat, deepseek-coder

Advanced Configuration (Optional)

Create .github/sentry-config.yml in your repository:

# Custom zero-nitpick rules
custom_rules:
  - "Focus on thread safety in async code"
  - "Flag potential integer overflows"
  - "Check for unvalidated user input"

# Files/paths to ignore during review
ignore_paths:
  - "test/"
  - "docs/"
  - "*.md"

# Patterns to ignore (regex)
ignore_patterns:
  - "^# Auto-generated"
  - "DO NOT EDIT"

# Slop detection threshold (0-100, higher = stricter)
slop_threshold: 70

Multi-Language Support

Set the report language:

- name: Run PR-Sentry
  uses: Ebuodinde/PR_SENTRY@v3
  with:
    anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    locale: "tr"  # en, tr

GitLab CI/CD Support

PR-Sentry also works with GitLab merge requests! Add to your .gitlab-ci.yml:

pr-sentry-review:
  stage: test
  image: python:3.11-slim
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  before_script:
    - pip install git+https://github.com/Ebuodinde/PR_SENTRY.git
  script:
    - python -m pr_sentry.gitlab_runner
  allow_failure: true

Required CI/CD Variables:

  • ANTHROPIC_API_KEY: Your Anthropic API key
  • GITLAB_TOKEN: GitLab personal access token (api scope)

See examples/gitlab-ci.yml for full configuration.

Docker Usage

Run locally with Docker:

docker-compose up

# Or build and run:
docker build -t pr-sentry .
docker run --env-file .env pr-sentry

CLI Tool

Use PR-Sentry from the command line:

# Install
pip install git+https://github.com/Ebuodinde/PR_SENTRY.git

# Review a GitHub PR
export GITHUB_TOKEN=your_token
export ANTHROPIC_API_KEY=your_key
python cli.py review --repo owner/repo --pr 123

# Review a GitLab MR
export GITLAB_TOKEN=your_token
python cli.py review --gitlab --project-id 12345 --pr 67

# Analyze any diff
git diff HEAD~1 | python cli.py analyze

# View usage statistics
python cli.py stats --all-time

Examples

See real-world examples in the examples/ directory:

  • JavaScript - Auth module with security issues
  • Go - Database package with credential leaks
  • Rust - Config module with unsafe blocks

Development

Setup

# Clone and install dependencies
git clone https://github.com/Ebuodinde/PR_SENTRY.git
cd PR_SENTRY
pip install -r requirements.txt
pip install -r requirements-dev.txt

# Run tests
pytest

# Run with coverage
pytest --cov=. --cov-report=html

Project Structure

pr-sentry/
β”œβ”€β”€ main.py              # Entry point, GitHub Actions integration
β”œβ”€β”€ cli.py               # CLI tool for local reviews
β”œβ”€β”€ reviewer.py          # LLM integration with smart routing
β”œβ”€β”€ llm_router.py        # Multi-LLM cascading logic
β”œβ”€β”€ providers/           # Multi-provider LLM support
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ base.py          # BaseProvider interface
β”‚   β”œβ”€β”€ factory.py       # Provider auto-detection
β”‚   β”œβ”€β”€ anthropic_provider.py
β”‚   β”œβ”€β”€ openai_provider.py
β”‚   └── deepseek_provider.py
β”œβ”€β”€ performance.py       # Large PR optimization
β”œβ”€β”€ metrics.py           # Token/cost tracking
β”œβ”€β”€ context_builder.py   # Lightweight RAG context
β”œβ”€β”€ gitlab_client.py     # GitLab CI/CD support
β”œβ”€β”€ slop_detector.py     # AI-generated content detection
β”œβ”€β”€ diff_parser.py       # Diff parsing, security scanning
β”œβ”€β”€ entropy_scanner.py   # Entropy-based secret detection
β”œβ”€β”€ github_commenter.py  # PR comment formatting (i18n)
β”œβ”€β”€ config_loader.py     # YAML config loading
β”œβ”€β”€ locales/             # Translation files (en, tr)
β”œβ”€β”€ tests/               # Pytest test suite
└── examples/            # Usage examples (GitHub, GitLab)

See CONTRIBUTING.md for contribution guidelines.


Privacy

  • Your code never leaves GitHub's infrastructure during diff fetching
  • API calls send only the changed lines (diff), never your full codebase
  • No external databases, no persistent storage
  • All secrets are masked in logs

License

MIT β€” free for open source and commercial use.


Credits

Developed by Şahin Uygutalp. Built with Claude (Anthropic).

About

GitHub Action to detect AI-generated PRs and security vulnerabilities. Statistical slop detection, Shannon entropy analysis, zero-nitpick LLM review.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages