cpp-algo-style

Enforces C++ coding style and engineering conventions for the cpp-algo module.

3.7k|317|Updated Mar 18, 2022
One-click install
npx skills add https://github.com/MaaEnd/MaaEnd --skill cpp-algo-style
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-algo-style
Source: https://github.com/MaaEnd/MaaEnd/tree/main/.agents/skills/cpp-algo-style
Command: npx skills add https://github.com/MaaEnd/MaaEnd --skill cpp-algo-style

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The cpp-algo module in MaaEnd suffers from inconsistent naming conventions, duplicated utility code, scattered magic numbers, and non-standard CMake practices. This Skill provides a single authoritative style guide so that code written, modified, or reviewed under agent/cpp-algo/ stays consistent with MaaFramework best practices.

Core Features & Use Cases

  • Naming & Formatting Rules: Defines a complete naming table (PascalCase classes, snake_case_ member variables, k-prefixed constants) plus include ordering and file naming conventions.
  • Refactoring Guidance: Identifies known violations (e.g., camelCase members in MapPosition, direct OpenCV includes) and provides concrete before/after fixes in reference.md.
  • Engineering Standards: Covers logging levels, error handling patterns, modern C++20 usage, magic-number elimination, and CMake explicit source listing, ending with a review checklist.
  • Use Case: When asked to add a new tracking feature to cpp-algo, the AI consults this Skill to name constants correctly, reuse ScopedImageBuffer instead of duplicating it, route OpenCV through NoWarningCV.hpp, and sync schema files.

Quick Start

Review my changes to agent/cpp-algo/MapLocator against the cpp-algo style guide and fix any violations.

Frequently Asked Questions about cpp-algo-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I name C++ member variables and constants in cpp-algo?

Member variables use snake_case with a trailing underscore, such as locator_ or current_zone_id_. Constants use a k prefix with PascalCase, like kMaxLostFrames. Classes use PascalCase and member functions use camelCase.

How should OpenCV be included in a MaaFramework-based C++ project?

OpenCV must be included through <MaaUtils/NoWarningCV.hpp> rather than <opencv2/opencv.hpp> directly. This is the MaaFramework convention for suppressing compiler warnings from OpenCV headers.

Why is file(GLOB_RECURSE) discouraged in CMakeLists.txt?

CMake officially discourages file(GLOB_RECURSE) because adding or removing source files does not trigger reconfiguration, leading to stale builds. The guide requires explicitly listing sources with target_sources instead.

What logging level should I use for per-frame inference output?

High-frequency data like full softmax vectors must use LogTrace, key results use LogDebug, and only state changes or failures use LogInfo or LogError. Printing full vectors every frame with LogInfo is a serious performance problem.

When should duplicated utility code be extracted in cpp-algo?

When the same utility appears in multiple files, such as ScopedImageBuffer or DetectControllerType, it must be extracted into a shared header under source/common/. Module-internal helpers stay in anonymous or detail namespaces.