cpp-header-template

作者: clickhouse

Generate C++ header files following Google Style Guide. Use when creating new header files or asking for a header template.

npx skills add https://github.com/clickhouse/pg_stat_ch --skill cpp-header-template

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 PathGuard
foo/bar/baz.hFOO_BAR_BAZ_H_
src/http/parser.hSRC_HTTP_PARSER_H_
my_project/utils.hMY_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

  1. Related header (for .cc files)
  2. Blank line
  3. C system headers (<unistd.h>)
  4. Blank line
  5. C++ standard library (<string>, <vector>)
  6. Blank line
  7. Other libraries
  8. Blank line
  9. Project headers

Each section sorted alphabetically.

來自 clickhouse 的更多技能

clickhouse-best-practices
clickhouse
我们要求翻译一段文本,目标语言是繁体中文。文本内容是关于ClickHouse最佳实践的规则,包括模式设计、查询优化和数据摄取策略。需要保留名称"clickhouse-best-practices"(但名称不在<text>内,所以不翻译)。注意不要添加额外内容,只翻译<text>内的文字。 翻译时注意专业术语:schema design -> 模式設計,query optimization -> 查詢優化,data ingestion strategy -> 數據攝取策略,primary key -> 主鍵,data type selection -> 數據類型選擇,immutable design decisions -> 不可變設計決策,JOIN -> JOIN(保留),insert batching -> 插入批次處理,mutation avoidance -> 避免突變,columnar storage -> 列式存儲,sparse index mechanics -> 稀疏索引機制,structured review procedures -> 結構化審查程序。 注意繁体中文用词:规则、组织、涵盖、关键、标记、提供等。 文本末尾有"for...",但原文是"for..."后面没有完整
official
clickhouse-js-node-coding
clickhouse
Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js…
official
clickhousectl-cloud-deploy
clickhouse
當用戶想要將ClickHouse部署到雲端、上線生產環境、使用ClickHouse Cloud、託管受管理的ClickHouse服務,或從本地遷移時使用。
official
clickstack-otel-collector
clickhouse
當使用者想要將 OpenTelemetry collector 接入 ClickHouse Cloud 上的 Managed ClickStack 服務時使用,無論是透過部署新的本地 collector…
official
infra-clickhouse
clickhouse
使用clickhousectl CLI設定及管理ClickHouse——安裝並執行本機ClickHouse伺服器以利開發,同時建立受管理的ClickHouse Cloud…
official
infra-postgres
clickhouse
使用 clickhousectl CLI 設定並管理 Postgres — 執行本機 Docker 支援的 Postgres 以進行開發,並建立及操作受管理的 ClickHouse…
official
clickhouse-best-practices
clickhouse
審查 ClickHouse 結構、查詢或配置時必須使用。包含 31 條規則,在提供建議前必須檢查。務必閱讀…
official
setup
clickhouse
引導用戶設定與此插件捆綁的 ClickHouse MCP 伺服器連線。當用戶首次安裝插件或遇到問題時使用…
official