Files
pi-dro/.github/instructions/cpp.instructions.md
2026-03-24 20:32:07 +01:00

2.6 KiB

description, applyTo
description applyTo
Guidelines for building C++ Arduino applications **/*.cpp, **/*.h, **/*.hpp, **/*ino

C++ Development

C++ Instructions

  • C++ standard for Arduino.
  • Write clear and concise comments for each function.

General Instructions

  • Make only high confidence suggestions when reviewing code changes.
  • Write code with good maintainability practices, including comments on why certain design decisions were made.
  • Handle edge cases and write clear exception handling.
  • For libraries or external dependencies, mention their usage and purpose in comments.
  • Arduino does not support standard libray
  • Standard library can be used in the unit tests

Formatting

  • Apply code-formatting style defined in .clang-format.
  • Prefer file-scoped namespace declarations and single-line using directives.
  • Insert a newline before the opening curly brace of any code block (e.g., after if, for, while, foreach, using, try, etc.).
  • Ensure that the final return statement of a method is on its own line.
  • Use pattern matching and switch expressions wherever possible.
  • Use nameof instead of string literals when referring to member names.
  • Ensure that XML doc comments are created for any public APIs. When applicable, include <example> and <code> documentation in the comments.

Project Setup and Structure

  • Explain the purpose of each generated file and folder to build understanding of the project structure.
  • Demonstrate how to organize code using feature folders or domain-driven design principles.
  • Show proper separation of concerns with models, services, and data access layers.
  • Explain the Program.cpp and configuration system in C++ including environment-specific settings.

Testing

  • Always include test cases for critical paths of the application.
  • Guide users through creating unit tests.
  • Do not emit "Act", "Arrange" or "Assert" comments.
  • Copy existing style in nearby files for test method names and capitalization.
  • Explain integration testing approaches for API endpoints.
  • Demonstrate how to mock dependencies for effective testing.
  • Show how to test authentication and authorization logic.
  • Explain test-driven development principles as applied to API development.

Performance Optimization

  • Guide users on implementing caching strategies (in-memory, distributed, response caching).
  • Explain asynchronous programming patterns and why they matter for API performance.
  • Demonstrate pagination, filtering, and sorting for large data sets.
  • Show how to implement compression and other performance optimizations.
  • Explain how to measure and benchmark API performance.