cpp

Diagnoses and fixes C++ ownership, concurrency, and CMake build boundary defects.

22|Updated Sep 10, 2026
One-click install
npx skills add https://github.com/Lynricsy/HyperSkills --skill cpp-lynricsy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp
Source: https://github.com/Lynricsy/HyperSkills/tree/main/skills/cpp
Command: npx skills add https://github.com/Lynricsy/HyperSkills --skill cpp-lynricsy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? C++ code often fails at boundaries that compile and link cleanly: dangling string_view borrows, broken atomic publication protocols, coroutine frames outliving their closures, and ABI mismatches between producer and consumer targets. This Skill provides structured workflows to find and fix these lifetime, concurrency, and build-contract defects. ## Core Features & Use Cases - Ownership and lifetime analysis: Track borrows, invalidation, construction failure, and move semantics with a lifetime ledger covering views, spans, and container relocation. - Concurrency protocol diagnosis: Distinguish data races from broken release/acquire publication, callback reentrancy, and unsafe shutdown, with guidance on when TSan evidence is and is not sufficient. - CMake and ABI boundary repair: Place usage requirements on the producing target, separate compiler from standard-library feature support, and verify consumers through clean builds rather than link success. - Use Case: A queued callback captures a string_view and prints corrupted labels after the source string mutates. The Skill walks you through identifying the borrow, transferring snapshot ownership into the deferred work, and verifying with a C++17 ASan build. ## Quick Start Use the cpp skill to review my C++20 coroutine scheduler for lifetime bugs and explain why the queued task loses its captured report.

Frequently Asked Questions about cpp

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

FAQPage Schema
How do I fix a dangling string_view in C++?

Trace the borrow to its owner and last use, then give the consumer an owned snapshot such as std::string instead of the view. Copying a string_view copies only the pointer and length, not the characters, so extending container lifetime or calling reserve does not repair the borrow.

Why does my C++ program link but crash with ABI mismatch?

A successful link does not prove ABI compatibility. Macro differences like a PRIVATE compile definition can give producer and consumer different struct layouts, violating ODR silently. Move the definition to PUBLIC on the producing target and compare actual compile commands or preprocessed headers on both sides.

Does a clean ThreadSanitizer run prove my atomics are correct?

No. TSan detects data races in observed executions but cannot prove an all-atomic ordering protocol is correct. Relaxed operations on separate atomics are race-free yet fail to establish publication; you need a release store and an acquire load that reads it to build the happens-before chain.

Why does my C++20 coroutine lose its captured variables?

A coroutine frame is separate from the lambda closure that created it. Captures live in the closure, so retaining only the returned task leaves the frame referencing a destroyed closure. Pass owning values as by-value parameters of a named coroutine, which are copied into coroutine state before initial suspension.

Can I combine ASan and TSan in one build?

No, ASan and TSan must run in separate builds. Use ASan plus UBSan for memory reproducers and a separate TSan build with -fsanitize=thread -pthread for races, instrumenting the code under investigation rather than only the test driver.

When should I not use this C++ skill?

It does not cover Unreal Engine reflection, RPC, or Gameplay Ability System questions, embedded board initialization, GPU kernels, or general test methodology. Route engine-specific questions to an Unreal skill and general testing practice to a test-driven-development skill.