Skip to content
SkillModel-led2,227 tokens in use

modern-cpp

Guides C++ code to C++20, C++23 and C++26 idioms and adds compiler hardening, hardened libc++ and sanitizers to cut vulnerability classes.

8,319 stars on the repository CC-BY-SA-4.0trailofbits/skills · plugins/modern-cpp/skills/modern-cpp
/plugin marketplace add trailofbits/skills
View source

Install command as written in the repository's README

Skill label

measured from its files

What installing modern-cpp costs

70tokens idle
2,227tokens in use
13,565tokens, up to

Idle is what sits in context while the skill is installed. In use is its instructions, loaded when it runs. Up to adds the files its instructions link. Counts are approximate, made offline with cl100k_base.

Model dependence Model-led

Script-ledMixedModel-led

Mostly instructions, so how well it works depends on the model that follows them.

This describes the skill's structure, how much of it is scripts. It does not say how well it works.

Touches

Nothing detected: no shell, network, file writes, git or credentials in its files.

Declared tags come from the skill's frontmatter; detected ones from its scripts, its code blocks and the commands it names in inline code. This is detected, not audited.

How it scores

Quality

How well the skill is written, counted from its own files: its frontmatter, its steps, examples, stated output and constraints, its size and whether every file it ships is one it names.How we score it →
Good
  • Frontmatter12/15
  • Structure9/25
  • Examples9/15
  • Output10/15
  • Size15/15
  • Resources15/15

Security

Starts at 100 and loses points for each thing in the skill's files that a reader should look at first.How we score it →
Excellent

No findings.

Repository health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
Good
  • Development activity100
  • Maintenance52
  • Community64
  • Maturity32
  • Momentum40

Modern C++ steers the agent toward current C++ when it writes or modernizes code. It maps legacy patterns to safer replacements: smart pointers for new and delete, std::span for pointer plus length, std::format and std::print for printf, concepts for SFINAE, std::expected for error codes and std::variant for unions.

It also covers deployment steps that need no standard bump, namely hardening flags, hardened libc++ and sanitizers in CI, and ranks features by how usable they are today.

What You Get

  • A table of legacy patterns and their modern replacements with the reason for each
  • A hardening flag set for GCC and Clang, plus the hardened libc++ mode
  • A tiered view of C++20 to C++26 features by practical usability
  • A best-practices checklist for ownership, errors, templates and initialization
  • Reference files on feature sets, hardening and safe idioms by vulnerability class

Common Use Cases

  • Writing a new C++ library with modern defaults
  • Modernizing pre-C++20 code in priority order, memory first
  • Hardening build flags for security-critical code
  • Reviewing C++ for use of old idioms

What Makes It Unique

The security emphasis sets it apart: replacements are chosen because they remove classes of memory and type errors, and the skill separates changes that need a newer standard from hardening that works on any standard. It includes a list of rationalizations to reject, for example the claim that smart pointers are slower, and a frank view of which C++26 features are worth adopting now.

Under The Hood

The skill is prose and reference files with no scripts. It shapes the code the agent writes and reviews and recommends compiler flags and sanitizer settings for you to put in your build. It runs no commands itself, calls no services and writes nothing beyond the code you ask for. Build system setup is explicitly out of scope.

Join founders building with open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on SubstackJoin 750+ subscribers