Xpersona
C

C++/CPP Code Style

CLAWHUB · Unverified

C++/CPP代码都用这个coding style, code style, 代码风格,写代码之前阅读下面规则 Skill: C++/CPP Code Style Owner: daxiali Summary: C++/CPP代码都用这个coding style, code style, 代码风格,写代码之前阅读下面规则 Tags: latest:1.0.0 Version history: v1.0.0 | 2026-04-12T08:52:47.373Z | user - 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, a

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17aj1q7keam2ewrmptrc606qs83mdqs:cpp-code-style
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-daxiali-cpp-code-style/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

5,416 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: C++/CPP Code Style
description: C++/CPP代码都用这个coding style, code style, 代码风格,写代码之前阅读下面规则
metadata: {"clawdbot":{"emoji":"⚡","requires":{"bins":["g++", "gcc"]},"os":["linux","darwin","win32"]}}
---

# 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 字符(软限制)
- **大括号**: 函数和类的开始大括号在新行,控制流语句的大括号在同一行
- **行尾空格**: 去掉行尾空格

```cpp
class Foo : public Bar {
 public:
  void Method() {
    if (condition) {
      DoSomething();
    }
  }
};
```

### 3. 空格

- 二元和三元操作符周围有空格
- 函数参数列表的第一个左括号紧贴函数名
- 返回类型和函数名之间有一个空格
- 指针/引用符号贴在类型上,而不是变量名

```cpp
// 正确
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. 头文件保护

```cpp
#pragma once
// 或者
#ifndef _FILE_NAME_H_
#define _FILE_NAME_H_

// ... code ...

#endif  // _FILE_NAME_H_
```

### 5. 命名空间

- 不使用 `using namespace` 污染全局命名空间
- 使用 `namespace foo {` 和 `}  // namespace foo` 的格式
- 文件作用域的 `namespace` 声明后跟一对空大括号

```cpp
namespace litho {
namespace geo {

class Point { ... };

}  // namespace geo
}  // namespace litho
```

### 6. 注释

- 使用英文注释
- 使用 `//` 单行注释
- 使用 `/* */` 多行注释(仅当需要块注释时)
- 函数和类的文档使用 `/** ... */` 格式

```cpp
// 单行注释

/*
 * 多行注释
 */

/**
 * 函数描述
 * @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` 文件。

格式化文件:
```bash
clang-format -i src/geo/*.hpp tests/*.cpp
```

## 参考

- [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
- [A C++ Guide](https://www.google-styleguide.com/)

_meta.json

{
  "ownerId": "kn7cagwb5cc9td65pzf92ajdnx83ca9b",
  "slug": "cpp-code-style",
  "version": "1.0.0",
  "publishedAt": 1775983967373
}

skill-card.md

## Description:

Applies a C++/CPP code style guide based on Google C++ style conventions before writing or revising C++ code.

This skill is ready for commercial/non-commercial use.

## Publisher:

[daxiali](https://clawhub.ai/user/daxiali)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and coding agents use this skill to keep C++ source, headers, comments, namespaces, includes, CMake files, and formatting aligned with the stated Google-style conventions.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill can cause agents to apply style rules that conflict with an existing repository's own C++ conventions.

Mitigation: Override this skill when a repository has its own style rules, especially around comment language or formatting changes.

Risk: Formatting or code-style proposals can introduce misleading or unwanted changes if accepted without review.

Mitigation: Review proposed edits and run the repository's normal formatting, linting, and test checks before deployment.

## Reference(s):

- [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
- [A C++ Guide](https://www.google-styleguide.com/)
- [ClawHub skill page](https://clawhub.ai/daxiali/skills/cpp-code-style)

## Skill Output:

**Output Type(s):** [Guidance, Code, Shell commands, Configuration]

**Output Format:** [Markdown guidance with inline C++, shell, and configuration examples]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May propose style-aligned edits, clang-format usage, and .clang-format configuration checks.]

## Skill Version(s):

1.0.0 (source: server release metadata)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to C++/CPP Code Style and adjacent AI workflows.