openharmony-cpp
OpenHarmony C++ Coding Skills
Core Mandates (Common Pitfalls)
These rules are strictly enforced in OpenHarmony and often differ from general C++ projects.
1. Strict Naming & Formatting
- Extensions: Always use
.cppand.h. - Files: Filenames must match class names (Unix-like, e.g.,
my_class.cpp). - Variables: Global vars must start with
g_(e.g.,g_config). Class members must end with_(e.g.,value_). - Braces: K&R Style is mandatory (opening brace on the same line).
- Details: See naming_formatting.md.
2. Header Management
- Guards: Use
#ifndefguards. #pragma once is FORBIDDEN. - Includes: Prefer
#includeover forward declarations to prevent hidden dependencies. - Details: See headers_scopes.md.
3. Critical Security Requirements
- Input Validation: All external data must be validated before use (indices, sizes, loops).
- Memory Safety: Pointers must be set to
nullptrimmediately after deletion. - Bitwise: Only on unsigned types.
- Details: See secure_coding.md.
Usage Guide
When to use
- New Code: Generating new classes or modules.
- Refactoring: Cleaning up legacy code.
- Review: Checking code against OpenHarmony standards.
Reference Map
- naming_formatting.md: Naming conventions (g_, _), braces (K&R), line length.
- secure_coding.md: Input validation, integer safety, memory management, prohibited functions.
- class_function_design.md: Constructors, inheritance, modern C++ (nullptr, const), function size.
- headers_scopes.md: Header guards, namespaces, include rules.
More from openharmonyinsight/openharmony-skills
openharmony-security-review
Use when reviewing OpenHarmony C++ system service code for security vulnerabilities, particularly IPC handlers, multithreaded components, or code handling sensitive user data
77oh-ut-generator
|
65cpp-core-guidelines-review
Parallel C++ Core Guidelines code review using multiple specialized sub-agents. Use when reviewing C++ code, modules, or files against C++ Core Guidelines to identify violations. Each sub-agent reviews against a specific guideline section (Functions, Classes, Resource Management, etc.) and outputs findings to separate markdown files in the review/ directory, followed by a consolidated summary.
59openharmony-build
This skill should be used when the user asks to "编译 OpenHarmony", "build OpenHarmony", "编译完整代码", "执行编译", "编译 OpenHarmony 代码", "快速编译", "跳过gn编译", "fast-build", "编译测试", "编译测试用例", "build ace_engine_test", "编译 sdk", "编译 SDK", "build sdk", "build SDK", "编译 ohos-sdk", "编译测试列表", "build test list", "按列表编译测试", "编译指定测试", or mentions building the full OpenHarmony system, fast rebuild, test compilation, SDK compilation, or building tests from a target list. Handles complete build process including build execution, success verification, and failure log analysis with primary focus on out/{product}/build.log.
55ohos-chromium-security-review
|
55ai-generated-business-code-review
Use when reviewing or scoring AI-generated business/application code quality in any language, especially when a numeric score, risk level, or must-fix checklist is requested, or when C++ code must comply with OpenHarmony C++ and security standards
53