npx skills add ...
npx skills add clickhouse/pg_stat_ch --skill google-cpp-style
npx skills add clickhouse/pg_stat_ch --skill google-cpp-style
Google C++ Style Guide rules for writing clean, maintainable C++ code. Use when writing C++, reviewing code, discussing naming conventions, formatting, class design, or any C++ best practices. Covers headers, scoping, classes, functions, naming, comments, and formatting.
This skill provides the complete Google C++ Style Guide for C++20. Apply these rules when writing or reviewing C++ code.
| Topic | Key Rules |
|---|---|
| Naming | Types: PascalCase, functions: PascalCase, variables: snake_case, constants: kPascalCase, macros: UPPER_CASE |
| Formatting | 80 char lines, 2-space indent, spaces (not tabs), { on same line |
| Headers | Self-contained, #define guards, include what you use |
| Classes | Prefer composition over inheritance, explicit constructors, private data members |
Code should target C++20. Do not use C++23 features or non-standard extensions.
For complete rules on specific topics:
#define guards in all headersexplicitnullptr (not NULL or 0) for pointersoverride or final for virtual function overridesprivateusing namespace directivesstatic_cast, etc.)std::auto_ptr (use std::unique_ptr)class MyClass {
public:
// Types and type aliases
using ValueType = int;
// Static constants
static constexpr int kMaxSize = 100;
// Constructors and assignment
MyClass();
MyClass(const MyClass&) = default;
MyClass& operator=(const MyClass&) = default;
// Destructor
~MyClass();
// All other methods
void Process();
protected:
// Protected members (if needed)
private:
// Private methods
void InternalHelper();
// Data members
int value_;
};// Returns an iterator positioned at the first entry >= `start_word`.
// Returns nullptr if no such entry exists.
// The client must not use the iterator after the table is destroyed.
std::unique_ptr<Iterator> GetIterator(absl::string_view start_word) const;