google-cpp-style
Skill129 starsChanged 8 months agoApache-2.0View on GitHub
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.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- UMU618/skillstheir own version, first seen Oct 11, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- UMU618/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- cpp-header-templateSkill
- cpp-naming-checkSkill
- cpp-reviewSkill
- create-new-releaseSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Be consistent: - Follow existing patterns in the codebase
- Distinctive: line 23
Avoid surprising constructs: - Prefer clear over clever
- Very specific: line 127
Use #define guards in all headers
- Very specific: line 129
Use nullptr (not NULL or 0) for pointers
- Very specific: line 130
Use override or final for virtual function overrides
- Very specific: line 137
Use C-style casts (use static_cast, etc.)
- Distinctive: line 138
Use exceptions (in Google code)
- Very specific: line 141
Use std::auto_ptr (use std::unique_ptr)
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Google C++ Style Guide
This skill provides the complete Google C++ Style Guide for C++20. Apply these rules when writing or reviewing C++ code.
Quick Reference
| 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 |
Core Principles
- Optimize for the reader - Code is read more than written
- Be consistent - Follow existing patterns in the codebase
- Avoid surprising constructs - Prefer clear over clever
Target Version
Code should target C++20. Do not use C++23 features or non-standard extensions.
Detailed References
For complete rules on specific topics:
- Header Files - Include guards, ordering, forward declarations
- Scoping - Namespaces, linkage, static/global variables
- Classes - Constructors, inheritance, operator overloading
- Functions - Parameters, overloading, default arguments
- C++ Features - Smart pointers, exceptions, RTTI, lambdas
- Naming - All naming conventions with examples
- Comments - Documentation style and requirements
- Formatting - Whitespace, braces, line length
Common Patterns
Header File Template
#ifndef PROJECT_PATH_FILE_H_
#define PROJECT_PATH_FILE_H_
#include "project/public/header.h"
#include <sys/types.h>
#include <string>
#include <vector>
#include "other/library.h"
#include "project/internal.h"
namespace project {
class MyClass {
public:
MyClass();
explicit MyClass(int value);
void DoSomething();
int count() const { return count_; }
void set_count(int count) { count_ = count; }
private:
int count_;
};
} // namespace project
#endif // PROJECT_PATH_FILE_H_Class Declaration Order
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_;
};Function Comments
// 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;Critical Rules Summary
Always Do
- Use
#defineguards in all headers - Make single-argument constructors
explicit - Use
nullptr(notNULLor0) for pointers - Use
overrideorfinalfor virtual function overrides - Declare data members
private - Initialize variables at declaration
Never Do
- Use
using namespacedirectives - Use C-style casts (use
static_cast, etc.) - Use exceptions (in Google code)
- Use non-standard extensions
- Define macros in headers (when possible)
- Use
std::auto_ptr(usestd::unique_ptr)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

