cpp-review
БесплатноБез исполняемых скриптовНе проверенReviewing C++ code - what to flag, and what the compiler, clang-tidy and sanitizers already flag for you USE WHEN: you are reviewing, critiquing or auditing…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Reviewing C++
A reviewer's leverage is what the toolchain cannot say. C++ is the language where that gap is widest — but the gap is not "undefined behaviour" in the abstract. Listing UB categories is not a review; it is a textbook.
What earns a comment is a lifetime or ownership claim that the code makes and nothing checks. Almost every check below is one of those.
Two things decide how much the toolchain said before you did, and both are project settings rather than language facts:
- Warnings are off by default. A CMake project that never sets
-Wall -Wextracompiles almost silently. Check before assuming. - Sanitizers find these defects, but only on executed paths. ASan and UBSan turn most lifetime bugs below into loud failures — if the test suite reaches them. An untested branch is exactly where they survive.
The snippets are fragments cut down to the defect, not runnable programs.
Already covered - do not spend review on it
| Defect | Reported by |
|---|---|
| Unused variable, unused parameter | -Wall / -Wextra |
| Signed/unsigned comparison | -Wextra (-Wsign-compare) |
| Missing return on some path | -Wreturn-type (in -Wall) |
| Member initialisation order mismatch | -Wreorder (in -Wall) |
delete through a base with no virtual dtor, direct case |
-Wdelete-non-virtual-dtor (in -Wall) |
| Use after move | clang-tidy bugprone-use-after-move — only if clang-tidy runs |
Raw new/delete where a smart pointer belongs |
clang-tidy modernize-make-unique, cppcoreguidelines-owning-memory |
| Heap use-after-free, buffer overflow, leak | ASan — only on executed paths |
| Signed overflow, misaligned load, bad shift | UBSan — only on executed paths |
Read the build first. If CMakeLists.txt sets no warning flags, no
clang-tidy target and no sanitizer preset, then rows 1-9 are all yours. That is
one comment about the build, followed by the specific instances — not a
per-line campaign.
The table above dates; the tools do not. Verify a default set with
mcp__documentation__fetch_docson technologycpp-quality— topicsgcc-warning-options,clang-tidy-checks,address-sanitizer,undefined-behavior-sanitizer. Those entries point at the indexes the tool authors maintain, so they follow the version the project actually pins rather than the one this skill was written against.
The checks that earn their place
A guard that guards nothing
std::lock_guard<std::mutex>(m); // a TEMPORARY: destroyed at the semicolon
std::lock_guard<std::mutex> guard(m); // holds until end of scope
When you see it: any RAII type constructed without a variable name —
lock_guard, unique_lock, scoped_lock, a timer, a transaction guard.
Ask: does this have a name? The unnamed form locks and unlocks on the same
line, so the critical section below runs unprotected. It compiles, it looks
right, and the race it creates is intermittent. (Some compilers warn under
-Wunused-value; many do not for types with non-trivial destructors.)
A string_view or reference outliving what it points into
std::string_view name = person().full_name(); // temporary dies at the semicolon
return name; // dangling
When you see it: string_view, span, a reference or a raw pointer
initialised from a function call returning by value; a string_view stored as a
class member.
Ask: who owns the buffer, and does it outlive this? string_view and span
are non-owning by design, so every one of them is a lifetime claim. A member of
that type is a claim about an object the class does not control.
A range-for over a temporary's subobject
for (const auto& row : getTable().rows()) { } // getTable() dies before the loop
When you see it: for (... : expr) where expr is a member access, an index
or a call on a temporary rather than the temporary itself.
Ask: is the temporary itself bound, or something inside it? Lifetime extension applies to the whole temporary bound directly to the reference — and not to a subobject reached through a call. C++23 fixed this for the direct case only; the shape above still dangles.
An iterator used after the container was modified
for (auto it = v.begin(); it != v.end(); ++it) {
if (pred(*it)) v.push_back(*it); // may reallocate; `it` and `end()` dangle
}
When you see it: push_back, insert, erase or resize inside a loop
over the same container.
Ask: can this reallocate or shift? For vector any growth invalidates
everything; erase invalidates from the erase point on. The erase case has a
correct idiom (it = v.erase(it)) that is one character from the wrong one.
An owning raw pointer member with compiler-generated copy
class Buffer {
char* data_; // owns
public:
~Buffer() { delete[] data_; }
// no copy ctor, no copy assignment
Установить cpp-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobFAQ
Что делает скилл cpp-review?
Reviewing C++ code - what to flag, and what the compiler, clang-tidy and sanitizers already flag for you USE WHEN: you are reviewing, critiquing or auditing existing C++ code - a "code review", a "review" of a .cpp/.hpp/.cc/.h file, a diff, a PR or a pull request; deciding what to comment on in C++; avoiding false positives on C++ DO NOT USE FOR: writing, explaining or learning C++ - use `languages/cpp`; anything `-Wall -Wextra`, clang-tidy or a sanitizer run already reports (this skill lists those so you can stay silent about them); build system questions - use the CMake material; embedded specifics - use `systems/embedded-rtos`
Как установить скилл cpp-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cpp-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic