# modern-cpp

Directs C++ development toward C++20/23/26 idioms, replacing dangerous raw pointers, legacy macros, and SFINAE boilerplate with memory-safe patterns.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1200 installs · ★ 7805
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/modern-cpp/skills/modern-cpp/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/modern-cpp

## What it does

This skill from Trail of Bits steers assistant suggestions toward safe idioms from C++20, C++23, and C++26. It replaces manual memory management and `new`/`delete` calls with smart pointers like `std::make_unique`. Passing pointers with lengths shifts to `std::span`, while `printf` gives way to type-safe `std::print` and `std::format`.

The instructions organize modernization into practical tiers. Tier 1 covers well-supported features such as concepts, ranges, and `std::expected`. Tier 2 applies hardening flags like `-D_FORTIFY_SOURCE=3` and hardened libc++ modes without bumping the language standard version.

For pure C codebases, the skill is useless. It targets C++ exclusively. It explicitly steps aside when projects require older standards due to embedded constraints or legacy ABI requirements. Build system setups in CMake or Meson are completely out of scope.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill modern-cpp -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/modern-cpp/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/modern-cpp/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill modern-cpp -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/modern-cpp/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill modern-cpp -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/modern-cpp/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills modern-cpp
```

2. **Manually: put the files in place**
- File: `.github/skills/modern-cpp/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill modern-cpp -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/modern-cpp/skills/modern-cpp
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/modern-cpp/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill modern-cpp -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills/tree/HEAD/plugins/modern-cpp/skills/modern-cpp/SKILL.md

## When to use it
- Replace owning raw pointers and `new`/`delete` calls with smart pointers
- Refactor complex SFINAE templates using concepts and `requires` clauses
- Switch unsafe `printf` calls to `std::print` and `std::format`
- Apply compiler hardening flags and sanitizers to security-sensitive builds

## Example prompts
- Review this legacy class and refactor raw buffer pointers to use std::span.
- Modernize our error handling in this module using std::expected from C++23.
- Suggest Clang hardening flags and sanitizers for our C++ service.

## Similar
- [migrate-to-shoehorn](https://affpapa.org/en/nevibecode/skills/migrate-to-shoehorn.md) — skill · 475388 installs
- [write-swift](https://affpapa.org/en/nevibecode/skills/write-swift.md) — skill · 119300 installs
- [megacave](https://affpapa.org/en/nevibecode/skills/megacave.md) — skill · 25400 installs
- [find-docs](https://affpapa.org/en/nevibecode/skills/find-docs.md) — skill · 9400 installs
- [typescript-advanced-types](https://affpapa.org/en/nevibecode/skills/typescript-advanced-types.md) — skill · 92169 installs
- [smart-explore](https://affpapa.org/en/nevibecode/skills/smart-explore.md) — skill · 7300 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 77 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
