Overview
Review AI-generated business/application code for correctness, robustness, maintainability, performance, and security. Output a 0-10 score, a risk level, and a must-fix checklist. For C++ code, REQUIRED: use openharmony-cpp and openharmony-security-review as hard constraints.
When to Use
- AI-generated business/app code review or quality evaluation
- Need scoring, risk level, or must-fix checklist
- C++ business code must meet OpenHarmony coding/security requirements
Workflow
- Identify language and code type (business vs test). If test code, use
ai-generated-ut-code-reviewinstead. - For C++: load and apply
openharmony-cpp+openharmony-security-reviewas mandatory constraints. - Inspect behavior vs requirements, edge cases, error handling, resource management, and security.
- Score by rubric, assign risk level, list must-fix items with concrete evidence (file/line or snippet).
Scoring (0-10)
Each dimension 0-2 points. Sum = total score.
| Dimension | 0 | 1 | 2 |
|---|---|---|---|
| Correctness | Wrong/missing key behavior | Partial/assumptions | Meets requirements |
| Robustness | Crashes/leaks/unchecked errors | Some edge handling | Solid edge/error handling |
| Maintainability | Hard to read/modify | Mixed quality | Clear structure & naming |
| Performance | Inefficient hot paths | Acceptable but improvable | Efficient for expected load |
| Security | Clear vulnerabilities | Weak validation/unsafe | Safe-by-default, validated |
Risk Levels
- Blocker: security vulnerabilities, severe logic errors, or violations of mandatory C++ specifications
- High: missing critical paths, incomplete exception handling, obvious resource leaks
- Medium: significant maintainability or performance risks
- Low: minor issues or style consistency
Must-Fix Checklist
- External input has explicit validation and error feedback
- Critical exception paths are reachable and observable (logs/error codes/exceptions)
- Resource release or RAII guarantees (C++)
- C++ scenarios satisfy
openharmony-cppandopenharmony-security-review
AI-Generated Code Pitfalls (Check Explicitly)
- Misunderstanding of requirements, incorrect implicit assumptions
- Only covers the happy path, ignores exceptions/boundaries
- Swallows exceptions or uses unreasonable default values
- Copy-paste causes duplication and inconsistency
- Overcomplicated or incorrect abstraction
Output Format (Required, Semi-fixed)
Score: x/10 — Correctness x, Robustness x, Maintainability x, Performance x, Security xRisk: Low/Medium/High/Blocker — briefly describe the reason for risk (1 line)Must-fix:- [Action + Evidence]
- [Action + Evidence]
Key Evidence:- Cite specific functions/classes/paths (1-2 items)
Notes:- Minimal fix suggestion or alternative approach (1-2 lines)
Rules:
- C++ must be in
Key EvidenceorMust-fixexplicitly point out violations ofopenharmony-cpp/openharmony-security-reviewpoints - At least 2 pieces of evidence; if evidence is insufficient, explain and deduct points
- Providing only an overall evaluation is prohibited
Common Mistakes
- Only provides an overall evaluation without evidence
- Ignores mandatory C++ specifications
- Treats style issues as blocking risks
Example (Concise)
Score: 6/10 (Correctness 1, Robustness 1, Maintainability 1, Performance 1, Security 2) Risk: High Must-fix:
- Missing input validation in
createUser()(null/empty, length, format) - Error path swallows exceptions without logging Key Evidence:
createUser()accepts raw input without checkscatchblock is empty inpersistUser()Notes:- Add explicit validation and return structured errors.