An extensible stability rule review framework that performs stability risk review on C/C++ codebases and generates structured reports. Rules are stored as Markdown documents in the references/ directory. The AI model directly reads the rule documents to perform the review and outputs a Chinese review report to the ./report/ directory. For the detailed workflow, core concepts, and operational details, please refer to references/WORKFLOW_GUIDE.md。
Trigger Scenarios
- Full-repository stability special scan: Perform a stability audit or risk review on a C/C++ codebase
- Specified rule scan: The user explicitly specifies rule IDs, levels, or categories for targeted review
- Local review before code submission: Perform a stability review before code submission
- Detect stability risks (improper exception handling, concurrency deadlocks, performance degradation, resource leaks, etc.)
- Review lifecycle management (object lifecycle, asynchronous task management)
- When the user explicitly requests checking code stability
Trigger Examples:
# 全量扫描
稳定性全量扫描 ./rosen/
代码稳定性检视 ./src/
Specified rule scan
Use the ExceptionHandling_001 rule to review ./src/ Use the ExceptionHandling_001,ExceptionHandling_002,BoundaryCondition_001 rules to review ./rosen/
Filter scan by levelPerform a stability scan on ./rosen/, reviewing only HIGH-level rules
Specified category scanPerform a stability scan on ./src/, reviewing only rules in the exception handling category Use rules in the BoundaryCondition and GraphicsStability categories to review ./rosen/
## NEVER
1. **永远不要修改被扫描的源代码** — 你的工作只是检视代码,识别稳定性风险,禁止对源代码文件进行任何修改操作
2. **不要输出非必要的过程中间件** — 除了目标输出的中文检视报告之外,不要输出其它非必要的过程中间文件或临时文件
3. **永远不要报告没有可复现 RiskFlow 和 ImpactAnalysis 的检出** — 缺少风险流和影响分析的检出是无效的,必须说明来源、传播和后果
4. **永远不要在应用白名单之前标记 test、mock、generated、build 或 protobuf 文件** — 必须先执行白名单过滤再进行规则检视
5. **永远不要将崩溃、内存损坏、资源耗尽或 GPU 资源泄漏降级为风格问题** — 严重程度由后果决定,不由代码外观决定
6. **永远不要静默跳过用户请求的规则 ID** — 无效或不存在的规则必须在开始检视前报告给用户
7. **永远不要合并底层风险路径或规则 ID 不同的检出** — 同位置但不同规则或不同风险传播路径的问题应分别保留
## 渐进式加载触发器
根据扫描场景精确控制加载内容,避免过度加载或不足加载:
### 全量扫描
**必须加载**:`config/rules.yaml`、`config/whitelist.yaml`、`references/RULE_INDEX.md`、所有启用的规则文档、`references/PROBLEM_TEMPLATE.md`、`references/REPORT_TEMPLATE.md`、`references/REPORT_TEMPLATE.csv`
**不要加载**:`references/RULE_DEVELOPMENT_GUIDE.md`、`references/RULE_TEMPLATE.md`、`references/WORKFLOW_GUIDE.md`(除非你对流程有疑问)
### 指定规则扫描
**必须加载**:`config/rules.yaml`、`config/whitelist.yaml`、用户指定的规则文档、`references/PROBLEM_TEMPLATE.md`、`references/REPORT_TEMPLATE.md`、`references/REPORT_TEMPLATE.csv`
**不要加载**:未指定的规则文档、`references/RULE_DEVELOPMENT_GUIDE.md`、`references/RULE_TEMPLATE.md`
### 分类扫描
**必须加载**:`references/RULE_INDEX.md`、`config/whitelist.yaml`、该分类下的规则文档、`references/PROBLEM_TEMPLATE.md`、`references/REPORT_TEMPLATE.md`、`references/REPORT_TEMPLATE.csv`
**不要加载**:其他分类的规则文档、`references/RULE_DEVELOPMENT_GUIDE.md`、`references/RULE_TEMPLATE.md`
### 新增/修改规则
**必须加载**:`references/RULE_DEVELOPMENT_GUIDE.md`、`references/RULE_TEMPLATE.md`、`config/rules.yaml`
**不要加载**:规则检视文档和报告模板(除非同时进行检视)
## 工作流决策树
User input │ ├─ Specify rule ID? ──→ Parse the ID list, validate validity → Load the corresponding rule documents ├─ Specify level? ──→ Filter matching levels from rules.yaml → Load the corresponding rule documents ├─ Specify category? ──→ Filter matching categories from RULE_INDEX.md → Load the corresponding rule documents └─ Not specified? ──→ Load all enabled rules from rules.yaml → Load all rule documents │ ▼ Load config/whitelist.yaml, initialize whitelist filtering │ ▼ Launch 5 Subagents in parallel for review by stability category Each Subagent: whitelist filtering → iterate rules → RISK_PATTERN → CONTEXT → IMPACT → safe-pattern exclusion → output in PROBLEM_TEMPLATE.md format │ ▼ Main Agent aggregation: collect → format validation → deduplicate and merge → group and sort by severity (CRITICAL→HIGH→MEDIUM→LOW) │ ▼ Output report to the ./report/ directory ├── report_{target}{timestamp}.md (according to REPORT_TEMPLATE.md) └── report{target}_{timestamp}.csv (according to REPORT_TEMPLATE.csv)
详细工作流图示、核心概念定义和操作细节请参考 [references/WORKFLOW_GUIDE.md](references/WORKFLOW_GUIDE.md)。
## 输出合约
| 项目 | 要求 |
|------|------|
| 问题格式 | 严格遵循 `references/PROBLEM_TEMPLATE.md`,必须包含:标题、分类、规则、位置、函数、严重程度、关键源码、问题描述、RiskFlow、ImpactAnalysis、修复建议 |
| 报告格式 | Markdown 报告遵循 `references/REPORT_TEMPLATE.md`,CSV 报告遵循 `references/REPORT_TEMPLATE.csv` |
| 输出路径 | 默认 `./report/`,用户可指定其他路径;若目录不存在则先创建 |
| 去重规则 | 同位置同规则问题合并;不同规则或不同风险路径的问题保留 |
| 规则覆盖 | 必须遍历所有指定或启用的规则,不得遗漏;无效规则 ID 必须在检视前报告 |
## 项目结构
├── SKILL.md # Skill description (this file, compact routing) ├── README.md # Project description ├── config/ │ ├── rules.yaml # Rule configuration │ └── whitelist.yaml # Whitelist configuration ├── references/ │ ├── RULE_INDEX.md # Master rule index │ ├── WORKFLOW_GUIDE.md # Detailed workflow guide │ ├── RULE_DEVELOPMENT_GUIDE.md # Rule development guide (loaded only during rule development) │ ├── RULE_TEMPLATE.md # Rule document template (loaded only during rule development) │ ├── PROBLEM_TEMPLATE.md # Detected issue format template │ ├── REPORT_TEMPLATE.md # Report format template (Markdown) │ ├── REPORT_TEMPLATE.csv # Report format template (CSV) │ ├── ExceptionHandling/ # Exception handling (2 items) │ ├── ConcurrencyStability/ # Concurrency stability (1 item) │ ├── ResourceManagement/ # Resource management (5 items) │ ├── BoundaryCondition/ # Boundary conditions (14 items) │ └── GraphicsStability/ # Graphics stability (12 items) └── scripts/ └── add-rule.py # Rule scaffolding tool