Overview
BharatCode PR Reviewer automates routine pull request feedback. It parses unified diffs, runs local regex checks, sends code chunks to language models for review, and posts structured results back to the pull request.
Inline Review Comments
Maps findings directly to modified lines with GitHub-native code suggestion blocks that maintainers can commit in one click.
Automated Severity Labels
Synchronizes repository labels such as bug, needs-review, and nit based on active findings.
Pre-Flight Regex Engine
Executes pattern checks locally to catch banned debug statements and secrets before sending diffs to the API at zero token cost.
Multi-Provider Failover
Automatically falls back to OpenAI or Anthropic if the primary API returns temporary rate-limit or upstream outage errors.
Single Repository Setup
Enable automated reviews on any repository in two steps.
Add Repository Secret
Navigate to Settings > Secrets and variables > Actions > New repository secret:
- Name:
BHARATCODE_API_KEY - Secret: Your API key from bharatcode.ai
Add Workflow File
Save the following as .github/workflows/bharatcode-review.yml:
name: BharatCode Review
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
checks: write
jobs:
review:
name: Review PR Changes
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Run BharatCode Reviewer
uses: Sreeju7733/bharatcode-review-action@v1
with:
bharatcode-api-key: ${{ secrets.BHARATCODE_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
mode: "summary+inline"
severity-threshold: "warning"
fail-on-severity: "error"
Inline Review Comments & Suggestions
BharatCode inspects the diff changes and uses GitHub's pulls.createReview API to post comments directly on the exact lines in the diff. When a correction is straightforward, it generates GitHub-native code suggestions that maintainers can commit right from the PR review UI.
Local Regex Engine
To save API tokens and enforce immediate code standards, BharatCode executes local regex patterns before making any network calls. If a pattern matches, an error or warning is reported with zero latency and zero token spend.
Quality Gates & Merge Protection
Configure fail-on-severity: "error" to block pull requests from merging if critical security flaws, remote execution sinks (like eval()), or unhandled errors are introduced. The GitHub Actions check run will fail until the code is corrected.
Organization-Wide Rollout
Deploy BharatCode across all repositories in an organization using the automated setup script.
1. Configure Organization Secret
Set the API key at the organization level so repositories inherit it automatically:
gh secret set BHARATCODE_API_KEY --org "Your-Org" --body "your_api_key" --visibility all
2. Run Bulk Rollout Script
Run the provided script to open pull requests across all non-archived repositories:
export GH_TOKEN="ghp_your_github_admin_token"
export BHARATCODE_API_KEY="your_api_key"
./scripts/rollout-action.sh
- Creates branches and pull requests only; never pushes to default branches.
- Skips archived, disabled, and already-configured repositories.
3. Organization Reusable Workflow
Repositories can also reference a central reusable workflow for unified governance:
jobs:
review:
uses: Sreeju7733/bharatcode-review-action/.github/workflows/reusable-review.yml@v1
secrets:
BHARATCODE_API_KEY: ${{ secrets.BHARATCODE_API_KEY }}
Configuration Reference
Action Inputs
| Input | Default | Description |
|---|---|---|
bharatcode-api-key |
Required | API key passed via secrets.BHARATCODE_API_KEY. |
github-token |
Required | GitHub token with pull-requests: write permission. |
model |
glm-5.3-flash |
Model used for review (glm-5.3-flash or deepseek-v4.1-flash). |
mode |
summary+inline |
Format: summary, inline, summary+inline, or gate. |
severity-threshold |
warning |
Minimum severity to report: info, warning, or error. |
fail-on-severity |
none |
Fails status check on severity: none, warning, or error. |
post-labels |
true |
Automatically manages PR labels based on findings. |
cache-enabled |
true |
Caches review results by commit SHA and prompt version. |
max-usd-budget |
0 |
Maximum USD spend cap per PR run (0 = unlimited). |
Repository Configuration (.bharatcode-review.yml)
Place this file in the repository root for custom exclusions and regex rules:
model: glm-5.3-flash
severity-threshold: warning
ignore-globs:
- "docs/**"
- "**/*.lock"
- "**/generated/**"
rules:
- name: no-console-log
pattern: 'console\.(log|debug)'
severity: warning
category: style
message: "Remove debugging console statements before merge."
- name: avoid-hardcoded-keys
pattern: 'AKIA[0-9A-Z]{16}'
severity: error
category: security
message: "Potential AWS access key detected."
Supported Models
| Model | Tier | Context | Best For |
|---|---|---|---|
glm-5.3-flash |
Standard / Free (10M tokens/day) | 256k | Default for general pull requests, quick diff feedback, and style checks. |
deepseek-v4.1-flash |
BharatCode Pro | 1M | Deep reasoning across large, complex multi-file pull requests. |
Multi-Provider Failover
Configure fallback providers to maintain review continuity during upstream outages:
- uses: Sreeju7733/bharatcode-review-action@v1
with:
bharatcode-api-key: ${{ secrets.BHARATCODE_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
fallback-providers: "openai,anthropic"
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}