cpp
Skill15 starsChanged 9 months agoMITView on GitHub
Google's official C++ style guide. Covers headers, naming conventions, formatting, classes, memory management, RAII, smart pointers, and modern C++ features.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- its-ash/skillstheir own version, first seen Nov 1, 2026
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Oct 13, 2026
- Mindrally/skillstheir own version, first seen Oct 8, 2026
- mordechai30/cpp_skillstheir own version, first seen Oct 8, 2026
- kimtth/agent-skill-100-lines-or-lesstheir own version, first seen Jun 26, 2026
Used with
Projects with it also use kotlin.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
margeloSkillkotlin
Design, implement, and review Kotlin and Android APIs. Use when working on .kt files, Kotlin nullability, sealed classes/interfaces, coroutines, Android threading, Java interop, or Kotlin-backed React Native Nitro Module implementations.
Also in 3 projects that use this
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- Mindrally/skills★ 275same name
- margelo/react-native-skills★ 172same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- G1Joshi/Agent-Skills★ 15same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- its-ash/skills★ 0same name
- mordechai30/cpp_skills★ 0same 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 repository17 other files it gives its agents.
- angularjsSkill
- common-lispSkill
- csharpSkill
- goSkill
- html-cssSkill
- javascriptSkill
- javaSkill
- jsonSkill
- markdownSkill
- objective-cSkill
- pythonSkill
- rSkill
- shellSkill
- google-styleguides-skillsSkill
- swiftSkill
- typescriptSkill
- vim-scriptSkill
The file
Files
Google C++ Style Guide
Official Google C++ coding standards for consistent, maintainable code.
Golden Rules
- Target C++20 — avoid non-standard extensions
- 80-character line limit — for readability
- 2-space indentation — no tabs
- Use
constliberally — for correctness and thread safety - Avoid exceptions — Google code doesn't use C++ exceptions
- Smart pointers for ownership —
std::unique_ptrandstd::shared_ptr - Header guards — use
PROJECT_PATH_FILE_H_format
Quick Reference
Naming Conventions
| Element | Convention | Example |
| Files | snake_case | url_table.cc, url_table.h |
| Classes/Structs | UpperCamelCase | UserService |
| Functions | UpperCamelCase | GetUserById |
| Variables | snake_case | user_count |
| Constants | kUpperCamelCase | kMaxRetries |
| Class members | snake_case_ | user_name_ (trailing _) |
| Macros | UPPER_SNAKE_CASE | MAX_BUFFER_SIZE |
Headers
// ✓ CORRECT - self-contained header with guard
#ifndef FOO_BAR_BAZ_H_
#define FOO_BAR_BAZ_H_
#include <string>
#include "base/basictypes.h"
class Baz {
public:
void DoSomething();
};
#endif // FOO_BAR_BAZ_H_Include order: related header → C system → C++ stdlib → other libs → your headers.
Classes
// ✓ CORRECT
class MyClass {
public:
explicit MyClass(int value); // explicit for single-arg ctors
~MyClass();
void DoSomething();
int GetValue() const { return value_; }
private:
int value_;
std::string name_;
};Smart Pointers
// ✓ CORRECT - unique_ptr for exclusive ownership
std::unique_ptr<Foo> FooFactory();
void FooConsumer(std::unique_ptr<Foo> ptr);
// ✓ CORRECT - shared_ptr for shared ownership
std::shared_ptr<const Foo> immutable_foo;
// ✗ INCORRECT - avoid raw new/delete
Foo* foo = new Foo(); // avoid
delete foo; // avoidModern C++ Features
// ✓ CORRECT - use auto for complex types
auto it = my_map.find(key);
auto widget = std::make_unique<Widget>(arg1, arg2);
// ✓ CORRECT - range-based for loops
for (const auto& item : container) {
Process(item);
}
// ✓ CORRECT - nullptr, not NULL
Foo* ptr = nullptr;
// ✓ CORRECT - constexpr for compile-time constants
constexpr int kArraySize = 100;Functions
// ✓ CORRECT - return type on same line
ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {
DoSomething();
return result;
}
// ✓ CORRECT - wrap long parameter lists (4-space indent)
ReturnType LongClassName::ReallyLongFunctionName(
Type par_name1,
Type par_name2,
Type par_name3) {
DoSomething();
}Formatting
// ✓ CORRECT - braces and spacing
if (condition) {
DoSomething();
} else {
DoSomethingElse();
}
// ✓ CORRECT - pointer/reference alignment (attached to type)
char* c;
const std::string& str;Common Mistakes
| Mistake | Correct Approach |
| Using exceptions | Use error codes or absl::Status |
Bare new/delete | Use smart pointers (unique_ptr) |
NULL or 0 for null | Use nullptr |
| C-style casts | Use C++ casts (static_cast, etc.) |
using namespace std | Never in headers; avoid in .cc |
| Mutable global variables | Use singletons or dependency injection |
Missing explicit | Mark single-arg constructors explicit |
When to Use This Guide
- Writing new C++ code
- Refactoring existing C++
- Code reviews
- Setting up clang-format rules
- Onboarding new team members
Install
npx skills add testdino-hq/google-styleguides-skills/cppFull Guide
See cpp.md for complete details, examples, and edge cases.
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.

