Cpp Coding Standards
xu-xiang/everything-claude-code-zh
基于 C++ 核心指南 (isocpp.github.io) 的 C++ 编码规范。在编写、评审或重构 C++ 代码时使用,以强制执行现代、安全且地道的实践。
基于C++核心指南(isocpp.github.io)的C++编码标准。在编写、审查或重构C++代码时使用,以强制实施现代、安全和惯用的实践。
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install affaan-m/ECC cpp-coding-standards --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .claude/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .claude/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standardsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install affaan-m/ECC cpp-coding-standards --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .agents/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .agents/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .agents/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install affaan-m/ECC cpp-coding-standards --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .cursor/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .cursor/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/affaan-m/ECC.git --path docs/zh-CN/skills/cpp-coding-standards--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install affaan-m/ECC cpp-coding-standards --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .gemini/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .gemini/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install affaan-m/ECC cpp-coding-standardsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .github/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .github/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .github/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add affaan-m/ECC --skill cpp-coding-standards -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install affaan-m/ECC cpp-coding-standards --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/docs/zh-CN/skills/cpp-coding-standards .opencode/skills/cpp-coding-standards && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "cpp-coding-standards" agent skill from https://github.com/affaan-m/ECC/tree/main/docs/zh-CN/skills/cpp-coding-standards into .opencode/skills/cpp-coding-standards/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "cpp-coding-standards", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
cpp-coding-standards基于C++核心指南(isocpp.github.io)的C++编码标准。在编写、审查或重构C++代码时使用,以强制实施现代、安全和惯用的实践。
Cpp Coding Standards is an agent skill from affaan-m/ECC. 基于C++核心指南(isocpp.github.io)的C++编码标准。在编写、审查或重构C++代码时使用,以强制实施现代、安全和惯用的实践。
Its SKILL.md is about 4.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Development, covering Code quality. It works with C++ and GitHub. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.
6 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit ef648e0. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp).
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
isocpp.github.ioFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Cpp Coding Standards loads about 4.2k tokens when it runs. Until then it costs about 23 tokens; SKILL.md has 690 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from affaan-m/ECC at commit ef648e0, republished under its MIT licence (© affaan-m). 690 words, ~4,183 tokens.
.claude/skills/cpp-coding-standards/SKILL.md (or your agent's skills folder).源自 C++ 核心准则 的现代 C++(C++17/20/23)综合编码标准。强制执行类型安全、资源安全、不变性和清晰性。
enum 对比 enum class,原始指针对比智能指针)这些主题在整个准则中反复出现,并构成了基础:
const/constexpr 开始;可变性是例外| 规则 | 摘要 |
|---|---|
| P.1 | 直接在代码中表达想法 |
| P.3 | 表达意图 |
| P.4 | 理想情况下,程序应是静态类型安全的 |
| P.5 | 优先编译时检查而非运行时检查 |
| P.8 | 不要泄漏任何资源 |
| P.10 | 优先不可变数据而非可变数据 |
| I.1 | 使接口明确 |
| I.2 | 避免非 const 全局变量 |
| I.4 | 使接口精确且强类型化 |
| I.11 | 切勿通过原始指针或引用转移所有权 |
| I.23 | 保持函数参数数量少 |
// P.10 + I.4: Immutable, strongly typed interface
struct Temperature {
double kelvin;
};
Temperature boil(const Temperature& water);// Weak interface: unclear ownership, unclear units
double boil(double* temp);
// Non-const global variable
int g_counter = 0; // I.2 violation| 规则 | 摘要 |
|---|---|
| F.1 | 将有意义的操作打包为精心命名的函数 |
| F.2 | 函数应执行单一逻辑操作 |
| F.3 | 保持函数简短简单 |
| F.4 | 如果函数可能在编译时求值,则将其声明为 constexpr |
| F.6 | 如果你的函数绝不能抛出异常,则将其声明为 noexcept |
| F.8 | 优先纯函数 |
| F.16 | 对于 "输入" 参数,按值传递廉价可复制类型,其他类型通过 const& 传递 |
| F.20 | 对于 "输出" 值,优先返回值而非输出参数 |
| F.21 | 要返回多个 "输出" 值,优先返回结构体 |
| F.43 | 切勿返回指向局部对象的指针或引用 |
// F.16: Cheap types by value, others by const&
void print(int x); // cheap: by value
void analyze(const std::string& data); // expensive: by const&
void transform(std::string s); // sink: by value (will move)
// F.20 + F.21: Return values, not output parameters
struct ParseResult {
std::string token;
int position;
};
ParseResult parse(std::string_view input); // GOOD: return struct
// BAD: output parameters
void parse(std::string_view input,
std::string& token, int& pos); // avoid this// F.4 + F.8: Pure, constexpr where possible
constexpr int factorial(int n) noexcept {
return (n <= 1) ? 1 : n * factorial(n - 1);
}
static_assert(factorial(5) == 120);T&& (F.45)va_arg / C 风格可变参数 (F.55)const T,这会抑制移动语义 (F.49)| 规则 | 摘要 |
|---|---|
| C.2 | 如果存在不变式,使用 class;如果数据成员独立变化,使用 struct |
| C.9 | 最小化成员的暴露 |
| C.20 | 如果你能避免定义默认操作,就这么做(零规则) |
| C.21 | 如果你定义或 =delete 任何拷贝/移动/析构函数,则处理所有(五规则) |
| C.35 | 基类析构函数:公开虚函数或受保护非虚函数 |
| C.41 | 构造函数应创建完全初始化的对象 |
| C.46 | 将单参数构造函数声明为 explicit |
| C.67 | 多态类应禁止公开拷贝/移动 |
| C.128 | 虚函数:精确指定 virtual、override 或 final 中的一个 |
// C.20: Let the compiler generate special members
struct Employee {
std::string name;
std::string department;
int id;
// No destructor, copy/move constructors, or assignment operators needed
};// C.21: If you must manage a resource, define all five
class Buffer {
public:
explicit Buffer(std::size_t size)
: data_(std::make_unique<char[]>(size)), size_(size) {}
~Buffer() = default;
Buffer(const Buffer& other)
: data_(std::make_unique<char[]>(other.size_)), size_(other.size_) {
std::copy_n(other.data_.get(), size_, data_.get());
}
Buffer& operator=(const Buffer& other) {
if (this != &other) {
auto new_data = std::make_unique<char[]>(other.size_);
std::copy_n(other.data_.get(), other.size_, new_data.get());
data_ = std::move(new_data);
size_ = other.size_;
}
return *this;
}
Buffer(Buffer&&) noexcept = default;
Buffer& operator=(Buffer&&) noexcept = default;
private:
std::unique_ptr<char[]> data_;
std::size_t size_;
};// C.35 + C.128: Virtual destructor, use override
class Shape {
public:
virtual ~Shape() = default;
virtual double area() const = 0; // C.121: pure interface
};
class Circle : public Shape {
public:
explicit Circle(double r) : radius_(r) {}
double area() const override { return 3.14159 * radius_ * radius_; }
private:
double radius_;
};memset/memcpy (C.90)const 或引用,这会抑制移动/拷贝 (C.12)| 规则 | 摘要 |
|---|---|
| R.1 | 使用 RAII 自动管理资源 |
| R.3 | 原始指针 (T*) 是非拥有的 |
| R.5 | 优先作用域对象;不要不必要地在堆上分配 |
| R.10 | 避免 malloc()/free() |
| R.11 | 避免显式调用 new 和 delete |
| R.20 | 使用 unique_ptr 或 shared_ptr 表示所有权 |
| R.21 | 除非共享所有权,否则优先 unique_ptr 而非 shared_ptr |
| R.22 | 使用 make_shared() 来创建 shared_ptr |
// R.11 + R.20 + R.21: RAII with smart pointers
auto widget = std::make_unique<Widget>("config"); // unique ownership
auto cache = std::make_shared<Cache>(1024); // shared ownership
// R.3: Raw pointer = non-owning observer
void render(const Widget* w) { // does NOT own w
if (w) w->draw();
}
render(widget.get());// R.1: Resource acquisition is initialization
class FileHandle {
public:
explicit FileHandle(const std::string& path)
: handle_(std::fopen(path.c_str(), "r")) {
if (!handle_) throw std::runtime_error("Failed to open: " + path);
}
~FileHandle() {
if (handle_) std::fclose(handle_);
}
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
FileHandle(FileHandle&& other) noexcept
: handle_(std::exchange(other.handle_, nullptr)) {}
FileHandle& operator=(FileHandle&& other) noexcept {
if (this != &other) {
if (handle_) std::fclose(handle_);
handle_ = std::exchange(other.handle_, nullptr);
}
return *this;
}
private:
std::FILE* handle_;
};new/delete (R.11)malloc()/free() (R.10)unique_ptr 足够时使用 shared_ptr (R.21)| 规则 | 摘要 |
|---|---|
| ES.5 | 保持作用域小 |
| ES.20 | 始终初始化对象 |
| ES.23 | 优先 {} 初始化语法 |
| ES.25 | 除非打算修改,否则将对象声明为 const 或 constexpr |
| ES.28 | 使用 lambda 进行 const 变量的复杂初始化 |
| ES.45 | 避免魔法常量;使用符号常量 |
| ES.46 | 避免有损的算术转换 |
| ES.47 | 使用 nullptr 而非 0 或 NULL |
| ES.48 | 避免强制类型转换 |
| ES.50 | 不要丢弃 const |
// ES.20 + ES.23 + ES.25: Always initialize, prefer {}, default to const
const int max_retries{3};
const std::string name{"widget"};
const std::vector<int> primes{2, 3, 5, 7, 11};
// ES.28: Lambda for complex const initialization
const auto config = [&] {
Config c;
c.timeout = std::chrono::seconds{30};
c.retries = max_retries;
c.verbose = debug_mode;
return c;
}();0 或 NULL 作为指针 (ES.47 -- 使用 nullptr)static_cast、const_cast 等)const (ES.50)| 规则 | 摘要 |
|---|---|
| E.1 | 在设计早期制定错误处理策略 |
| E.2 | 抛出异常以表示函数无法执行其分配的任务 |
| E.6 | 使用 RAII 防止泄漏 |
| E.12 | 当抛出异常不可能或不可接受时,使用 noexcept |
| E.14 | 使用专门设计的用户定义类型作为异常 |
| E.15 | 按值抛出,按引用捕获 |
| E.16 | 析构函数、释放和 swap 绝不能失败 |
| E.17 | 不要试图在每个函数中捕获每个异常 |
// E.14 + E.15: Custom exception types, throw by value, catch by reference
class AppError : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
class NetworkError : public AppError {
public:
NetworkError(const std::string& msg, int code)
: AppError(msg), status_code(code) {}
int status_code;
};
void fetch_data(const std::string& url) {
// E.2: Throw to signal failure
throw NetworkError("connection refused", 503);
}
void run() {
try {
fetch_data("https://api.example.com");
} catch (const NetworkError& e) {
log_error(e.what(), e.status_code);
} catch (const AppError& e) {
log_error(e.what());
}
// E.17: Don't catch everything here -- let unexpected errors propagate
}int 或字符串字面量 (E.14)errno)的错误处理 (E.28)| 规则 | 摘要 |
|---|---|
| Con.1 | 默认情况下,使对象不可变 |
| Con.2 | 默认情况下,使成员函数为 const |
| Con.3 | 默认情况下,传递指向 const 的指针和引用 |
| Con.4 | 对构造后不改变的值使用 const |
| Con.5 | 对可在编译时计算的值使用 constexpr |
// Con.1 through Con.5: Immutability by default
class Sensor {
public:
explicit Sensor(std::string id) : id_(std::move(id)) {}
// Con.2: const member functions by default
const std::string& id() const { return id_; }
double last_reading() const { return reading_; }
// Only non-const when mutation is required
void record(double value) { reading_ = value; }
private:
const std::string id_; // Con.4: never changes after construction
double reading_{0.0};
};
// Con.3: Pass by const reference
void display(const Sensor& s) {
std::cout << s.id() << ": " << s.last_reading() << '\n';
}
// Con.5: Compile-time constants
constexpr double PI = 3.14159265358979;
constexpr int MAX_SENSORS = 256;| 规则 | 摘要 |
|---|---|
| CP.2 | 避免数据竞争 |
| CP.3 | 最小化可写数据的显式共享 |
| CP.4 | 从任务的角度思考,而非线程 |
| CP.8 | 不要使用 volatile 进行同步 |
| CP.20 | 使用 RAII,切勿使用普通的 lock()/unlock() |
| CP.21 | 使用 std::scoped_lock 来获取多个互斥量 |
| CP.22 | 持有锁时切勿调用未知代码 |
| CP.42 | 不要在没有条件的情况下等待 |
| CP.44 | 记得为你的 lock_guard 和 unique_lock 命名 |
| CP.100 | 除非绝对必要,否则不要使用无锁编程 |
// CP.20 + CP.44: RAII locks, always named
class ThreadSafeQueue {
public:
void push(int value) {
std::lock_guard<std::mutex> lock(mutex_); // CP.44: named!
queue_.push(value);
cv_.notify_one();
}
int pop() {
std::unique_lock<std::mutex> lock(mutex_);
// CP.42: Always wait with a condition
cv_.wait(lock, [this] { return !queue_.empty(); });
const int value = queue_.front();
queue_.pop();
return value;
}
private:
std::mutex mutex_; // CP.50: mutex with its data
std::condition_variable cv_;
std::queue<int> queue_;
};// CP.21: std::scoped_lock for multiple mutexes (deadlock-free)
void transfer(Account& from, Account& to, double amount) {
std::scoped_lock lock(from.mutex_, to.mutex_);
from.balance_ -= amount;
to.balance_ += amount;
}volatile 进行同步 (CP.8 -- 它仅用于硬件 I/O)std::lock_guard<std::mutex>(m); 会立即销毁 (CP.44)| 规则 | 摘要 |
|---|---|
| T.1 | 使用模板来提高抽象级别 |
| T.2 | 使用模板为多种参数类型表达算法 |
| T.10 | 为所有模板参数指定概念 |
| T.11 | 尽可能使用标准概念 |
| T.13 | 对于简单概念,优先使用简写符号 |
| T.43 | 优先 using 而非 typedef |
| T.120 | 仅在确实需要时使用模板元编程 |
| T.144 | 不要特化函数模板(改用重载) |
#include <concepts>
// T.10 + T.11: Constrain templates with standard concepts
template<std::integral T>
T gcd(T a, T b) {
while (b != 0) {
a = std::exchange(b, a % b);
}
return a;
}
// T.13: Shorthand concept syntax
void sort(std::ranges::random_access_range auto& range) {
std::ranges::sort(range);
}
// Custom concept for domain-specific constraints
template<typename T>
concept Serializable = requires(const T& t) {
{ t.serialize() } -> std::convertible_to<std::string>;
};
template<Serializable T>
void save(const T& obj, const std::string& path);constexpr 足够时使用模板元编程 (T.120)typedef 而非 using (T.43)| 规则 | 摘要 |
|---|---|
| SL.1 | 尽可能使用库 |
| SL.2 | 优先标准库而非其他库 |
| SL.con.1 | 优先 std::array 或 std::vector 而非 C 数组 |
| SL.con.2 | 默认情况下优先 std::vector |
| SL.str.1 | 使用 std::string 来拥有字符序列 |
| SL.str.2 | 使用 std::string_view 来引用字符序列 |
| SL.io.50 | 避免 endl(使用 '\n' -- endl 会强制刷新) |
// SL.con.1 + SL.con.2: Prefer vector/array over C arrays
const std::array<int, 4> fixed_data{1, 2, 3, 4};
std::vector<std::string> dynamic_data;
// SL.str.1 + SL.str.2: string owns, string_view observes
std::string build_greeting(std::string_view name) {
return "Hello, " + std::string(name) + "!";
}
// SL.io.50: Use '\n' not endl
std::cout << "result: " << value << '\n';| 规则 | 摘要 |
|---|---|
| Enum.1 | 优先枚举而非宏 |
| Enum.3 | 优先 enum class 而非普通 enum |
| Enum.5 | 不要对枚举项使用全大写 |
| Enum.6 | 避免未命名的枚举 |
// Enum.3 + Enum.5: Scoped enum, no ALL_CAPS
enum class Color { red, green, blue };
enum class LogLevel { debug, info, warning, error };
// BAD: plain enum leaks names, ALL_CAPS clashes with macros
enum { RED, GREEN, BLUE }; // Enum.3 + Enum.5 + Enum.6 violation
#define MAX_SIZE 100 // Enum.1 violation -- use constexpr| 规则 | 摘要 |
|---|---|
| SF.1 | 代码文件使用 .cpp,接口文件使用 .h |
| SF.7 | 不要在头文件的全局作用域内写 using namespace |
| SF.8 | 所有 .h 文件都应使用 #include 防护 |
| SF.11 | 头文件应是自包含的 |
| NL.5 | 避免在名称中编码类型信息(不要使用匈牙利命名法) |
| NL.8 | 使用一致的命名风格 |
| NL.9 | 仅宏名使用 ALL_CAPS |
| NL.10 | 优先使用 underscore_style 命名 |
// SF.8: Include guard (or #pragma once)
#ifndef PROJECT_MODULE_WIDGET_H
#define PROJECT_MODULE_WIDGET_H
// SF.11: Self-contained -- include everything this header needs
#include <string>
#include <vector>
namespace project::module {
class Widget {
public:
explicit Widget(std::string name);
const std::string& name() const;
private:
std::string name_;
};
} // namespace project::module
#endif // PROJECT_MODULE_WIDGET_H// NL.8 + NL.10: Consistent underscore_style
namespace my_project {
constexpr int max_buffer_size = 4096; // NL.9: not ALL_CAPS (it's not a macro)
class tcp_connection { // underscore_style class
public:
void send_message(std::string_view msg);
bool is_connected() const;
private:
std::string host_; // trailing underscore for members
int port_;
};
} // namespace my_projectusing namespace std; (SF.7)strName、iCount (NL.5)| 规则 | 摘要 |
|---|---|
| Per.1 | 不要无故优化 |
| Per.2 | 不要过早优化 |
| Per.6 | 没有测量数据,不要断言性能 |
| Per.7 | 设计时应考虑便于优化 |
| Per.10 | 依赖静态类型系统 |
| Per.11 | 将计算从运行时移至编译时 |
| Per.19 | 以可预测的方式访问内存 |
// Per.11: Compile-time computation where possible
constexpr auto lookup_table = [] {
std::array<int, 256> table{};
for (int i = 0; i < 256; ++i) {
table[i] = i * i;
}
return table;
}();
// Per.19: Prefer contiguous data for cache-friendliness
std::vector<Point> points; // GOOD: contiguous
std::vector<std::unique_ptr<Point>> indirect_points; // BAD: pointer chasing在标记 C++ 工作完成之前:
new/delete —— 使用智能指针或 RAII (R.11)const/constexpr (Con.1, ES.25)const (Con.2)enum class 而非普通 enum (Enum.3)nullptr 而非 0/NULL (ES.47)explicit (C.46)using namespace (SF.7)scoped_lock/lock_guard) (CP.20)'\n' 而非 std::endl (SL.io.50)© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in docs/zh-CN/skills/cpp-coding-standards of affaan-m/ECC.
Open the folder on GitHubat commit ef648e0
We found 3 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 3 other GitHub owners. This page covers the copy in affaan-m/ECC, which our catalogue first saw on October 7, 2026.
Cpp Coding Standards next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Cpp Coding Standards this skillaffaan-m/ECC | 274k | 3 repos | ~4.2k | Automated safety check: Pass | MIT | |
| Cpp Coding Standardsxu-xiang/everything-claude-code-zh | 2k | — | ~4.1k | Automated safety check: Pass | MIT | |
| Add Opik Code Quality Hookcomet-ml/opik | 22k | — | ~2.3k | Automated safety check: Pass | Apache-2.0 | |
| Qt C++ Code Reviewx-tools-author/x-tools | 1.1k | 2 repos | ~4.3k | Automated safety check: Pass | BSD-3-Clause | |
| pybind11 Release Publicationpybind/pybind11 | 18k | — | ~2.5k | Automated safety check: Pass | Custom licence | |
| OBS Plugin Dependency Upgradesorayuki/obs-multi-rtmp | 5.1k | — | ~609 | Automated safety check: Pass | GPL-2.0 |
xu-xiang/everything-claude-code-zh
基于 C++ 核心指南 (isocpp.github.io) 的 C++ 编码规范。在编写、评审或重构 C++ 代码时使用,以强制执行现代、安全且地道的实践。
comet-ml/opik
Checklist for wiring a new linter into Opik's Code Quality pipeline: the four files to edit, the silent-failure gotchas and the pass/fail verification loop.
x-tools-author/x-tools
Read-only review of Qt6 C++ code that combines a deterministic lint script with six parallel analysis agents and reports only high-confidence issues.
pybind/pybind11
Walks a maintainer through publishing a pybind11 release after the preparation PR merges, with preflight checks, confirmations before each push and a GitHub release.
sorayuki/obs-multi-rtmp
Updates the obs-multi-rtmp plugin repo to the latest upstream plugin template and OBS Studio version, including dependency metadata, then rebuilds it with CMake.
The-OpenROAD-Project/OpenROAD
Fixes an OpenROAD bug from a GitHub issue or error code: finds the root cause, implements the fix, adds a regression test and prepares a signed-off commit.
affaan-m/ECC
Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.
affaan-m/ECC
Ingest, index, search, edit, and monitor video and audio with the VideoDB Python SDK — upload from files, URLs, or RTSP feeds, build spoken and scene indexes with timestamped search and playable…
affaan-m/ECC
Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.
affaan-m/ECC
Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.
affaan-m/ECC
Measures whether agents actually follow a skill, rule or agent definition by generating scenarios at three strictness levels and scoring tool-call traces.
affaan-m/ECC
Instinct-based learning system that observes sessions via hooks, creates atomic instincts with confidence scoring, and evolves them into skills/commands/agents.
Categories
基于C++核心指南(isocpp.github.io)的C++编码标准。在编写、审查或重构C++代码时使用,以强制实施现代、安全和惯用的实践。. Cpp Coding Standards is an agent skill from affaan-m/ECC.
Cpp Coding Standards fits situations like: tasks that involve Code quality.
Run `npx skills add affaan-m/ECC --skill cpp-coding-standards -a claude-code`. Or copy the skill folder (docs/zh-CN/skills/cpp-coding-standards in affaan-m/ECC) into .claude/skills/cpp-coding-standards in your project. Claude Code loads it when a task matches its description.
Run `npx skills add affaan-m/ECC --skill cpp-coding-standards -a codex`. Or copy the skill folder (docs/zh-CN/skills/cpp-coding-standards in affaan-m/ECC) into .agents/skills/cpp-coding-standards in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill cpp-coding-standards -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cpp-coding-standards, .gemini/skills/cpp-coding-standards, .github/skills/cpp-coding-standards and .opencode/skills/cpp-coding-standards in your project.
SKILL.md names no scripts, command-line tools or credentials: Cpp Coding Standards is instructions for the agent only.
SKILL.md names 1 domain. As links in the text: isocpp.github.io. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Cpp Coding Standards is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 4.2k tokens (SKILL.md is roughly 17k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Cpp Coding Standards: Cpp Coding Standards (xu-xiang/everything-claude-code-zh, 2k stars), Add Opik Code Quality Hook (comet-ml/opik, 22k stars), Qt C++ Code Review (x-tools-author/x-tools, 1.1k stars) and pybind11 Release Publication (pybind/pybind11, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 274,360 GitHub stars. The repository holds 657 skills in this directory. The repository was last updated on October 5, 2026.
Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.