docs(agents): add cpp-code-review skill
Add a code review skill with reference files for memory safety, concurrency, correctness idioms, false positives, cppreference lookup, and report format. Move the coding conventions from AGENTS.md into the skill's project-style reference so reviews enforce them. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# Correctness & Modern Idioms
|
||||
|
||||
Docs: cppreference language/library pages; C++ Core Guidelines.
|
||||
|
||||
## Errors & exceptions
|
||||
|
||||
- Errors aren't silently ignored (unchecked return codes, empty `catch (...)`).
|
||||
- Mark functions whose result must be used `[[nodiscard]]`.
|
||||
- Exception safety: on throw, no leaks and objects stay valid (RAII gives this
|
||||
for free).
|
||||
- Destructors and move operations are `noexcept`; no throwing from destructors.
|
||||
- Catch exceptions by const reference (`catch (std::exception const& e)`).
|
||||
- Consider `std::optional` / `std::expected` (C++23) for expected failures, per
|
||||
project style.
|
||||
|
||||
## Types & integers
|
||||
|
||||
- Fixed-width integers: use the project's aliases (`u32`, `i64`, ...) instead of
|
||||
`std::uint32_t` etc., e.g. for sizes in protocols, files, and hardware.
|
||||
- Signed/unsigned comparison and mixing (`int` vs `size_t`); use `std::cmp_less`
|
||||
etc. (C++20) or `std::ssize`.
|
||||
- Narrowing conversions are explicit and checked; prefer `{}` initialization to
|
||||
catch them.
|
||||
- No implicit conversions via single-arg constructors; mark them `explicit`.
|
||||
- `enum class` over plain `enum`.
|
||||
|
||||
## API & classes
|
||||
|
||||
- `const` correctness: methods, references, and parameters.
|
||||
- Pass cheap types by value, large read-only by `const&`, sinks by value +
|
||||
`std::move`.
|
||||
- `override` on virtual overrides; `final` where intended.
|
||||
- No object slicing (passing derived by value as base).
|
||||
- Header hygiene: include what you use, no `using namespace` in headers.
|
||||
|
||||
## Modern idioms
|
||||
|
||||
- Prefer standard algorithms and range-for over hand-rolled loops.
|
||||
- `constexpr` for compile-time constants instead of macros.
|
||||
- `std::string_view` / `std::span` for non-owning parameters (watch lifetimes).
|
||||
- New logic has tests; edge cases (empty, max, error path) are covered.
|
||||
Reference in New Issue
Block a user