programming-cpp-naming-rules
Skill5 starsChanged 16 days agoMITView on GitHub
C++ file and class naming conventions - folder structure matches namespaces, no redundant prefixes
In this repository50 other files it gives its agents.
- analyze-pr-commentsSkill
- architecture-analyzeSkill
- architecture-tradeoffSkill
- askSkill
- code-smellsSkill
- debugging-rocprof-sysSkill
- exploration-explore-codeSkill
- git-commitSkill
- git-gh-clientSkill
- git-prepare-pull-requestSkill
- git-pull-request-statusSkill
- gitSkill
- grill-meSkill
- library-amd-smiSkill
- notify-meSkill
- planning-architectureSkill
- planning-baseSkill
- planning-bugfixSkill
- planning-docsSkill
- planning-featureSkill
- planning-refactorSkill
- programming-cmake-best-practicesSkill
- programming-cpp-constexprSkill
- programming-cpp-design-patternsSkill
- programming-cpp-policy-based-diSkill
- programming-cppSkill
- programming-cpp-stl-algorithmsSkill
- programming-pythonSkill
- pr-review-interactiveSkill
- pr-reviewSkill
- radisha-create-skillSkill
- radisha-helpSkill
- radisha-improve-skillSkill
- radisha-skillsSkill
- radisha-updateSkill
- refactoring-techniquesSkill
- review-architectureSkill
- rocprofsys-buildSkill
- rocprofsys-configureSkill
- rocprofsysSkill
- static-analysisSkill
- testing-gtest-gmockSkill
- testing-pytestSkill
- testing-testplanSkill
- therock-build-to-commitSkill
- therock-commit-in-buildSkill
- therock-first-build-with-commitSkill
- update-pr-descriptionSkill
- verify-pmc-metricsSkill
- watchSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when creating new C++ files or refactoring file structure.
- Very specific: line 28
No redundant prefixes: If file is in amd_smi/, don't name it amd_smi_driver.hpp - use driver.hpp
- Distinctive: line 44
Use nested namespace syntax when declaring:
- Distinctive: line 84
Folder = namespace context: - don't repeat it in filenames
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
C++ Naming Rules
Use this skill when creating new C++ files or refactoring file structure.
Folder Structure = Namespace
Folder structure should correspond to namespaces. Don't repeat namespace prefixes in filenames.
// ❌ BAD: amd_smi/amd_smi_driver.hpp
namespace amd_smi {
class amd_smi_driver {}; // Redundant prefix
}
// ✅ GOOD: amd_smi/driver.hpp
namespace amd_smi {
class driver {}; // Clean, folder provides context
}Rules
- No redundant prefixes: If file is in
amd_smi/, don't name itamd_smi_driver.hpp- usedriver.hpp - Namespace = folder path:
foo/bar/baz.hpp→namespace foo::bar { class baz {} } - Class name = file name:
driver.hppcontainsclass driverorstruct driver - One class per file (when practical): Easier to find and maintain
Examples
| Folder Path | File Name | Namespace | Class/Struct |
amd_smi/ | driver.hpp | amd_smi | driver |
amd_smi/gpu/ | metrics.hpp | amd_smi::gpu | metrics |
core/utils/ | string_helper.hpp | core::utils | string_helper |
network/http/ | client.hpp | network::http | client |
Nested Namespaces (C++17)
Use nested namespace syntax when declaring:
// ✅ GOOD: C++17 nested namespace
namespace network::http {
class client {
// ...
};
} // namespace network::http
// ❌ AVOID: Old style (more verbose)
namespace network {
namespace http {
class client {
// ...
};
} // namespace http
} // namespace networkInclude Guards / #pragma once
Match the full path in include guards:
// File: amd_smi/gpu/metrics.hpp
#pragma once // Preferred
// OR traditional include guard matching full path:
#ifndef AMD_SMI_GPU_METRICS_HPP
#define AMD_SMI_GPU_METRICS_HPP
// ...
#endif // AMD_SMI_GPU_METRICS_HPPSummary
- Folder = namespace context - don't repeat it in filenames
- Filename = class name - easy to find
- Path tells the full story:
project/module/submodule/class.hpp
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.

