skills/comprehensive-code-review/SKILL.md
Code review for ACE Engine (OpenHarmony ArkUI) covering C++/JS/TS/ArkTS. Analyzes 19+ dimensions: stability, performance, threading, security, memory, Modern C++ practices, SOLID principles, design patterns, robustness, testability, maintainability, observability, API design, technical debt, backward compatibility. Reports severity levels, refactoring suggestions, and ACE Engine checks (Pattern/Model/Property, component lifecycle, RefPtr/WeakPtr, four-layer architecture). Use when: reviewing PRs, analyzing code quality, enforcing standards, identifying technical debt, validating architecture, generating quality reports.
npx skillsauth add openharmonyinsight/openharmony-skills comprehensive-code-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Perform comprehensive code review analysis directly with AI:
"Review the code in frameworks/core/components_ng for memory management issues"
"Analyze this pull request focusing on security vulnerabilities"
"Check path/to/code.cpp for ACE Engine architecture compliance"
AI will analyze code across all relevant dimensions based on:
Review code across 19+ dimensions. See DIMENSIONS.md for complete coverage.
High-Priority Dimensions:
Medium-Priority Dimensions:
AI generates comprehensive review report including:
Quick reference to all dimensions:
| Dimension | Focus | Severity Levels | Reference | |-----------|-------|-----------------|-----------| | Stability | Error handling, boundaries | 🔴🟠🟡🟢 | STABILITY.md | | Performance | Algorithms, optimization | 🔴🟠🟡🟢 | DIMENSIONS.md | | Threading | Concurrency, synchronization | 🔴🟠🟡 | DIMENSIONS.md | | Security | Input validation, vulnerabilities | 🔴🟠🟡 | SECURITY.md | | Memory | Smart pointers, leaks | 🔴🟠🟡 | MEMORY.md | | Modern C++ | C++11/14/17/20 features | 🟠🟡 | DIMENSIONS.md | | Effective C++ | RAII, Rule of Five | 🟠🟡 | DIMENSIONS.md | | Code Smells | 22 types of smells | 🟠🟡 | CODE_SMELLS.md | | SOLID | Design principles | 🟠🟡 | SOLID.md | | Design Patterns | Pattern usage | 🟡🟢 | DIMENSIONS.md | | Robustness | Fault tolerance | 🟠🟡 | DIMENSIONS.md | | Testability | Dependency injection | 🟠🟡 | DIMENSIONS.md | | Maintainability | Code complexity | 🟡🟢 | DIMENSIONS.md | | Observability | Logging, monitoring | 🟡🟢 | DIMENSIONS.md | | API Design | Interface quality | 🟠🟡 | DIMENSIONS.md | | Technical Debt | TODO/FIXME tracking | 🟡🟢 | DIMENSIONS.md | | Backward Compatibility | API stability | 🟠🟡 | DIMENSIONS.md | | Architecture | ACE Engine compliance | 🔴🟠🟡 | ACE_ENGINE_SPECIFIC.md |
Four-Layer Architecture:
Frontend Bridge Layer
↓
Component Framework Layer (Pattern/Model/Property)
↓
Layout/Render Layer
↓
Platform Adapter Layer (OHOS/Preview)
Check:
components_ng/pattern/<component>/
├── *_pattern.h/cpp # Business logic & lifecycle
├── *_model.h/cpp # Data model interface
├── *_layout_property.h/cpp # Layout properties
├── *_paint_property.h/cpp # Render properties
└── *_event_hub.h/cpp # Event handling
// ✅ Creation
auto node = AceType::MakeRefPtr<FrameNode>();
// ✅ Type-safe casting
auto pattern = AceType::DynamicCast<MenuPattern>(node->GetPattern());
if (!pattern) {
LOGE("Failed to get pattern");
return false;
}
// ✅ Breaking cycles with WeakPtr
class Child {
WeakPtr<Parent> parent_; // Use weak, not strong
};
// ✅ Safe callbacks
auto weak = AceType::WeakClaim(this);
PostTask([weak]() {
auto pattern = AceType::DynamicCast<MenuPattern>(weak.Upgrade());
if (pattern) pattern->Update();
});
class MenuPattern { // PascalCase
public:
void OnModifyDone(); // PascalCase
int GetWidth() const; // Get prefix
private:
int width_; // snake_case_ with trailing underscore
std::string component_id_; // Abbreviations lowercase
};
constexpr int MAX_MENU_ITEMS = 100; // UPPER_CASE
🔴 CRITICAL - Must fix before merge
🟠 HIGH - Should fix before merge
🟡 MEDIUM - Fix soon
🟢 LOW - Nice to have
| Pattern | Dimension | Severity | Detection |
|---------|-----------|----------|-----------|
| Raw pointer instead of RefPtr | Memory | HIGH | new T() without RefPtr |
| Command injection | Security | CRITICAL | system(user_input) |
| Buffer overflow | Security | CRITICAL | strcpy(), sprintf() |
| Unsafe this capture | Threading | HIGH | [this] in PostTask |
| Long method (>50 lines) | Code Smell | MEDIUM | Function length |
| Large class (>500 lines) | Code Smell | HIGH | Class size |
| Missing null check | Stability | HIGH | Pointer use without validation |
| static_cast instead of DynamicCast | Memory | MEDIUM | static_cast<T*> |
"Review the changes in this PR with focus on memory management and threading safety"
AI will:
"Perform a security audit of path/to/code, focusing on input validation and potential vulnerabilities"
AI will check for:
"Analyze frameworks/core/components for potential memory leaks and improper RefPtr usage"
AI will identify:
"Verify that components_ng/menu follows the four-layer architecture and Pattern/Model/Property separation"
AI will validate:
For pre-commit hooks, consider using traditional static analysis tools:
#!/bin/bash
# .git/hooks/pre-commit
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|cc|cxx|h|hpp|ts|tsx)$')
if [ -n "$CHANGED_FILES" ]; then
echo "Running basic static analysis..."
# Use clang-tidy, cppcheck, eslint, etc.
for file in $CHANGED_FILES; do
if [[ $file == *.cpp || $file == *.h ]]; then
clang-tidy $file --checks='*' || true
elif [[ $file == *.ts ]]; then
eslint $file || true
fi
done
fi
For comprehensive AI-powered review:
Detailed documentation for all dimensions in references/:
Before merging code:
Code Quality:
Architecture:
Memory:
Security:
Testing:
development
Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.
development
OpenHarmony PR full lifecycle workflow. Five modes: - Commit: standardized commit with DCO sign-off and Issue linking - Create PR: commit + push to fork + create Issue + create PR on upstream - Fix Codecheck: fetch gate CI codecheck defects from a PR and auto-fix them - Review PR: fetch a PR's changes to local for code review - Fix Review: fetch unresolved review comments from a PR and auto-fix them Triggers on: /oh-pr-workflow, "提交代码", "创建PR", "提个PR", "commit", "修复告警", "修复门禁", "修复codecheck", "fix codecheck", "review pr", "review这个pr", "看下这个pr", "检视pr", "修复review", "修复检视意见", "fix review", or a GitCode PR URL with fix/review intent.
testing
分析 HM Desktop PRD 文档,提取需求信息、验证完整性、检查章节顺序(需求来源→需求背景→需求价值分析→竞品分析→需求描述)、检查 KEP 定义、检测需求冲突并生成结构化分析报告。适用于用户请求:(1) 分析或审查 PRD 文档, (2) 从需求中提取 KEP 列表, (3) 检查 PRD 完整性或一致性, (4) 将需求映射到模块架构, (5) 验证 PRD 格式合规性, (6) 验证竞品分析章节完整性。关键词:PRD分析, requirement extraction, KEP验证, completeness check, chapter order validation, 竞品分析检查, analyze PRD, 需求提取, 完整性检查, 章节顺序验证
development
基于 PRD 文档自动生成鸿蒙系统设计文档,包括架构设计文档和功能设计文档。生成前会分析 OpenHarmony 存量代码结构,确保与现有架构兼容。架构设计文档第2章必须为竞品方案分析,位于需求背景之后。适用于用户请求:(1) 生成架构设计文档, (2) 生成功能设计文档, (3) 从 PRD 生成设计文档, (4) 创建系统架构设计, (5) 编写功能规格说明, (6) 分析 OH 代码结构。关键词:architecture design, functional design, design doc, 竞品方案分析, OpenHarmony code analysis, 架构设计, 功能设计, 设计文档生成, OH代码分析, analyze codebase, competitor analysis