Skip to content
Skills Library
Programming · Review & audit

google-cpp-style

/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.

Repository
pg_stat_ch ↗
Licence
Apache-2.0
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
9
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

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.

Original author description

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.

How it works

  1. Quick Reference
  2. Core Principles
  3. Target Version
  4. Detailed References
  5. Common Patterns
  6. Critical Rules Summary
Original SKILL.md headings · 138 lines, 466 words
SKILL.md preview
---
name: google-cpp-style
description: 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.
---

# 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

1. **Optimize for the reader** - Code is read more than written
2. **Be consistent** - Follow existing patterns in the codebase
3. **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](headers.md) - Include guards, ordering, forward declarations
- [Scoping](scoping.md) - Namespaces, linkage, static/global variables
- [Classes](classes.md) - Constructors, inheritance, operator overloading
- [Functions](functions.md) - Parameters, overloading, default arguments
- [C++ Features](features.md) - Smart pointers, exceptions, RTTI, lambdas
- [Naming](naming.md) - All naming conventions with examples
- [Comments](comments.md) - Documentation style and requirements
- [Formatting](formatting.md) - Whitespace, braces, line length

## Common Patterns

### Header File Template

```cpp
#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

```cpp
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

```cpp
// 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 `#define` guards in all headers
- Make single-argument constructors `explicit`
- Use `nullptr` (not `NULL` or `0`) for pointers
- Use `override` or `final` for virtual function overrides
- Declare data members `private`
- Initialize variables at declaration

### Never Do

- Use `using namespace` directives
- 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` (use `std::unique_ptr`)
Files in this package (9)
  • SKILL.md 4 KB
  • classes.md 4 KB
  • comments.md 4 KB
  • features.md 5 KB
  • formatting.md 6 KB
  • functions.md 3 KB
  • headers.md 2 KB
  • naming.md 4 KB
  • scoping.md 4 KB

Versions

The database has no other skills named google-cpp-style.

Database snapshot: 13.11.2026 · package version f3e776e7dcdc (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100js-google
    JavaScript style and best practices based on Google's official JavaScript Style Guide. This skill should be used when writing, reviewing, or refactoring JavaScript code to ensure consistent style and prevent common bugs. Triggers on tasks involving JavaScript, ES6, modules,…
  • 100cpp-naming-check
    Check C++ naming conventions against Google Style Guide. Use when checking if names follow conventions or when renaming identifiers.
  • 100cpp-review
    Review C++ code against Google C++ Style Guide. Use when reviewing C++ code, pull requests, or when asked to check code style compliance.
  • 90google-ts-styleguide
    Google TypeScript Style Guide reference for writing, reviewing, and refactoring TypeScript code. Use this skill whenever you are writing TypeScript code, reviewing TypeScript code, refactoring TypeScript, configuring ESLint or linter rules for TypeScript, or when the user asks…
  • 95cpp-style
    Applies C++ coding conventions when writing, reviewing, or refactoring code. Covers .h, .hpp, and .cpp files, Doxygen documentation, naming, formatting, error handling, includes, file ordering, template patterns, embedded (Arduino/PlatformIO) conventions, and Python C++…
  • 100python-code-style
    Python code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.