Table of content
Advanced C++ programming skills for modern C++ and template metaprogramming
Installation
npx claude-plugins install @TheBushidoCollective/han/jutsu-cpp
Contents
Folders: cpp-modern-features, cpp-smart-pointers, cpp-templates-metaprogramming, scripts, skills
Files: CHANGELOG.md, README.md
Documentation
Advanced C++ programming skills for modern C++ and template metaprogramming
Skills
This plugin provides the following skills:
- Cpp Modern Features
- Cpp Smart Pointers
- Cpp Templates Metaprogramming
Usage
Once enabled, Claude will automatically apply these skills when working with relevant code. The plugin provides context and expertise that Claude uses to:
- Write idiomatic code following best practices
- Suggest appropriate patterns and architectures
- Catch common mistakes and anti-patterns
- Provide framework-specific guidance
Installation
Install with npx (no installation required):
han plugin install jutsu-cpp
License
Licensed under MIT - see repository for details.
Included Skills
This plugin includes 3 skill definitions:
cpp-modern-features
Use when working with modern C++ codebases requiring features from C++11 to C++23 including lambdas, move semantics, ranges, and concepts.
View skill definition
C++ Modern Features
Master modern C++ features from C++11 through C++23, including lambdas, move semantics, ranges, concepts, and compile-time evaluation. This skill enables you to write efficient, expressive, and maintainable modern C++ code.
C++11 Features
Auto Type Deduction
The auto keyword enables automatic type inference, reducing verbosity and
improving maintainability:
// Traditional
std::vector<int>::iterator it = vec.begin();
std::map<std::string, std::vector<int>>::const_iterator map_it = mymap.find("key");
// Modern C++11
auto it = vec.begin();
auto map_it = mymap.find("key");
// Auto with initialization
auto value = 42; // int
auto pi = 3.14; // double
auto name = std::string("Alice"); // std::string
auto lambda = [](int x) { return x * 2; }; // lambda type
Range-Based For Loops
Simplified iteration over containers and arrays:
std::vector<int> numbers = {1, 2, 3, 4, 5};
// Traditional loop
for (std::vector<int>::iterator it = numbers.begin(); it != numbers.end(); ++it) {
std::cout << *it << " ";
}
// Range-based for (C++11)
for (int num : numbers) {
std::cout << num << " ";
}
// With references to modify elements
for (int& num : numbers) {
num *= 2;
}
// With const references for efficiency
for (const auto& str : string_vector) {
process(str);
}
Lambda Expressions
Anonymous functions with capture capabilities:
// Basic lambda
auto add = [](int a, int b) { re
...(truncated)
</details>
### cpp-smart-pointers
> Use when managing memory safely in C++ with smart pointers including unique_ptr, shared_ptr, weak_ptr, and RAII patterns.
<details>
<summary>View skill definition</summary>
# C++ Smart Pointers and RAII
Master C++ smart pointers and Resource Acquisition Is Initialization (RAII)
patterns for automatic, exception-safe resource management. This skill covers
unique_ptr, shared_ptr, weak_ptr, custom deleters, and best practices for
modern C++ memory management.
## RAII Principles
Resource Acquisition Is Initialization is a fundamental C++ idiom where
resource lifetime is tied to object lifetime.
### Core Concept
```cpp
// Bad: Manual resource management
void process_file_bad() {
FILE* file = fopen("data.txt", "r");
if (!file) return;
// ... process file ...
// If exception occurs, file never closed!
fclose(file);
}
// Good: RAII with smart pointer
void process_file_good() {
auto deleter = [](FILE* f) { if (f) fclose(f); };
std::unique_ptr<FILE, decltype(deleter)> file(fopen("data.txt", "r"), deleter);
if (!file) return;
// ... process file ...
// File automatically closed when unique_ptr destroyed
}
// Even better: Custom RAII wrapper
class FileHandle {
FILE* file;
public:
explicit FileHandle(const char* filename, const char* mode)
: file(fopen(filename, mode)) {
if (!file) throw std::runtime_error("Failed to open file");
}
~FileHandle() {
if (file) fclose(file);
}
// Delete copy operations
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
// Allow move operations
FileHandle(FileHandle&& other)
...(truncated)
</details>
### cpp-templates-metaprogramming
> Use when creating generic and type-safe C++ libraries with templates, SFINAE, concepts, and compile-time metaprogramming.
<details>
<summary>View skill definition</summary>
# C++ Templates and Metaprogramming
Master C++ templates, template metaprogramming, SFINAE, concepts, and
compile-time computation. This skill enables you to create generic, type-safe,
and highly efficient C++ libraries with compile-time guarantees.
## Function Templates
### Basic Function Templates
```cpp
// Simple function template
template<typename T>
T max(T a, T b) {
return (a > b) ? a : b;
}
// Usage
int i = max(10, 20); // T = int
double d = max(3.14, 2.71); // T = double
// auto x = max(10, 3.14); // ERROR: can't deduce T
// Multiple template parameters
template<typename T, typename U>
auto add(T a, U b) -> decltype(a + b) {
return a + b;
}
auto result = add(5, 3.14); // T = int, U = double, returns double
// C++14: simpler return type deduction
template<typename T, typename U>
auto multiply(T a, U b) {
return a * b;
}
Template Specialization
// Primary template
template<typename T>
T absolute(T value) {
return (value < 0) ? -value : value;
}
// Full specialization for const char*
template<>
const char* absolute<const char*>(const char* value) {
return value; // Strings don't have absolute value
}
// Full specialization for std::string
template<>
std::string absolute<std::string>(std::string value) {
return value;
}
// Usage
int a = absolute(-5); // Uses primary template
const char* b = absolute("test"); // Uses const char* specialization
Function Template Overloading
...(truncated)
</details>
## Source
[View on GitHub](https://github.com/TheBushidoCollective/han)