m15-anti-pattern

Detect and remediate C++ anti-patterns with modern replacements.

14|3|Updated Jan 25, 2026
One-click install
npx skills add https://github.com/13eholder/Modern-Cpp-Skills --skill m15-anti-pattern-13eholder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: m15-anti-pattern
Source: https://github.com/13eholder/Modern-Cpp-Skills/tree/main/m15-anti-pattern
Command: npx skills add https://github.com/13eholder/Modern-Cpp-Skills --skill m15-anti-pattern-13eholder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill identifies unsafe and outdated C++ patterns that cause memory leaks, undefined behavior, and brittle code, and it guides developers to safer, modern alternatives to improve maintainability and correctness.

Core Features & Use Cases

  • Detection and Explanation: Points out instances of raw new/delete, owning raw pointers, C-style casts, void pointer usage, and macros and explains the risks they introduce.
  • Concrete Modern Fixes: Suggests practical replacements such as smart pointers, standard containers, static_cast, constexpr, and template-based solutions to make code safer and easier to refactor.
  • Use Case: Apply during code reviews or refactoring sprints to convert legacy modules to modern C++ idioms and remove global state to improve testability and lifetime management.

Quick Start

Identify and suggest safe, compile-preserving replacements for occurrences of new, delete, C-style casts, macros, and global variables in the provided C++ files.

Frequently Asked Questions about m15-anti-pattern

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

FAQPage Schema
How do I detect and fix C++ anti-patterns like raw new and delete in legacy code?

To fix C++ anti-patterns, replace raw new/delete and C-style casts with smart pointers, standard containers, static_cast, and constexpr. This refactoring eliminates memory leaks and undefined behavior while preserving compilation during modernization workflows.

What are common C++ anti-patterns and how do they affect code quality?

Common C++ anti-patterns include raw new/delete, owning raw pointers, C-style casts, void pointers, macros, and global state. These introduce memory leaks, undefined behavior, and brittle code, degrading maintainability and testability across the codebase.

How do I replace C-style casts and void pointers with modern C++ alternatives?

Replace C-style casts and void pointers with static_cast, constexpr, and template-based solutions. These modern C++ alternatives provide type safety, eliminate undefined behavior risks, and make refactoring safer while maintaining compile-preserving behavior.

Can I use this anti-pattern detection approach for large C++ refactoring projects?

Yes, anti-pattern detection applies to C++ codebases from small to large projects. It supports code reviews, refactoring sprints, and static analysis workflows to convert legacy modules to modern C++ idioms and remove global state for improved testability.

Why should I remove global state when modernizing C++ codebases?

Removing global state improves testability and lifetime management in C++ codebases. Replacing global variables with dependency injection patterns ensures safer, more maintainable code and eliminates brittle dependencies during refactoring and modernization efforts.

What is the best way to refactor macros in C++ to modern alternatives?

The best way to refactor C++ macros is replacing them with constexpr and template-based solutions. These modern alternatives provide type safety, better debugging capabilities, and eliminate the brittle behavior macros introduce while preserving compilation.