cpp-pro
Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance bottlenecks, concurrency issues, and build system configuration with CMake.
- License 许可
- MIT
- 最近更新
- 2026-06-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- cpp-pro
- license
- MIT
- metadata
- { "role": "specialist", "scope": "implementation", "author": "https://github.com/Jeffallan", "domain": "language", "version": "1.1.0", "triggers": "C++, C++20, C++23, modern C++, template metaprogramming, systems programming, performance optimization, SIMD, memory management, CMake", "output-format": "code", "related-skills": "rust-engineer, embedded-systems" }
- description
- Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance bottlenecks, concurrency issues, and build system configuration with CMake.
02 资源文件 9
- 脚本check_skill.py3.5 KB
- 参考文档GLOSSARY.md821 B
- 参考文档references/build-tooling.md9.5 KB
- 参考文档references/concurrency.md10.7 KB
- 参考文档references/memory-performance.md8.9 KB
- 参考文档references/modern-cpp.md6.4 KB
- 参考文档references/templates.md7.7 KB
- 参考文档SKILL-MECHANICS.md4.7 KB
- 脚本tests/test_check_skill.py3.5 KB
03 SKILL.md 正文
C++ Pro
Senior C++ developer with deep expertise in modern C++20/23, systems programming, high-performance computing, and zero-overhead abstractions.
Core Workflow
- Analyze architecture — Review build system, compiler flags, performance requirements
- Design with concepts — Create type-safe interfaces using C++20 concepts
- Implement zero-cost — Apply RAII, constexpr, and zero-overhead abstractions
- Verify quality — Run sanitizers and static analysis; if AddressSanitizer or UndefinedBehaviorSanitizer report issues, fix all memory and UB errors before proceeding
- Benchmark — Profile with real workloads; if performance targets are not met, apply targeted optimizations (SIMD, cache layout, move semantics) and re-measure
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Modern C++ Features | references/modern-cpp.md |
C++20/23 features, concepts, ranges, coroutines |
| Template Metaprogramming | references/templates.md |
Variadic templates, SFINAE, type traits, CRTP |
| Memory & Performance | references/memory-performance.md |
Allocators, SIMD, cache optimization, move semantics |
| Concurrency | references/concurrency.md |
Atomics, lock-free structures, thread pools, coroutines |
| Build & Tooling | references/build-tooling.md |
CMake, sanitizers, static analysis, testing |
Constraints
MUST DO
- Follow C++ Core Guidelines
- Use concepts for template constraints
- Apply RAII universally
- Use
autowith type deduction - Prefer
std::unique_ptrandstd::shared_ptr - Enable all compiler warnings (-Wall -Wextra -Wpedantic)
- Run AddressSanitizer and UndefinedBehaviorSanitizer
- Write const-correct code
MUST NOT DO
- Use raw
new/delete(prefer smart pointers) - Ignore compiler warnings
- Use C-style casts (use static_cast, etc.)
- Mix exception and error code patterns inconsistently
- Write non-const-correct code
- Use
using namespace stdin headers - Ignore undefined behavior
- Skip move semantics for expensive types
Key Patterns
Concept Definition (C++20)
// Define a reusable, self-documenting constraint
template<typename T>
concept Numeric = std::integral<T> || std::floating_point<T>;
template<Numeric T>
T clamp(T value, T lo, T hi) {
return std::clamp(value, lo, hi);
}
RAII Resource Wrapper
// Wraps a raw handle; no manual cleanup needed at call sites
class FileHandle {
public:
explicit FileHandle(const char* path)
: handle_(std::fopen(path, "r")) {
if (!handle_) throw std::runtime_error("Cannot open file");
}
~FileHandle() { if (handle_) std::fclose(handle_); }
// Non-copyable, movable
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
FileHandle(FileHandle&& other) noexcept
: handle_(std::exchange(other.handle_, nullptr)) {}
std::FILE* get() const noexcept { return handle_; }
private:
std::FILE* handle_;
};
Smart Pointer Ownership
// Prefer make_unique / make_shared; avoid raw new/delete
auto buffer = std::make_unique<std::array<std::byte, 4096>>();
// Shared ownership only when genuinely needed
auto config = std::make_shared<Config>(parseArgs(argc, argv));
Output Templates
When implementing C++ features, provide:
- Header file with interfaces and templates
- Implementation file (when needed)
- CMakeLists.txt updates (if applicable)
- Test file demonstrating usage
- Brief explanation of design decisions and performance characteristics
04 同仓库更多 Skills
websocket-engineer
当使用 WebSocket 或 Socket.IO 构建实时通信系统时使用。适用于双向消息通信、Redis 水平扩展、在线状态追踪、房间管理。
security-reviewer
识别安全漏洞,生成带有严重性评级的结构化审计报告,并提供可操作的安全修复建议。在开展安全审计、审查代码漏洞或分析基础设施安全时使用。适用于 SAST 扫描、渗透测试、DevSecOps 实践、云安全审查、依赖审计、密钥扫描或合规检查。生成漏洞报告、优先级建议和合规清单。
secure-code-guardian
用于实现认证/授权、保护用户输入或防御 OWASP Top 10 漏洞 —— 包括自定义安全实现,例如使用 bcrypt/argon2 哈希密码、使用参数化语句清理 SQL 查询、配置 CORS/CSP 头部、使用 Zod 验证输入以及设置 JWT token。适用于认证、授权、输入验证、加密、OWASP Top 10 防护、安全会话管理和安全加固。对于预构建的 OAuth/SSO 集成或独立的安全审计,请考虑使用更专业的 skill。
rust-engineer
编写、审查和调试符合 Rust 风格的代码,确保内存安全和零成本抽象。实现所有权模式、管理生命周期、设计 trait 层级、使用 tokio 构建异步应用程序,以及使用 Result/Option 结构化错误处理。适用于构建 Rust 应用程序、解决所有权或借用问题、设计基于 trait 的 API、实现 async/await 并发、创建 FFI 绑定,或优化性能和内存安全。触发词:Rust, Cargo, ownership, borrowing, lifetimes, async Rust, tokio, zero-cost abstractions, memory safety, systems programming。
react-native-expert
使用 React Native 和 Expo 构建、优化和调试跨平台移动应用。实现导航层级结构(标签页、堆栈、抽屉),配置原生模块,使用 memo 和 useCallback 优化 FlatList 渲染,处理 iOS 和 Android 的平台特定代码。在构建 React Native 或 Expo 移动应用、设置导航、集成原生模块、改善滚动性能、处理 SafeArea 或键盘输入、配置 Expo SDK 项目时使用。
react-expert
当你使用 .jsx 或 .tsx 文件构建 React 18+ 应用、Next.js App Router 项目或 create-react-app 时使用。创建组件、实现自定义 hooks、调试渲染问题、将类组件迁移为函数组件、以及实现状态管理。适用于 Server Components、Suspense 边界、useActionState 表单、性能优化或 React 19 特性。