Menu

Post image 1
Post image 2
1 / 2
0

CLAUDE.md for Modern C++: 12 Rules That Stop AI from Writing 1998-Style C++

DEV Community·Olivia Craft·27 days ago
#3FtGslWT
#rule#include#cpp#claudeai#fullscreen#exit
Reading 0:00
15s threshold

You ask Claude to "add a Subscription service that calls Stripe" inside your C++ codebase, and you get back something that compiles cleanly and is still wrong: A function returning Subscription* whose ownership convention is "trust me, you delete it." Three new / delete pairs in the happy path because that's what the model saw on Stack Overflow circa 2009. A using namespace std; at the top of a header, leaking into every consumer. A std::mutex locked with m.lock() / m.unlock() by hand — guaranteed to leak on the next thrown exception. A C-style cast (MyType*)ptr that would be static_cast if the model knew you were past 2003. A class with seven uninitialized member variables, default-constructed into UB. The model isn't lazy. It's been trained on 25 years of C++ code, the median of which is C++98 with <vector> . A CLAUDE.md at the root of your project drags it forward to where you actually live — C++17 with selective C++20. Here are 12 rules I drop into every Modern C++ project.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More