简介
智能路由代码审查工具,根据代码复杂度自动选择最优AI模型,节省40%+成本,支持BYOK模式与本地部署
原始描述
AI-powered code review with intelligent model routing — saves 40%+ vs always using the most expensive model
中文使用说明 来自收录源
Astrai Code Review 综合评估
核心用法
Astrai Code Review 是一款基于智能路由的AI代码审查工具,核心机制在于按复杂度分级调用模型:复杂并发漏洞交由Claude Opus/GPT-4o处理,简单的格式问题则由Haiku/轻量模型完成。用户通过/review命令审查当前diff,支持--strict(严格模式,包含风格检查)和--focus security(安全审计)两种增强模式,也可针对特定文件审查。
显著优点
- 成本优化明确:官方宣称节省40%+,且每次审查返回实际节省金额,量化透明
- BYOK架构:用户自管API密钥,通过加密头
X-Astrai-Provider-Keys传输,Astrai不存储 provider keys,降低第三方托管风险 - 隐私承诺明确:diff和审查结果不保留,符合企业合规要求
- 开源可审计:源码托管于GitHub,路由逻辑和Prompt处理透明可查
- 多Provider兼容:支持Anthropic、OpenAI、Google、DeepSeek等10+主流服务商,灵活切换
潜在缺点与局限性
- 依赖外部路由服务:核心智能路由依赖
as-trai.com,若服务中断则无法工作;虽支持本地模式,但仅配置ASTRAI_API_KEY时使用Astrai托管模型,仍依赖其基础设施 - 成本节省依赖场景:简单代码库(如纯前端页面)节省明显,但复杂系统(微服务、分布式架构)可能多数diff触发高端模型,实际节省或低于预期
- 严格模式误报风险:
--strict引入风格检查,可能产生大量低价值建议,增加开发者噪音 - 安全审计覆盖度未知:安全模式聚焦常见漏洞类别(SQL注入、XSS等),但对供应链攻击、依赖漏洞等静态分析强项领域覆盖有限
适合人群
- 成本敏感的中小团队:需要AI审查但无法承担全量GPT-4o/Opus费用
- 多语言/多框架项目:路由逻辑可自动适配不同复杂度场景
- 合规要求严格的企业:BYOK模式+数据不保留承诺满足隐私需求
- 开源项目维护者:免费档1000次/日基本覆盖小型项目PR审查
常规风险
- API密钥管理:BYOK模式下用户需自行安全存储多个provider密钥,泄漏风险由用户承担
- 路由误判:复杂/简单分类依赖Astrai的黑盒路由模型,可能将关键bug路由至轻量模型导致漏检
- 服务商依赖:虽支持多provider,但路由决策本身集中在Astrai平台,存在单点风险
技能正文
name: astrai-code-review description: AI-powered code review with intelligent model routing — saves 40%+ vs always using the most expensive model version: 1.0.0 homepage: https://github.com/beee003/astrai-openclaw metadata: clawdbot: emoji: "🔍" requires: env: ["ASTRAI_API_KEY"] primaryEnv: "ASTRAI_API_KEY" files: ["plugin.py", "config.example.toml"] tags: [code-review, inference, routing, cost-optimization, pr-review, diff, quality]
Astrai Code Review
AI-powered code review with intelligent model routing. Complex logic goes to powerful models. Formatting and style goes to fast, cheap ones. You save 40%+ without sacrificing quality.
What it does
- Smart routing for reviews: Astrai analyzes the diff complexity and routes to the optimal model. A gnarly concurrency bug gets Opus. A missing semicolon gets Haiku. You only pay for the intelligence you need.
- Structured output: Every review returns typed issues with file, line number, severity (critical/warning/info), message, and a concrete suggestion.
- Strictness modes: Standard catches bugs and logic errors. Strict adds style and best-practice checks. Security mode focuses on vulnerabilities, injection, auth, and data exposure.
- BYOK (Bring Your Own Keys): Your provider API keys stay with you. Astrai decides which model to use, then calls the provider using YOUR key. You pay providers directly.
- Cost tracking: Every review response includes the cost and how much you saved vs always using the most expensive model.
- Local-only mode: If you only set
ASTRAI_API_KEYwithout provider keys, Astrai uses its own hosted models. Still routed intelligently, still cheap.
Setup
- Get a free API key at as-trai.com
- Set
ASTRAI_API_KEYin your environment or skill config - Optionally add provider API keys for BYOK routing (e.g.
ANTHROPIC_API_KEY,OPENAI_API_KEY) - Run
/reviewon any diff or PR
Usage
/review Review the current diff (staged changes)
/review --strict Strict mode: bugs + style + best practices
/review --focus security Security-focused review (vulns, injection, auth)
/review --file src/auth.py Review a specific file
Examples
Basic review of staged changes:
/review
Returns issues found in the current diff with severity levels and suggestions.
Strict review for a PR:
/review --strict
Catches not just bugs but also style violations, naming issues, and missed best practices.
Security audit:
/review --focus security
Focuses on SQL injection, XSS, auth bypass, hardcoded secrets, insecure deserialization, and other vulnerability classes.
Environment Variables
| Variable | Required | Description | Default |
|---|---|---|---|
ASTRAI_API_KEY |
Yes | Your API key from as-trai.com | -- |
ANTHROPIC_API_KEY |
No | Anthropic key for BYOK routing | -- |
OPENAI_API_KEY |
No | OpenAI key for BYOK routing | -- |
GOOGLE_API_KEY |
No | Google key for BYOK routing | -- |
DEEPSEEK_API_KEY |
No | DeepSeek key for BYOK routing | -- |
MISTRAL_API_KEY |
No | Mistral key for BYOK routing | -- |
GROQ_API_KEY |
No | Groq key for BYOK routing | -- |
TOGETHER_API_KEY |
No | Together key for BYOK routing | -- |
FIREWORKS_API_KEY |
No | Fireworks key for BYOK routing | -- |
COHERE_API_KEY |
No | Cohere key for BYOK routing | -- |
PERPLEXITY_API_KEY |
No | Perplexity key for BYOK routing | -- |
REVIEW_STRICTNESS |
No | standard, strict, or security | standard |
External Endpoints
| Endpoint | Purpose | Data Sent |
|---|---|---|
https://as-trai.com/v1/chat/completions |
Code review inference via intelligent routing | Diff content, file context, review instructions |
Security & Privacy
- All requests authenticated via API key in the Authorization header
- Diffs are sent to the Astrai routing API, which forwards to the selected provider
- In BYOK mode, provider keys are sent via encrypted header (
X-Astrai-Provider-Keys) and never stored - No diffs, code, or review results are retained by Astrai after the request completes
- Source code is fully open: github.com/beee003/astrai-openclaw
Model Invocation
This skill sends code diffs to the Astrai routing API. The router classifies the review complexity and selects the best model:
- High complexity (concurrency, security, architecture): Routes to Claude Opus, GPT-4o, or Gemini Pro
- Medium complexity (logic errors, missing edge cases): Routes to Claude Sonnet, GPT-4o-mini, or Gemini Flash
- Low complexity (formatting, typos, naming): Routes to Claude Haiku, GPT-4o-mini, or Gemini Flash
Your prompts are processed by third-party LLM providers according to the routing decision. In BYOK mode, calls are made using your own provider API keys.
Pricing
Same as Astrai platform pricing:
- Free: 1,000 requests/day, smart routing, all strictness modes
- Pro ($49/mo): Unlimited requests, priority routing, analytics dashboard
- Business ($199/mo): Team dashboards, compliance exports, SLA guarantee
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。