code-review-router

Intelligently routes code reviews between Gemini CLI and Codex CLI based on tech stack, complexity, and change characteristics. Use when you want an automated code review of your current changes.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-review-router" with this command: npx skills add win4r/agent-skills-code-review-router/win4r-agent-skills-code-review-router-code-review-router

Code Review Router

Routes code reviews to the optimal CLI (Gemini or Codex) based on change characteristics.

When NOT to Use This Skill

  • For non-code reviews (documentation proofreading, prose editing)
  • When reviewing external/third-party code you don't control
  • For commit message generation (use a dedicated commit skill)
  • When you need a specific reviewer (use that CLI directly)

Step 0: Environment Check

Verify we're in a git repository:

git rev-parse --git-dir 2>/dev/null || echo "NOT_A_GIT_REPO"

If not a git repo: Stop and inform the user: "This directory is not a git repository. Initialize with git init or navigate to a repo."

Step 1: Prerequisites Check

Verify both CLIs are available:

# Check for Gemini CLI
which gemini || echo "GEMINI_NOT_FOUND"

# Check for Codex CLI
which codex || echo "CODEX_NOT_FOUND"

If neither CLI is found: Stop and inform the user they need to install at least one:

  • Gemini: Check Google's Gemini CLI installation docs
  • Codex: Check OpenAI's Codex CLI installation docs

If only one CLI is available: Use that CLI (no routing needed).

If both are available: Proceed with routing analysis.

Step 2: Analyze Git Diff

Run these commands to gather diff statistics:

# Get diff stats (staged + unstaged)
git --no-pager diff --stat HEAD 2>/dev/null || git --no-pager diff --stat

# Get full diff for pattern analysis
git --no-pager diff HEAD 2>/dev/null || git --no-pager diff

# Count changed files
git --no-pager diff --name-only HEAD 2>/dev/null | wc -l

# Count total changed lines
git --no-pager diff --numstat HEAD 2>/dev/null | awk '{added+=$1; removed+=$2} END {print added+removed}'

If no changes detected: Report "Nothing to review - no uncommitted changes found." and stop.

Step 3: Calculate Complexity Score

Initialize complexity_score = 0, then add points:

ConditionPointsDetection Method
Files changed > 10+2git diff --name-only | wc -l
Files changed > 20+3(additional, total +5)
Lines changed > 300+2git diff --numstat sum
Lines changed > 500+3(additional, total +5)
Multiple directories touched+1Count unique dirs in changed files
Test files included+1Files matching *test*, *spec*
Config files changed+1Files: *.config.*, *.json, *.yaml, *.yml, *.toml
Database/schema changes+2Files: *migration*, *schema*, *.sql, prisma/*
API route changes+2Files in api/, routes/, containing endpoint, handler
Service layer changes+2Files in services/, *service*, *provider*

Step 4: Detect Language & Framework

Analyze file extensions and content patterns:

Primary Language Detection

.ts, .tsx     → TypeScript
.js, .jsx     → JavaScript
.py           → Python
.go           → Go
.rs           → Rust
.java         → Java
.rb           → Ruby
.php          → PHP
.cs           → C#
.swift        → Swift
.kt           → Kotlin

Framework Detection (check imports/file patterns)

React/Next.js    → "import React", "from 'react'", "next.config", pages/, app/
Vue              → ".vue" files, "import Vue", "from 'vue'"
Angular          → "angular.json", "@angular/core"
Django           → "django", "models.py", "views.py", "urls.py"
FastAPI          → "from fastapi", "FastAPI("
Express          → "express()", "from 'express'"
NestJS           → "@nestjs/", "*.module.ts", "*.controller.ts"
Rails            → "Gemfile" with rails, app/controllers/
Spring           → "springframework", "@RestController"

Security-Sensitive Patterns

Detect by file path OR code content:

File paths:

**/auth/**
**/security/**
**/*authentication*
**/*authorization*
**/middleware/auth*

Code patterns (in diff content):

password\s*=
api_key\s*=
secret\s*=
Bearer\s+
JWT
\.env
credentials
private_key
access_token

Config files:

.env*
*credentials*
*secrets*
*.pem
*.key

Step 5: Apply Routing Decision Tree

Routing Priority Order (evaluate top-to-bottom, first match wins):

Priority 1: Pattern-Based Rules (Hard Rules)

PatternRouteReason
Security-sensitive files/code detectedCodexRequires careful security analysis
Files > 20 OR lines > 500CodexLarge changeset needs thorough review
Database migrations or schema changesCodexArchitectural risk
API/service layer modificationsCodexBackend architectural changes
Changes span 3+ top-level directoriesCodexMulti-service impact
Complex TypeScript (generics, type utilities)CodexType system complexity
Pure frontend only (jsx/tsx/vue/css/html)GeminiSimpler, visual-focused review
Python ecosystem (py, Django, FastAPI)GeminiStrong Python support
Documentation only (md/txt/rst)GeminiSimple text review

Priority 2: Complexity Score (if no pattern matched)

ScoreRouteReason
≥ 6CodexHigh complexity warrants deeper analysis
< 6GeminiModerate complexity, prefer speed

Priority 3: Default

Gemini (faster feedback loop for unclear cases)

Step 6: Execute Review

Explain Routing Decision

Before executing, output:

## Code Review Routing

**Changes detected:**
- Files: [X] files changed
- Lines: [Y] lines modified
- Primary language: [language]
- Framework: [framework or "none detected"]

**Complexity score:** [N]/10
- [List contributing factors]

**Routing decision:** [Gemini/Codex]
- Reason: [primary reason for choice]

**Executing review...**

CLI Commands

Note: Gemini receives the diff via stdin (piped), while Codex has a dedicated review subcommand that reads the git context directly. If debugging, check that git diff HEAD produces output before running Gemini.

For Gemini:

# Pipe diff to Gemini with review prompt
git --no-pager diff HEAD | gemini -p "Review this code diff for: 1) Code quality issues, 2) Best practices violations, 3) Potential bugs, 4) Security concerns, 5) Performance issues. Provide specific, actionable feedback."

For Codex:

# Use dedicated 'review' subcommand for non-interactive code review
# Note: --uncommitted and [PROMPT] are mutually exclusive
codex review --uncommitted

Step 7: Handle Failures with Fallback

If the chosen CLI fails (non-zero exit or error output):

  1. Report the failure:

    [Primary CLI] failed: [error message]
    Attempting fallback to [other CLI]...
    
  2. Try the alternative CLI

  3. If fallback also fails:

    Both review CLIs failed.
    - Gemini error: [error]
    - Codex error: [error]
    
    Please check CLI installations and try manually.
    

Step 8: Format Output

Present the review results clearly:

## Code Review Results

**Reviewed by:** [Gemini/Codex]
**Routing:** [brief reason]

---

[CLI output here]

---

**Review complete.** [X files, Y lines analyzed]

Quick Reference

Change TypeRouteReason
React component stylingGeminiPure frontend
Django view updateGeminiPython ecosystem
Single bug fix < 50 linesGeminiSimple change
New API endpoint + testsCodexArchitectural
Auth system changesCodexSecurity-sensitive
Database migrationCodexSchema change
Multi-service refactorCodexHigh complexity
TypeScript type overhaulCodexComplex types

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

code-review-router

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

claude-code-clawdbot

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

claude-code-dispatch

No summary provided by upstream source.

Repository SourceNeeds Review
General

memory-lancedb-pro

No summary provided by upstream source.

Repository SourceNeeds Review
267-win4r