Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Language-specific super-code guidelines for cpp.
.claude/skills/lingxling-cpp/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 399% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 91% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 64% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 67% | 0% |
cpp// ❌ Raw new/delete Widget* w = new Widget(); // ... 15 lines later ... delete w; // ✅ auto w = std::make_unique<Widget>();
cpp// ❌ Shared ownership when unique suffices auto w = std::make_shared<Widget>(); transfer(w); // only one owner // ✅ — unique_ptr; move when transferring auto w = std::make_unique<Widget>(); transfer(std::move(w));
cpp// ❌ new[] for dynamic arrays int* arr = new int[n]; // ... use ... delete[] arr; // ✅ std::vector<int> arr(n);
cpp// ❌ Manual RAII wrapper for file/mutex FILE* f = fopen(path, "r"); // ... must remember fclose ... // ✅ std::ifstream f(path); // closes automatically at scope exit // For non-standard resources: use unique_ptr with custom deleter auto f = std::unique_ptr<FILE, decltype(&fclose)>(fopen(path, "r"), fclose);
Rule: if you type new, you almost certainly want make_unique or make_shared.
cpp// ❌ C-style string manipulation char buf[256]; sprintf(buf, "%s:%d", host, port); // ✅ auto addr = std::format("{}:{}", host, port); // C++20 // or: auto addr = host + ":" + std::to_string(port);
cpp// ❌ out-parameter for multiple returns void compute(int input, int& result, std::string& error); // ✅ struct ComputeResult { int value; std::string error; }; ComputeResult compute(int input); // or: std::pair / std::tuple with structured bindings auto [value, error] = compute(input);
cpp// ❌ Manual loop to find element int idx = -1; for (int i = 0; i < vec.size(); i++) { if (vec[i] == target) { idx = i; break; } } // ✅ auto it = std::ranges::find(vec, target); // C++20 // or: std::find(vec.begin(), vec.end(), target);
cpp// ❌ Checking .find() != .end() then accessing auto it = map.find(key); if (it != map.end()) { use(it->second); } // ✅ (C++20) if (map.contains(key)) { use(map[key]); } // or keep iterator version when you need the value without double lookup
Use std::string_view for function parameters that don't need ownership.
cpp// ❌ Copying a large container into a function void process(std::vector<Data> items) { ... } // copies on call // ✅ — const ref for read, move for sink void process(const std::vector<Data>& items) { ... } // read-only void consume(std::vector<Data> items) { ... } // sink: caller moves in
cpp// ❌ std::move on const object (silently copies) const std::string s = "hello"; take(std::move(s)); // still copies // ✅ — don't const things you intend to move std::string s = "hello"; take(std::move(s));
cpp// ❌ Returning std::move from local (prevents NRVO) std::vector<int> build() { std::vector<int> v; // ... fill ... return std::move(v); // pessimization // ✅ — just return the local; compiler applies NRVO or implicit move return v; }
cpp// ❌ SFINAE soup template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>> T square(T x) { return x * x; } // ✅ (C++20 concepts) template<std::integral T> T square(T x) { return x * x; }
cpp// ❌ Template for one type template<typename T> void log(T msg) { std::cout << msg; } // Only ever called with std::string // ✅ — don't templatize unless you need multiple types void log(std::string_view msg) { std::cout << msg; }
Concepts make template errors readable — prefer them over SFINAE and static_assert.
cpp// ❌ Error codes via int returns (C-style in C++) int parse(const std::string& input, Data& out); // ✅ — std::expected (C++23) or exceptions std::expected<Data, ParseError> parse(const std::string& input); // or throw for exceptional conditions Data parse(const std::string& input); // throws ParseError
cpp// ❌ Catching by value (slices derived exceptions) try { ... } catch (std::exception e) { ... } // ✅ catch (const std::exception& e) { ... }
cpp// ❌ Exception in destructor ~MyClass() { if (cleanup() < 0) throw CleanupError(); // terminates // ✅ — destructors must be noexcept; log/swallow errors ~MyClass() noexcept { if (cleanup() < 0) log_error("cleanup failed"); }
cpp// ❌ Manual thread + join tracking std::thread t(work); // ... must remember t.join() ... // ✅ (C++20) std::jthread t(work); // auto-joins on destruction
cpp// ❌ Lock/unlock manually mtx.lock(); data.push_back(item); mtx.unlock(); // missed on exception // ✅ { std::scoped_lock lock(mtx); data.push_back(item); }
cpp// ❌ Polling a shared bool for completion while (!done.load()) { std::this_thread::sleep_for(10ms); } // ✅ — use std::future or condition_variable auto future = std::async(std::launch::async, compute); auto result = future.get();
Use std::scoped_lock over lock_guard — it handles multiple mutexes and avoids deadlock.
| Anti-pattern | Preferred | |---|---| | Raw new/delete | make_unique / make_shared | | (Type)expr C-style cast | static_cast<Type>(expr) | | #define constants | constexpr variables | | NULL | nullptr | | using namespace std; in headers | explicit std:: prefix | | Manual loop for transform/filter | std::ranges or <algorithm> | | std::endl | '\n' (endl flushes — slow) | | char* for string parameters | std::string_view | | Exception specification throw() | noexcept | | Inheriting from std:: containers | composition, not inheritance | | volatile for thread synchronization | std::atomic | | Header-only mega-templates | separate declaration/definition where compile time matters |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | pass→pass | 10,131 | 8,455 | -17% | 1 | 1 | 0% | 1,818 | 3,474 | +91% | 0 | 0 | — |
case-01 | fail→pass | 8,761 | 37,411 | +327% | 1 | 1 | 0% | 1,338 | 6,681 | +399% | 0 | 0 | — |
case-03 | pass→pass | 11,501 | 7,500 | -35% | 1 | 1 | 0% | 2,001 | 3,282 | +64% | 0 | 0 | — |
case-04 | pass→pass | 10,337 | 8,016 | -22% | 1 | 1 | 0% | 2,039 | 3,395 | +67% | 0 | 0 | — |
case-05 | fail→pass | 14,385 | 9,008 | -37% | 1 | 1 | 0% | 2,670 | 3,611 | +35% | 0 | 0 | — |
case-06 | pass→pass | 9,457 | 6,752 | -29% | 1 | 1 | 0% | 1,923 | 3,282 | +71% | 0 | 0 | — |
case-07 | pass→pass | 4,554 | 2,339 | -49% | 1 | 1 | 0% | 746 | 2,380 | +219% | 0 | 0 | — |
case-08 | pass→pass | 8,534 | 5,745 | -33% | 1 | 1 | 0% | 1,592 | 3,032 | +90% | 0 | 0 | — |
case-09 | pass→pass | 8,307 | 4,729 | -43% | 1 | 1 | 0% | 1,434 | 2,813 | +96% | 0 | 0 | — |
case-10 | pass→pass | 9,506 | 4,815 | -49% | 1 | 1 | 0% | 1,692 | 2,889 | +71% | 0 | 0 | — |
case-11 | pass→pass | 9,925 | 4,324 | -56% | 1 | 1 | 0% | 1,824 | 2,626 | +44% | 0 | 0 | — |
case-12 | pass→pass | 13,509 | 7,069 | -48% | 1 | 1 | 0% | 2,419 | 3,281 | +36% | 0 | 0 | — |
case-13 | pass→pass | 7,938 | 4,369 | -45% | 1 | 1 | 0% | 1,369 | 2,738 | +100% | 0 | 0 | — |
case-14 | pass→pass | 9,987 | 6,346 | -36% | 1 | 1 | 0% | 1,809 | 3,094 | +71% | 0 | 0 | — |
case-15 | pass→pass | 11,934 | 6,543 | -45% | 1 | 1 | 0% | 2,312 | 3,249 | +41% | 0 | 0 | — |
case-16 | pass→pass | 11,717 | 10,748 | -8% | 1 | 1 | 0% | 2,181 | 3,949 | +81% | 0 | 0 | — |
case-17 | pass→pass | 8,377 | 4,984 | -41% | 1 | 1 | 0% | 1,389 | 2,881 | +107% | 0 | 0 | — |
case-18 | pass→pass | 11,235 | 10,646 | -5% | 1 | 1 | 0% | 1,883 | 3,682 | +96% | 0 | 0 | — |
case-19 | pass→pass | 10,026 | 6,399 | -36% | 1 | 1 | 0% | 1,731 | 3,023 | +75% | 0 | 0 | — |
case-20 | pass→pass | 7,199 | 4,854 | -33% | 1 | 1 | 0% | 1,387 | 2,884 | +108% | 0 | 0 | — |
case-21 | pass→pass | 42,538 | 36,723 | -14% | 1 | 1 | 0% | 7,859 | 9,355 | +19% | 0 | 0 | — |
case-22 | pass→pass | 14,859 | 11,810 | -21% | 1 | 1 | 0% | 2,812 | 4,496 | +60% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.