| name | code-analysis |
| description | This skill should be used when analyzing ACE Engine (OpenHarmony ArkUI) code including components, patterns, models, and properties. Supports multiple analysis levels: quick diagnosis (5-15 min), comprehensive analysis (30-45 min), and deep audit (1-2 hr). Covers architecture review, bug analysis, performance optimization, component design guidance, API review, and test coverage analysis. Emphasizes code-first principle - always verify with actual code using Read/Grep tools and provide file:line references. |
ACE Engine Code Analysis Skill
Comprehensive code analysis guidelines for ACE Engine (OpenHarmony ArkUI) development.
Core Principles
1. Code-First Principle (代码为准原则)
Always verify with actual source code - never guess or fabricate.
- ✅ Use Read/Grep tools to locate and read actual source code
- ✅ Reference complete file paths with line numbers (e.g.,
frameworks/core/xxx/yyy.cpp:123)
- ✅ Provide source location for all code snippets
- ❌ Never assume functionality without reading source code
- ❌ Never write hypothetical code without verification
Example of correct code reference:
### Text Pattern Initialization
Source: `OpenHarmony/foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/text/text_pattern.cpp:123-145`
```cpp
void TextPattern::OnModifyDone()
{
// Actual implementation from source
auto host = GetHost();
if (host) {
host->MarkDirtyNode(PROPERTY_PATTERN_RENDER_CONTEXT);
}
}
### 2. Evidence-Based Analysis
All conclusions must be supported by:
- **Code location references** (`file:line` format)
- **Actual code snippets** (not fabricated)
- **Verification with Read/Grep tools**
### 3. Structured Output
Analysis results should include:
- **Core findings** (with code references)
- **Potential issues** (grouped by severity)
- **Actionable recommendations** (specific and executable)
- **Visual diagrams** (class hierarchy, call flows, data flow)
## Analysis Levels
### Level 1: Quick Analysis (基础版本快速分析)
**Time**: 5-15 minutes
**Use cases**: Quick problem diagnosis, simple code understanding, initial assessment
**Analysis Requirements**:
1. Read specific file path source code
2. Focus on specific class/function/feature
3. Analyze specific problem point (e.g., memory management, performance, lifecycle, error handling)
4. Provide conclusions based on actual code with file:line references
**Output Format**:
- Core findings (with code references)
- Potential issues (if any)
- Improvement suggestions (if any)
### Level 2: Comprehensive Analysis (完整版本深度分析)
**Time**: 30-45 minutes
**Use cases**: Code review, architecture refactoring, comprehensive technical assessment
**Analysis Steps**:
#### Step 1: Code Location & Verification
1. Use Glob/Grep to locate relevant source files
2. Verify file path existence
3. Confirm code version (current branch)
#### Step 2: Structure Analysis
1. Read core file contents
2. Draw class inheritance diagrams (if applicable)
3. Identify key function call chains
4. Mark important code locations (file:line format)
#### Step 3: Deep Analysis
**Architecture Design**:
- [ ] Pattern/Model/Property separation
- [ ] NG architecture compliance
- [ ] Component lifecycle completeness
**Memory Safety**:
- [ ] Smart pointer usage (AceType::RefPtr)
- [ ] Raw pointer usage justification
- [ ] Memory leak risks
**Performance**:
- [ ] Unnecessary copying
- [ ] Loop/recursion complexity
- [ ] Layout/render performance impact
**Error Handling**:
- [ ] Null pointer checks
- [ ] Boundary condition handling
- [ ] Exception handling
**Test Coverage**:
- [ ] Find corresponding test files
- [ ] Unit test coverage
- [ ] Critical path testing
#### Step 4: Cross-Validation
1. Compare with knowledge base documents (if available)
2. Check related component implementation patterns
3. Verify API usage compliance
**Output Requirements**:
**Must Include**:
1. **Code location references**: All conclusions must cite `file:line`
2. **Actual code snippets**: Key implementation excerpts
3. **Visual diagrams**:
- Class inheritance relationships
- Function call flows
- Data flow diagrams
4. **Issue list**: Problems grouped by severity
5. **Improvement recommendations**: Specific actionable suggestions
**Prohibited**:
- ❌ No guessing or fabricating code
- ❌ No conclusions without code references
- ❌ No skipping error handling analysis
- ❌ No skipping actual code verification
### Level 3: Deep Audit (深度审计)
**Time**: 1-2 hours
**Use cases**: Full audit with test verification and performance analysis
Includes all Level 2 analysis plus:
- Test execution and verification
- Performance benchmarking
- Security vulnerability assessment
- Documentation accuracy review
## Scenario-Specific Analysis
### Bug Analysis (Bug分析专用)
**Use cases**: Problem troubleshooting, error location, defect fixing
**Analysis Requirements**:
1. Locate problem code (exact line number)
2. Analyze root cause
3. Check related code for similar issues
4. Provide fix solution (with code example)
**Analysis Method**:
1. Use Grep to search related error messages/exceptions
2. Trace function call chains
3. Check log output locations
4. Analyze boundary condition handling
**Output Format**: