Statly Code
AI Code Review

AI Code Review

Statly Code includes AI-powered code review that automatically reviews pull requests using your own AI API keys. Support for Claude (Anthropic), GPT-4 (OpenAI), and Gemini (Google).

AI Code Review uses your own API keys (BYOK - Bring Your Own Key). Statly never pays for your AI usage.

Overview

AI Code Review provides:

  • Automatic PR review on creation and updates
  • Security vulnerability detection
  • Performance issue identification
  • Best practice recommendations
  • One-click fix suggestions
  • Auto-merge when AI approves + CI passes

Setting Up

Configure API Key

  1. Go to Repository Settings β†’ AI Review
  2. Select your AI provider
  3. Enter your API key
  4. Click Test Connection

Choose Model

ProviderRecommended ModelSpeedQuality
AnthropicClaude Sonnet 4MediumHigh
AnthropicClaude 3.5 HaikuFastGood
OpenAIGPT-4oMediumHigh
OpenAIGPT-4o MiniFastGood
GoogleGemini 1.5 ProMediumHigh
GoogleGemini 1.5 FlashFastGood

Enable Auto-Review

Toggle Auto-review PRs to automatically review new PRs.

Configuration Options

SettingDescriptionDefault
enabledEnable AI reviewfalse
autoReviewPRsAutomatically review new PRstrue
reviewDraftsReview draft PRsfalse
autonomyLevelsuggest, apply, or mergesuggest
requireHumanApprovalRequire human approval before auto-mergetrue
focusAreasAreas to focus on["security", "performance", "best_practices"]

Focus Areas

Configure which issues the AI prioritizes:

Focus AreaDescription
securitySQL injection, XSS, auth issues, secrets
performanceN+1 queries, memory leaks, slow algorithms
best_practicesCode style, naming, patterns
error_handlingMissing try/catch, unhandled promises
testingMissing tests, test quality
documentationMissing docs, outdated comments

Review Results

Overall Sentiment

SentimentDescriptionAction
positiveCode looks goodCan merge
neutralMinor suggestionsCan merge
needs_workSignificant issuesShould fix

Suggestion Categories

CategoryIconDescription
SecurityπŸ”΄Critical security vulnerabilities
Performance🟑Performance issues
Best PracticeπŸ”΅Style and pattern suggestions
BugπŸ”΄Potential bugs
Refactor🟒Code quality improvements

Suggestion Severity

SeverityDescriptionBlocks Merge
criticalMust fix before mergingYes (if required)
warningShould consider fixingNo
infoNice to haveNo

Applying Suggestions

One-Click Apply

For suggestions with code fixes:

  1. Review the suggested change
  2. Click Apply to create a commit
  3. The fix is committed to the PR branch

Dismissing Suggestions

If a suggestion isn't relevant:

  1. Click Dismiss
  2. Optionally add a reason
  3. The suggestion is marked as dismissed

Autonomy Levels

Suggest (Default)

AI posts review comments but takes no action:

[AI reviews PR]
     ↓
[Posts comments with suggestions]
     ↓
[Human reviews and applies/dismisses]
     ↓
[Human merges]

Apply

AI can automatically apply its own suggestions:

[AI reviews PR]
     ↓
[Posts comments with suggestions]
     ↓
[AI applies safe suggestions automatically]
     ↓
[Human reviews and merges]

Merge

AI can merge PRs when all checks pass:

[AI reviews PR]
     ↓
[Posts comments / applies suggestions]
     ↓
[CI passes] + [AI approves] + [Human approval (if required)]
     ↓
[AI auto-merges]
⚠️

Auto-merge with autonomyLevel: merge requires careful configuration. Ensure human approval is required for production deployments.

Auto-Merge Flow

When auto-merge is enabled (autonomyLevel: merge):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PR Created     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Review      │──→ needs_work? ──→ Stop
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓ (positive/neutral)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CI Runs        │──→ failed? ──→ Stop
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓ (success)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Human Approval │──→ not approved? ──→ Stop
β”‚  (if required)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ↓ (approved)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AUTO-MERGE     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

API Key Security

API keys are encrypted using:

  1. AES-256 encryption at rest
  2. Organization-specific key derivation
  3. Master secret from environment

Keys are never:

  • Logged
  • Exposed in responses
  • Shared with other orgs

Observe Integration

AI Review integrates with Statly Observe for automatic bug fixes:

  1. Error captured in production
  2. Stack trace linked to code via git blame
  3. AI generates fix PR
  4. CI runs tests
  5. Auto-merge if tests pass (configurable)

Enable in Repository Settings β†’ AI Review β†’ Auto-fix from Observe.

API Reference

Get AI Settings

GET /api/v1/code/repos/{org}/{repo}/ai/settings
 
# Response
{
  "enabled": true,
  "modelProvider": "anthropic",
  "modelName": "claude-sonnet-4-20250514",
  "hasApiKey": true,
  "autoReviewPRs": true,
  "autonomyLevel": "suggest",
  "focusAreas": ["security", "performance"]
}

Update AI Settings

PATCH /api/v1/code/repos/{org}/{repo}/ai/settings
Content-Type: application/json
 
{
  "enabled": true,
  "modelProvider": "anthropic",
  "modelName": "claude-sonnet-4-20250514",
  "apiKey": "sk-ant-xxx",
  "autonomyLevel": "suggest"
}

Trigger AI Review

POST /api/v1/code/repos/{org}/{repo}/pulls/{number}/ai-review

Get Review Status

GET /api/v1/code/repos/{org}/{repo}/pulls/{number}/ai-review
 
# Response
{
  "status": "completed",
  "summary": "This PR looks good overall...",
  "overallSentiment": "positive",
  "suggestionsCount": 3,
  "securityIssues": 0,
  "performanceIssues": 1
}

Apply Suggestion

POST /api/v1/code/repos/{org}/{repo}/ai/suggestions/{id}/apply

Dismiss Suggestion

POST /api/v1/code/repos/{org}/{repo}/ai/suggestions/{id}/dismiss
Content-Type: application/json
 
{
  "reason": "Not applicable to this use case"
}

Costs

AI review costs depend on your provider and model:

ProviderModel~Cost per PR Review
AnthropicClaude Sonnet 4$0.03 - $0.10
AnthropicClaude 3.5 Haiku$0.01 - $0.03
OpenAIGPT-4o$0.05 - $0.15
OpenAIGPT-4o Mini$0.01 - $0.05
GoogleGemini 1.5 Pro$0.02 - $0.08
GoogleGemini 1.5 Flash$0.01 - $0.03

Costs vary based on PR size. Large PRs with many files may cost more.