AGENT SKILL

cr-review

代码审查技能 — 基于 RAG 知识库对代码变更进行深度审查。当用户提供 GitHub PR、GitLab MR 链接,或说"审查代码"、"code review"、"帮我 review"、"CR"、"代码评审"时触发。支持安全漏洞检查、性能问题分析、Bug 模式匹配、代码风格评估和架构设计审查。自动获取 diff、检索相关 CR 规则并生成结构化审查报告。

License 许可
MIT
最近更新
2026-07-30
Stars
★ 0
Forks
0

01 前言 Front Matter

name
cr-review
description
代码审查技能 — 基于 RAG 知识库对代码变更进行深度审查。当用户提供 GitHub PR、GitLab MR 链接,或说"审查代码"、"code review"、"帮我 review"、"CR"、"代码评审"时触发。支持安全漏洞检查、性能问题分析、Bug 模式匹配、代码风格评估和架构设计审查。自动获取 diff、检索相关 CR 规则并生成结构化审查报告。

03 SKILL.md 正文

CR Review Skill

概述

本技能让当前 code-reviewer Agent 结合 RAG MCP 知识库中的审查规则,对用户提供的代码变更进行全方位审查。

工作流程

Step 1: 收集变更上下文

  • 如果消息包含 github.com/.../pull/... 或 gitlab.com/.../-/merge_requests/... 链接:立即调用 fetch_pr_diff 获取完整 diff,不要求用户手工导出或粘贴 diff
  • 如果用户上传或粘贴了 diff/代码片段:直接使用
  • 只有当前 Agent 确实拥有 shell 工具并且用户要求审查本地仓库时,才执行 git diff
  • 如果私有仓库返回鉴权错误,明确提示服务端需要配置 GITHUB_TOKEN 或 GITLAB_TOKEN
  • 确定涉及的语言和框架

Step 2: 检索规则与历史案例

  • 调用 search_cr_rules 根据 diff 内容和语言检索匹配的规则
  • 调用 search_code_patterns 检测已知的代码反模式
  • 调用 search_cr_cases,查询应概括本次改动、核心风险、组件和语言;默认取 3 个不同案例
  • 区分 synthetic_seed 与 reviewed_pr 来源。模拟案例只能作为风险检查清单和修复思路,不能当成真实事故证据
  • 调用 list_categories 了解可用的规则分类

Step 3: 逐文件分析

  • 对每个变更文件应用匹配的规则
  • 标注严重程度(critical / major / minor / info)
  • 提供修复建议和代码示例

Step 4: 生成审查报告

  • 汇总所有发现的问题
  • 按严重程度排序
  • 生成结构化报告(Markdown 格式)

Step 5: 保存本次审查并立即建立向量索引

  • PR/MR 审查报告完成后、回复用户前,必须调用一次 save_cr_review_case
  • review_markdown 传入最终完整报告,但不要把完整原始 diff 永久写入报告
  • findings 传入结构化问题,至少包含 severity、title、description、recommendation;有位置时补充 file 和 line
  • 工具返回 case_id 与 chunks_indexed 才算入库成功;相同 URL 和相同报告重试是幂等的
  • 调用失败时重试一次;仍失败则照常返回审查结论,但必须明确说明本次案例未写入 RAG,不能声称保存成功

输出格式

# 代码审查报告

## 概览
- 审查文件:3
- 发现问题:8(Critical: 1, Major: 3, Minor: 4)
- 审查时间:2026-07-28 14:30

## Critical Issues
### [SEC-001] SQL 注入风险
- 文件:src/api/users.py:42
- 描述:......
- 修复:......

## Major Issues
...

## Minor Issues
...

## 总结
...

依赖

  • RAG MCP Server: cr-rag 需要已在 extensions_config.json 中配置并启动。配置示例:
{
  "mcpServers": {
    "cr-rag": {
      "enabled": true,
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "mcp-servers/cr-rag", "src/server.py"],
      "env": {
        "EMBEDDING_PROVIDER": "local",
        "EMBEDDING_MODEL_PATH": "/app/project/mcp-servers/cr-rag/data/models/jinaai/jina-code-embeddings-0.5b",
        "EMBEDDING_BATCH_SIZE": "4",
        "EMBEDDING_MAX_LENGTH": "512",
        "CHROMA_PERSIST_DIR": "/app/project/mcp-servers/cr-rag/data/chroma",
        "SQLITE_PATH": "/app/project/mcp-servers/cr-rag/data/cr_rules.db",
        "CR_RAG_READ_ONLY": "true",
        "CR_CASE_WRITE_ENABLED": "true",
        "CR_CASE_SEED_DIR": "/app/project/knowledge/cr-cases-seed",
        "GITHUB_TOKEN": "$GITHUB_TOKEN",
        "GITLAB_TOKEN": "$GITLAB_TOKEN"
      },
      "description": "RAG-enhanced code review knowledge base",
      "routing": {
        "mode": "prefer",
        "priority": 80,
        "keywords": ["review", "cr", "code review", "代码审查", "代码评审", "github.com", "/pull/", "gitlab.com", "merge_requests"]
      }
    }
  }
}

首次启动前需导入种子规则:

cd mcp-servers/cr-rag && CR_SEED_DIR=../../knowledge/cr-rules-seed uv run src/server.py --seed

导入模拟历史案例:

cd mcp-servers/cr-rag && CR_CASE_SEED_DIR=../../knowledge/cr-cases-seed uv run src/server.py --seed-cases
  • code-reviewer Agent: 需要启用本 Skill 和 cr-rag MCP 工具
  • 知识库: 需要已导入种子规则(knowledge/cr-rules-seed/)和案例(knowledge/cr-cases-seed/)

04 同仓库更多 Skills

yixinD777
yixinD777/deer-flow-agent

web-design-guidelines

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

★ 0
yixinD777
yixinD777/deer-flow-agent

video-generation

Use this skill when the user requests to generate, create, or imagine videos. Supports structured prompts and reference image for guided generation.

★ 0
yixinD777
yixinD777/deer-flow-agent

vercel-deploy

Deploy applications and websites to Vercel. Use this skill when the user requests deployment actions such as "Deploy my app", "Deploy this to production", "Create a preview deployment", "Deploy and give me the link", or "Push this live". No authentication required - returns preview URL and claimable deployment link.

★ 0
yixinD777
yixinD777/deer-flow-agent

systematic-literature-review

Use this skill when the user wants a systematic literature review, survey, or synthesis across multiple academic papers on a topic. Also covers annotated bibliographies and cross-paper comparisons. Searches arXiv and outputs reports in APA, IEEE, or BibTeX format. Not for single-paper tasks — use academic-paper-review for reviewing one paper.

★ 0
yixinD777
yixinD777/deer-flow-agent

surprise-me

Create a delightful, unexpected "wow" experience for the user by dynamically discovering and creatively combining other enabled skills. Triggers when the user says "surprise me" or any request expressing a desire for an unexpected creative showcase. Also triggers when the user is bored, wants inspiration, or asks for "something interesting".

★ 0
yixinD777
yixinD777/deer-flow-agent

zh-output-example

Reviews Chinese skill documentation for publication readiness. Invoke when the user asks in Chinese to review a skill.

★ 0