https://www.bilibili.com/video/BV1KErQB4Esx/
An Agent Skill that intelligently routes code reviews between Gemini CLI and Codex CLI based on tech stack, complexity, and change characteristics.
Agent Skills are reusable packages of knowledge that extend what AI agents can do. A Skill is a markdown file (SKILL.md) containing instructions that the agent follows when working on specific tasks. Skills follow a progressive disclosure pattern:
- Discovery: The agent sees available Skills with their names and descriptions
- Activation: When your task matches a Skill's description, the agent loads the full instructions
- Execution: The agent follows the Skill's instructions automatically
This Skill works with both Claude Code and Google Antigravity.
| Advantage | Description |
|---|---|
| Deterministic & Predictable | Unlike free-form prompts, decision trees follow explicit rules, ensuring consistent routing every time |
| Transparent Logic | Every routing decision can be traced back to specific criteria—no black-box behavior |
| Optimized Tool Selection | Automatically selects the best tool (Gemini vs Codex) based on change characteristics |
| Reduced Token Usage | Pre-defined decision paths eliminate the need for lengthy reasoning chains |
| Extensible | Easy to add new routing rules or modify existing ones without rewriting the entire logic |
| Fallback Handling | Built-in graceful degradation when the primary tool fails |
- Multi-tool orchestration: Choosing between different CLIs, APIs, or services
- Complex conditional logic: When routing depends on multiple factors
- Audit requirements: When you need to explain why a specific tool was selected
- Performance optimization: Avoiding unnecessary reasoning overhead
- 🔀 Smart Routing — Automatically selects Gemini or Codex based on code characteristics
- 📊 Complexity Scoring — Calculates a 0-10 complexity score based on multiple factors
- 🔍 Language Detection — Identifies TypeScript, Python, Go, Rust, and 10+ languages
- 🛡️ Security Pattern Recognition — Detects auth, credentials, and sensitive code patterns
- 🔄 Automatic Fallback — Switches to alternative CLI if the primary one fails
- ⏱️ Timeout Protection — 120-second safeguard prevents hanging reviews
Place the skill file in one of these locations:
# Project-specific (shared with team)
.claude/skills/code-review-router/SKILL.md
# Personal (all projects)
~/.claude/skills/code-review-router/SKILL.mdPlace the skill file in one of these locations:
# Workspace-specific
<workspace-root>/.agent/skills/code-review-router/SKILL.md
# Global (all workspaces)
~/.gemini/antigravity/skills/code-review-router/SKILL.md- A Git repository with uncommitted changes
- At least one CLI installed:
- Gemini CLI — Google's command-line AI assistant
- Codex CLI — OpenAI's code review tool
Simply ask the agent to review your code:
Review my current changes
or
/code-review-router
The Skill automatically:
- Verifies Git repository and CLI prerequisites
- Analyzes your diff (files, lines, patterns)
- Calculates complexity score
- Routes to the optimal CLI
- Presents formatted review results
The routing follows a priority-based decision tree:
| Pattern | Routes To | Reason |
|---|---|---|
| Security-sensitive files/code | Codex | Requires careful security analysis |
| Files > 20 OR lines > 500 | Codex | Large changeset needs thorough review |
| Database migrations/schema | Codex | Architectural risk |
| API/service layer changes | Codex | Backend architectural changes |
| Changes span 3+ directories | Codex | Multi-service impact |
| Complex TypeScript generics | Codex | Type system complexity |
| Pure frontend (jsx/vue/css) | Gemini | Simpler, visual-focused review |
| Python ecosystem | Gemini | Strong Python support |
| Documentation only | Gemini | Simple text review |
| Score | Routes To | Reason |
|---|---|---|
| ≥ 6 | Codex | High complexity warrants deeper analysis |
| < 6 | Gemini | Moderate complexity, prefer speed |
Falls back to Gemini for faster feedback on unclear cases.
| Condition | Points |
|---|---|
| Files changed > 10 | +2 |
| Files changed > 20 | +3 (additional) |
| Lines changed > 300 | +2 |
| Lines changed > 500 | +3 (additional) |
| Multiple directories | +1 |
| Test files included | +1 |
| Config files changed | +1 |
| Database/schema changes | +2 |
| API route changes | +2 |
| Service layer changes | +2 |
| Change Type | Route | Reason |
|---|---|---|
| React component styling | Gemini | Pure frontend |
| Django view update | Gemini | Python ecosystem |
| Single bug fix < 50 lines | Gemini | Simple change |
| New API endpoint + tests | Codex | Architectural |
| Auth system changes | Codex | Security-sensitive |
| Database migration | Codex | Schema change |
| Multi-service refactor | Codex | High complexity |
MIT
一个 Agent Skill,根据技术栈、复杂度和代码变更特征,智能地在 Gemini CLI 和 Codex CLI 之间路由代码审查。
Agent Skills 是可复用的知识包,用于扩展 AI 代理的能力。Skill 是一个包含指令的 markdown 文件(SKILL.md),代理在处理特定任务时会遵循这些指令。Skills 采用渐进式披露模式:
- 发现阶段:代理看到可用 Skills 的名称和描述
- 激活阶段:当你的任务匹配某个 Skill 的描述时,代理加载完整指令
- 执行阶段:代理自动遵循 Skill 的指令执行任务
此 Skill 同时支持 Claude Code 和 Google Antigravity。
| 优势 | 描述 |
|---|---|
| 确定性与可预测性 | 与自由形式的提示不同,决策树遵循明确规则,确保每次路由结果一致 |
| 逻辑透明 | 每个路由决策都可以追溯到具体条件——没有黑盒行为 |
| 优化工具选择 | 根据代码变更特征自动选择最佳工具(Gemini vs Codex) |
| 减少 Token 消耗 | 预定义的决策路径消除了冗长的推理链需求 |
| 易于扩展 | 可以轻松添加新的路由规则或修改现有规则,无需重写整个逻辑 |
| 故障回退处理 | 当主要工具失败时,内置优雅降级机制 |
- 多工具编排:在不同的 CLI、API 或服务之间进行选择
- 复杂条件逻辑:当路由依赖多个因素时
- 审计需求:当需要解释为什么选择特定工具时
- 性能优化:避免不必要的推理开销
- 🔀 智能路由 — 根据代码特征自动选择 Gemini 或 Codex
- 📊 复杂度评分 — 基于多个因素计算 0-10 的复杂度分数
- 🔍 语言检测 — 识别 TypeScript、Python、Go、Rust 等 10+ 种语言
- 🛡️ 安全模式识别 — 检测认证、凭证和敏感代码模式
- 🔄 自动故障回退 — 主 CLI 失败时自动切换到备用 CLI
- ⏱️ 超时保护 — 120 秒安全机制防止审查挂起
将 skill 文件放置在以下位置之一:
# 项目级(与团队共享)
.claude/skills/code-review-router/SKILL.md
# 个人级(所有项目)
~/.claude/skills/code-review-router/SKILL.md将 skill 文件放置在以下位置之一:
# 工作区级
<workspace-root>/.agent/skills/code-review-router/SKILL.md
# 全局级(所有工作区)
~/.gemini/antigravity/skills/code-review-router/SKILL.md- 包含未提交更改的 Git 仓库
- 至少安装以下 CLI 之一:
- Gemini CLI — Google 的命令行 AI 助手
- Codex CLI — OpenAI 的代码审查工具
只需让代理审查你的代码:
审查我当前的更改
或者
/code-review-router
Skill 会自动:
- 验证 Git 仓库和 CLI 前置条件
- 分析你的 diff(文件、行数、模式)
- 计算复杂度分数
- 路由到最优的 CLI
- 呈现格式化的审查结果
路由遵循基于优先级的决策树:
| 模式 | 路由至 | 原因 |
|---|---|---|
| 安全敏感文件/代码 | Codex | 需要仔细的安全分析 |
| 文件 > 20 或行数 > 500 | Codex | 大型变更集需要彻底审查 |
| 数据库迁移/Schema | Codex | 架构风险 |
| API/服务层变更 | Codex | 后端架构变更 |
| 变更跨越 3+ 目录 | Codex | 多服务影响 |
| 复杂 TypeScript 泛型 | Codex | 类型系统复杂度 |
| 纯前端 (jsx/vue/css) | Gemini | 更简单、专注视觉的审查 |
| Python 生态系统 | Gemini | 强大的 Python 支持 |
| 仅文档 | Gemini | 简单文本审查 |
| 分数 | 路由至 | 原因 |
|---|---|---|
| ≥ 6 | Codex | 高复杂度需要更深入的分析 |
| < 6 | Gemini | 中等复杂度,优先速度 |
对于不明确的情况,回退到 Gemini 以获得更快的反馈。
| 条件 | 分数 |
|---|---|
| 变更文件 > 10 | +2 |
| 变更文件 > 20 | +3(额外) |
| 变更行数 > 300 | +2 |
| 变更行数 > 500 | +3(额外) |
| 涉及多个目录 | +1 |
| 包含测试文件 | +1 |
| 配置文件变更 | +1 |
| 数据库/Schema 变更 | +2 |
| API 路由变更 | +2 |
| 服务层变更 | +2 |
| 变更类型 | 路由 | 原因 |
|---|---|---|
| React 组件样式 | Gemini | 纯前端 |
| Django 视图更新 | Gemini | Python 生态系统 |
| 单个 bug 修复 < 50 行 | Gemini | 简单变更 |
| 新 API 端点 + 测试 | Codex | 架构性 |
| 认证系统变更 | Codex | 安全敏感 |
| 数据库迁移 | Codex | Schema 变更 |
| 多服务重构 | Codex | 高复杂度 |
MIT