← 返回 Skills 市场
132
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install cpp-code-style
功能描述
C++/CPP代码都用这个coding style, code style, 代码风格,写代码之前阅读下面规则
使用说明 (SKILL.md)
Google C++ Style Guide
写代码严格按照下面规则。 注意:external,3rdparty,.gitignore里面的文件都不在该规则范围内。
关键规则
1. 命名规范
- 文件名:
snake_case.hpp,snake_case.cpp - 类名:
CamelCase - 函数名:
camelCase(小驼峰,首字母小写) - 变量名:
snake_case - 类成员变量:
m_camelCase(m_前缀 + 小驼峰),不要m_camelCase_ - 常量:
kCamelCase(全局常量用g_CamelCase) - 命名空间:
snake_case
2. 缩进和格式
- 缩进: 2 个空格,不使用 Tab
- 行宽: 80 字符(软限制)
- 大括号: 函数和类的开始大括号在新行,控制流语句的大括号在同一行
- 行尾空格: 去掉行尾空格
class Foo : public Bar {
public:
void Method() {
if (condition) {
DoSomething();
}
}
};
3. 空格
- 二元和三元操作符周围有空格
- 函数参数列表的第一个左括号紧贴函数名
- 返回类型和函数名之间有一个空格
- 指针/引用符号贴在类型上,而不是变量名
// 正确
int* ptr;
int& ref;
void Func(int param1, int param2) { ... }
// 类成员变量
class MyClass {
public:
void myMethod() {
m_counter = 0; // m_ 前缀
int local_var = 0; // 局部变量用 snake_case
}
private:
int m_counter; // 成员变量 m_ + camelCase
};
// 错误
int *ptr;
int &ref;
void Func( int param1, int param2 ) { ... }
class MyClass {
int counter; // 缺少 m_ 前缀
};
4. 头文件保护
#pragma once
// 或者
#ifndef _FILE_NAME_H_
#define _FILE_NAME_H_
// ... code ...
#endif // _FILE_NAME_H_
5. 命名空间
- 不使用
using namespace污染全局命名空间 - 使用
namespace foo {和} // namespace foo的格式 - 文件作用域的
namespace声明后跟一对空大括号
namespace litho {
namespace geo {
class Point { ... };
} // namespace geo
} // namespace litho
6. 注释
- 使用英文注释
- 使用
//单行注释 - 使用
/* */多行注释(仅当需要块注释时) - 函数和类的文档使用
/** ... */格式
// 单行注释
/*
* 多行注释
*/
/**
* 函数描述
* @param x 参数描述
* @return 返回值描述
*/
7. 其他重要规则
- 私有成员: 在
private:之前声明公有的 - 内联函数: 定义在头文件中
- 虚拟函数: 声明为
virtual,在定义中不使用virtual关键字 - 常量成员: 使用
constexpr而不是const - 字符串字面量: 使用
// NOLINT关闭特定的 lint 警告(如果需要) - CMakefile:不要用绝对路径和中文注释
- CopyRight: 使用当前年份,如2026
- template: template在class和function上一行
- 类成员变量: 需要初始化
- include顺序:标准库 → 第三方库 → 项目头文件
工具
clang-format
项目已配置 .clang-format 文件,使用 Google 风格。
检查.clang-format 文件是否符合上述规则,不符合修改.clang-format 文件。
格式化文件:
clang-format -i src/geo/*.hpp tests/*.cpp
参考
安全使用建议
This skill is primarily a local C++ style guide and formatter helper and appears safe in intent, but take these precautions before using it:
- Confirm tooling: The instructions call for clang-format, but the skill metadata lists g++/gcc instead. Make sure clang-format is installed and available (and that g++/gcc are actually needed) before running any automated formatting.
- Expect file changes: The skill tells the agent to modify .clang-format and run clang-format -i on source files. Run it on a branch or a copy, or commit your work first so you can review changes.
- Verify file paths and scope: The example formatting command targets specific paths (src/geo/*.hpp tests/*.cpp). Ensure the paths match your project or adjust them; automatic recursive edits can touch many files if misconfigured.
- Trust and provenance: The skill has no homepage and an unknown source; if the style rules or automatic edits are important for your project, prefer an internally-reviewed .clang-format and trusted tooling.
If you want to proceed: install and verify clang-format, test the formatting commands on a small sample, and run in a safe/isolated branch so you can inspect changes before merging.
功能分析
Type: OpenClaw Skill
Name: cpp-code-style
Version: 1.0.0
The skill bundle provides standard C++ coding style guidelines based on the Google C++ Style Guide. The instructions in SKILL.md are focused on naming conventions, formatting, and the use of clang-format, with no evidence of malicious intent, data exfiltration, or unauthorized execution.
能力评估
Purpose & Capability
The skill's stated purpose is a C++ code style guide and formatter. The SKILL.md refers to running clang-format and editing .clang-format, but the skill metadata requires g++ and gcc. Requiring compilers (g++, gcc) is unnecessary for a style guide/formatter and does not match the actions described; conversely, clang-format (which is needed) is not listed as a required binary.
Instruction Scope
The instructions are focused on style rules and explicitly tell the agent to check and modify the project's .clang-format and to run clang-format on source files (e.g., clang-format -i src/geo/*.hpp tests/*.cpp). This is within the scope of a style/formatting skill, but it does instruct the agent to modify repository files — users should expect automatic source edits.
Install Mechanism
No install spec or code files are present; this is an instruction-only skill. No downloads or installs are requested, so there is low install risk.
Credentials
The skill declares no required environment variables, credentials, or config paths. That is appropriate for a style guide/formatter helper.
Persistence & Privilege
The skill is not always-enabled and can be invoked by the user. It does not request persistent privileges or modify other skills or global agent settings.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install cpp-code-style - 安装完成后,直接呼叫该 Skill 的名称或使用
/cpp-code-style触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of the C++/CPP Code Style skill.
- Provides a comprehensive C++ code style guide based on the Google C++ Style Guide.
- Covers naming conventions, indentation, bracket placement, whitespace, header guards, namespaces, and commenting standards.
- Includes rules for include order, member variable initialization, and CMakefile practices.
- Recommends use of a project `.clang-format` file in Google style and lists formatting commands.
元数据
常见问题
C++/CPP Code Style 是什么?
C++/CPP代码都用这个coding style, code style, 代码风格,写代码之前阅读下面规则. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 132 次。
如何安装 C++/CPP Code Style?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install cpp-code-style」即可一键安装,无需额外配置。
C++/CPP Code Style 是免费的吗?
是的,C++/CPP Code Style 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
C++/CPP Code Style 支持哪些平台?
C++/CPP Code Style 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(linux, darwin, win32)。
谁开发了 C++/CPP Code Style?
由 daxiali(@daxiali)开发并维护,当前版本 v1.0.0。
推荐 Skills