cpp-modernize

Modernizes legacy C++98/03 code to C++17/20 with smart pointers and nullptr.

Updated Mar 4, 2026
One-click install
npx skills add https://github.com/chisuhua/home --skill cpp-modernize-chisuhua
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cpp-modernize
Source: https://github.com/chisuhua/home/tree/main/.config/opencode/skills/cpp-modernize
Command: npx skills add https://github.com/chisuhua/home --skill cpp-modernize-chisuhua

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy C++ codebases written in C++98/03 contain raw pointers, NULL macros, and typedef declarations that are error-prone and hard to maintain. This Skill systematically identifies and refactors these outdated patterns into modern C++17/20 equivalents. ## Core Features & Use Cases - Pattern Recognition: Scans source files to flag raw pointer ownership, NULL macros, and typedef declarations for modernization. - Safe Refactoring Rules: Converts raw pointers to std::unique_ptr, NULL to nullptr, and typedef to using aliases, while protecting polymorphic deletions and C API boundaries. - Verification Workflow: Integrates clang-tidy and cmake build/test commands to validate that refactored code compiles and passes existing tests. - Use Case: When a user asks to modernize src/legacy.cpp, the Skill scans for new/delete pairs and NULL usage, applies smart pointer conversions, then runs clang-tidy and the test suite to confirm correctness. ## Quick Start Modernize the legacy C++ code in src/engine.cpp to C++17 by replacing raw pointers with smart pointers and NULL with nullptr.

Frequently Asked Questions about cpp-modernize

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

FAQPage Schema
How do I convert raw pointers to smart pointers in C++?▼

Replace owning raw pointers with std::unique_ptr for exclusive ownership or std::shared_ptr for shared ownership. The Skill scans for new/delete pairs and applies the appropriate smart pointer conversion while preserving ownership semantics.

How to modernize legacy C++98 code to C++17?▼

Scan the code for outdated patterns like NULL macros, typedef declarations, and manual memory management, then replace them with nullptr, using aliases, and smart pointers. Verify the result with clang-tidy and your existing cmake test targets.

When should raw pointers not be replaced with smart pointers?▼

Avoid converting raw pointers involved in polymorphic deletion without first verifying virtual destructors, and never convert pointers exposed across extern "C" API boundaries. These cases require manual analysis before refactoring.

Does C++ modernization work with C API boundaries?▼

Pointers crossing extern "C" boundaries must remain raw because C has no smart pointer types. The Skill explicitly excludes these pointers from conversion to preserve ABI compatibility with C consumers.

What tools are needed to verify C++ refactoring?▼

Verification requires clang-tidy for static analysis, cmake for building, and the project's existing test targets. Run clang-tidy against the compile database, rebuild the target, and execute the test binary to confirm correctness.