cpp-development

Apply modern C++17/20 patterns to writing, reviewing, and refactoring code.

16|9|Updated Nov 6, 2013
One-click install
npx skills add https://github.com/erikstmartin/dotfiles --skill cpp-development
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-development
Source: https://github.com/erikstmartin/dotfiles/tree/main/skills/catalog/cpp/cpp-development
Command: npx skills add https://github.com/erikstmartin/dotfiles --skill cpp-development

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured, best-practice-driven approach to writing, reviewing, and refactoring modern C++ code (C++17/20), including a pre-commit checklist to enforce quality.

Core Features & Use Cases

  • Rule of Zero: Let the compiler generate all special members and compose from types that manage their own resources.
  • Rule of Five: If you manage a raw resource directly, define (or delete) all five special members to ensure proper ownership semantics.
  • RAII + const correctness: Prefer RAII patterns and const correctness to improve safety and clarity.
  • Concepts and templates: Use C++20 concepts to constrain templates and improve readability.
  • Pre-Commit Checklist: A practical checklist to ensure safe, robust code before commits.
  • Common pitfalls: Guidance to avoid common mistakes in C++ design and implementation.

Quick Start

Apply these patterns to a current C++ project to guide writing, reviewing, and refactoring.

Frequently Asked Questions about cpp-development

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

FAQPage Schema
How do I apply modern C++ patterns like RAII and Rule of Zero to refactor existing code?

To apply modern C++ patterns, compose types that manage their own resources so the compiler can generate special members automatically. This Rule of Zero approach, combined with RAII and const correctness, improves code safety and clarity during refactoring.

What is the Rule of Five in C++ and when should I use it?

The Rule of Five in C++ requires defining or deleting all five special member functions when directly managing raw resources. Use it to ensure proper ownership semantics and prevent resource leaks, contrasting the Rule of Zero for composing resource-managing types.

How do I use C++20 concepts to constrain templates and improve readability?

C++20 concepts constrain template parameters by enforcing specific compile-time requirements on types. Using concepts instead of complex SFINAE patterns improves compiler error messages and overall template readability in modern C++ codebases.

What should be on a C++ pre-commit checklist to ensure code safety?

A C++ pre-commit checklist for code safety should verify correct application of RAII, const correctness, and Rule of Zero or Five. It ensures proper ownership semantics and confirms common C++ design pitfalls are avoided before changes are committed.

Can I use this approach to review C++17 codebases or is it limited to C++20?

You can use this approach to review C++17 codebases as well as C++20. The patterns enforced, including RAII, const correctness, and Rule of Zero, apply across both versions, while C++20 concepts are utilized specifically where template constraints are needed.

Why does my C++ template fail to compile without explicit constraints?

C++ templates often fail to compile without constraints because they accept types lacking required operations. Applying C++20 concepts constrains templates to enforce specific type requirements, replacing complex SFINAE and improving readability.