modern-cpp — Claude Code skill: what it does, how to install
Directs C++ development toward C++20/23/26 idioms, replacing dangerous raw pointers, legacy macros, and SFINAE boilerplate with memory-safe patterns.
npx skills add trailofbits/skills --skill modern-cpp -a claude-codeWhat modern-cpp 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.
What it helps with
- Replace owning raw pointers and
new/deletecalls with smart pointers - Refactor complex SFINAE templates using concepts and
requiresclauses - Switch unsafe
printfcalls tostd::printandstd::format - Apply compiler hardening flags and sanitizers to security-sensitive builds
Example prompts for the agent
- 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.
How to install modern-cpp
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill modern-cpp -a claude-code2Manually: put the files in place
~/.claude/skills/modern-cpp/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/modern-cpp/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill modern-cpp -a codex2Manually: put the files in place
.agents/skills/modern-cpp/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill modern-cpp -a cursor2Manually: put the files in place
.cursor/skills/modern-cpp/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install trailofbits/skills modern-cpp2Manually: put the files in place
.github/skills/modern-cpp/SKILL.md1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill modern-cpp -a gemini-cli2Platform CLI
gemini skills install https://github.com/trailofbits/skills --path plugins/modern-cpp/skills/modern-cppManually: put the files in place
.devin/skills/modern-cpp/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add trailofbits/skills --skill modern-cpp -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about modern-cpp
How to install modern-cpp in Claude Code?
Run npx skills add trailofbits/skills --skill modern-cpp -a claude-code in your terminal. This downloads the skill into ~/.claude/skills/modern-cpp/SKILL.md.
What does the modern-cpp skill do?
It guides AI coders to generate modern C++20, C++23, and C++26 code. It focuses on eliminating memory vulnerabilities through smart pointers, bounds-aware containers, and type-safe alternatives.
When should modern-cpp not be used?
It does not handle pure C projects or build tools like CMake and Meson. It also steps aside when a project strictly mandates an older C++ standard for legacy ABI compatibility.