C/C++ Cursor Rules

April 15, 2026

C/C++ Cursor Rules

Code Style

  • 4 spaces indentation
  • snake_case for functions/variables
  • PascalCase for types/classes
  • SCREAMING_SNAKE_CASE for macros
  • 100 char line limit

Best Practices

  • Use modern C++ (C++17+)
  • Prefer smart pointers over raw pointers
  • Use RAII for resource management
  • Use std::vector over raw arrays
  • Use std::optional for nullable values
  • Prefer constexpr for compile-time

AI Instructions

  • Include necessary headers
  • Use forward declarations when possible
  • Provide CMakeLists.txt for build
  • Add Google Test or Catch2 tests
  • Comment complex logic