cpp
Skill33 starsChanged 33 days agoMITView on GitHub
Use when writing modern C++ (17/20/23). Covers RAII, smart-pointer ownership, move semantics, ranges, concepts, and eliminating undefined behavior with sanitizers. Trigger on "segfault in my c++ code", "should this be a unique_ptr or shared_ptr", "get rid of the raw new and delete", "asan reports heap-use-after-free".
7 other projects use a version of this.
Adopted by
Most recently taken up by
- testdino-hq/google-styleguides-skillstheir own version, first seen Nov 8, 2026
- its-ash/skillstheir own version, first seen Nov 1, 2026
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
- Mindrally/skillstheir own version, first seen Oct 8, 2026
- mordechai30/cpp_skillstheir own version, first seen Oct 8, 2026
- kimtth/agent-skill-100-lines-or-lesstheir own version, first seen Jun 26, 2026
Used with
Projects with it also use kotlin.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
margeloSkillkotlin
Design, implement, and review Kotlin and Android APIs. Use when working on .kt files, Kotlin nullability, sealed classes/interfaces, coroutines, Android threading, Java interop, or Kotlin-backed React Native Nitro Module implementations.
Also in 3 projects that use this
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- Mindrally/skills★ 275same name
- margelo/react-native-skills★ 172same name
- G1Joshi/Agent-Skills★ 15same name
- testdino-hq/google-styleguides-skills★ 15same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- its-ash/skills★ 0same name
- mordechai30/cpp_skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository137 other files it gives its agents.
- agent-instructionsSkill
- agent-memorySkill
- hooksSkill
- plugin-developmentSkill
- skill-authoringSkill
- skill-reviewSkill
- slash-commandsSkill
- subagentsSkill
- agent-designSkill
- context-engineeringSkill
- fine-tuningSkill
- llm-cost-optimizationSkill
- llm-evaluationSkill
- llm-integrationSkill
- mcp-serverSkill
- ml-pipelineSkill
- model-selectionSkill
- prompt-engineeringSkill
- ragSkill
- structured-outputSkill
- api-designSkill
- background-jobsSkill
- cachingSkill
- djangoSkill
- event-driven-architectureSkill
- fastapiSkill
- graphqlSkill
- microservicesSkill
- nestjsSkill
- realtime-websocketsSkill
- spring-bootSkill
- competitive-analysisSkill
- lead-researchSkill
- product-analysisSkill
- resumeSkill
- user-researchSkill
- database-performanceSkill
- data-modelingSkill
- data-qualitySkill
- pandasSkill
- postgresSkill
- sparkSkill
- brand-guidelinesSkill
- generative-artSkill
- themingSkill
- ui-reviewSkill
- visual-designSkill
- architecture-decisionsSkill
- bug-fix-protocolSkill
- cli-developmentSkill
- code-reviewSkill
- debuggingSkill
- design-patternsSkill
- domain-modelingSkill
- git-workflowSkill
- legacy-modernizationSkill
- refactoringSkill
- repository-explorationSkill
- simple-designSkill
- system-designSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Write C++ where resources are owned by objects, ownership is visible in the type, and undefined behavior is actively hunted with tooling …
- Very specific: line 54
Prefer values and references.
- Very specific: line 56
Never return a reference or string_view to a temporary.
- Very specific: line 58
Use std::span instead of pointer+length parameter pairs.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C++
Purpose
Write C++ where resources are owned by objects, ownership is visible in the type, and undefined behavior is actively hunted with tooling rather than hoped away.
When to Use
- Writing or reviewing C++17 and later.
- Modernizing code that uses raw
new/deleteor manual resource cleanup. - Diagnosing memory corruption, leaks, or data races.
- Designing value types with correct copy/move semantics.
- Optimizing hot paths where allocation or copying dominates.
Capabilities
- RAII and ownership modeling with
unique_ptr,shared_ptr, and value semantics. - Move semantics, the rule of zero/five, and copy elision.
- Ranges, views, and algorithm composition.
- Concepts for constrained templates and readable errors.
- Sanitizer-driven debugging: ASan, UBSan, TSan.
Inputs
- Source, build system (CMake preferred), and target standard.
- Platform and toolchain constraints.
- Performance budget for hot paths.
Outputs
- Code with no raw owning pointers and no manual
delete. - A CMake configuration with warnings-as-errors and sanitizer build types.
- Benchmarks for any change justified on performance grounds.
Workflow
- Establish ownership — Every resource has exactly one owner. Express it in the type: value,
unique_ptr, or a documented non-owningT*/span. - Apply the rule of zero — If a class needs a destructor, it probably should not also hold business logic.
- Constrain templates — Use concepts; unconstrained templates produce unreadable errors and accept nonsense.
- Sanitize — Build and run the test suite under ASan+UBSan, then TSan separately.
- Measure before optimizing — Profile, change one thing, benchmark again.
Best Practices
- Prefer values and references. Reach for
shared_ptronly when ownership is genuinely shared — it is not a default. - Pass by
const&for large read-only inputs; pass by value andstd::movewhen you intend to store. - Never return a reference or
string_viewto a temporary. This is the most common lifetime bug in modern C++. - Compile with
-Wall -Wextra -Wpedantic -Werror. Warnings in C++ are usually latent bugs. - Use
std::spaninstead of pointer+length parameter pairs. - Mark single-argument constructors
explicitunless implicit conversion is genuinely desired.
Examples
RAII wrapper with clear ownership:
class FileHandle {
public:
explicit FileHandle(const std::filesystem::path& path)
: file_(std::fopen(path.c_str(), "rb")) {
if (!file_) {
throw std::system_error(errno, std::generic_category(), path.string());
}
}
FileHandle(FileHandle&&) noexcept = default;
FileHandle& operator=(FileHandle&&) noexcept = default;
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
~FileHandle() { if (file_) std::fclose(file_); }
[[nodiscard]] std::FILE* get() const noexcept { return file_; }
private:
std::FILE* file_;
};Constrained template with concepts:
template <std::ranges::input_range R>
requires std::totally_ordered<std::ranges::range_value_t<R>>
auto median(R&& range) {
std::vector values(std::ranges::begin(range), std::ranges::end(range));
if (values.empty()) throw std::invalid_argument("median of empty range");
auto mid = values.begin() + std::ssize(values) / 2;
std::ranges::nth_element(values, mid);
return *mid;
}Notes
- ASan and TSan cannot be combined in a single build. Run them as separate CI jobs.
- Copy elision is guaranteed for prvalues since C++17 — returning a local by value costs nothing.
shared_ptrcycles leak. Break them withweak_ptron the back-reference.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

