cpp-header-template
Skill129 starsChanged 8 months agoApache-2.0View on GitHub
Generate C++ header files following Google Style Guide. Use when creating new header files or asking for a header template.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- cpp-naming-checkSkill
- cpp-reviewSkill
- create-new-releaseSkill
- google-cpp-styleSkill
The file
Files
C++ Header File Template Generator
Generate header files following Google C++ Style Guide conventions.
Usage
Provide: class name, namespace, and file path to generate a compliant header.
Template
// Copyright [year] [copyright holder]
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
#ifndef [PROJECT]_[PATH]_[FILENAME]_H_
#define [PROJECT]_[PATH]_[FILENAME]_H_
// C system headers (if needed)
// #include <sys/types.h>
// C++ standard library headers
#include <memory>
#include <string>
#include <vector>
// Other library headers
// #include "other/library.h"
// Project headers
// #include "project/base.h"
namespace [namespace] {
// Forward declarations (avoid when possible)
/// Brief description of the class.
///
/// Detailed description if needed. Include:
/// - Purpose and responsibilities
/// - Thread safety guarantees
/// - Example usage (for complex classes)
class [ClassName] {
public:
// Types and type aliases
using ValueType = int;
// Static constants
static constexpr int kDefaultSize = 100;
// Factory functions (if needed)
static std::unique_ptr<[ClassName]> Create();
// Constructors
[ClassName]();
explicit [ClassName](int value);
// Rule of five - be explicit about copy/move
[ClassName](const [ClassName]&) = default;
[ClassName]& operator=([const ClassName]&) = default;
[ClassName]([ClassName]&&) noexcept = default;
[ClassName]& operator=([ClassName]&&) noexcept = default;
// Destructor
~[ClassName]();
// Public methods
void Process();
// Accessors and mutators
int value() const { return value_; }
void set_value(int value) { value_ = value; }
protected:
// Protected members (only if needed for inheritance)
private:
// Private methods
void InternalHelper();
// Data members (always private for classes)
int value_ = 0;
std::string name_;
};
} // namespace [namespace]
#endif // [PROJECT]_[PATH]_[FILENAME]_H_Include Guard Format
Convert path to uppercase with underscores:
| File Path | Guard |
foo/bar/baz.h | FOO_BAR_BAZ_H_ |
src/http/parser.h | SRC_HTTP_PARSER_H_ |
my_project/utils.h | MY_PROJECT_UTILS_H_ |
Struct Template
For passive data with public members and no invariants:
namespace [namespace] {
/// Brief description.
struct [StructName] {
int field_one; // No trailing underscore for structs
std::string field_two;
float field_three = 0.0f; // Default values OK
};
} // namespace [namespace]Include Order
- Related header (for
.ccfiles) - Blank line
- C system headers (
<unistd.h>) - Blank line
- C++ standard library (
<string>,<vector>) - Blank line
- Other libraries
- Blank line
- Project headers
Each section sorted alphabetically.
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.

