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
28개의 ClickHouse 모범 사례 규칙으로, 스키마 설계, 쿼리 최적화, 데이터 수집 전략별로 구성되어 있습니다. 기본 키 및 데이터 유형 선택(변경 불가능한 설계 결정), JOIN 및 쿼리 최적화, 삽입 배치 및 변형 회피 등 세 가지 핵심 영역을 다룹니다. 영향도에 따라 우선순위가 매겨진 28개의 규칙을 포함하며, ClickHouse의 컬럼 기반 스토리지 및 희소 인덱스 메커니즘으로 인해 스키마 설계 및 쿼리 최적화 규칙은 CRITICAL로 표시됩니다. 구조화된 검토 절차를 제공합니다...
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
사용자가 ClickHouse Cloud의 Managed ClickStack 서비스에 OpenTelemetry collector를 연결하려는 경우 사용합니다. 새 로컬 collector를 배포하거나…
official
infra-clickhouse
clickhouse
Sets up and manages ClickHouse using the clickhousectl CLI — installs and runs a local ClickHouse server for development, and creates managed ClickHouse Cloud…
official
infra-postgres
clickhouse
Sets up and manages Postgres using the clickhousectl CLI — runs a local Docker-backed Postgres for development, and creates and operates managed ClickHouse…
official
clickhouse-best-practices
clickhouse
ClickHouse 스키마, 쿼리 또는 구성을 검토할 때 반드시 사용해야 합니다. 권장 사항을 제공하기 전에 반드시 확인해야 하는 31개의 규칙이 포함되어 있습니다. 항상 읽어보세요…
official
setup
clickhouse
이 플러그인에 포함된 ClickHouse MCP 서버 연결 설정을 사용자에게 안내합니다. 사용자가 플러그인을 처음 설치하거나 문제가 있을 때 사용합니다.
official