Home/Help/Custom rules

Documentation

Using .prclarityrc

Add deterministic repository rules that run during PR analysis. PR Clarity loads this JSON from the PR head commit and merges findings into the posted comment.

How it works

1

PR Clarity fetches changed files and patch text.

2

It loads .prclarityrc from the same PR head SHA.

3

Rules are validated with a strict JSON schema.

4

Matching findings are appended in a fixed section of the PR comment.

Example config

Commit a .prclarityrc file at the repository root (JSON).

`.prclarityrc`
{
  "version": 1,
  "rules": [
    {
      "id": "no-direct-db-outside-repos",
      "enabled": true,
      "severity": "high",
      "type": "patchContent",
      "includePaths": ["**/*.ts", "**/*.tsx"],
      "excludePaths": ["**/lib/repository/**", "**/drizzle/**"],
      "match": {
        "pattern": "\\b(db|prisma)\\.",
        "flags": "i"
      },
      "message": "Possible direct DB access outside repository layer."
    },
    {
      "id": "guard-large-prs",
      "enabled": true,
      "severity": "medium",
      "type": "patchStats",
      "threshold": {
        "maxFilesChanged": 40,
        "maxAdditions": 1200,
        "maxDeletions": 800
      },
      "message": "Large PR; consider splitting for review quality."
    },
    {
      "id": "critical-config-changes",
      "enabled": true,
      "severity": "medium",
      "type": "pathMatch",
      "includePaths": [".github/workflows/**", "vercel.json", "drizzle/**"],
      "message": "Infrastructure/config file changed; verify deployment impact."
    }
  ]
}

Schema limits

These limits match the server parser in PR Clarity. The config file path is .prclarityrc at the repo root.

  • File size: at most 65,536 bytes
  • Rules: at most 100 per file
  • Per rule: id up to 80 characters, message up to 240 characters, optional description up to 400 characters
  • Path patterns: 40 per list; each pattern up to 200 characters
  • Regex: pattern up to 300 characters; optional flags are limited to d, g, i, etc. (valid JavaScript RegExp flag letters only)

Supported rule types

pathMatch

Triggers when changed filenames match include path globs.

patchContent

Runs regex over patch text for matching files and returns evidence snippets.

patchStats

Compares PR totals against max thresholds for files, additions, or deletions.

PR comment examples

Custom rule output is appended under Custom Rule Findings when rules match. See Anatomy of a PR comment for the full format.

## Understanding Summary

### Goal

Refactors order fulfillment flow and introduces retry logic for failed shipments.

## Conceptual Changes

- Adds a new shipment retry worker and queue consumer.
- Updates order service to enqueue retry jobs on transient carrier errors.
- Introduces additional telemetry around fulfillment latency.

## System Impact

Increases asynchronous job volume for fulfillment events and changes failure handling
from hard-fail to delayed retry.

Invalid config behavior

If .prclarityrc is missing, invalid JSON, too large, or fails schema validation, PR Clarity still posts the normal summary and adds a short configuration warning in the comment.

Ready on your repo?

Install the GitHub App and get summaries on every PR.

Install on GitHub